aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbuild.sh33
-rwxr-xr-xlib_build.sh9
2 files changed, 33 insertions, 9 deletions
diff --git a/build.sh b/build.sh
index 017b516..5c28c02 100755
--- a/build.sh
+++ b/build.sh
@@ -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
diff --git a/lib_build.sh b/lib_build.sh
index 0fa656c..7327d52 100755
--- a/lib_build.sh
+++ b/lib_build.sh
@@ -292,6 +292,11 @@ EOF
}
make_zip() (
- cd "$BUILDDIR"
- ${HAKETILO_ZIP:-zip -r} build.zip *;;
+ cd "$PACKDIR"
+ if [ "x$KEY" = x ]; then
+ ${HAKETILO_ZIP:-zip -r} build.zip *;
+ else
+ ${HAKETILO_CHROMIUM:-chromium} --pack-extension="$(realpath inner)" --pack-extension-key="$KEY"
+ mv *.crx build.zip
+ fi
)