forked from kiss-community/kiss
kiss: fix regex error
1. Matching of owner was .*<path>$ to accomodate pkg_fix_deps's partial path resolution (/lib instead of /usr/lib). Code now changed to search fully resolved paths. 2. Our matching is now fixed strings and whole line. This removes the possibility of false-positives due to partial matching by prior regex (/bin/ls -> /usr/local/bin/ls (wrong file!)) 3. This should be faster (no more regex, now full line matches). Closes #241
This commit is contained in:
parent
08631865e9
commit
22d96abf58
36
kiss
36
kiss
@ -142,13 +142,27 @@ as_user() {
|
|||||||
pkg_owner() {
|
pkg_owner() {
|
||||||
ok "$2" || { set +f; set -f -- "$1" "$sys_db"/*/manifest; }
|
ok "$2" || { set +f; set -f -- "$1" "$sys_db"/*/manifest; }
|
||||||
|
|
||||||
_owns=$(grep -l "$@")
|
_owns=$(grep -lxF "$@")
|
||||||
_owns=${_owns%/*}
|
_owns=${_owns%/*}
|
||||||
_owns=${_owns##*/}
|
_owns=${_owns##*/}
|
||||||
|
|
||||||
ok "$_owns"
|
ok "$_owns"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resolve_path() {
|
||||||
|
_rpath=$KISS_ROOT/${1#/}
|
||||||
|
|
||||||
|
# Attempt to resolve symlinks by using 'cd'.
|
||||||
|
# If this fails, fallback to the file's parent
|
||||||
|
# directory.
|
||||||
|
cd -P "${_rpath%/*}" 2>/dev/null || PWD=${_rpath%/*}
|
||||||
|
|
||||||
|
# Final resolved path.
|
||||||
|
_rpath=${PWD#"$KISS_ROOT"}/${_rpath##*/}
|
||||||
|
|
||||||
|
cd "$OLDPWD"
|
||||||
|
}
|
||||||
|
|
||||||
run_hook() {
|
run_hook() {
|
||||||
# Run all hooks in KISS_HOOK (a colon separated
|
# Run all hooks in KISS_HOOK (a colon separated
|
||||||
# list of absolute file paths).
|
# list of absolute file paths).
|
||||||
@ -671,11 +685,13 @@ pkg_fix_deps() {
|
|||||||
continue
|
continue
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
resolve_path "$lib"
|
||||||
|
|
||||||
# Skip file if owned by current package
|
# Skip file if owned by current package
|
||||||
! pkg_owner "/${lib#/}\$" manifest ||
|
! pkg_owner -e "$_rpath" manifest ||
|
||||||
continue
|
continue
|
||||||
|
|
||||||
! pkg_owner "/${lib#/}\$" "$@" ||
|
! pkg_owner -e "$_rpath" "$@" ||
|
||||||
printf '%s\n' "$_owns"
|
printf '%s\n' "$_owns"
|
||||||
|
|
||||||
esac done <<EOF || :
|
esac done <<EOF || :
|
||||||
@ -1032,17 +1048,9 @@ pkg_conflicts() {
|
|||||||
# Filter the tarball's manifest and select only files. Resolve all
|
# Filter the tarball's manifest and select only files. Resolve all
|
||||||
# symlinks in file paths as well.
|
# symlinks in file paths as well.
|
||||||
while read -r file; do case $file in *[!/])
|
while read -r file; do case $file in *[!/])
|
||||||
file=$KISS_ROOT/${file#/}
|
resolve_path "$file"
|
||||||
|
|
||||||
# Attempt to resolve symlinks by using 'cd'.
|
|
||||||
# If this fails, fallback to the file's parent
|
|
||||||
# directory.
|
|
||||||
cd -P "${file%/*}" 2>/dev/null || PWD=${file%/*}
|
|
||||||
|
|
||||||
# Print the file with all symlinks in its path
|
|
||||||
# resolved to their real locations.
|
|
||||||
printf '%s\n' "${PWD#"$KISS_ROOT"}/${file##*/}"
|
|
||||||
|
|
||||||
|
printf '%s\n' "$_rpath"
|
||||||
esac done < "$PWD/$pkg_db/$_pkg/manifest" > "$_tmp_file_pre"
|
esac done < "$PWD/$pkg_db/$_pkg/manifest" > "$_tmp_file_pre"
|
||||||
|
|
||||||
cd "$tar_dir/$_pkg"
|
cd "$tar_dir/$_pkg"
|
||||||
@ -1134,7 +1142,7 @@ pkg_swap() {
|
|||||||
die "Alternative '$1 ${2:-null}' doesn't exist"
|
die "Alternative '$1 ${2:-null}' doesn't exist"
|
||||||
|
|
||||||
if [ -f "$KISS_ROOT$2" ]; then
|
if [ -f "$KISS_ROOT$2" ]; then
|
||||||
pkg_owner "/${2#/}\$" ||
|
pkg_owner "/${2#/}" ||
|
||||||
die "File '$2' exists on filesystem but isn't owned"
|
die "File '$2' exists on filesystem but isn't owned"
|
||||||
|
|
||||||
log "Swapping '$2' from '$_owns' to '$1'"
|
log "Swapping '$2' from '$_owns' to '$1'"
|
||||||
|
Loading…
Reference in New Issue
Block a user