From 4b171150d6b4c111bc5daca39c76f5504bbad46d Mon Sep 17 00:00:00 2001 From: "dylan.araps@gmail.com" Date: Sat, 29 Jun 2019 07:42:27 +0000 Subject: kiss-new: Initial dependency solver FossilOrigin-Name: 65c145f86da78d214e14a6831470f4f36a5aae1ad56f8086af248b3e1e5bc0fc --- kiss-new | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/kiss-new b/kiss-new index f229c0c..c4916e0 100755 --- a/kiss-new +++ b/kiss-new @@ -103,7 +103,7 @@ pkg_list() { # Also warn if a package is missing its version file. for pkg; do [ -d "$pkg" ] || { - log "Package '$pkg' is not installed." + log "Package '$pkg' is not installed." >&2 return 1 } @@ -159,6 +159,32 @@ pkg_sources() { done < "$repo_dir/sources" } +pkg_depends() { + # Resolve all dependencies and install them in the right order. + for pkg; do + # Find the package's repository files. This needs to keep + # happening as we can't store this data in any kind of data + # structure. + repo_dir=$(pkg_search "$pkg") + + # Package doesn't depend on anything, skip it. + [ -f "$repo_dir/depends" ] || continue + + while read -r dep _; do + pkg_list "$dep" >/dev/null || { + case $missing_deps in + # Dependency is already in list, skip it. + *" $dep "*) ;; + + *) + missing_deps="$missing_deps $dep " + ;; + esac + } + done < "$repo_dir/depends" + done +} + pkg_build() { # Build packages and turn them into packaged tarballs. This function # also checks checksums, downloads sources and ensure all dependencies @@ -184,6 +210,8 @@ pkg_build() { # Die here as packages without checksums were found above. [ "$no_checkums" ] && die "Run '$kiss checksum ${no_checkums% }' to generate checksums." + + pkg_depends "$@" } pkg_checksums() { -- cgit v1.2.3