kiss: only split version once per package

This commit is contained in:
Dylan Araps 2021-07-14 23:39:44 +03:00
parent aa0c62fe4a
commit 679d145434
No known key found for this signature in database
GPG Key ID: 13295DAC2CF13B5C
1 changed files with 14 additions and 15 deletions

29
kiss
View File

@ -184,6 +184,15 @@ pkg_find_version() {
read -r repo_ver repo_rel 2>/dev/null < "$repo_dir/version" ||
die "$1" "Failed to read version file ($repo_dir/version)"
case $2 in *?*)
# Split the version on '.+-' to obtain individual components.
# Intentional, globbing disabled.
# shellcheck disable=2086
IFS=.+- read -r repo_major repo_minor repo_patch repo_ident <<EOF
$repo_ver
EOF
esac
}
pkg_find_die() {
@ -276,24 +285,14 @@ source_resolve_vars() {
_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 <<EOF
$repo_ver
EOF
# Loop until no identifiers are found and all have been removed.
# This works backwards replacing each identifier with its value.
while :; do case $_src_res in
*VERSION*) _src_sub VERSION "$repo_ver" ;;
*MAJOR*) _src_sub MAJOR "$major" ;;
*MINOR*) _src_sub MINOR "$minor" ;;
*PATCH*) _src_sub PATCH "$patch" ;;
*IDENT*) _src_sub IDENT "$ident" ;;
*MAJOR*) _src_sub MAJOR "$repo_major" ;;
*MINOR*) _src_sub MINOR "$repo_minor" ;;
*PATCH*) _src_sub PATCH "$repo_patch" ;;
*IDENT*) _src_sub IDENT "$repo_ident" ;;
*PKG*) _src_sub PKG "${repo_dir##*/}" ;;
*) break
esac done
@ -349,7 +348,7 @@ pkg_source_resolve() {
pkg_source() {
# Download any remote package sources. The existence of local files is
# also checked.
pkg_find_version "$1"
pkg_find_version "$1" 1
# Support packages without sources. Simply do nothing.
[ -f "$repo_dir/sources" ] || return 0