aboutsummaryrefslogtreecommitdiffstats
path: root/main/abuild/0001-abuild-try-to-validate-maintainer-address.patch
blob: 9198661356b708f64ac841f285dd344881676e1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
From aa32ec14e67bc003697625a1a4ca7cad69480c20 Mon Sep 17 00:00:00 2001
From: Carlo Landmeter <clandmeter@gmail.com>
Date: Wed, 16 Sep 2015 11:00:10 +0200
Subject: [PATCH] abuild: try to validate maintainer address

abuild will error when the maintainer is set but is not a RFC822 address
---
 abuild.in | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/abuild.in b/abuild.in
index f2b322d..557775e 100644
--- a/abuild.in
+++ b/abuild.in
@@ -210,7 +210,7 @@ default_sanitycheck() {
 	[ -n "$pkggroup" ] && spell_error pkggroup pkggroups
 	[ -n "$subpackage" ] && spell_error subpackage subpackages
 
-	grep '^# Maintainer:' $APKBUILD >/dev/null || warning "No maintainer"
+	get_maintainer || die "Provide a valid RFC822 maintainer address"
 
 	makedepends_has 'g++' && warning "g++ should not be in makedepends"
 	return 0
@@ -721,9 +721,25 @@ git_last_commit() {
 	git log --format=oneline -n 1 "$startdir" | awk '{print $1}'
 }
 
+# this will try to check for a valid rfc822 address
+check_rfc822() {
+	local address="$1"
+	case "$address" in
+		*[A-Za-z0-9]*\ \<*@*.*\>) ;;
+		*) return 1 ;;
+	esac
+}
+
 get_maintainer() {
 	if [ -z "$maintainer" ]; then
 		maintainer=$(awk -F': ' '/\# *Maintainer/ {print $2}' "$APKBUILD")
+		# remove surrounding whitespace
+		maintainer=$(echo "$maintainer" | xargs)
+		if ! [ -z "$maintainer" ]; then
+			check_rfc822 "$maintainer" || return 1
+		else
+			warning "No maintainer"
+		fi
 	fi
 }
 
@@ -789,7 +805,6 @@ EOF
 	fi
 	echo "commit = $last_commit" >> "$pkginfo"
 
-	get_maintainer
 	if [ -n "$maintainer" ]; then
 		echo "maintainer = $maintainer" >> "$pkginfo"
 	fi
-- 
2.5.2