kiss: optimize pkg_conflicts
This commit is contained in:
parent
9ef498e308
commit
cc31977ecb
43
kiss
43
kiss
|
@ -639,29 +639,42 @@ pkg_conflicts() {
|
||||||
# This function takes a path to a KISS tar-ball as an argument.
|
# This function takes a path to a KISS tar-ball as an argument.
|
||||||
log "[$2] Checking for package conflicts"
|
log "[$2] Checking for package conflicts"
|
||||||
|
|
||||||
# Extract manifest from the tar-ball and only extract files entries.
|
# Save the package name as we modify the argument list below.
|
||||||
tar xf "$1" -O "./$pkg_db/$2/manifest" |
|
tar_file=$1
|
||||||
while read -r line; do
|
pkg_name=$2
|
||||||
[ "${line%%*/}" ] && printf '%s\n' "$line" >> "$cac_dir/manifest-$pid"
|
|
||||||
done ||:
|
|
||||||
|
|
||||||
# Enable globbing.
|
# Enable globbing.
|
||||||
set +f
|
set +f
|
||||||
|
|
||||||
# Compare extracted manifest to all installed manifests.
|
# Generate a list of all installed package manifests.
|
||||||
# If there are matching lines (files) there is a package conflict.
|
set -f -- "$KISS_ROOT/$pkg_db/"*/manifest
|
||||||
for db in "$KISS_ROOT/$pkg_db/"*; do
|
|
||||||
[ "$2" = "${db##*/}" ] && continue
|
|
||||||
|
|
||||||
grep -Fxf "$cac_dir/manifest-$pid" "$db/manifest" 2>/dev/null &&
|
# Go through the manifest list and filter out the
|
||||||
die "Package '$2' conflicts with '${db##*/}'"
|
# package which will be installed.
|
||||||
|
for manifest; do
|
||||||
|
manifest_name=${manifest%/*}
|
||||||
|
manifest_name=${manifest_name##*/}
|
||||||
|
|
||||||
|
shift
|
||||||
|
|
||||||
|
[ "$manifest_name" = "$pkg_name" ] &&
|
||||||
|
continue
|
||||||
|
|
||||||
|
set -- "$@" "$manifest"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Disable globbing.
|
# Extract manifest from the tar-ball and only extract files entries.
|
||||||
set -f
|
tar xf "$tar_file" -O "./$pkg_db/$pkg_name/manifest" |
|
||||||
|
while read -r line; do
|
||||||
|
[ "${line%%*/}" ] && printf '%s\n' "$line"
|
||||||
|
done |
|
||||||
|
|
||||||
# Remove this temporary file as we no longer need it.
|
# Compare the package's files against all owned files on the system.
|
||||||
rm -f "$cac_dir/manifest-$pid"
|
grep -Fxf - "$@" 2>/dev/null &&
|
||||||
|
die "Package '$pkg_name' conflicts with another package"
|
||||||
|
|
||||||
|
# Force a '0' return code as the 'grep' above fails on success.
|
||||||
|
:
|
||||||
}
|
}
|
||||||
|
|
||||||
pkg_remove() {
|
pkg_remove() {
|
||||||
|
|
Loading…
Reference in New Issue