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

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: Fix permissions and shebangs Created 7 years, 6 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
« no previous file with comments | « third_party/JSON/README.chromium ('k') | third_party/JSON/out/lib/perl5/JSON.pm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9f86967fb791fbef96984c65a32e4df7db9be815
--- /dev/null
+++ b/third_party/JSON/get_and_build_json_pm.sh
@@ -0,0 +1,80 @@
+#!/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'
+PACKAGE='JSON'
+VERSION='2.59'
+SRC_URL="http://www.cpan.org/authors/id/M/MA/MAKAMAKA/$PACKAGE-$VERSION.tar.gz"
+FILENAME="$(basename $SRC_URL)"
+SHA1_FILENAME="$FILENAME.sha1"
+BUILD_DIR="$PACKAGE-$VERSION"
+INSTALL_DIR="$(pwd)/out"
+
+curl --remote-name "$SRC_URL"
+
+# Check hash
+# SHA-1 hash generated via:
+# shasum JSON-2.59.tar.gz > JSON-2.59.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
+cd ..
+rm "$FILENAME"
+
+# Rename :: to __ because : is reserved in Windows filenames
+# (only occurs in man pages, which aren't necessary)
+for i in $(find . -name '*::*')
+do
+ mv -f "$i" `echo "$i" | sed s/::/__/g`
+done
+
+# Fix permissions and shebangs
+# https://rt.cpan.org/Public/Bug/Display.html?id=85917
+# Make examples executable
+cd "$BUILD_DIR"
+chmod +x eg/*.pl
+cd t
+
+# Strip shebangs from test files that have them
+for i in *.t
+do
+ if head -1 "$i" | grep --quiet '^#!'
+ then
+ ed -s "$i" <<END
+# Delete line 1
+1d
+# Write and Quit
+wq
+END
+ fi
+done
« no previous file with comments | « third_party/JSON/README.chromium ('k') | third_party/JSON/out/lib/perl5/JSON.pm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698