diff options
author | merakor <cem@ckyln.com> | 2021-02-23 13:40:30 +0000 |
---|---|---|
committer | merakor <cem@ckyln.com> | 2021-02-23 13:40:30 +0000 |
commit | 5a9bd4ebbde9f250633455505816e0cea8289e30 (patch) | |
tree | 82e49fa45ea2aa7dd26b33ed38e02bfe7b3c5dfd | |
parent | f134f150ed336ad6b418806ce5720c07507b3913 (diff) | |
download | cpt-5a9bd4ebbde9f250633455505816e0cea8289e30.tar.gz |
pkg_query_meta(): new function to query meta files inside package directories
FossilOrigin-Name: 6ffa441f3ea44d7176fd45de239f0f54ac2175f1e17b6d6419579a2d5c2cbc98
-rw-r--r-- | src/cpt-lib.in | 14 |
1 files changed, 14 insertions, 0 deletions
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. |