forked from zotero/zotero-standalone-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetch_xulrunner.sh
executable file
·161 lines (138 loc) · 4.27 KB
/
fetch_xulrunner.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/bin/bash
set -euo pipefail
# Copyright (c) 2011 Zotero
# Center for History and New Media
# George Mason University, Fairfax, Virginia, USA
# http://zotero.org
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
CALLDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. "$CALLDIR/config.sh"
DOWNLOAD_URL="https://ftp.mozilla.org/pub/firefox/releases/$GECKO_VERSION"
function usage {
cat >&2 <<DONE
Usage: $0 -p platforms
Options
-p PLATFORMS Platforms to build (m=Mac, w=Windows, l=Linux)
DONE
exit 1
}
BUILD_MAC=0
BUILD_WIN32=0
BUILD_LINUX=0
while getopts "p:" opt; do
case $opt in
p)
for i in `seq 0 1 $((${#OPTARG}-1))`
do
case ${OPTARG:i:1} in
m) BUILD_MAC=1;;
w) BUILD_WIN32=1;;
l) BUILD_LINUX=1;;
*)
echo "$0: Invalid platform option ${OPTARG:i:1}"
usage
;;
esac
done
;;
esac
shift $((OPTIND-1)); OPTIND=1
done
# Require at least one platform
if [[ $BUILD_MAC == 0 ]] && [[ $BUILD_WIN32 == 0 ]] && [[ $BUILD_LINUX == 0 ]]; then
usage
fi
#
# Make various modifications to omni.ja
#
function modify_omni {
mkdir omni
mv omni.ja omni
cd omni
# omni.ja is an "optimized" ZIP file, so use a script from Mozilla to avoid a warning from unzip
# here and to make it work after rezipping below
python2.7 "$CALLDIR/scripts/optimizejars.py" --deoptimize ./ ./ ./
unzip omni.ja
rm omni.ja
# Modify AddonConstants.jsm in omni.ja to allow unsigned add-ons
#
# Theoretically there should be other ways of doing this (e.g., an 'override' statement in
# chrome.manifest, an enterprise config.js file that clears SIGNED_TYPES in XPIProvider.jsm),
# but I couldn't get them to work.
perl -pi -e 's/value: true/value: false/' modules/addons/AddonConstants.jsm
# Delete binary version of file
rm jsloader/resource/gre/modules/addons/AddonConstants.jsm
# Increase internal SQL transaction timeout to an hour
perl -pi -e 's/TRANSACTIONS_QUEUE_TIMEOUT_MS = .+/TRANSACTIONS_QUEUE_TIMEOUT_MS = 3600000;/' modules/Sqlite.jsm
rm jsloader/resource/gre/modules/Sqlite.jsm
# Disable unwanted components
cat components/components.manifest | grep -vi telemetry > components/components2.manifest
mv components/components2.manifest components/components.manifest
zip -qr9XD omni.ja *
mv omni.ja ..
cd ..
python2.7 "$CALLDIR/scripts/optimizejars.py" --optimize ./ ./ ./
rm -rf omni
}
rm -rf xulrunner
mkdir xulrunner
cd xulrunner
if [ $BUILD_MAC == 1 ]; then
rm -rf Firefox.app
curl -O "$DOWNLOAD_URL/mac/en-US/Firefox%20$GECKO_VERSION.dmg"
set +e
hdiutil detach -quiet /Volumes/Firefox 2>/dev/null
set -e
hdiutil attach -quiet "Firefox%20$GECKO_VERSION.dmg"
cp -a /Volumes/Firefox/Firefox.app .
hdiutil detach -quiet /Volumes/Firefox
pushd Firefox.app/Contents/Resources
modify_omni
popd
rm "Firefox%20$GECKO_VERSION.dmg"
fi
if [ $BUILD_WIN32 == 1 ]; then
XDIR=firefox-win32
rm -rf $XDIR
mkdir $XDIR
curl -O "$DOWNLOAD_URL/win32/en-US/Firefox%20Setup%20$GECKO_VERSION.exe"
7z x Firefox%20Setup%20$GECKO_VERSION.exe -o$XDIR 'core/*'
mv $XDIR/core $XDIR-core
rm -rf $XDIR
mv $XDIR-core $XDIR
cd $XDIR
modify_omni
cd ..
rm "Firefox%20Setup%20$GECKO_VERSION.exe"
fi
if [ $BUILD_LINUX == 1 ]; then
rm -rf firefox
curl -O "$DOWNLOAD_URL/linux-i686/en-US/firefox-$GECKO_VERSION.tar.bz2"
rm -rf firefox-i686
tar xvf firefox-$GECKO_VERSION.tar.bz2
mv firefox firefox-i686
cd firefox-i686
modify_omni
cd ..
rm "firefox-$GECKO_VERSION.tar.bz2"
curl -O "$DOWNLOAD_URL/linux-x86_64/en-US/firefox-$GECKO_VERSION.tar.bz2"
rm -rf firefox-x86_64
tar xvf firefox-$GECKO_VERSION.tar.bz2
mv firefox firefox-x86_64
cd firefox-x86_64
modify_omni
cd ..
rm "firefox-$GECKO_VERSION.tar.bz2"
fi