forked from kiss-community/kiss
kiss: Added dependency check on package removal.
This commit is contained in:
parent
9792df69f5
commit
82b7db05b6
29
kiss
29
kiss
@ -565,13 +565,24 @@ pkg_remove() {
|
|||||||
cp "$(command -v rm)" "$cac_dir"
|
cp "$(command -v rm)" "$cac_dir"
|
||||||
cp "$(command -v rmdir)" "$cac_dir"
|
cp "$(command -v rmdir)" "$cac_dir"
|
||||||
|
|
||||||
for pkg; do
|
|
||||||
# The package is not installed, don't do anything.
|
# The package is not installed, don't do anything.
|
||||||
pkg_list "$pkg" >/dev/null || {
|
pkg_list "$1" >/dev/null || {
|
||||||
log "[$pkg]: Not installed."
|
log "[$1]: Not installed."
|
||||||
continue
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Make sure that nothing depends on this package.
|
||||||
|
[ "$2" = check ] && for file in "$KISS_ROOT/var/db/kiss/"*; do
|
||||||
|
# Check each depends file for the package and if it's
|
||||||
|
# a run-time dependency, append to the $required_by string.
|
||||||
|
grep -q "^$1$" "$file/depends" 2>/dev/null &&
|
||||||
|
required_by="$required_by${file##*/}, "
|
||||||
|
done
|
||||||
|
|
||||||
|
[ "$required_by" ] &&
|
||||||
|
die "[$1]: Package is required by ${required_by%, }." \
|
||||||
|
"[$1]: Aborting here..."
|
||||||
|
|
||||||
while read -r file; do
|
while read -r file; do
|
||||||
# The file is in '/etc' skip it. This prevents the package
|
# The file is in '/etc' skip it. This prevents the package
|
||||||
# manager from removing user edited configuration files.
|
# manager from removing user edited configuration files.
|
||||||
@ -581,12 +592,11 @@ pkg_remove() {
|
|||||||
"$cac_dir/rmdir" "$KISS_ROOT/$file" 2>/dev/null || continue
|
"$cac_dir/rmdir" "$KISS_ROOT/$file" 2>/dev/null || continue
|
||||||
else
|
else
|
||||||
"$cac_dir/rm" -f -- "$KISS_ROOT/$file" ||
|
"$cac_dir/rm" -f -- "$KISS_ROOT/$file" ||
|
||||||
log "[$pkg]: Failed to remove '$file'."
|
log "[$1]: Failed to remove '$file'."
|
||||||
fi
|
fi
|
||||||
done < "$KISS_ROOT/var/db/kiss/$pkg/manifest"
|
done < "$KISS_ROOT/var/db/kiss/$1/manifest"
|
||||||
|
|
||||||
log "[$pkg]: Removed successfully."
|
log "[$1]: Removed successfully."
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pkg_install() {
|
pkg_install() {
|
||||||
@ -643,6 +653,7 @@ pkg_install() {
|
|||||||
|
|
||||||
log "[$pkg_name]: Removing previous version of package if it exists."
|
log "[$pkg_name]: Removing previous version of package if it exists."
|
||||||
pkg_remove "$pkg_name"
|
pkg_remove "$pkg_name"
|
||||||
|
log "[$pkg_name]: Installing package..."
|
||||||
|
|
||||||
# Installation works by unpacking the tar-ball to a specified location,
|
# Installation works by unpacking the tar-ball to a specified location,
|
||||||
# manually running 'mkdir' to create each directory and finally, using
|
# manually running 'mkdir' to create each directory and finally, using
|
||||||
@ -814,7 +825,7 @@ args() {
|
|||||||
shift
|
shift
|
||||||
[ "$1" ] || die "'kiss remove' requires an argument."
|
[ "$1" ] || die "'kiss remove' requires an argument."
|
||||||
root_check
|
root_check
|
||||||
pkg_remove "$@"
|
for pkg; do pkg_remove "$pkg" check; done
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# List installed packages.
|
# List installed packages.
|
||||||
|
Loading…
Reference in New Issue
Block a user