kiss: fixes to depends

This commit is contained in:
Dylan Araps 2020-09-12 11:09:46 +03:00
parent 3d670da1f4
commit ab625e39bd
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E
1 changed files with 22 additions and 10 deletions

32
kiss
View File

@ -146,8 +146,10 @@ pkg_find() {
unset IFS unset IFS
[ "$1" ] || [ "$1" ] || {
die "Package '$query' not in any repository" log "Package '$query' not in any repository"
return 1
}
[ -z "$all" ] || [ -z "$all" ] ||
printf '%s\n' "$@" printf '%s\n' "$@"
@ -155,8 +157,8 @@ pkg_find() {
repo_dir=$1 repo_dir=$1
} }
pkg_list() { pkg_list() (
cd "$sys_db" 2>/dev/null cd "$sys_db"
# If no arguments are passed, list all. # If no arguments are passed, list all.
[ "$1" ] || { [ "$1" ] || {
@ -174,7 +176,7 @@ pkg_list() {
printf '%s\n' "$pkg $version" printf '%s\n' "$pkg $version"
done done
} )
pkg_cache() { pkg_cache() {
# Find the tarball of a package using a glob. Use the first found match # Find the tarball of a package using a glob. Use the first found match
@ -358,14 +360,24 @@ pkg_depends() {
# Resolve all dependencies and generate an ordered list. The deepest # Resolve all dependencies and generate an ordered list. The deepest
# dependencies are listed first and then the parents in reverse order. # dependencies are listed first and then the parents in reverse order.
contains "$deps" "$1" || { contains "$deps" "$1" || {
pkg_find "$1"
# Filter out non-explicit, aleady installed dependencies. # Filter out non-explicit, aleady installed dependencies.
[ "$3" ] && [ -z "$2" ] && (pkg_list "$1" >/dev/null) && return case $3-$2 in
*?-) ! pkg_list "$1" >/dev/null || return 0
esac
pkg_find "$1" || repo_dir=null
# Recurse through the dependencies of the child packages. # Recurse through the dependencies of the child packages.
while read -r dep _ || [ "$dep" ]; do while read -r dep _ || [ "$dep" ]; do
[ "${dep##\#*}" ] && pkg_depends "$dep" '' "$3" case $dep in
\#* | '')
# Comments and blank lines.
;;
*)
pkg_depends "$dep" '' "$3" ||:
;;
esac
done 2>/dev/null < "$repo_dir/depends" ||: done 2>/dev/null < "$repo_dir/depends" ||:
# After child dependencies are added to the list, # After child dependencies are added to the list,
@ -1095,7 +1107,7 @@ pkg_etc() (
pkg_remove() { pkg_remove() {
# Remove a package and all of its files. The '/etc' directory is handled # Remove a package and all of its files. The '/etc' directory is handled
# differently and configuration files are *not* overwritten. # differently and configuration files are *not* overwritten.
pkg_list "$1" >/dev/null || return pkg_list "$1" >/dev/null
# Make sure that nothing depends on this package. # Make sure that nothing depends on this package.
[ "$KISS_FORCE" = 1 ] || { [ "$KISS_FORCE" = 1 ] || {