1
0
mirror of https://codeberg.org/kiss-community/kiss synced 2024-12-25 00:20:05 -07:00

kiss-new: Full dependency resolvers.

This commit is contained in:
Dylan Araps 2019-06-29 10:56:39 +03:00
parent 4a84fe78f5
commit f6d7a387ea

View File

@ -103,7 +103,7 @@ pkg_list() {
# Also warn if a package is missing its version file. # Also warn if a package is missing its version file.
for pkg; do for pkg; do
[ -d "$pkg" ] || { [ -d "$pkg" ] || {
log "Package '$pkg' is not installed." >&2 log "Package '$pkg' is not installed."
return 1 return 1
} }
@ -161,28 +161,27 @@ pkg_sources() {
pkg_depends() { pkg_depends() {
# Resolve all dependencies and install them in the right order. # 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. # Find the package's repository files. This needs to keep
[ -f "$repo_dir/depends" ] || continue # happening as we can't store this data in any kind of data
# structure.
repo_dir=$(pkg_search "$1")
while read -r dep _; do pkg_list "$1" >/dev/null || {
pkg_list "$dep" >/dev/null || { case $missing_deps in
case $missing_deps in # Dependency is already in list, skip it.
# Dependency is already in list, skip it. *" $1 "*) ;;
*" $dep "*) ;;
*) *)
missing_deps="$missing_deps $dep " [ -f "$repo_dir/depends" ] &&
;; while read -r dep _; do
esac pkg_depends "$dep"
} done < "$repo_dir/depends"
done < "$repo_dir/depends"
done missing_deps="$missing_deps $1 "
;;
esac
}
} }
pkg_build() { pkg_build() {
@ -190,6 +189,20 @@ pkg_build() {
# also checks checksums, downloads sources and ensure all dependencies # also checks checksums, downloads sources and ensure all dependencies
# are installed. # are installed.
# Resolve dependencies and generate a list.
log "Resolving dependencies..."
for pkg; do pkg_depends "$pkg"; done
# Disable globbing with 'set -f' to ensure that the unquoted
# variable doesn't expand into anything nasty.
# shellcheck disable=2086,2046
{
# Set the resolved dependency list as the function's arguments.
set -f
set -- $missing_deps
set +f
}
for pkg; do for pkg; do
# Find the package's repository files. This needs to keep # Find the package's repository files. This needs to keep
# happening as we can't store this data in any kind of data # happening as we can't store this data in any kind of data
@ -210,8 +223,6 @@ pkg_build() {
# Die here as packages without checksums were found above. # Die here as packages without checksums were found above.
[ "$no_checkums" ] && [ "$no_checkums" ] &&
die "Run '$kiss checksum ${no_checkums% }' to generate checksums." die "Run '$kiss checksum ${no_checkums% }' to generate checksums."
pkg_depends "$@"
} }
pkg_checksums() { pkg_checksums() {