11#! /usr/bin/env bash
22
3- # Build an HTTPS Everywhere .crx Chromium extension (for Chromium 17+)
3+ # Build an HTTPS Everywhere .crx & .xpi extension
44#
55# To build the current state of the tree:
66#
7- # ./makecrx.sh #
7+ # ./make.sh
8+ #
89# To build a particular tagged release:
910#
10- # ./makecrx .sh <version number>
11+ # ./make .sh <version number>
1112#
1213# eg:
1314#
14- # ./makecrx .sh chrome-2012.1.26
15+ # ./make .sh 2017.8.15
1516#
1617# Note that .crx files must be signed; this script makes you a
1718# "dummy-chromium.pem" private key for you to sign your own local releases,
2021
2122cd $( dirname $0 )
2223
23- if [ -n " $1 " ]; then
24+ if [ -n " $1 " -a " $1 " != " --remove-update-channel " ]; then
2425 BRANCH=` git branch | head -n 1 | cut -d \ -f 2-`
2526 SUBDIR=checkout
2627 [ -d $SUBDIR ] || mkdir $SUBDIR
3233
3334VERSION=` python2.7 -c " import json ; print(json.loads(open('chromium/manifest.json').read())['version'])" `
3435
35- echo " Building chrome version" $VERSION
36+ echo " Building version" $VERSION
3637
3738[ -d pkg ] || mkdir -p pkg
3839[ -e pkg/crx ] && rm -rf pkg/crx
40+ [ -e pkg/xpi-amo ] && rm -rf pkg/xpi-amo
41+ [ -e pkg/xpi-eff ] && rm -rf pkg/xpi-eff
3942
4043# Clean up obsolete ruleset databases, just in case they still exist.
4144rm -f src/chrome/content/rules/default.rulesets src/defaults/rulesets.sqlite
@@ -60,23 +63,40 @@ cp src/$RULESETS pkg/crx/rules/default.rulesets
6063
6164sed -i -e " s/VERSION/$VERSION /g" pkg/crx/manifest.json
6265
63- python2.7 -c " import json; m=json.loads(open('pkg/crx/manifest.json').read()); e=m['author']; m['author']={'email': e}; del m['applications']; open('pkg/crx/manifest.json','w').write(json.dumps(m,indent=4,sort_keys=True))"
66+ cp -a pkg/crx pkg/xpi-amo
67+ cp -a pkg/crx pkg/xpi-eff
68+ cp -a src/META-INF pkg/xpi-amo
69+ cp -a src/META-INF pkg/xpi-eff
6470
65- # sed -i -e "s/VERSION/$VERSION/g" pkg/crx/updates.xml
66- # sed -e "s/VERSION/$VERSION/g" pkg/updates-master.xml > pkg/crx/updates.xml
71+ # Remove the 'applications' manifest key from the crx version of the extension and change the 'author' string to a hash
72+ python2.7 -c " import json; m=json.loads(open('pkg/crx/manifest.json').read()); e=m['author']; m['author']={'email': e}; del m['applications']; open('pkg/crx/manifest.json','w').write(json.dumps(m,indent=4,sort_keys=True))"
73+ # Remove the 'update_url' manifest key from the xpi version of the extension delivered to AMO
74+ python2.7 -c " import json; m=json.loads(open('pkg/xpi-amo/manifest.json').read()); del m['applications']['gecko']['update_url']; open('pkg/xpi-amo/manifest.json','w').write(json.dumps(m,indent=4,sort_keys=True))"
75+
76+ # If the --remove-update-channel flag is set, ensure the extension is unable to update
77+ if [ " $1 " == " --remove-update-channel" -o " $2 " == " --remove-update-channel" ]; then
78+ echo " Flag --remove-update-channel specified. Removing the XPI extensions' ability to update."
79+ python2.7 -c " import json; m=json.loads(open('pkg/xpi-amo/manifest.json').read()); m['applications']['gecko']['update_url'] = 'data:text/plain,'; open('pkg/xpi-amo/manifest.json','w').write(json.dumps(m,indent=4,sort_keys=True))"
80+ python2.7 -c " import json; m=json.loads(open('pkg/xpi-eff/manifest.json').read()); m['applications']['gecko']['update_url'] = 'data:text/plain,'; open('pkg/xpi-eff/manifest.json','w').write(json.dumps(m,indent=4,sort_keys=True))"
81+ fi
6782
6883if [ -n " $BRANCH " ] ; then
6984 crx=" pkg/https-everywhere-$VERSION .crx"
85+ xpi_amo=" pkg/https-everywhere-$VERSION -amo.xpi"
86+ xpi_eff=" pkg/https-everywhere-$VERSION -eff.xpi"
7087 key=../dummy-chromium.pem
7188else
7289 crx=" pkg/https-everywhere-$VERSION ~pre.crx"
90+ xpi_amo=" pkg/https-everywhere-$VERSION ~pre-amo.xpi"
91+ xpi_eff=" pkg/https-everywhere-$VERSION ~pre-eff.xpi"
7392 key=dummy-chromium.pem
7493fi
7594if ! [ -f " $key " ] ; then
7695 echo " Making a dummy signing key for local build purposes"
7796 openssl genrsa 2048 > " $key "
7897fi
7998
99+
80100# # Based on https://code.google.com/chrome/extensions/crx.html
81101
82102dir=pkg/crx
117137 echo " $crmagic_hex $version_hex $pub_len_hex $sig_len_hex " | $sed -e ' s/\s//g' -e ' s/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf
118138 cat " $pub " " $sig " " $zip "
119139) > " $crx "
140+
141+
142+
143+ # now zip up the xpi AMO dir
144+ name=pkg/xpi-amo
145+ dir=pkg/xpi-amo
146+ zip=" $name .zip"
147+
148+ cwd=$( pwd -P)
149+ (cd " $dir " && ../../utils/create_xpi.py -n " $cwd /$zip " -x " ../../.build_exclusions" .)
150+ echo >&2 " AMO xpi package has sha1sum: ` sha1sum " $cwd /$zip " ` "
151+
152+ cp $zip $xpi_amo
153+
154+
155+
156+ # now zip up the xpi EFF dir
157+ name=pkg/xpi-eff
158+ dir=pkg/xpi-eff
159+ zip=" $name .zip"
160+
161+ cwd=$( pwd -P)
162+ (cd " $dir " && ../../utils/create_xpi.py -n " $cwd /$zip " -x " ../../.build_exclusions" .)
163+ echo >&2 " EFF xpi package has sha1sum: ` sha1sum " $cwd /$zip " ` "
164+
165+ cp $zip $xpi_eff
166+
167+
168+
169+ bash utils/android-push.sh " $xpi_eff "
170+
120171# rm -rf pkg/crx
121172
122173# python2.7 githubhelper.py $VERSION
129180
130181echo >&2 " Total included rules: ` find src/chrome/content/rules -name " *.xml" | wc -l` "
131182echo >&2 " Rules disabled by default: ` find src/chrome/content/rules -name " *.xml" | xargs grep -F default_off | wc -l` "
132- echo >&2 " Created $crx "
183+
184+ # send the following to stdout so scripts can parse it
185+ # see test/selenium/shim.py
186+ echo " Created $xpi_amo "
187+ echo " Created $xpi_eff "
188+ echo " Created $crx "
189+
133190if [ -n " $BRANCH " ]; then
134191 cd ..
135192 cp $SUBDIR /$crx pkg
193+ cp $SUBDIR /$xpi_amo pkg
194+ cp $SUBDIR /$xpi_eff pkg
136195 rm -rf $SUBDIR
137196fi
138- echo " $crx " # send to stdout so scripts can parse it
0 commit comments