Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Build System #26

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
27 changes: 24 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
rm Archive.zip Archive.xpi
zip -r Archive.zip manifest.json css/ icons/ js/ src/
zip -r Archive.xpi manifest.json install.rdf css/ icons/ js/ src/
mkdir -pv build/planner-helper
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add #!/bin/bash to the top of this file?

mkdir -pv build/planner-helper/src/inject
mkdir -pv build/planner-helper/src/bg
mkdir -pv build/planner-helper/icons
mkdir -pv build/planner-helper/js

cp -v manifest.json build/planner-helper/
cp -v icons/* build/planner-helper/icons/
cp -v src/inject/inject.css build/planner-helper/src/inject/
cp -v js/*.min.js build/planner-helper/js/

JS=js/*.js
BG=src/bg/*.js
INJECT=src/inject/*.js

for f in $FILES $BG $INJECT
do
uglifyjs -v $f -o build/planner-helper/$f
done

google-chrome --pack-extension=./build/planner-helper/
./createCRX.sh build/planner-helper build/planner-helper.pem

rm -rv build/
44 changes: 44 additions & 0 deletions createCRX.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash -e
#
# Purpose: Pack a Chromium extension directory into crx format

# This was taken from https://developer.chrome.com/extensions/crx

if test $# -ne 2; then
echo "Usage: crxmake.sh <extension dir> <pem path>"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this use createCRX.sh instead of crxmake.sh?

exit 1
fi

dir=$1
key=$2
name=$(basename "$dir")
crx="$name.crx"
pub="$name.pub"
sig="$name.sig"
zip="$name.zip"
trap 'rm -f "$pub" "$sig" "$zip"' EXIT

# zip up the crx dir
cwd=$(pwd -P)
(cd "$dir" && zip -qr -9 -X "$cwd/$zip" .)

# signature
openssl sha1 -sha1 -binary -sign "$key" < "$zip" > "$sig"

# public key
openssl rsa -pubout -outform DER < "$key" > "$pub" 2>/dev/null

byte_swap () {
# Take "abcdefgh" and return it as "ghefcdab"
echo "${1:6:2}${1:4:2}${1:2:2}${1:0:2}"
}

crmagic_hex="4372 3234" # Cr24
version_hex="0200 0000" # 2
pub_len_hex=$(byte_swap $(printf '%08x\n' $(ls -l "$pub" | awk '{print $5}')))
sig_len_hex=$(byte_swap $(printf '%08x\n' $(ls -l "$sig" | awk '{print $5}')))
(
echo "$crmagic_hex $version_hex $pub_len_hex $sig_len_hex" | xxd -r -p
cat "$pub" "$sig" "$zip"
) > "$crx"
echo "Wrote $crx"
7 changes: 3 additions & 4 deletions src/inject/planner_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,9 @@ PlannerHelper.prototype.createElement = function () {
PlannerHelper.prototype.abort = function () {
this.aborted = true;

var message = `
Sorry, it appears that either WebReg or one of the data dependencies for Planner Helper
have changed their format. An error report has been sent and an update will be released
soon to make Planner Helper compatible with these changes.`;
var message = "Sorry, it appears that either WebReg or one of the data dependencies for Planner Helper" +
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There needs to be a space at the end of this string or else the output will look like "...Planner Helperhave changed...". (same goes for line 197)

"have changed their format. An error report has been sent and an update will be released" +
"soon to make Planner Helper compatible with these changes.";
this.element.children('#planner-helper-data').text(message);
this.disableSearchEvent();
};
Expand Down