From b0f526ebd172531a015833d6d4140d6dc77720fa Mon Sep 17 00:00:00 2001 From: Kevin Anthony Date: Fri, 19 Oct 2012 22:08:04 -0400 Subject: Added find_depends --- diff --git a/src/opkbootstrap.sh b/src/opkbootstrap.sh index 3ad3c27..2ea0005 100755 --- a/src/opkbootstrap.sh +++ b/src/opkbootstrap.sh @@ -5,6 +5,7 @@ # Main program script. # # Copyright (C) 2012 Patrick "P. J." McDermott +# Copyright (C) 2012 Kevin Anthony # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -43,7 +44,7 @@ main() print_help exit ;; - V) + /V) print_version exit ;; @@ -208,8 +209,8 @@ get_dist_src_list() # find_essential find_essential() { - for _list in "${LISTS_DIR}/"*; do - _pkg= + for _list in ${LISTS_DIR}/*; do + _pkg= _essential=false while read _line; do if [ -z "${line}" ]; then @@ -235,12 +236,49 @@ find_essential() done } -# find_depends find_depends() { - : + _pkgs=${PKGS_ALL} + for _list in ${LISTS_DIR}/*; do + recurs_find_deps "${_pkgs}" ${_list} + while [ "$deps" != "${_pkgs}" ]; do + _pkgs=$deps + recurs_find_deps "${_pkgs}" ${_list} + done + PKGS_ALL="${PKGS_ALL} ${_pkgs}" + PKGS_ALL=$(echo ${PKGS_ALL} | sed 's/ /\n/g' | sort | uniq) + done +} + +recurs_find_deps() +{ + deps=$(awk -v pkgs="${1}" -v list="${2}" 'BEGIN { + deppkg = 0 + while (getline line < list){ + if (match(line,"Package:")){ + split(line,linearr,": ") + if (index(pkgs,linearr[2]) != 0){ + print linearr[2] + deppkg++ + continue + } + } + if (deppkg > 0){ + if (match(line,"Depends:")){ + split(line,deps,": ") + split(deps[2],dep,",") + for (i in dep){ + split(dep[i],d,r" ") + print d[1] + } + deppkg-- + } + } + } + };' | sort | uniq) } +#check if libcurl exists or wget # get_pkgs get_pkgs() { @@ -248,11 +286,12 @@ get_pkgs() } # unpack_pkgs +#test this fucntion unpack_pkgs() { cd "${TARGET}" - for _opk in "${PKGS_DIR}"/*; do + for _opk in ${PKGS_DIR}/*; do _pkg="${opk##*/}" _pkg="${pkg%%_*}" -- cgit v0.9.1