forked from kiss-community/kiss
kiss: Clean up pkg_remove
This commit is contained in:
parent
d3b988300a
commit
1f9ab42fd6
28
kiss
28
kiss
@ -864,20 +864,13 @@ pkg_remove() {
|
|||||||
# overwritten.
|
# overwritten.
|
||||||
pkg_list "$1" >/dev/null || return
|
pkg_list "$1" >/dev/null || return
|
||||||
|
|
||||||
set +f
|
|
||||||
|
|
||||||
# Make sure that nothing depends on this package.
|
# Make sure that nothing depends on this package.
|
||||||
[ "$2" = check ] && for file in "$sys_db/"*; do
|
[ "$2" = check ] && {
|
||||||
# Check each depends file for the package and if it's
|
log "$1" "Checking for reverse dependencies"
|
||||||
# a run-time dependency, append to the $required_by string.
|
|
||||||
"$grep" -qFx "$1" "$file/depends" 2>/dev/null &&
|
|
||||||
required_by="$required_by'${file##*/}', "
|
|
||||||
done
|
|
||||||
|
|
||||||
[ "$required_by" ] &&
|
(cd "$sys_db"; set +f; "$grep" -lFx "$1" -- */depends) &&
|
||||||
die "$1" "Package is required by ${required_by%, }"
|
die "$1" "Can't remove package, others depend on it"
|
||||||
|
}
|
||||||
set -f
|
|
||||||
|
|
||||||
# Block being able to abort the script with 'Ctrl+C' during removal.
|
# Block being able to abort the script with 'Ctrl+C' during removal.
|
||||||
# Removes all risk of the user aborting a package removal leaving
|
# Removes all risk of the user aborting a package removal leaving
|
||||||
@ -894,12 +887,11 @@ pkg_remove() {
|
|||||||
# manager from removing user edited configuration files.
|
# manager from removing user edited configuration files.
|
||||||
[ "${file##/etc/*}" ] || continue
|
[ "${file##/etc/*}" ] || continue
|
||||||
|
|
||||||
if [ -d "$KISS_ROOT/$file" ]; then
|
# Lazy removal. Try remove as a directory first before
|
||||||
rmdir "$KISS_ROOT/$file" 2>/dev/null || continue
|
# falling back to a file removal. Removes all files and
|
||||||
else
|
# only directories if empty.
|
||||||
rm -f "$KISS_ROOT/$file"
|
rmdir "$KISS_ROOT/$file" || rm -f "$KISS_ROOT/$file" ||:
|
||||||
fi
|
done < "$sys_db/$1/manifest" 2>/dev/null
|
||||||
done < "$sys_db/$1/manifest"
|
|
||||||
|
|
||||||
# Reset 'trap' to its original value. Removal is done so
|
# Reset 'trap' to its original value. Removal is done so
|
||||||
# we no longer need to block 'Ctrl+C'.
|
# we no longer need to block 'Ctrl+C'.
|
||||||
|
Loading…
Reference in New Issue
Block a user