cpt

[ARCHIVED] Carbs Packaging Tools
git clone git://git.ckyln.com/~cem/cpt.git
Log | Files | Refs | README | LICENSE

commit cc31977ecb2dce4d5f36c35a883ffdfabccf2c00
parent 9ef498e3080042d7698e7d601b9943d373aa4ac8
Author: Dylan Araps <dylan.araps@gmail.com>
Date:   Tue, 20 Aug 2019 11:58:24 +0000

kiss: optimize pkg_conflicts

Diffstat:
Mkiss | 43++++++++++++++++++++++++++++---------------
1 file changed, 28 insertions(+), 15 deletions(-)

diff --git 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() {