diff options
Diffstat (limited to 'build.sh')
-rwxr-xr-x | build.sh | 33 |
1 files changed, 26 insertions, 7 deletions
@@ -21,8 +21,10 @@ print_usage() { echo " -b, build=[LOC]: set file/directory to use for building" echo " -h, help: print usage information and exit" echo " -o, output=[LOC]: set output file/directory" + echo " -k, key=[LOC]: select a key to use in building and" + echo " signing a CRX" echo " -s, safe: don't delete existing directories;" - echo " throw an error instead." + echo " throw an error instead" echo " -z, zip: pack the extension as a file" echo echo "environment variables (optional)" @@ -46,6 +48,8 @@ while [ "x$1" != x ]; do -b | --build) BUILDDIR="$2"; shift;; build=*) BUILDDIR="$(echo "$1" | cut -c 7-)";; -h | --help | help) print_usage;; + -k | --key) KEY="$2"; shift;; + key=*) KEY="$(echo "$1" | cut -c 5-)";; -o | --output) OUTPUT="$2"; shift;; output=*) OUTPUT="$(echo "$1" | cut -c 8-)";; -s | --safe | safe) FORCE=0;; @@ -57,16 +61,31 @@ done if [ "x$BROWSER" = x ]; then print_usage 1 No browser was specified. +elif [ "x$KEY" != x ]; then + if [ $BROWSER != chromium ]; then + print_usage 4 The "'key'" option applies only to builds 'for' Chromium. + elif [ $MAKEZIP = 0 ]; then + print_usage 4 The "'key'" option must be used in conjunction with the "'zip'" option. + elif [ ! -e "$KEY" ]; then + print_usage 5 The specified key file "'$KEY'" does not exist. + fi + KEY="$(realpath "$KEY")" fi - -if [ $MAKEZIP = 1 ]; then +if [ "x$KEY" != x ]; then + PACKDIR="${BUILDDIR:-build_$BROWSER}" + BUILDDIR="$PACKDIR"/inner + OUTPUT="${OUTPUT:-build.crx}" + + mkdir "$PACKDIR" +elif [ $MAKEZIP = 1 ]; then BUILDDIR="${BUILDDIR:-build_$BROWSER}" + PACKDIR="$BUILDDIR" if [ "x$OUTPUT" = x ]; then case $BROWSER in - chromium) OUTPUT=build.zip;; - mozilla) OUTPUT=build.xpi;; + chromium) OUTPUT=build.zip;; + mozilla) OUTPUT=build.xpi;; esac fi else @@ -99,8 +118,8 @@ mkdir "$BUILDDIR" main if [ $MAKEZIP = 1 ]; then make_zip - mv "$BUILDDIR"/build.zip "$OUTPUT" - rm -rf "$BUILDDIR" + mv "$PACKDIR"/build.zip "$OUTPUT" + rm -rf "$PACKDIR" elif [ "$BUILDDIR" != "$OUTPUT" ]; then mv "$BUILDDIR" "$OUTPUT" fi |