From fa6a59e303d9290bd293bd0dbc8997d31bc387fc Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 4 Jan 2021 16:49:43 +0100 Subject: add build-crx.sh and install-crx.sh --- build-crx.sh | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 build-crx.sh (limited to 'build-crx.sh') diff --git a/build-crx.sh b/build-crx.sh new file mode 100755 index 0000000..ad0460e --- /dev/null +++ b/build-crx.sh @@ -0,0 +1,56 @@ +#! /bin/sh +# usage: ./build-crx.sh [--generate-key] [OUTPUT_DIR [TABFS_SOURCE_DIR]] +set -efu + +# TODO keep in sync with ./install-crx.sh +source_dir=${2-$(dirname "$0")} +out_dir=${1-$source_dir/out} +crx_file=$out_dir/TabFS.crx +update_file=$out_dir/TabFS.xml +policy_file=$out_dir/TabFS.json + +# TODO keep in sync with system_extensions_dir and system_update_dir in +# ./install-crx.sh +crx_url=file:///etc/chromium/extensions/TabFS.crx +update_url=file:///etc/chromium/extensions/TabFS.xml + +key_file=$out_dir/TabFS.pem +key_size=2048 + + +mkdir -p "$out_dir" + +if ! test -e "$key_file" || printf %s $* | grep -q -- '--generate-key\>'; then + openssl genrsa -out "$key_file" "$key_size" +fi + +ext_dir=$source_dir/extension + +crxmake "$ext_dir" "$key_file" "$crx_file" + +appid=$(crxid "$key_file") +version=$(jq -r .version "$ext_dir"/manifest.json) + +cat > "$update_file" < + + + + + +EOF + +jq > "$policy_file" \ +--null-input \ +--arg appid "$appid" \ +--arg update_url "$update_url" \ +' +{ + ExtensionSettings: { + "\($appid)": { + installation_mode: "normal_installed", + $update_url + } + } +} +' -- cgit v1.2.3