diff options
Diffstat (limited to 'src/deps.sh')
-rw-r--r-- | src/deps.sh | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/deps.sh b/src/deps.sh index 862caff..9a30fe9 100644 --- a/src/deps.sh +++ b/src/deps.sh @@ -1,6 +1,6 @@ # Functions for parsing dependency field values # -# Copyright (C) 2012, 2014 Patrick "P. J." McDermott +# Copyright (C) 2012-2014 Patrick "P. J." McDermott # # This file is part of the ProteanOS Development Kit. # @@ -18,6 +18,38 @@ # along with the ProteanOS Development Kit. If not, see # <http://www.gnu.org/licenses/>. +resolve_deps() +{ + local new_pkgs="${1}" + local deps="${2}" + local all_deps= + local new_deps= + local pkg= + + all_deps='' + new_pkgs="${new_pkgs} " + while [ "x${new_pkgs}" != 'x' ]; do + all_deps="${all_deps}${new_pkgs}" + new_deps='' + for pkg in ${new_pkgs}; do + case "${pkg}" in + *[!a-z0-9+.-]*) continue;; + esac + new_deps="${new_deps} $(printf '%s' "${deps}" | \ + sed -n "s/^${pkg}: *//p")" + done + new_deps="$(printf '%s\n' ${new_deps} | sort -u)" + new_pkgs='' + for pkg in ${new_deps}; do + if [ "x${all_deps# ${pkg} }" = "x${all_deps}" ]; then + new_pkgs="${new_pkgs}${pkg} " + fi + done + done + + printf '%s\n' "${all_deps% }" +} + parse_dep() { local dep="${1}" |