blob: d268832df8ca7fa7c46a67110e0ddf922b8d3560 (
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
#!/bin/bash
# Download and extract MarkupSafe
# Homepage:
# https://github.com/mitsuhiko/markupsafe
# Download page:
# https://pypi.python.org/pypi/MarkupSafe
PACKAGE='MarkupSafe'
VERSION='0.18'
PACKAGE_DIR='markupsafe'
CHROMIUM_FILES="README.chromium OWNERS get_markupsafe.sh"
EXTRA_FILES='LICENSE AUTHORS'
REMOVE_FILES='tests.py'
SRC_URL='https://pypi.python.org/packages/source/'
SRC_URL+="${PACKAGE:0:1}/$PACKAGE/$PACKAGE-$VERSION.tar.gz"
FILENAME="$(basename $SRC_URL)"
MD5_FILENAME="$FILENAME.md5"
SHA512_FILENAME="$FILENAME.sha512"
CHROMIUM_FILES+=" $MD5_FILENAME $SHA512_FILENAME"
BUILD_DIR="$PACKAGE-$VERSION"
THIRD_PARTY="$(dirname $(realpath $(dirname "${BASH_SOURCE[0]}")))"
INSTALL_DIR="$THIRD_PARTY/$PACKAGE_DIR"
OUT_DIR="$INSTALL_DIR/$BUILD_DIR/$PACKAGE_DIR"
OLD_DIR="$THIRD_PARTY/$PACKAGE_DIR.old"
function check_hashes {
# Hashes generated via:
# FILENAME=MarkupSafe-0.18.tar.gz
# md5sum "$FILENAME" > "$FILENAME.md5"
# sha512sum "$FILENAME" > "$FILENAME.sha512"
# unset FILENAME
# MD5
if ! [ -f "$MD5_FILENAME" ]
then
echo "MD5 hash file $MD5_FILENAME not found, could not verify archive"
exit 1
fi
# 32-digit hash, followed by filename
MD5_HASHFILE_REGEX="^[0-9a-f]{32} $FILENAME"
if ! grep --extended-regex --line-regex --silent \
"$MD5_HASHFILE_REGEX" "$MD5_FILENAME"
then
echo "MD5 hash file $MD5_FILENAME does not contain hash for $FILENAME," \
'could not verify archive'
echo 'Hash file contents are:'
cat "$MD5_FILENAME"
exit 1
fi
if ! md5sum --check "$MD5_FILENAME"
then
echo 'MD5 hash does not match,' \
"archive file $FILENAME corrupt or compromised!"
exit 1
fi
# SHA-512
if ! [ -f "$SHA512_FILENAME" ]
then
echo "SHA-512 hash file $SHA512_FILENAME not found," \
'could not verify archive'
exit 1
fi
# 128-digit hash, followed by filename
SHA512_HASHFILE_REGEX="^[0-9a-f]{128} $FILENAME"
if ! grep --extended-regex --line-regex --silent \
"$SHA512_HASHFILE_REGEX" "$SHA512_FILENAME"
then
echo "SHA-512 hash file $SHA512_FILENAME does not contain hash for" \
"$FILENAME, could not verify archive"
echo 'Hash file contents are:'
cat "$SHA512_FILENAME"
exit 1
fi
if ! sha512sum --check "$SHA512_FILENAME"
then
echo 'SHA-512 hash does not match,' \
"archive file $FILENAME corrupt or compromised!"
exit 1
fi
}
################################################################################
# Body
cd "$INSTALL_DIR"
echo "Downloading $SRC_URL"
curl --remote-name "$SRC_URL"
check_hashes
tar xvzf "$FILENAME"
# Copy extra files over
for FILE in $CHROMIUM_FILES
do
cp "$FILE" "$OUT_DIR"
done
cd "$BUILD_DIR"
for FILE in $EXTRA_FILES
do
cp "$FILE" "$OUT_DIR"
done
cd "$OUT_DIR"
for FILE in $REMOVE_FILES
do
rm -fr "$FILE"
done
# Replace with new directory
cd ..
mv "$INSTALL_DIR" "$OLD_DIR"
mv "$PACKAGE_DIR" "$INSTALL_DIR"
cd "$INSTALL_DIR"
rm -fr "$OLD_DIR"
|