1 |
commit: 279a7ebed5c004e1da3df8fa77c783a1e42ab955 |
2 |
Author: Ian Stakenvicius <axs <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Apr 27 14:43:07 2016 +0000 |
4 |
Commit: Ian Stakenvicius <axs <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Apr 27 14:43:10 2016 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/mozilla.git/commit/?id=279a7ebe |
7 |
|
8 |
added script that helps with verifying SHA512 hashes of distfiles against upstream |
9 |
|
10 |
The script also checks the signature of the SHA512SUMS file is valid, though the trust |
11 |
of the mozilla key used is entirely up to the user to verify and validate. |
12 |
|
13 |
scripts/verify_distfiles.sh | 63 +++++++++++++++++++++++++++++++++++++++++++++ |
14 |
1 file changed, 63 insertions(+) |
15 |
|
16 |
diff --git a/scripts/verify_distfiles.sh b/scripts/verify_distfiles.sh |
17 |
new file mode 100755 |
18 |
index 0000000..b418620 |
19 |
--- /dev/null |
20 |
+++ b/scripts/verify_distfiles.sh |
21 |
@@ -0,0 +1,63 @@ |
22 |
+#!/bin/sh |
23 |
+ |
24 |
+# Script to check distfiles against SHA512SUMS in upstream repo |
25 |
+# Note - your gpg setup needs to have the mozilla release key imported for signature verification |
26 |
+# Author: Ian Stakenvicius |
27 |
+# 2016-03-10 |
28 |
+ |
29 |
+check_distfiles() { |
30 |
+ local myver myname tmp |
31 |
+ myname=$(qatom $1 |awk '{print $2}') |
32 |
+ mybasename=${myname/-bin/} |
33 |
+ if grep 'MOZ_ESR=""' $1 &>/dev/null || [[ -n $(grep -L MOZ_ESR $1) ]] ; then |
34 |
+ myver=$(qatom $1 |awk '{print $3}') |
35 |
+ else |
36 |
+ myver=$(qatom $1 |awk '{print $3 "esr"}') |
37 |
+ fi |
38 |
+ |
39 |
+ sigfile=$(mktemp) |
40 |
+ wget -O ${sigfile}.asc -q https://archive.mozilla.org/pub/${mybasename}/releases/${myver}/SHA512SUMS.asc |
41 |
+ wget -O ${sigfile} -q https://archive.mozilla.org/pub/${mybasename}/releases/${myver}/SHA512SUMS |
42 |
+ gpg --verify ${sigfile}.asc ${sigfile} || exit 1 |
43 |
+ |
44 |
+ grep -e "^DIST ${mybasename}-${myver}[-\.]" \ |
45 |
+ -e "^DIST ${myname}_.*-${myver}[-\.]" \ |
46 |
+ Manifest |
47 |
+ exit 1 |
48 |
+ |
49 |
+ grep -e "^DIST ${myname}-${myver}[-\.]" \ |
50 |
+ -e "^DIST ${mybasename}_.*-${myver}[-\.]" \ |
51 |
+ Manifest |grep -v -- "${myname}-.*-patches-" |awk '{print $7}' |while read ech ; do |
52 |
+ tmp=$(grep ${ech} Manifest |awk '{print $2}') |
53 |
+ if grep $ech ${sigfile} &>/dev/null ; then |
54 |
+ echo -n $tmp |
55 |
+ grep ${ech} ${sigfile} |awk '{print " -> " $2 " OK"}' |
56 |
+ else |
57 |
+ echo -n "ERROR - no file with sum ${ech} found -- ${tmp}" |
58 |
+ exit 1 |
59 |
+ fi |
60 |
+ done |
61 |
+ rm -f ${sigfile}.asc ${sigfile} |
62 |
+} |
63 |
+ |
64 |
+ |
65 |
+if [[ ! -e Manifest ]]; then |
66 |
+ echo "ERROR - must be run in the directory of the package (with ebuilds and Manifest)" |
67 |
+ echo "USAGE: $0 [ebuild file(s)]" |
68 |
+ exit 1 |
69 |
+fi |
70 |
+ |
71 |
+ebuild_list=( "$@" ) |
72 |
+if [ "$#" -eq 0 ]; then |
73 |
+ echo "No arguments specified, verifying all ebuilds in current directory" |
74 |
+ ebuild_list=( *.ebuild ) |
75 |
+fi |
76 |
+ |
77 |
+for ebuild in "${ebuild_list[@]}"; do |
78 |
+ echo "Checking $ebuild" |
79 |
+ if [[ -e $ebuild ]]; then |
80 |
+ check_distfiles $ebuild |
81 |
+ else |
82 |
+ echo "ERROR - $ebuild does not exist, skipping" |
83 |
+ fi |
84 |
+done |