Add ICU message format support
[chromium-blink-merge.git] / third_party / markupsafe / get_markupsafe.sh
blobd268832df8ca7fa7c46a67110e0ddf922b8d3560
1 #!/bin/bash
2 # Download and extract MarkupSafe
3 # Homepage:
4 # https://github.com/mitsuhiko/markupsafe
5 # Download page:
6 # https://pypi.python.org/pypi/MarkupSafe
7 PACKAGE='MarkupSafe'
8 VERSION='0.18'
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"
33 # unset FILENAME
35 # MD5
36 if ! [ -f "$MD5_FILENAME" ]
37 then
38 echo "MD5 hash file $MD5_FILENAME not found, could not verify archive"
39 exit 1
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"
46 then
47 echo "MD5 hash file $MD5_FILENAME does not contain hash for $FILENAME," \
48 'could not verify archive'
49 echo 'Hash file contents are:'
50 cat "$MD5_FILENAME"
51 exit 1
54 if ! md5sum --check "$MD5_FILENAME"
55 then
56 echo 'MD5 hash does not match,' \
57 "archive file $FILENAME corrupt or compromised!"
58 exit 1
61 # SHA-512
62 if ! [ -f "$SHA512_FILENAME" ]
63 then
64 echo "SHA-512 hash file $SHA512_FILENAME not found," \
65 'could not verify archive'
66 exit 1
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"
73 then
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"
78 exit 1
81 if ! sha512sum --check "$SHA512_FILENAME"
82 then
83 echo 'SHA-512 hash does not match,' \
84 "archive file $FILENAME corrupt or compromised!"
85 exit 1
90 ################################################################################
91 # Body
93 cd "$INSTALL_DIR"
94 echo "Downloading $SRC_URL"
95 curl --remote-name "$SRC_URL"
96 check_hashes
97 tar xvzf "$FILENAME"
98 # Copy extra files over
99 for FILE in $CHROMIUM_FILES
101 cp "$FILE" "$OUT_DIR"
102 done
104 cd "$BUILD_DIR"
105 for FILE in $EXTRA_FILES
107 cp "$FILE" "$OUT_DIR"
108 done
110 cd "$OUT_DIR"
111 for FILE in $REMOVE_FILES
113 rm -fr "$FILE"
114 done
116 # Replace with new directory
117 cd ..
118 mv "$INSTALL_DIR" "$OLD_DIR"
119 mv "$PACKAGE_DIR" "$INSTALL_DIR"
120 cd "$INSTALL_DIR"
121 rm -fr "$OLD_DIR"