Allow Mandoline to load URLs via Intent while its singleTask activity is still running.
[chromium-blink-merge.git] / third_party / jinja2 / get_jinja2.sh
blob950214653ba1c69356157e7d01ab8550c0e59841
1 #!/bin/bash
2 # Download and extract Jinja2
3 # Homepage:
4 # http://jinja.pocoo.org/
5 # Installation instructions:
6 # http://jinja.pocoo.org/docs/intro/#from-the-tarball-release
7 # Download page:
8 # https://pypi.python.org/pypi/Jinja2
9 PACKAGE='Jinja2'
10 VERSION='2.7.1'
11 PACKAGE_DIR='jinja2'
13 CHROMIUM_FILES="README.chromium OWNERS get_jinja2.sh"
14 EXTRA_FILES='LICENSE AUTHORS'
15 REMOVE_FILES='testsuite'
17 SRC_URL='https://pypi.python.org/packages/source/'
18 SRC_URL+="${PACKAGE:0:1}/$PACKAGE/$PACKAGE-$VERSION.tar.gz"
19 FILENAME="$(basename $SRC_URL)"
20 MD5_FILENAME="$FILENAME.md5"
21 SHA512_FILENAME="$FILENAME.sha512"
22 CHROMIUM_FILES+=" $MD5_FILENAME $SHA512_FILENAME"
24 BUILD_DIR="$PACKAGE-$VERSION"
25 THIRD_PARTY="$(dirname $(realpath $(dirname "${BASH_SOURCE[0]}")))"
26 INSTALL_DIR="$THIRD_PARTY/$PACKAGE_DIR"
27 OUT_DIR="$INSTALL_DIR/$BUILD_DIR/$PACKAGE_DIR"
28 OLD_DIR="$THIRD_PARTY/$PACKAGE_DIR.old"
30 function check_hashes {
31 # Hashes generated via:
32 # FILENAME=Jinja2-2.7.1.tar.gz
33 # md5sum "$FILENAME" > "$FILENAME.md5"
34 # sha512sum "$FILENAME" > "$FILENAME.sha512"
35 # unset FILENAME
37 # MD5
38 if ! [ -f "$MD5_FILENAME" ]
39 then
40 echo "MD5 hash file $MD5_FILENAME not found, could not verify archive"
41 exit 1
44 # 32-digit hash, followed by filename
45 MD5_HASHFILE_REGEX="^[0-9a-f]{32} $FILENAME"
46 if ! grep --extended-regex --line-regex --silent \
47 "$MD5_HASHFILE_REGEX" "$MD5_FILENAME"
48 then
49 echo "MD5 hash file $MD5_FILENAME does not contain hash for $FILENAME," \
50 'could not verify archive'
51 echo 'Hash file contents are:'
52 cat "$MD5_FILENAME"
53 exit 1
56 if ! md5sum --check "$MD5_FILENAME"
57 then
58 echo 'MD5 hash does not match,' \
59 "archive file $FILENAME corrupt or compromised!"
60 exit 1
63 # SHA-512
64 if ! [ -f "$SHA512_FILENAME" ]
65 then
66 echo "SHA-512 hash file $SHA512_FILENAME not found," \
67 'could not verify archive'
68 exit 1
71 # 128-digit hash, followed by filename
72 SHA512_HASHFILE_REGEX="^[0-9a-f]{128} $FILENAME"
73 if ! grep --extended-regex --line-regex --silent \
74 "$SHA512_HASHFILE_REGEX" "$SHA512_FILENAME"
75 then
76 echo "SHA-512 hash file $SHA512_FILENAME does not contain hash for" \
77 "$FILENAME, could not verify archive"
78 echo 'Hash file contents are:'
79 cat "$SHA512_FILENAME"
80 exit 1
83 if ! sha512sum --check "$SHA512_FILENAME"
84 then
85 echo 'SHA-512 hash does not match,' \
86 "archive file $FILENAME corrupt or compromised!"
87 exit 1
92 ################################################################################
93 # Body
95 cd "$INSTALL_DIR"
96 echo "Downloading $SRC_URL"
97 curl --remote-name "$SRC_URL"
98 check_hashes
99 tar xvzf "$FILENAME"
100 # Copy extra files over
101 for FILE in $CHROMIUM_FILES
103 cp "$FILE" "$OUT_DIR"
104 done
106 cd "$BUILD_DIR"
107 for FILE in $EXTRA_FILES
109 cp "$FILE" "$OUT_DIR"
110 done
112 cd "$OUT_DIR"
113 for FILE in $REMOVE_FILES
115 rm -fr "$FILE"
116 done
118 # Replace with new directory
119 cd ..
120 mv "$INSTALL_DIR" "$OLD_DIR"
121 mv "$PACKAGE_DIR" "$INSTALL_DIR"
122 cd "$INSTALL_DIR"
123 rm -fr "$OLD_DIR"