aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjahoti <jahoti@tilde.team>2021-09-28 00:00:00 +0000
committerjahoti <jahoti@tilde.team>2021-09-28 00:00:00 +0000
commit81910556643b5878b001ed443aebf719d5bf99b9 (patch)
treea6a1046ce81126b2f38b2929a9586305ee4ca0f3
parentfbf0503fe362df07eb34c4bd69d1b945f60922b4 (diff)
downloadbrowser-extension-81910556643b5878b001ed443aebf719d5bf99b9.tar.gz
browser-extension-81910556643b5878b001ed443aebf719d5bf99b9.zip
Add build support for update URLsjahoti-update
The 'url' parameter can now be used to provide an update URL
-rwxr-xr-xbuild.sh21
-rwxr-xr-xlib_build.sh10
-rw-r--r--manifest.json2
3 files changed, 24 insertions, 9 deletions
diff --git a/build.sh b/build.sh
index 5c28c02..c548e75 100755
--- a/build.sh
+++ b/build.sh
@@ -18,18 +18,19 @@ print_usage() {
echo " -C, chromium: build for Chromium and derivatives"
echo " -M, mozilla: build for Firefox and derivatives"
echo "options:"
- echo " -b, build=[LOC]: set file/directory to use for building"
+ echo " -b, build=[LOC]: 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 " -o, output=[LOC]: output file/directory"
+ echo " -k, key=[LOC]: the key to use in signing a CRX;"
+ echo " builds a CRX instead of a ZIP"
echo " -s, safe: don't delete existing directories;"
echo " throw an error instead"
+ echo " -u, url=[URL]: URL to check for updates"
echo " -z, zip: pack the extension as a file"
echo
echo "environment variables (optional)"
- echo " HAKETILO_ZIP: command to use for generating ZIP files"
- echo " HAKETILO_CHROMIUM: command to user to invoke Chromium"
+ echo " HAKETILO_ZIP: command to use for generating ZIP files"
+ echo " HAKETILO_CHROMIUM: command to use for invoking Chromium"
exit $EXIT_STATUS
}
@@ -38,6 +39,8 @@ print_usage() {
BROWSER=''
BUILDDIR=''
+KEY=''
+UPDATE_URL=''
MAKEZIP=0
FORCE=1
@@ -53,6 +56,8 @@ while [ "x$1" != x ]; do
-o | --output) OUTPUT="$2"; shift;;
output=*) OUTPUT="$(echo "$1" | cut -c 8-)";;
-s | --safe | safe) FORCE=0;;
+ -u | --url) UPDATE_URL="$2"; shift;;
+ url=*) UPDATE_URL="$(echo "$1" | cut -c 5-)";;
-z | --zip | zip_ext) MAKEZIP=1;;
*) print_usage 2 Unrecognized option "'$1'.";;
esac
@@ -67,8 +72,10 @@ elif [ "x$KEY" != x ]; then
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.
+ errcho "The specified key file '$KEY' does not exist."
+ exit 5
fi
+
KEY="$(realpath "$KEY")"
fi
diff --git a/lib_build.sh b/lib_build.sh
index 7327d52..f4912bf 100755
--- a/lib_build.sh
+++ b/lib_build.sh
@@ -185,13 +185,20 @@ main() {
done
CHROMIUM_KEY=''
+ CHROMIUM_UPDATE_URL=''
GECKO_APPLICATIONS=''
+
+ if [ "x$UPDATE_URL" != x ]; then
+ UPDATE_URL=",\n \"update_url\": \"$UPDATE_URL\""
+ fi
if [ "$BROWSER" = "chromium" ]; then
CHROMIUM_KEY="$(dd if=/dev/urandom bs=32 count=1 2>/dev/null | base64)"
CHROMIUM_KEY=$(echo chromium-key-dummy-file-$CHROMIUM_KEY | tr / -)
touch $BUILDDIR/$CHROMIUM_KEY
+ CHROMIUM_UPDATE_URL="$UPDATE_URL"
+
CHROMIUM_KEY="\n\
// WARNING!!!\n\
// EACH USER SHOULD REPLACE DUMMY FILE's VALUE WITH A UNIQUE ONE!!!\n\
@@ -205,7 +212,7 @@ main() {
\"applications\": {\n\
\"gecko\": {\n\
\"id\": \"{6fe13369-88e9-440f-b837-5012fb3bedec}\",\n\
- \"strict_min_version\": \"60.0\"\n\
+ \"strict_min_version\": \"60.0\"$UPDATE_URL\n\
}\n\
},"
fi
@@ -213,6 +220,7 @@ main() {
sed "\
s^_GECKO_APPLICATIONS_^$GECKO_APPLICATIONS^
s^_CHROMIUM_KEY_^$CHROMIUM_KEY^
+s^_CHROMIUM_UPDATE_URL_^$CHROMIUM_UPDATE_URL^
s^_BGSCRIPTS_^$BGSCRIPTS^
s^_CONTENTSCRIPTS_^$CONTENTSCRIPTS^" \
< manifest.json > $BUILDDIR/manifest.json
diff --git a/manifest.json b/manifest.json
index 3caa6af..b18ea3e 100644
--- a/manifest.json
+++ b/manifest.json
@@ -43,7 +43,7 @@
"options_ui": {
"page": "html/options.html",
"open_in_tab": true
- },
+ }_CHROMIUM_UPDATE_URL_,
"web_accessible_resources": [_CHROMIUM_KEY_
],
"background": {