aboutsummaryrefslogtreecommitdiff
path: root/kiss
diff options
context:
space:
mode:
authordylan.araps@gmail.com <dylan.araps@gmail.com>2019-09-11 08:30:43 +0000
committerdylan.araps@gmail.com <dylan.araps@gmail.com>2019-09-11 08:30:43 +0000
commitb128efcb0c0ce5ff386763d3b64d645b25a43b5a (patch)
tree051cefcb5b1bea65366ad028a82412dd05827e13 /kiss
parenta514ea41a71d36a3151d110d4c6bd681fc9b9454 (diff)
downloadcpt-b128efcb0c0ce5ff386763d3b64d645b25a43b5a.tar.gz
pkg_conflicts: smaller and safer
FossilOrigin-Name: 28a7a91f5626cd47823c0b644cbd668523fff305499d721267f76b66ffb897f4
Diffstat (limited to 'kiss')
-rwxr-xr-xkiss42
1 files changed, 11 insertions, 31 deletions
diff --git a/kiss b/kiss
index 47f2cd1..9e098ac 100755
--- a/kiss
+++ b/kiss
@@ -535,40 +535,20 @@ pkg_conflicts() {
# This function takes a path to a KISS tar-ball as an argument.
log "[$2] Checking for package conflicts"
- # Save the package name as we modify the argument list below.
- tar_file=$1
- pkg_name=$2
+ # Extract manifest from the tar-ball and only extract files entries.
+ tar xf "$1" -O "./$pkg_db/$2/manifest" | sed '/\/$/d' > "$cac_dir/$pid-m"
- # Enable globbing.
+ cd "$sys_db"
set +f
- # Generate a list of all installed package manifests.
- set -f -- "$sys_db/"*/manifest
-
- # Go through the manifest list and filter out the
- # package which will be installed.
- for manifest; do
- shift
-
- case $manifest in
- */$pkg_name/manifest) continue
- esac
-
- set -- "$@" "$manifest"
- done
-
- # 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"
+ # Iterate over each manifest and check it for conflicts.
+ for db in *; do
+ [ "$db" != "$2" ] &&
+ grep -HFxf "$cac_dir/$pid-m" "$db/manifest" 2>/dev/null &&
+ die "Package '$2' conflicts with another package"
+ done ||:
- # Force a '0' return code as the 'grep' above fails on success.
- :
+ set -f
}
pkg_remove() {
@@ -866,7 +846,7 @@ pkg_clean() {
trap '' INT
# Remove temporary directories.
- rm -rf -- "$mak_dir" "$pkg_dir" "$tar_dir"
+ rm -rf -- "$mak_dir" "$pkg_dir" "$tar_dir" "$cac_dir/$pid-m"
}
args() {