From d296b90b75d02ee81ec9a5902f107144f6dda3b8 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 14 Jul 2021 17:08:58 +0300 Subject: [PATCH] kiss: support variables in sources files. This adds support for replacement of simple markers with corresponding values. To handle cases where a replacement is not 1:1, various transformations are made available. - VERSION : The full version string (first field in version file). - MAJOR : First component separated by '.'. - MINOR : Second component separated by '.'. - PATCH : Third component separated by '.'. - IDENT : All remaining components separated by '.+-'. - PKG : The name of the current package. NOTE: This may be reverted. Depends on how good the benefits are. Will do an evaluation of the repositories. --- kiss | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/kiss b/kiss index 3bf9eb8..3abe311 100755 --- a/kiss +++ b/kiss @@ -278,10 +278,41 @@ pkg_cache() { [ -f "$2" ] } +source_resolve_vars() { + # Replace all occurances of markers with their respective values + # if found in the source string. + _src_sub() { _src_res=${_src_res%"$1"*}${2}${_src_res##*"$1"}; } + _src_res=$1 + + # Split the version on '.' to obtain MAJOR, MINOR and PATCH. + # Fields beyond this are currently unsupported, the entire + # version string is still available via VERSION. + # + # Intentional, globbing disabled. + # shellcheck disable=2086 + IFS=.+- read -r major minor patch ident <