[Dev] [dbscripts] [PATCH 10/31] db-update: Disallow invalid package names [ci skip]

Luke Shumaker lukeshu at lukeshu.com
Fri Apr 6 18:43:43 GMT 2018


From: Pierre Schmitz <pierre at archlinux.de>

(cherry picked from commit e84b36059f82edb6d5f9eec1c99695cc80e6fb82)
---
 db-functions              |  2 +-
 test/cases/db-update.bats | 25 ++++++++++++++++++++++++-
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/db-functions b/db-functions
index 2629b85..2ef0a44 100644
--- a/db-functions
+++ b/db-functions
@@ -297,7 +297,7 @@ check_pkgfile() {
 
 	in_array "${pkgarch}" "${ARCHES[@]}" 'any' || return 1
 
-	if echo "${pkgfile##*/}" | grep "${pkgname}-${pkgver}-${pkgarch}" &>/dev/null; then
+	if echo "${pkgfile##*/}" | grep "^${pkgname}-${pkgver}-${pkgarch}" &>/dev/null; then
 		return 0
 	else
 		return 1
diff --git a/test/cases/db-update.bats b/test/cases/db-update.bats
index f0bb85b..4163530 100755
--- a/test/cases/db-update.bats
+++ b/test/cases/db-update.bats
@@ -128,7 +128,6 @@ load ../lib/common
 	done
 }
 
-
 @test "add incomplete split package" {
 	skip # commented out with "This is fucking obnoxious" -- abslibre is broken
 	local repo='extra'
@@ -191,3 +190,27 @@ load ../lib/common
 
 	checkRemovedPackage extra pkg-simple-a-1-1-i686.pkg.tar.xz i686
 }
+
+ at test "add package with inconsistent version fails" {
+	local p
+	releasePackage extra 'pkg-simple-a' 'i686'
+
+	for p in "${STAGING}"/extra/*; do
+		mv "${p}" "${p/1/2}"
+	done
+
+	! db-update >/dev/null 2>&1
+	checkRemovedPackage extra 'pkg-simple-a-2-1-i686.pkg.tar.xz' 'i686'
+}
+
+ at test "add package with inconsistent name fails" {
+	local p
+	releasePackage extra 'pkg-simple-a' 'i686'
+
+	for p in "${STAGING}"/extra/*; do
+		mv "${p}" "${p/pkg-/foo-pkg-}"
+	done
+
+	! db-update >/dev/null 2>&1
+	checkRemovedPackage extra 'foo-pkg-simple-a-1-1-i686.pkg.tar.xz' 'i686'
+}
-- 
2.16.2




More information about the Dev mailing list