mirror of
https://codeberg.org/kiss-community/kiss
synced 2024-11-04 14:05:41 -07:00
cb9fe25776
Co-authored-by: git-bruh <e817509a-8ee9-4332-b0ad-3a6bdf9ab63f@aleeas.com> Reviewed-on: https://codeberg.org/kiss-community/kiss/pulls/86
37 lines
676 B
Bash
Executable File
37 lines
676 B
Bash
Executable File
#!/bin/sh -e
|
|
# Check which package owns a file
|
|
|
|
# Follow symlinks to any paths.
|
|
case $1 in
|
|
/*)
|
|
cd -P "${KISS_ROOT:-/}${1%/*}"
|
|
[ "$PWD" = / ] && KISS_ROOT=
|
|
;;
|
|
|
|
*/*)
|
|
cd -P "${1%/*}"
|
|
;;
|
|
|
|
*)
|
|
cd -P .
|
|
;;
|
|
esac
|
|
|
|
[ -f "$PWD/${1##*/}" ] || {
|
|
printf 'usage: kiss-owns [/path/to/file]\n' >&2
|
|
exit 1
|
|
}
|
|
|
|
# Print the full path to the manifest file which contains
|
|
# the match to our search.
|
|
pkg_owns=$(grep -lFx \
|
|
"${PWD#"$KISS_ROOT"}/${1##*/}" \
|
|
"$KISS_ROOT/var/db/kiss/installed/"*/manifest)
|
|
|
|
|
|
# Extract the package name from the path above.
|
|
pkg_owns=${pkg_owns%/*}
|
|
pkg_owns=${pkg_owns##*/}
|
|
|
|
printf '%s\n' "$pkg_owns"
|