aboutsummaryrefslogtreecommitdiff
path: root/nex-build.sh
diff options
context:
space:
mode:
authorEinar Egilsson <einar@einaregilsson.com>2015-10-05 10:58:39 +0000
committerEinar Egilsson <einar@einaregilsson.com>2015-10-05 10:58:39 +0000
commit60341ef37cf9046d0f99b5d3eb4dc1a2ad90acf9 (patch)
tree8c887593b655549ba353ebf6b6aad7d0f5b29c1d /nex-build.sh
parent36d4fe49ee7ff432fd0c270ddec5800d26c1ee5a (diff)
Build that works for Opera
Diffstat (limited to 'nex-build.sh')
-rwxr-xr-xnex-build.sh33
1 files changed, 33 insertions, 0 deletions
diff --git a/nex-build.sh b/nex-build.sh
new file mode 100755
index 0000000..ade44cc
--- /dev/null
+++ b/nex-build.sh
@@ -0,0 +1,33 @@
+#!/bin/bash -e
+#
+# Purpose: Convert a .zip file into a .nex file for Opera
+# Adapted from
+
+dir=$PWD
+zip="$PWD/$1"
+nex="$PWD/$2"
+key=$3
+pub="tmp.pub"
+sig="tmp.sig"
+trap 'rm -f "$pub" "$sig" "$zip"' EXIT
+
+# 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"
+) > "$nex"
+echo "Wrote $nex" \ No newline at end of file