summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/local.mk1
-rw-r--r--lib/pkg.sh23
2 files changed, 21 insertions, 3 deletions
diff --git a/lib/local.mk b/lib/local.mk
index 0e8b497..2fc6dfd 100644
--- a/lib/local.mk
+++ b/lib/local.mk
@@ -5,5 +5,6 @@ pkgdata_sources = \
lib/fd.sh \
lib/control.sh \
lib/feed.sh \
+ lib/pkg.sh \
lib/cmd.sh \
lib/profile.sh
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% }"
}