diff options
author | Nick White <git@njw.me.uk> | 2010-11-13 21:06:41 +0000 |
---|---|---|
committer | Nick White <git@njw.me.uk> | 2010-11-13 21:06:41 +0000 |
commit | 1b483bb48a316bb634a84db5b33c00f9b8883b61 (patch) | |
tree | 38d48f96850e97cf8e722ab67466f3a1cbb189ed /chromium | |
parent | 2b4521d90cdb3e5fe0b29d681eec0b899cb81d4b (diff) |
Add crx creation script (untested)
Diffstat (limited to 'chromium')
-rwxr-xr-x | chromium/makecrx.sh | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/chromium/makecrx.sh b/chromium/makecrx.sh new file mode 100755 index 0000000..ca97835 --- /dev/null +++ b/chromium/makecrx.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# +# Purpose: Pack a Chromium extension directory into crx format +# +# Based on bash script at: +# http://code.google.com/chrome/extensions/crx.html +# Licensed under the BSD license + +test $# -ne 2 && echo "Usage: $0 dir pem" && exit 1 + +dir=$1 +key=$2 +pub="pubkey" +sig="sig" +zip="tmp.zip" +trap 'rm -f "$pub" "$sig" "$zip"' EXIT + +wd=`pwd` && cd "$dir" && zip -qr -9 -X "$wd/$zip" . ; cd "$wd" + +openssl sha1 -sha1 -binary -sign "$key" < "$zip" > "$sig" +openssl rsa -pubout -outform DER < "$key" > "$pub" 2>/dev/null + +crmagic_hex="4372 3234" # Cr24 +version_hex="0200 0000" # 2 +pub_len_hex=`stat -c %s "$pub" | xargs printf '%08x\n' | rev | dd conv=swab 2>/dev/null` +sig_len_hex=`stat -c %s "$sig" | xargs printf '%08x\n' | rev | dd conv=swab 2>/dev/null` + +echo "$crmagic_hex $version_hex $pub_len_hex $sig_len_hex" | xxd -r -p +cat "$pub" "$sig" "$zip" |