2 # Download and extract MarkupSafe
4 # https://github.com/mitsuhiko/markupsafe
6 # https://pypi.python.org/pypi/MarkupSafe
9 PACKAGE_DIR
='markupsafe'
11 CHROMIUM_FILES
="README.chromium OWNERS get_markupsafe.sh"
12 EXTRA_FILES
='LICENSE AUTHORS'
13 REMOVE_FILES
='tests.py'
15 SRC_URL
='https://pypi.python.org/packages/source/'
16 SRC_URL
+="${PACKAGE:0:1}/$PACKAGE/$PACKAGE-$VERSION.tar.gz"
17 FILENAME
="$(basename $SRC_URL)"
18 MD5_FILENAME
="$FILENAME.md5"
19 SHA512_FILENAME
="$FILENAME.sha512"
20 CHROMIUM_FILES
+=" $MD5_FILENAME $SHA512_FILENAME"
22 BUILD_DIR
="$PACKAGE-$VERSION"
23 THIRD_PARTY
="$(dirname $(realpath $(dirname "${BASH_SOURCE[0]}")))"
24 INSTALL_DIR
="$THIRD_PARTY/$PACKAGE_DIR"
25 OUT_DIR
="$INSTALL_DIR/$BUILD_DIR/$PACKAGE_DIR"
26 OLD_DIR
="$THIRD_PARTY/$PACKAGE_DIR.old"
28 function check_hashes
{
29 # Hashes generated via:
30 # FILENAME=MarkupSafe-0.18.tar.gz
31 # md5sum "$FILENAME" > "$FILENAME.md5"
32 # sha512sum "$FILENAME" > "$FILENAME.sha512"
36 if ! [ -f "$MD5_FILENAME" ]
38 echo "MD5 hash file $MD5_FILENAME not found, could not verify archive"
42 # 32-digit hash, followed by filename
43 MD5_HASHFILE_REGEX
="^[0-9a-f]{32} $FILENAME"
44 if ! grep --extended-regex --line-regex --silent \
45 "$MD5_HASHFILE_REGEX" "$MD5_FILENAME"
47 echo "MD5 hash file $MD5_FILENAME does not contain hash for $FILENAME," \
48 'could not verify archive'
49 echo 'Hash file contents are:'
54 if ! md5sum --check "$MD5_FILENAME"
56 echo 'MD5 hash does not match,' \
57 "archive file $FILENAME corrupt or compromised!"
62 if ! [ -f "$SHA512_FILENAME" ]
64 echo "SHA-512 hash file $SHA512_FILENAME not found," \
65 'could not verify archive'
69 # 128-digit hash, followed by filename
70 SHA512_HASHFILE_REGEX
="^[0-9a-f]{128} $FILENAME"
71 if ! grep --extended-regex --line-regex --silent \
72 "$SHA512_HASHFILE_REGEX" "$SHA512_FILENAME"
74 echo "SHA-512 hash file $SHA512_FILENAME does not contain hash for" \
75 "$FILENAME, could not verify archive"
76 echo 'Hash file contents are:'
77 cat "$SHA512_FILENAME"
81 if ! sha512sum
--check "$SHA512_FILENAME"
83 echo 'SHA-512 hash does not match,' \
84 "archive file $FILENAME corrupt or compromised!"
90 ################################################################################
94 echo "Downloading $SRC_URL"
95 curl
--remote-name "$SRC_URL"
98 # Copy extra files over
99 for FILE
in $CHROMIUM_FILES
101 cp "$FILE" "$OUT_DIR"
105 for FILE
in $EXTRA_FILES
107 cp "$FILE" "$OUT_DIR"
111 for FILE
in $REMOVE_FILES
116 # Replace with new directory
118 mv "$INSTALL_DIR" "$OLD_DIR"
119 mv "$PACKAGE_DIR" "$INSTALL_DIR"