aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordylan.araps@gmail.com <dylan.araps@gmail.com>2019-08-20 11:58:23 +0000
committerdylan.araps@gmail.com <dylan.araps@gmail.com>2019-08-20 11:58:23 +0000
commit540f7488f6eb39d3a48beda8b3b1710a77dddc4a (patch)
tree3e80b4aeb861358de9b04f36f45217076aa81a11
parenta7aba1770d87e477835035f2f7b8b7947e1ddcce (diff)
downloadcpt-540f7488f6eb39d3a48beda8b3b1710a77dddc4a.tar.gz
kiss: optimize pkg_conflicts
FossilOrigin-Name: dcbd1eeb8f9c446f7d3ba8ab96aa1f22f7a77ca3388c6c794ea2f7dfd0715eed
-rwxr-xr-xkiss43
1 files changed, 28 insertions, 15 deletions
diff --git a/kiss b/kiss
index 464c768..3c7b073 100755
--- a/kiss
+++ b/kiss
@@ -639,29 +639,42 @@ pkg_conflicts() {
# This function takes a path to a KISS tar-ball as an argument.
log "[$2] Checking for package conflicts"
- # Extract manifest from the tar-ball and only extract files entries.
- tar xf "$1" -O "./$pkg_db/$2/manifest" |
- while read -r line; do
- [ "${line%%*/}" ] && printf '%s\n' "$line" >> "$cac_dir/manifest-$pid"
- done ||:
+ # Save the package name as we modify the argument list below.
+ tar_file=$1
+ pkg_name=$2
# Enable globbing.
set +f
- # Compare extracted manifest to all installed manifests.
- # If there are matching lines (files) there is a package conflict.
- for db in "$KISS_ROOT/$pkg_db/"*; do
- [ "$2" = "${db##*/}" ] && continue
+ # Generate a list of all installed package manifests.
+ set -f -- "$KISS_ROOT/$pkg_db/"*/manifest
+
+ # Go through the manifest list and filter out the
+ # package which will be installed.
+ for manifest; do
+ manifest_name=${manifest%/*}
+ manifest_name=${manifest_name##*/}
+
+ shift
+
+ [ "$manifest_name" = "$pkg_name" ] &&
+ continue
- grep -Fxf "$cac_dir/manifest-$pid" "$db/manifest" 2>/dev/null &&
- die "Package '$2' conflicts with '${db##*/}'"
+ set -- "$@" "$manifest"
done
- # Disable globbing.
- set -f
+ # Extract manifest from the tar-ball and only extract files entries.
+ tar xf "$tar_file" -O "./$pkg_db/$pkg_name/manifest" |
+ while read -r line; do
+ [ "${line%%*/}" ] && printf '%s\n' "$line"
+ done |
+
+ # Compare the package's files against all owned files on the system.
+ grep -Fxf - "$@" 2>/dev/null &&
+ die "Package '$pkg_name' conflicts with another package"
- # Remove this temporary file as we no longer need it.
- rm -f "$cac_dir/manifest-$pid"
+ # Force a '0' return code as the 'grep' above fails on success.
+ :
}
pkg_remove() {