From e3145335fb336b83e32ba22a0ec259e0c1cbe61a Mon Sep 17 00:00:00 2001 From: merakor Date: Sun, 25 Oct 2020 21:43:52 +0000 Subject: pkg_owner(): add function to retrieve the owning package of a file This function is almost identical to the function with the same name on kiss. However, instead of saving the owner on a global variable, the function prints the owning package to the standard output. The function can be called similar to grep. The usage is: pkg_owner GREP_FLAGS FILE_TO_CHECK MANIFEST_LOCATIONS... If no manifest is specified, the function will use every installed package on the system database. FossilOrigin-Name: 53cbeff7a92850efd172960f12848885961655c9c53e24a5f8cb8da7642ce541 --- src/cpt-lib | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/cpt-lib b/src/cpt-lib index 12d2f2d..56f43de 100644 --- a/src/cpt-lib +++ b/src/cpt-lib @@ -393,6 +393,19 @@ sh256() { while read -r hash _; do printf '%s %s\n' "$hash" "$1"; done } +pkg_owner() { + set +f + + [ "$3" ] || set -- "$1" "$2" "$sys_db"/*/manifest + + pkg_owner=$(grep "$@") + pkg_owner=${pkg_owner%/*} + pkg_owner=${pkg_owner##*/} + + set -f -- "$pkg_owner"; unset pkg_owner + [ "$1" ] && printf '%s\n' "$1" +} + pkg_isbuilt() ( # Check if a package is built or not. read -r ver rel < "$(pkg_find "$1")/version" -- cgit v1.2.3