Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(702)

Unified Diff: third_party/JSON/get_and_build_json_pm.sh

Issue 15736030: Add JSON.pm to third_party (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Check SHA-1 hash Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/JSON/get_and_build_json_pm.sh
diff --git a/third_party/JSON/get_and_build_json_pm.sh b/third_party/JSON/get_and_build_json_pm.sh
new file mode 100755
index 0000000000000000000000000000000000000000..952ea92a8f88dfc6d05013dc2a58da11f2c491da
--- /dev/null
+++ b/third_party/JSON/get_and_build_json_pm.sh
@@ -0,0 +1,47 @@
+#!/bin/bash
+# Download and build JSON.pm
+# Homepage:
+# http://search.cpan.org/~makamaka/JSON-2.58/lib/JSON.pm
+SRC_URL='http://www.cpan.org/authors/id/M/MA/MAKAMAKA/JSON-2.58.tar.gz'
+FILENAME="$(basename $SRC_URL)"
+SHA1_FILENAME="$FILENAME.sha1"
+BUILD_DIR='JSON-2.58'
+INSTALL_DIR="$(pwd)/out"
+
+curl --remote-name "$SRC_URL"
+
+# Check hash
+# SHA-1 hash generated via:
+# shasum JSON-2.58.tar.gz > JSON-2.58.tar.gz.sha1
+if ! [ -f "$SHA1_FILENAME" ]
+then
+ echo "SHA-1 hash file $SHA1_FILENAME not found, could not verify archive"
+ exit 1
+fi
+
+# Check that hash file contains hash for archive
+HASHFILE_REGEX="^[0-9a-f]{40} $FILENAME" # 40-digit hash, followed by filename
+if ! grep --extended-regex --line-regex --silent \
+ "$HASHFILE_REGEX" "$SHA1_FILENAME"
+then
+ echo "SHA-1 hash file $SHA1_FILENAME does not contain hash for $FILENAME," \
+ 'could not verify archive'
+ echo 'Hash file contents are:'
+ cat "$SHA1_FILENAME"
+ exit 1
+fi
+
+if ! shasum --check "$SHA1_FILENAME"
+then
+ echo 'SHA-1 hash does not match,' \
+ "archive file $FILENAME corrupt or compromised!"
+ exit 1
+fi
+
+# Extract and build
+tar xvzf "$FILENAME"
+cd "$BUILD_DIR"
+perl Makefile.PL INSTALL_BASE="$INSTALL_DIR"
+make
+make test
+make install

Powered by Google App Engine
This is Rietveld 408576698