Compare commits

..

2 Commits

Author SHA1 Message Date
Vekhir --
d9b8c8019b Merge branch 'fix-pkgrel-pkgver-match' into 'master'
fix(pkgbuild.sh): Use grep -Fx to check for pkgrel and pkgver declaration

Closes #242

See merge request archlinux/devtools!283
2025-07-25 12:19:58 +00:00
Vekhir
b66d2a4928 fix(pkgbuild.sh): Use grep -Fx to check for pkgrel and pkgver declaration
In order to automatically replace pkgrel and pkgver, we must first check
that they are declared in the usual way as a key-value pair.
If pkgrel or pkgver contain special characters like +, they are currently
interpreted as regex. Use -F to instead signify that they should be literal
patterns. Since the declaration must be on its own line and anchors can't be
in literal patterns, also specify -x to only consider whole line matches.
2025-03-02 07:39:54 +00:00
2 changed files with 9 additions and 9 deletions

View File

@@ -94,19 +94,19 @@ pkgctl_license_check() {
pushd "${path}" >/dev/null pushd "${path}" >/dev/null
if [[ ! -f PKGBUILD ]]; then if [[ ! -f PKGBUILD ]]; then
msg_error "${BOLD}${path}:${ALL_OFF} no PKGBUILD found" msg_error "${BOLD}${pkgbase}:${ALL_OFF} no PKGBUILD found"
return 1 return 1
fi fi
if [[ ! -f .SRCINFO ]]; then # reset common PKGBUILD variables
msg_error "${BOLD}${path}:${ALL_OFF} no .SRCINFO found" unset pkgbase
return 1
fi
if ! pkgbase=$(grep --max-count=1 --extended-regexp "pkgbase = (.+)" .SRCINFO | awk '{print $3}'); then # shellcheck source=contrib/makepkg/PKGBUILD.proto
msg_error "${BOLD}${path}:${ALL_OFF} pkgbase not found in .SRCINFO" if ! . ./PKGBUILD; then
msg_error "${BOLD}${pkgbase}:${ALL_OFF} failed to source PKGBUILD"
return 1 return 1
fi fi
pkgbase=${pkgbase:-$pkgname}
if [[ ! -e LICENSE ]]; then if [[ ! -e LICENSE ]]; then
msg_error "${BOLD}${pkgbase}:${ALL_OFF} is missing the LICENSE file" msg_error "${BOLD}${pkgbase}:${ALL_OFF} is missing the LICENSE file"

View File

@@ -26,7 +26,7 @@ pkgbuild_set_pkgver() {
warning 'setting pkgver variable has no effect if the PKGBUILD has a pkgver() function' warning 'setting pkgver variable has no effect if the PKGBUILD has a pkgver() function'
fi fi
if ! grep --extended-regexp --quiet --max-count=1 "^pkgver=${pkgver}$" PKGBUILD; then if ! grep -Fx --quiet --max-count=1 "pkgver=${pkgver}" PKGBUILD; then
die "Non-standard pkgver declaration" die "Non-standard pkgver declaration"
fi fi
sed --regexp-extended "s|^(pkgver=)${pkgver}$|\1${new_pkgver}|g" --in-place PKGBUILD sed --regexp-extended "s|^(pkgver=)${pkgver}$|\1${new_pkgver}|g" --in-place PKGBUILD
@@ -38,7 +38,7 @@ pkgbuild_set_pkgrel() {
local new_pkgrel=$1 local new_pkgrel=$1
local pkgrel=${pkgrel} local pkgrel=${pkgrel}
if ! grep --extended-regexp --quiet --max-count=1 "^pkgrel=${pkgrel}$" PKGBUILD; then if ! grep -Fx --quiet --max-count=1 "pkgrel=${pkgrel}" PKGBUILD; then
die "Non-standard pkgrel declaration" die "Non-standard pkgrel declaration"
fi fi
sed --regexp-extended "s|^(pkgrel=)${pkgrel}$|\1${new_pkgrel}|g" --in-place PKGBUILD sed --regexp-extended "s|^(pkgrel=)${pkgrel}$|\1${new_pkgrel}|g" --in-place PKGBUILD