File tree 5 files changed +114
-0
lines changed 5 files changed +114
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ bash_completion
7
7
checkpkg
8
8
commitpkg
9
9
diffpkg
10
+ export-pkgbuild-keys
10
11
finddeps
11
12
lddd
12
13
makechrootpkg
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ IN_PROGS = \
13
13
commitpkg \
14
14
crossrepomove\
15
15
diffpkg \
16
+ export-pkgbuild-keys \
16
17
finddeps \
17
18
find-libdeps \
18
19
lddd \
@@ -74,6 +75,7 @@ BASHCOMPLETION_LINKS = \
74
75
MANS = \
75
76
doc/archbuild.1 \
76
77
doc/arch-nspawn.1 \
78
+ doc/export-pkgbuild-keys.1 \
77
79
doc/makechrootpkg.1 \
78
80
doc/lddd.1 \
79
81
doc/checkpkg.1 \
Original file line number Diff line number Diff line change @@ -48,6 +48,21 @@ case "$cmd" in
48
48
;;
49
49
esac
50
50
51
+
52
+ if (( ${# validpgpkeys[@]} != 0 )) ; then
53
+ if [[ -d keys ]]; then
54
+ for key in " ${validpgpkeys[@]} " ; do
55
+ if [[ ! -f keys/pgp/$key .asc ]]; then
56
+ export-pkgbuild-keys || die ' Failed to export valid PGP keys for source files'
57
+ fi
58
+ done
59
+ else
60
+ export-pkgbuild-keys || die ' Failed to export valid PGP keys for source files'
61
+ fi
62
+
63
+ svn add --parents --force keys/pgp/*
64
+ fi
65
+
51
66
# find files which should be under source control
52
67
needsversioning=()
53
68
for s in " ${source[@]} " ; do
@@ -60,6 +75,9 @@ for i in 'changelog' 'install'; do
60
75
needsversioning+=(" $file " )
61
76
done < <( sed -n " s/^[[:space:]]*$i =//p" PKGBUILD)
62
77
done
78
+ for key in " ${validpgpkeys[@]} " ; do
79
+ needsversioning+=(" keys/pgp/$key .asc" )
80
+ done
63
81
64
82
# assert that they really are controlled by SVN
65
83
if (( ${# needsversioning[*]} )) ; then
Original file line number Diff line number Diff line change
1
+ export-pkgbuild-keys(1)
2
+ =======================
3
+
4
+ Name
5
+ ----
6
+ export-pkgbuild-keys - Export valid source signing keys from a PKGBUILD
7
+
8
+ Synopsis
9
+ --------
10
+ export-pkgbuild-keys
11
+
12
+ Description
13
+ -----------
14
+
15
+ Export the PGP keys from a PKGBUILDs validpgpkeys array into the keys/pgp/
16
+ subdirectory. Useful for distributing packager validated source signing
17
+ keys alongside PKGBUILDs.
18
+
19
+ Options
20
+ -------
21
+
22
+ *-h, --help* ::
23
+ Show a help text.
24
+
25
+ include::footer.asciidoc[]
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ #
3
+ # SPDX-License-Identifier: GPL-3.0-or-later
4
+
5
+ m4_include(lib/common.sh)
6
+
7
+ usage () {
8
+ cat << - _EOF_
9
+ Usage: ${BASH_SOURCE[0]##*/ }
10
+
11
+ Export the PGP keys from a PKGBUILDs validpgpkeys array into the keys/pgp/
12
+ subdirectory. Useful for distributing packager validated source signing
13
+ keys alongside PKGBUILDs.
14
+
15
+ OPTIONS
16
+ -h, --help Show this help text
17
+ _EOF_
18
+ }
19
+
20
+ # option checking
21
+ while (( $# )) ; do
22
+ case $1 in
23
+ -h|--help)
24
+ usage
25
+ exit 0
26
+ ;;
27
+ * )
28
+ die " invalid argument: %s" " $1 "
29
+ ;;
30
+ esac
31
+ done
32
+
33
+ if [[ ! -f PKGBUILD ]]; then
34
+ die " This must be run a directory containing a PKGBUILD."
35
+ fi
36
+
37
+ mapfile -t validpgpkeys < <(
38
+ # shellcheck source=PKGBUILD.proto
39
+ . ./PKGBUILD
40
+ printf " %s\n" " ${validpgpkeys[@]} "
41
+ )
42
+
43
+ if (( ${# validpgpkeys[@]} == 0 )) ; then
44
+ exit 0
45
+ fi
46
+
47
+ mkdir -p keys/pgp
48
+ error=0
49
+
50
+ for key in " ${validpgpkeys[@]} " ; do
51
+ gpg --output " keys/pgp/$key .asc.tmp" --armor --export --export-options export-minimal " $key " 2> /dev/null
52
+
53
+ # gpg does not give a non-zero return value if it fails to export...
54
+ if [[ -f keys/pgp/$key .asc.tmp ]]; then
55
+ mv " keys/pgp/$key .asc.tmp" " keys/pgp/$key .asc"
56
+ else
57
+ if [[ -f keys/pgp/$key .asc ]]; then
58
+ warning " Failed to update key: $key "
59
+ else
60
+ error " Key unavailable: $key "
61
+ error=1
62
+ fi
63
+ fi
64
+ done
65
+
66
+ if (( error )) ; then
67
+ die " Failed to export all \'validpgpkeys\' entries."
68
+ fi
You can’t perform that action at this time.
0 commit comments