From 5a9bd4ebbde9f250633455505816e0cea8289e30 Mon Sep 17 00:00:00 2001 From: merakor Date: Tue, 23 Feb 2021 13:40:30 +0000 Subject: pkg_query_meta(): new function to query meta files inside package directories FossilOrigin-Name: 6ffa441f3ea44d7176fd45de239f0f54ac2175f1e17b6d6419579a2d5c2cbc98 --- src/cpt-lib.in | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/cpt-lib.in b/src/cpt-lib.in index 2c7471f..0e80577 100644 --- a/src/cpt-lib.in +++ b/src/cpt-lib.in @@ -1911,6 +1911,20 @@ pkg_gentree() ( printf "$format" "$@" ) +pkg_query_meta() { + # Query the 'meta' file of the given meta package. If there is no meta file, + # or the key being queried is unavailable, the function will return with + # error. + repo_dir=$(pkg_find "$1") + [ -f "$repo_dir/meta" ] || return + while IFS=': ' read -r key val; do + case $key in + "$2") printf '%s\n' "$val"; return 0 + esac + done < "$repo_dir/meta" + return 1 +} + pkg_clean() { # Clean up on exit or error. This removes everything related # to the build. -- cgit v1.2.3