Skip to content

Commit 8c29f4b

Browse files
authored
Merge pull request EFForg#13368 from EFForg/webextensions
Webextensions
2 parents e958e4b + 9cef98b commit 8c29f4b

17 files changed

Lines changed: 93 additions & 505 deletions

File tree

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,9 @@ Run the latest code and rulesets in a standalone Tor Browser profile:
2929

3030
bash test/tor path_to_tor_browser.tar.xz
3131

32-
Build the Firefox extension as a .xpi package:
32+
Build the Firefox (.xpi) & Chromium (.crx) extensions:
3333

34-
bash makexpi.sh
35-
36-
Build the Chromium extension as a .crx package:
37-
38-
bash makecrx.sh
34+
bash make.sh
3935

4036
Both of the build commands store their output under pkg/.
4137

hooks/update

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,18 @@ echo "attempting to validate $newrev" >&2
4242

4343
# --- Test build
4444

45-
if [ -f makexpi.sh && -f makecrx.sh ]; then
46-
./makexpi.sh
47-
XPIBULID=$?
45+
if [ -f make.sh ]; then
46+
./make.sh
47+
EXTBULID=$?
4848

49-
./makecrx.sh
50-
CRXBUILD=$?
51-
52-
if [ "$XPIBULID" != 0 || "$CRXBUILD" != 0 ]; then
49+
if [ "$EXTBULID" != 0 ]; then
5350
echo "*** build failed" >&2
5451
exit 1
5552
else
5653
exit 0
5754
fi
5855
else
59-
echo "*** could not find makexpi.sh or makecrx.sh." >&2
56+
echo "*** could not find make.sh." >&2
6057
exit 1
6158
fi
6259

makecrx.sh renamed to make.sh

Lines changed: 69 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
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,
@@ -20,7 +21,7 @@
2021

2122
cd $(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
@@ -32,10 +33,12 @@ fi
3233

3334
VERSION=`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.
4144
rm -f src/chrome/content/rules/default.rulesets src/defaults/rulesets.sqlite
@@ -60,23 +63,40 @@ cp src/$RULESETS pkg/crx/rules/default.rulesets
6063

6164
sed -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

6883
if [ -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
7188
else
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
7493
fi
7594
if ! [ -f "$key" ] ; then
7695
echo "Making a dummy signing key for local build purposes"
7796
openssl genrsa 2048 > "$key"
7897
fi
7998

99+
80100
## Based on https://code.google.com/chrome/extensions/crx.html
81101

82102
dir=pkg/crx
@@ -117,6 +137,37 @@ fi
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
@@ -129,10 +180,17 @@ fi
129180

130181
echo >&2 "Total included rules: `find src/chrome/content/rules -name "*.xml" | wc -l`"
131182
echo >&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+
133190
if [ -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
137196
fi
138-
echo "$crx" # send to stdout so scripts can parse it

makexpi.sh

Lines changed: 0 additions & 142 deletions
This file was deleted.

rewriter/rewriter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
// Usage:
88
// cd https-everywhere
9-
// ./makecrx.sh # to build default.rulesets
9+
// ./make.sh # to build default.rulesets
1010
// cd rewriter
1111
// (install node and npm)
1212
// npm install

setup_travis.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function setup_firefox {
2020
sudo tar -xvf /tmp/geckodriver.tar.gz -C /usr/local/bin/
2121
sudo chmod a+x /usr/local/bin/geckodriver
2222

23-
# ./makexpi.sh requires xmllint
23+
# ./make.sh requires xmllint
2424
sudo apt-get -qq update
2525
sudo apt-get install -y libxml2-utils
2626
}

0 commit comments

Comments
 (0)