summaryrefslogtreecommitdiff
path: root/libre/qutebrowser/PKGBUILD
diff options
context:
space:
mode:
authorbill-auger <mr.j.spam.me@gmail.com>2023-08-28 16:15:19 -0400
committerbill-auger <mr.j.spam.me@gmail.com>2023-09-09 23:22:46 -0400
commite12ab1a472156d18db504b7510a4906530350f22 (patch)
treee7988a4ad074aeca7c4f7030e9421dbf87821105 /libre/qutebrowser/PKGBUILD
parent9b8c97d0384fd89fc6518a0a8ca2071266a684e9 (diff)
housekeeping - nornmalize _version_constraint() implementations across PKGBUILDs
Diffstat (limited to 'libre/qutebrowser/PKGBUILD')
-rw-r--r--libre/qutebrowser/PKGBUILD53
1 files changed, 37 insertions, 16 deletions
diff --git a/libre/qutebrowser/PKGBUILD b/libre/qutebrowser/PKGBUILD
index c8da6833c..be86517b3 100644
--- a/libre/qutebrowser/PKGBUILD
+++ b/libre/qutebrowser/PKGBUILD
@@ -53,31 +53,52 @@ sha256sums+=('e18216f24387b61a109611958bb59248beaf5afc90da8654e29ea8b0a7ef1610')
_version_constraint() # (dep_pkgname [precision])
{
+ Log() { [[ "${FUNCNAME[2]}" == package ]] && echo "$@" >&2 || : ; }
+
+
local dep_pkgname=$1
- local full_version=$(pacman -S --print-format='%v' ${dep_pkgname} | tail -n 1)
+ declare -i req_precision=$2
+ local full_version=$(pacman -S --print-format='%v' ${dep_pkgname} 2> /dev/null | tail -n 1)
local n_dots=$(tmp=${full_version%-*} ; tmp=${tmp//[^\.]} ; echo "${#tmp}" ;)
local def_precision=$(( n_dots + 1 ))
- local precision=$( [[ "$2" =~ ^[1-${def_precision}]$ ]] && echo $2 || echo ${def_precision} )
- local pkgver_rx='[^-\.\ ]+'
+ local is_prec_valid=$(( req_precision > 0 && req_precision <= def_precision ))
+ local precision=$( (( is_prec_valid )) && echo ${req_precision} || echo ${def_precision} )
+ local pkgver_rx='[0-9A-Za-z_]+'
+ pkgver_rx=$(sed 's|\]|\+]|' <<<${pkgver_rx}) # according to the wiki, '+' is not allowed,
+ # but some pkgver have it (eg: 5.15.10+kde+r130)
local subver_rx='\.'${pkgver_rx}
- local pkgrel_rx='[^-\ ]+'
+ local pkgrel_rx='[0-9]+'
+ local garbage_rx='[^0-9].*'
local capture_rx=${pkgver_rx}
- for (( n_dots=1 ; n_dots < precision ; n_dots++ )) ; do capture_rx+=${subver_rx} ; done ;
-
- if [[ "${full_version}" =~ ^(${capture_rx})(${subver_rx})*-${pkgrel_rx}$ ]]
- then local version=${BASH_REMATCH[1]}
- local subver_inc=$(( ${version##*.} + 1 ))
- local version_inc=$( [[ "${version}" =~ \. ]] && echo ${version%.*}.${subver_inc} || \
- echo ${subver_inc} )
- local constraint_string="${dep_pkgname}>=${version} ${dep_pkgname}<${version_inc}"
-
- echo "applied version constraint: ${constraint_string}" >&2
- echo -n "${constraint_string}"
- else echo "ERROR: _version_constraint() error parsing: dep_pkgname='${dep_pkgname}' full_version='${full_version}'" >&2
+ for (( n_dots=1 ; n_dots < precision ; ++n_dots )) ; do capture_rx+=${subver_rx} ; done ;
+ local version pkgrel has_split_char version_min version_max constraint_string
+ declare -i subver subver_inc pkgrel_inc
+
+ if [[ "${full_version}" =~ ^(${capture_rx})(${subver_rx})*-(${pkgrel_rx}).*$ ]]
+ then version=${BASH_REMATCH[1]} # pkgver cut to the requested precision
+ #unused=${BASH_REMATCH[2]} # discarded pkgver segments
+ pkgrel=${BASH_REMATCH[3]} # pkgrel with non-numerics right-trimmed
+ has_split_char=$(grep '\.' <<<${version} &> /dev/null ; echo $((! $?)) ; )
+ subver=$(sed "s|${garbage_rx}||" <<<${version##*.}) # right-trim from any non-numeric
+ version=$( ((has_split_char)) && echo ${version%.*}.${subver} || echo ${subver} )
+ subver_inc=$(( subver + 1 ))
+ pkgrel_inc=$(( pkgrel + 1 ))
+ version_min=$( (( ! is_prec_valid )) && echo ${full_version%-*}-${pkgrel} || \
+ echo ${version} )
+ version_max=$( ( (( ! is_prec_valid )) && echo ${full_version%-*}-${pkgrel_inc} ) || \
+ ( [[ "${version}" =~ \. ]] && echo ${version%.*}.${subver_inc} ) || \
+ echo ${subver_inc} )
+ constraint_string="${dep_pkgname}>=${version_min} ${dep_pkgname}<${version_max}"
+
+ Log "Applied version constraint: '${constraint_string}'"
+ else Log "ERROR: in _version_constraint() parsing: dep_pkgname='${dep_pkgname}' full_version='${full_version}'"
exit 1
fi
+
+ echo -n "${constraint_string}"
}
+
prepare() {
# bsdtar: Pathname can't be converted from UTF-8 to current locale
tar xzf "$srcdir"/qutebrowser-$pkgver.tar.gz