diff options
author | dylan.araps@gmail.com <dylan.araps@gmail.com> | 2019-09-11 08:30:43 +0000 |
---|---|---|
committer | dylan.araps@gmail.com <dylan.araps@gmail.com> | 2019-09-11 08:30:43 +0000 |
commit | b128efcb0c0ce5ff386763d3b64d645b25a43b5a (patch) | |
tree | 051cefcb5b1bea65366ad028a82412dd05827e13 | |
parent | a514ea41a71d36a3151d110d4c6bd681fc9b9454 (diff) | |
download | cpt-b128efcb0c0ce5ff386763d3b64d645b25a43b5a.tar.gz |
pkg_conflicts: smaller and safer
FossilOrigin-Name: 28a7a91f5626cd47823c0b644cbd668523fff305499d721267f76b66ffb897f4
-rwxr-xr-x | kiss | 42 |
1 files changed, 11 insertions, 31 deletions
@@ -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() { |