[pacman-dev] [PATCH 1/2] libmakepkg/lint_pkgbuild: fix regression in linting depends=(foo=$pkgver-$pkgrel)

Eli Schwartz eschwartz at archlinux.org
Wed May 2 18:24:43 UTC 2018


In commit 91b72cc386ca03241791748da5da2b150c724ace support was added for
linting depends/etc. to ensure they contain only valid dependency
specifiers. However it did not properly take into account the
possibility of dependencies linked to a specific pkgrel, which promptly
failed to build because "-" is not allowed in a pkgver.

This is something supported by pacman and useful for e.g. split packages
which cannot be mismatched even if the pkgver is the same. Fix by
removing an optional suffixed "-$decimal" when checking for a valid
pkgver.

Signed-off-by: Eli Schwartz <eschwartz at archlinux.org>
---

Ouch! Sorry...

 scripts/libmakepkg/lint_pkgbuild/checkdepends.sh.in | 3 ++-
 scripts/libmakepkg/lint_pkgbuild/conflicts.sh.in    | 3 ++-
 scripts/libmakepkg/lint_pkgbuild/depends.sh.in      | 3 ++-
 scripts/libmakepkg/lint_pkgbuild/makedepends.sh.in  | 3 ++-
 scripts/libmakepkg/lint_pkgbuild/provides.sh.in     | 9 ++++++++-
 5 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/scripts/libmakepkg/lint_pkgbuild/checkdepends.sh.in b/scripts/libmakepkg/lint_pkgbuild/checkdepends.sh.in
index 5d15bfb2..a4f297d9 100644
--- a/scripts/libmakepkg/lint_pkgbuild/checkdepends.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/checkdepends.sh.in
@@ -46,7 +46,8 @@ lint_checkdepends() {
 		ver=${checkdepend#*@(<|>|=|>=|<=)}
 		lint_one_pkgname checkdepends "$name" || ret=1
 		if [[ $ver != $checkdepend ]]; then
-			check_pkgver "$ver" checkdepends || ret=1
+			# remove optional pkgrel in version specifier
+			check_pkgver "${ver%-+([0-9])?(.+([0-9]))}" checkdepends || ret=1
 		fi
 	done
 
diff --git a/scripts/libmakepkg/lint_pkgbuild/conflicts.sh.in b/scripts/libmakepkg/lint_pkgbuild/conflicts.sh.in
index d81e9784..0f81ddb1 100644
--- a/scripts/libmakepkg/lint_pkgbuild/conflicts.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/conflicts.sh.in
@@ -46,7 +46,8 @@ lint_conflicts() {
 		ver=${conflict#*@(<|>|=|>=|<=)}
 		lint_one_pkgname conflicts "$name" || ret=1
 		if [[ $ver != $conflict ]]; then
-			check_pkgver "$ver" conflicts || ret=1
+			# remove optional pkgrel in version specifier
+			check_pkgver "${ver%-+([0-9])?(.+([0-9]))}" conflicts || ret=1
 		fi
 	done
 
diff --git a/scripts/libmakepkg/lint_pkgbuild/depends.sh.in b/scripts/libmakepkg/lint_pkgbuild/depends.sh.in
index f17bc545..cbd97706 100644
--- a/scripts/libmakepkg/lint_pkgbuild/depends.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/depends.sh.in
@@ -46,7 +46,8 @@ lint_depends() {
 		ver=${depend#*@(<|>|=|>=|<=)}
 		lint_one_pkgname depends "$name" || ret=1
 		if [[ $ver != $depend ]]; then
-			check_pkgver "$ver" depends || ret=1
+			# remove optional pkgrel in version specifier
+			check_pkgver "${ver%-+([0-9])?(.+([0-9]))}" depends || ret=1
 		fi
 	done
 
diff --git a/scripts/libmakepkg/lint_pkgbuild/makedepends.sh.in b/scripts/libmakepkg/lint_pkgbuild/makedepends.sh.in
index 1d0762fb..fc1549d5 100644
--- a/scripts/libmakepkg/lint_pkgbuild/makedepends.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/makedepends.sh.in
@@ -46,7 +46,8 @@ lint_makedepends() {
 		ver=${makedepend#*@(<|>|=|>=|<=)}
 		lint_one_pkgname makedepends "$name" || ret=1
 		if [[ $ver != $makedepend ]]; then
-			check_pkgver "$ver" makedepends || ret=1
+			# remove optional pkgrel in version specifier
+			check_pkgver "${ver%-+([0-9])?(.+([0-9]))}" makedepends || ret=1
 		fi
 	done
 
diff --git a/scripts/libmakepkg/lint_pkgbuild/provides.sh.in b/scripts/libmakepkg/lint_pkgbuild/provides.sh.in
index 7500a88a..a0bef4f5 100644
--- a/scripts/libmakepkg/lint_pkgbuild/provides.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/provides.sh.in
@@ -37,6 +37,10 @@ lint_provides() {
 
 	get_pkgbuild_all_split_attributes provides provides_list
 
+	# this function requires extglob - save current status to restore later
+	local shellopts=$(shopt -p extglob)
+	shopt -s extglob
+
 	for provide in "${provides_list[@]}"; do
 		if [[ $provide == *['<>']* ]]; then
 			error "$(gettext "%s array cannot contain comparison (< or >) operators.")" "provides"
@@ -47,9 +51,12 @@ lint_provides() {
 		ver=${provide#*=}
 		lint_one_pkgname provides "$name" || ret=1
 		if [[ $ver != $provide ]]; then
-			check_pkgver "$ver" provides || ret=1
+			# remove optional pkgrel in version specifier
+			check_pkgver "${ver%-+([0-9])?(.+([0-9]))}" provides || ret=1
 		fi
 	done
 
+	eval "$shellopts"
+
 	return $ret
 }
-- 
2.17.0


More information about the pacman-dev mailing list