1*635a8641SAndroid Build Coastguard Worker#!/bin/bash 2*635a8641SAndroid Build Coastguard Worker# Download and extract MarkupSafe 3*635a8641SAndroid Build Coastguard Worker# Homepage: 4*635a8641SAndroid Build Coastguard Worker# https://github.com/mitsuhiko/markupsafe 5*635a8641SAndroid Build Coastguard Worker# Download page: 6*635a8641SAndroid Build Coastguard Worker# https://pypi.python.org/pypi/MarkupSafe 7*635a8641SAndroid Build Coastguard WorkerPACKAGE='MarkupSafe' 8*635a8641SAndroid Build Coastguard WorkerVERSION='0.18' 9*635a8641SAndroid Build Coastguard WorkerPACKAGE_DIR='markupsafe' 10*635a8641SAndroid Build Coastguard Worker 11*635a8641SAndroid Build Coastguard WorkerCHROMIUM_FILES="README.chromium OWNERS get_markupsafe.sh" 12*635a8641SAndroid Build Coastguard WorkerEXTRA_FILES='LICENSE AUTHORS' 13*635a8641SAndroid Build Coastguard WorkerREMOVE_FILES='tests.py' 14*635a8641SAndroid Build Coastguard Worker 15*635a8641SAndroid Build Coastguard WorkerSRC_URL='https://pypi.python.org/packages/source/' 16*635a8641SAndroid Build Coastguard WorkerSRC_URL+="${PACKAGE:0:1}/$PACKAGE/$PACKAGE-$VERSION.tar.gz" 17*635a8641SAndroid Build Coastguard WorkerFILENAME="$(basename $SRC_URL)" 18*635a8641SAndroid Build Coastguard WorkerMD5_FILENAME="$FILENAME.md5" 19*635a8641SAndroid Build Coastguard WorkerSHA512_FILENAME="$FILENAME.sha512" 20*635a8641SAndroid Build Coastguard WorkerCHROMIUM_FILES+=" $MD5_FILENAME $SHA512_FILENAME" 21*635a8641SAndroid Build Coastguard Worker 22*635a8641SAndroid Build Coastguard WorkerBUILD_DIR="$PACKAGE-$VERSION" 23*635a8641SAndroid Build Coastguard WorkerTHIRD_PARTY="$(dirname $(realpath $(dirname "${BASH_SOURCE[0]}")))" 24*635a8641SAndroid Build Coastguard WorkerINSTALL_DIR="$THIRD_PARTY/$PACKAGE_DIR" 25*635a8641SAndroid Build Coastguard WorkerOUT_DIR="$INSTALL_DIR/$BUILD_DIR/$PACKAGE_DIR" 26*635a8641SAndroid Build Coastguard WorkerOLD_DIR="$THIRD_PARTY/$PACKAGE_DIR.old" 27*635a8641SAndroid Build Coastguard Worker 28*635a8641SAndroid Build Coastguard Workerfunction check_hashes { 29*635a8641SAndroid Build Coastguard Worker # Hashes generated via: 30*635a8641SAndroid Build Coastguard Worker # FILENAME=MarkupSafe-0.18.tar.gz 31*635a8641SAndroid Build Coastguard Worker # md5sum "$FILENAME" > "$FILENAME.md5" 32*635a8641SAndroid Build Coastguard Worker # sha512sum "$FILENAME" > "$FILENAME.sha512" 33*635a8641SAndroid Build Coastguard Worker # unset FILENAME 34*635a8641SAndroid Build Coastguard Worker 35*635a8641SAndroid Build Coastguard Worker # MD5 36*635a8641SAndroid Build Coastguard Worker if ! [ -f "$MD5_FILENAME" ] 37*635a8641SAndroid Build Coastguard Worker then 38*635a8641SAndroid Build Coastguard Worker echo "MD5 hash file $MD5_FILENAME not found, could not verify archive" 39*635a8641SAndroid Build Coastguard Worker exit 1 40*635a8641SAndroid Build Coastguard Worker fi 41*635a8641SAndroid Build Coastguard Worker 42*635a8641SAndroid Build Coastguard Worker # 32-digit hash, followed by filename 43*635a8641SAndroid Build Coastguard Worker MD5_HASHFILE_REGEX="^[0-9a-f]{32} $FILENAME" 44*635a8641SAndroid Build Coastguard Worker if ! grep --extended-regex --line-regex --silent \ 45*635a8641SAndroid Build Coastguard Worker "$MD5_HASHFILE_REGEX" "$MD5_FILENAME" 46*635a8641SAndroid Build Coastguard Worker then 47*635a8641SAndroid Build Coastguard Worker echo "MD5 hash file $MD5_FILENAME does not contain hash for $FILENAME," \ 48*635a8641SAndroid Build Coastguard Worker 'could not verify archive' 49*635a8641SAndroid Build Coastguard Worker echo 'Hash file contents are:' 50*635a8641SAndroid Build Coastguard Worker cat "$MD5_FILENAME" 51*635a8641SAndroid Build Coastguard Worker exit 1 52*635a8641SAndroid Build Coastguard Worker fi 53*635a8641SAndroid Build Coastguard Worker 54*635a8641SAndroid Build Coastguard Worker if ! md5sum --check "$MD5_FILENAME" 55*635a8641SAndroid Build Coastguard Worker then 56*635a8641SAndroid Build Coastguard Worker echo 'MD5 hash does not match,' \ 57*635a8641SAndroid Build Coastguard Worker "archive file $FILENAME corrupt or compromised!" 58*635a8641SAndroid Build Coastguard Worker exit 1 59*635a8641SAndroid Build Coastguard Worker fi 60*635a8641SAndroid Build Coastguard Worker 61*635a8641SAndroid Build Coastguard Worker # SHA-512 62*635a8641SAndroid Build Coastguard Worker if ! [ -f "$SHA512_FILENAME" ] 63*635a8641SAndroid Build Coastguard Worker then 64*635a8641SAndroid Build Coastguard Worker echo "SHA-512 hash file $SHA512_FILENAME not found," \ 65*635a8641SAndroid Build Coastguard Worker 'could not verify archive' 66*635a8641SAndroid Build Coastguard Worker exit 1 67*635a8641SAndroid Build Coastguard Worker fi 68*635a8641SAndroid Build Coastguard Worker 69*635a8641SAndroid Build Coastguard Worker # 128-digit hash, followed by filename 70*635a8641SAndroid Build Coastguard Worker SHA512_HASHFILE_REGEX="^[0-9a-f]{128} $FILENAME" 71*635a8641SAndroid Build Coastguard Worker if ! grep --extended-regex --line-regex --silent \ 72*635a8641SAndroid Build Coastguard Worker "$SHA512_HASHFILE_REGEX" "$SHA512_FILENAME" 73*635a8641SAndroid Build Coastguard Worker then 74*635a8641SAndroid Build Coastguard Worker echo "SHA-512 hash file $SHA512_FILENAME does not contain hash for" \ 75*635a8641SAndroid Build Coastguard Worker "$FILENAME, could not verify archive" 76*635a8641SAndroid Build Coastguard Worker echo 'Hash file contents are:' 77*635a8641SAndroid Build Coastguard Worker cat "$SHA512_FILENAME" 78*635a8641SAndroid Build Coastguard Worker exit 1 79*635a8641SAndroid Build Coastguard Worker fi 80*635a8641SAndroid Build Coastguard Worker 81*635a8641SAndroid Build Coastguard Worker if ! sha512sum --check "$SHA512_FILENAME" 82*635a8641SAndroid Build Coastguard Worker then 83*635a8641SAndroid Build Coastguard Worker echo 'SHA-512 hash does not match,' \ 84*635a8641SAndroid Build Coastguard Worker "archive file $FILENAME corrupt or compromised!" 85*635a8641SAndroid Build Coastguard Worker exit 1 86*635a8641SAndroid Build Coastguard Worker fi 87*635a8641SAndroid Build Coastguard Worker} 88*635a8641SAndroid Build Coastguard Worker 89*635a8641SAndroid Build Coastguard Worker 90*635a8641SAndroid Build Coastguard Worker################################################################################ 91*635a8641SAndroid Build Coastguard Worker# Body 92*635a8641SAndroid Build Coastguard Worker 93*635a8641SAndroid Build Coastguard Workercd "$INSTALL_DIR" 94*635a8641SAndroid Build Coastguard Workerecho "Downloading $SRC_URL" 95*635a8641SAndroid Build Coastguard Workercurl --remote-name "$SRC_URL" 96*635a8641SAndroid Build Coastguard Workercheck_hashes 97*635a8641SAndroid Build Coastguard Workertar xvzf "$FILENAME" 98*635a8641SAndroid Build Coastguard Worker# Copy extra files over 99*635a8641SAndroid Build Coastguard Workerfor FILE in $CHROMIUM_FILES 100*635a8641SAndroid Build Coastguard Workerdo 101*635a8641SAndroid Build Coastguard Worker cp "$FILE" "$OUT_DIR" 102*635a8641SAndroid Build Coastguard Workerdone 103*635a8641SAndroid Build Coastguard Worker 104*635a8641SAndroid Build Coastguard Workercd "$BUILD_DIR" 105*635a8641SAndroid Build Coastguard Workerfor FILE in $EXTRA_FILES 106*635a8641SAndroid Build Coastguard Workerdo 107*635a8641SAndroid Build Coastguard Worker cp "$FILE" "$OUT_DIR" 108*635a8641SAndroid Build Coastguard Workerdone 109*635a8641SAndroid Build Coastguard Worker 110*635a8641SAndroid Build Coastguard Workercd "$OUT_DIR" 111*635a8641SAndroid Build Coastguard Workerfor FILE in $REMOVE_FILES 112*635a8641SAndroid Build Coastguard Workerdo 113*635a8641SAndroid Build Coastguard Worker rm -fr "$FILE" 114*635a8641SAndroid Build Coastguard Workerdone 115*635a8641SAndroid Build Coastguard Worker 116*635a8641SAndroid Build Coastguard Worker# Replace with new directory 117*635a8641SAndroid Build Coastguard Workercd .. 118*635a8641SAndroid Build Coastguard Workermv "$INSTALL_DIR" "$OLD_DIR" 119*635a8641SAndroid Build Coastguard Workermv "$PACKAGE_DIR" "$INSTALL_DIR" 120*635a8641SAndroid Build Coastguard Workercd "$INSTALL_DIR" 121*635a8641SAndroid Build Coastguard Workerrm -fr "$OLD_DIR" 122