kiss: Simplify pkg_depends and pkg_install() dependency checking.

This commit is contained in:
Dylan Araps 2020-06-10 11:07:58 +03:00
parent ae8a48cd30
commit 2ca86ee2c0
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E

21
kiss
View File

@ -352,13 +352,11 @@ pkg_depends() {
# the parents in reverse order.
contains "$deps" "$1" || {
# Filter out non-explicit, aleady installed dependencies.
# Only filter installed if called from 'pkg_build()'.
[ "$pkg_build" ] && [ -z "$2" ] &&
(pkg_list "$1" >/dev/null) && return
[ "$3" ] && [ -z "$2" ] && (pkg_list "$1" >/dev/null) && return
# Recurse through the dependencies of the child packages.
while read -r dep _ || [ "$dep" ]; do
[ "${dep##\#*}" ] && pkg_depends "$dep"
[ "${dep##\#*}" ] && pkg_depends "$dep" '' "$3"
done 2>/dev/null < "$(pkg_find "$1")/depends" ||:
# After child dependencies are added to the list,
@ -552,7 +550,6 @@ pkg_tar() (
pkg_build() {
# Build packages and turn them into packaged tarballs.
pkg_build=1
log "Resolving dependencies"
@ -563,7 +560,7 @@ pkg_build() {
# This also resolves all dependencies and stores the result in '$deps'.
# Any duplicates are also filtered out.
for pkg do contains "$explicit" "$pkg" || {
pkg_depends "$pkg" explicit
pkg_depends "$pkg" explicit filter
explicit="$explicit $pkg "
} done
@ -1127,15 +1124,11 @@ pkg_install() {
die "File $line missing from tarball but mentioned in manifest"
done < "$tar_dir/$pkg_name/$pkg_db/$pkg_name/manifest"
log "$pkg_name" "Checking that all dependencies are installed"
[ -f "$tar_dir/$pkg_name/$pkg_db/$pkg_name/depends" ] &&
while read -r dep dep_type || [ "$dep" ]; do
[ "${dep##\#*}" ] || continue
[ "$dep_type" ] || pkg_list "$dep" >/dev/null ||
install_dep="$install_dep'$dep', "
done < "$tar_dir/$pkg_name/$pkg_db/$pkg_name/depends"
log "$pkg_name" "Resolving dependencies"; (
pkg_depends "$pkg_name" explicit filter
[ "$install_dep" ] && die "$1" "Package requires ${install_dep%, }"
case $deps in *[!\ ]*) printf '%s\n' "${deps# }"; false; esac
) || die "$1" "Package is missing dependencies"
}
run_hook pre-install "$pkg_name" "$tar_dir/$pkg_name"