summaryrefslogtreecommitdiffstats
path: root/lib/pkg.sh
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pkg.sh')
-rw-r--r--lib/pkg.sh23
1 files changed, 20 insertions, 3 deletions
diff --git a/lib/pkg.sh b/lib/pkg.sh
index 541c9df..3875e9a 100644
--- a/lib/pkg.sh
+++ b/lib/pkg.sh
@@ -22,15 +22,32 @@ _PKG_SM=1
resolve_deps()
{
- local new_pkgs="${*}"
+ 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}"
+ all_deps="${all_deps}${new_pkgs}"
new_deps=''
for pkg in ${new_pkgs}; do
- new_deps="$(sed -n "s/^${pkg} *//p' ")"
+ 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% }"
}