diff options
Diffstat (limited to 'crxmake')
-rwxr-xr-x | crxmake | 22 |
1 files changed, 14 insertions, 8 deletions
@@ -1,11 +1,13 @@ #! /bin/sh # Pack a Chromium extension directory into CRX3 format -# usage: crxmake EXTENSION_DIR KEY_FILE +# usage: crxmake EXTENSION_DIR KEY_FILE OUT_FILE set -efu -dir=$1 -key=$2 +dir=$(realpath "$1") +key=$(realpath "$2") +out=$(realpath "$3") + name=$(basename "$dir") crx="$name.crx" pub="$name.pub" @@ -13,16 +15,19 @@ sig="$name.sig" zip="$name.zip" tosign="$name.presig" binary_crx_id="$name.crxid" -trap 'rm -f "$pub" "$sig" "$zip" "$tosign" "$binary_crx_id"' EXIT +workdir=$(mktemp -d -t crxmake.XXXXXXXX) +oldworkdir=$PWD +cd "$workdir" +trap 'cd "$oldworkdir" && rm -fR "$workdir"' EXIT # zip up the crx dir -cwd=$(pwd -P) -(cd "$dir" && zip -qr -9 -X "$cwd/$zip" .) +(cd "$dir" && zip -qr -9 -X "$workdir/$zip" .) #extract crx id -openssl rsa -in "$key" -pubout -outform der | openssl dgst -sha256 -binary -out "$binary_crx_id" +openssl rsa -in "$key" -pubout -outform der 2>/dev/null | +openssl dgst -sha256 -binary -out "$binary_crx_id" truncate -s 16 "$binary_crx_id" #generate file to sign @@ -54,4 +59,5 @@ header_chunk_3="82 F1 04 12 0A 10" echo "$header_chunk_3" | xxd -r -p cat "$binary_crx_id" "$zip" ) > "$crx" -echo "Wrote $crx" + +mv "$crx" "$out" |