-
Notifications
You must be signed in to change notification settings - Fork 32
/
updatetoolvers
executable file
·70 lines (57 loc) · 2.24 KB
/
updatetoolvers
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
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
# Change the version numbers in the toolvers file and then run this
# script to update the hashes
# GNU keyring can be fetched from https://ftp.gnu.org/gnu/gnu-keyring.gpg
ARCHIVES=archives
GNU_MIRROR=https://mirrors.kernel.org/gnu
TOOLVERS_FILE="toolvers"
KEYRING_FILE=./gnu-keyring.gpg
. "$TOOLVERS_FILE"
function verify_sig() {
SIGFILE="$1"
ARCHIVE="$2"
if ! gpg -q --verify --keyring "$KEYRING_FILE" "$SIGFILE" "$ARCHIVE"; then
echo "Failed to verify $ARCHIVE, aborting"
exit 1
fi
}
function fetch_and_verify() {
PKG_URI_DIR="$1"
FILENAME="$2"
if [ ! -f "$ARCHIVES/$FILENAME" ]; then
wget -P "$ARCHIVES" -N "$PKG_URI_DIR/$FILENAME"
fi
if [ ! -f "$ARCHIVES/$FILENAME.sig" ]; then
wget -P "$ARCHIVES" -N "$PKG_URI_DIR/$FILENAME.sig"
fi
verify_sig "$ARCHIVES/$FILENAME.sig" "$ARCHIVES/$FILENAME"
}
fetch_and_verify "$GNU_MIRROR/binutils/" "binutils-$BINVER.tar.xz"
fetch_and_verify "$GNU_MIRROR/gcc/gcc-$GCCVER/" "gcc-$GCCVER.tar.xz"
fetch_and_verify "$GNU_MIRROR/gdb/" "gdb-$GDBVER.tar.xz"
fetch_and_verify "$GNU_MIRROR/gmp/" "gmp-$GMPVER.tar.xz"
fetch_and_verify "$GNU_MIRROR/mpc/" "mpc-$MPCVER.tar.gz"
fetch_and_verify "$GNU_MIRROR/mpfr/" "mpfr-$MPFRVER.tar.xz"
BINHASH=$(shasum -a 256 -b "$ARCHIVES/binutils-$BINVER.tar.xz" | cut -f1 -d' ')
GCCHASH=$(shasum -a 256 -b "$ARCHIVES/gcc-$GCCVER.tar.xz" | cut -f1 -d' ')
GDBHASH=$(shasum -a 256 -b "$ARCHIVES/gdb-$GDBVER.tar.xz" | cut -f1 -d' ')
GMPHASH=$(shasum -a 256 -b "$ARCHIVES/gmp-$GMPVER.tar.xz" | cut -f1 -d' ')
MPCHASH=$(shasum -a 256 -b "$ARCHIVES/mpc-$MPCVER.tar.gz" | cut -f1 -d' ')
MPFRHASH=$(shasum -a 256 -b "$ARCHIVES/mpfr-$MPFRVER.tar.xz" | cut -f1 -d' ')
tmp=$(mktemp)
echo "# Rerun updatetoolvers after modifying this file" > "$tmp"
echo "GCCVER=$GCCVER" >> "$tmp"
echo "BINVER=$BINVER" >> "$tmp"
echo "GDBVER=$GDBVER" >> "$tmp"
echo "GMPVER=$GMPVER" >> "$tmp"
echo "MPCVER=$MPCVER" >> "$tmp"
echo "MPFRVER=$MPFRVER" >> "$tmp"
echo "# Below is autogenerated by updatetoolvers" >> "$tmp"
echo "GCCHASH=$GCCHASH" >> "$tmp"
echo "BINHASH=$BINHASH" >> "$tmp"
echo "GDBHASH=$GDBHASH" >> "$tmp"
echo "GMPHASH=$GMPHASH" >> "$tmp"
echo "MPCHASH=$MPCHASH" >> "$tmp"
echo "MPFRHASH=$MPFRHASH" >> "$tmp"
mv "$tmp" "$TOOLVERS_FILE"
# vim: ts=4 sw=4 expandtab