-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e3934a
commit dee6566
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
zip -r netflex.zip netflex/ -x netflex/.git/\* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
if test $# -ne 2; then | ||
echo "Usage: crxmake.sh <extension dir> <pem path>" | ||
exit 1 | ||
fi | ||
|
||
dir=$1 | ||
key=$2 | ||
name=$(basename "$dir") | ||
crx="$name.crx" | ||
pub="$name.pub" | ||
sig="$name.sig" | ||
zip="$name.zip" | ||
trap 'rm -f "$pub" "$sig" "$zip"' EXIT | ||
|
||
# zip up the crx dir | ||
cwd=$(pwd -P) | ||
(cd "$dir" && zip -qr -9 -X "$cwd/$zip" .) | ||
|
||
# signature | ||
openssl sha1 -sha1 -binary -sign "$key" < "$zip" > "$sig" | ||
|
||
# public key | ||
openssl rsa -pubout -outform DER < "$key" > "$pub" 2>/dev/null | ||
|
||
byte_swap () { | ||
# Take "abcdefgh" and return it as "ghefcdab" | ||
echo "${1:6:2}${1:4:2}${1:2:2}${1:0:2}" | ||
} | ||
|
||
crmagic_hex="4372 3234" # Cr24 | ||
version_hex="0200 0000" # 2 | ||
pub_len_hex=$(byte_swap $(printf '%08x\n' $(ls -l "$pub" | awk '{print $5}'))) | ||
sig_len_hex=$(byte_swap $(printf '%08x\n' $(ls -l "$sig" | awk '{print $5}'))) | ||
( | ||
echo "$crmagic_hex $version_hex $pub_len_hex $sig_len_hex" | xxd -r -p | ||
cat "$pub" "$sig" "$zip" | ||
) > "$crx" | ||
echo "Wrote $crx" |