author | Wolfgang Rosenauer <wr@rosenauer.org> |
Mon, 09 Sep 2019 23:36:13 +0200 | |
branch | firefox69 |
changeset 1108 | 33b03cfb3747 |
parent 1098 | 538cbf0bbdca |
child 1111 | 97a6da6d7e29 |
permissions | -rwxr-xr-x |
262
b680975515e0
probably last working Firefox-on-xulrunner build
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
1 |
#!/bin/bash |
b680975515e0
probably last working Firefox-on-xulrunner build
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
2 |
|
1097 | 3 |
function print_usage_and_exit() { |
4 |
echo "Usage: create-tar.sh tar_stamp" |
|
5 |
echo "" |
|
6 |
echo "Where tar_stamp should look like this:" |
|
7 |
echo "" |
|
8 |
cat << EOF |
|
9 |
# Node ID: 64ee63facd4ff96b3e8590cff559d7e97ac6b061 |
|
10 |
PRODUCT="firefox" # "firefox" or "thunderbird" |
|
11 |
CHANNEL="esr60" |
|
12 |
VERSION="60.7.0" |
|
13 |
VERSION_SUFFIX="esr" |
|
14 |
FF_RELEASE_TAG="" # Needs only to be set if no tar-ball can be downloaded |
|
15 |
TB_RELEASE_TAG="" # Only relevant for Thunderbird |
|
16 |
PREV_VERSION="60.6.3" # Prev. version only needed for locales (leave empty to force l10n-generation) |
|
17 |
PREV_VERSION_SUFFIX="esr" |
|
18 |
#SKIP_LOCALES="" # Uncomment to skip l10n and compare-locales-generation |
|
19 |
EOF |
|
20 |
||
21 |
exit 1 |
|
22 |
} |
|
23 |
||
24 |
if [ $# -ne 1 ]; then |
|
25 |
print_usage_and_exit |
|
26 |
fi |
|
27 |
||
28 |
# Sourcing the given tar_stamp-file to have the variables available |
|
29 |
source "$1" || print_usage_and_exit |
|
30 |
||
31 |
# Internal variables |
|
32 |
BRANCH="releases/mozilla-$CHANNEL" |
|
33 |
if [ "$PRODUCT" = "firefox" ]; then |
|
34 |
LOCALE_FILE="firefox-$VERSION/browser/locales/l10n-changesets.json" |
|
35 |
else |
|
36 |
LOCALE_FILE="thunderbird-$VERSION/comm/mail/locales/l10n-changesets.json" |
|
37 |
fi |
|
38 |
||
39 |
SOURCE_TARBALL="$PRODUCT-$VERSION$VERSION_SUFFIX.source.tar.xz" |
|
40 |
FTP_URL="https://ftp.mozilla.org/pub/$PRODUCT/releases/$VERSION$VERSION_SUFFIX/source" |
|
41 |
# Make first letter of PRODCUT upper case |
|
42 |
PRODUCT_CAP="${PRODUCT^}" |
|
43 |
LOCALES_URL="https://product-details.mozilla.org/1.0/l10n/$PRODUCT_CAP" |
|
44 |
# Exit script on CTRL+C |
|
45 |
trap "exit" INT |
|
46 |
||
47 |
function check_tarball_source () { |
|
48 |
TARBALL=$1 |
|
49 |
# Print out what is going to be done: |
|
50 |
if [ -e $TARBALL ]; then |
|
51 |
echo "Reuse existing file" |
|
52 |
elif wget --spider $FTP_URL/$TARBALL 2> /dev/null; then |
|
53 |
echo "Download file" |
|
54 |
else |
|
55 |
echo "Mercurial checkout" |
|
56 |
fi |
|
57 |
} |
|
909 | 58 |
|
1097 | 59 |
function ask_cont_abort_question() { |
60 |
while true; do |
|
61 |
read -p "$1 [(c)ontinue/(a)bort] " ca |
|
62 |
case $ca in |
|
63 |
[Cc]* ) return 0 ;; |
|
64 |
[Aa]* ) return 1 ;; |
|
65 |
* ) echo "Please answer c or a.";; |
|
66 |
esac |
|
67 |
done |
|
68 |
} |
|
69 |
||
70 |
function check_for_binary() { |
|
71 |
if ! test -x $1; then |
|
72 |
echo "$1 is missing: execute zypper in $2" |
|
73 |
exit 5 |
|
74 |
fi |
|
75 |
} |
|
76 |
||
77 |
function locales_get() { |
|
78 |
TMP_VERSION="$1" |
|
79 |
URL_TO_CHECK="${LOCALES_URL}-${TMP_VERSION}" |
|
80 |
||
81 |
LAST_FOUND="" |
|
82 |
# Unfortunately, locales-files are not associated to releases, but to builds. |
|
1098 | 83 |
# And since we don't know which build was the final build, we go from 9 downwards |
84 |
# try to find the latest one that exists (assuming there are no more than 9 builds). |
|
1097 | 85 |
# Error only if not even the first one exists |
1098 | 86 |
for BUILD_ID in $(seq 9 -1 0); do |
1097 | 87 |
FINAL_URL="${URL_TO_CHECK}-build${BUILD_ID}.json" |
88 |
if wget --quiet --spider "$FINAL_URL"; then |
|
89 |
LAST_FOUND="$FINAL_URL" |
|
1098 | 90 |
break |
1097 | 91 |
fi |
92 |
done |
|
1098 | 93 |
|
94 |
if [ "$LAST_FOUND" != "" ]; then |
|
95 |
echo "$LAST_FOUND" |
|
96 |
return 0 |
|
97 |
else |
|
98 |
echo "Error: Could not find locales-file (json) for Firefox $TMP_VERSION !" 1>&2 |
|
99 |
return 1 |
|
100 |
fi |
|
1097 | 101 |
} |
102 |
||
103 |
function locales_parse() { |
|
104 |
URL="$1" |
|
105 |
curl -s "$URL" | python -c "import json; import sys; \ |
|
106 |
print('\n'.join(['{} {}'.format(key, value['changeset']) \ |
|
107 |
for key, value in sorted(json.load(sys.stdin)['locales'].items())]));" |
|
108 |
} |
|
109 |
||
110 |
function locales_unchanged() { |
|
111 |
# If no json-file for one of the versions can be found, we say "they changed" |
|
112 |
prev_url=$(locales_get "$PREV_VERSION$PREV_VERSION_SUFFIX") || return 1 |
|
113 |
curr_url=$(locales_get "$VERSION$VERSION_SUFFIX") || return 1 |
|
114 |
||
115 |
prev_content=$(locales_parse "$prev_url") || exit 1 |
|
116 |
curr_content=$(locales_parse "$curr_url") || exit 1 |
|
117 |
||
118 |
diff -y --suppress-common-lines -d <(echo "$prev_content") <(echo "$curr_content") |
|
119 |
} |
|
262
b680975515e0
probably last working Firefox-on-xulrunner build
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
120 |
|
1032
8220ea23b47d
remove obsolete patches
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
1031
diff
changeset
|
121 |
# check required tools |
1097 | 122 |
check_for_binary /usr/bin/hg "mercurial" |
123 |
check_for_binary /usr/bin/jq "jq" |
|
124 |
which python > /dev/null || exit 1 |
|
1032
8220ea23b47d
remove obsolete patches
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
1031
diff
changeset
|
125 |
|
990
0d76004e9fa4
support parallel compression if available
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
986
diff
changeset
|
126 |
# use parallel compression, if available |
0d76004e9fa4
support parallel compression if available
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
986
diff
changeset
|
127 |
compression='-J' |
0d76004e9fa4
support parallel compression if available
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
986
diff
changeset
|
128 |
pixz -h > /dev/null 2>&1 |
0d76004e9fa4
support parallel compression if available
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
986
diff
changeset
|
129 |
if (($? != 127)); then |
0d76004e9fa4
support parallel compression if available
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
986
diff
changeset
|
130 |
compression='-Ipixz' |
0d76004e9fa4
support parallel compression if available
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
986
diff
changeset
|
131 |
fi |
0d76004e9fa4
support parallel compression if available
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
986
diff
changeset
|
132 |
|
1097 | 133 |
if [ -z ${SKIP_LOCALES+x} ]; then |
134 |
# TODO: Thunderbird has usually "default" as locale entry. |
|
135 |
# There we probably need to double-check Firefox-locals |
|
136 |
# For now, just download every time for Thunderbird |
|
137 |
if [ "$PRODUCT" = "firefox" ] && [ "$PREV_VERSION" != "" ] && locales_unchanged; then |
|
138 |
printf "%-40s: Did not change. Skipping.\n" "locales" |
|
139 |
LOCALES_CHANGED=0 |
|
140 |
else |
|
141 |
printf "%-40s: Need to download.\n" "locales" |
|
142 |
LOCALES_CHANGED=1 |
|
143 |
fi |
|
144 |
else |
|
145 |
printf "%-40s: User forced skip (SKIP_LOCALES set)\n" "locales" |
|
146 |
fi |
|
147 |
||
148 |
# Check what is going to be done and ask for consent |
|
149 |
for ff in $SOURCE_TARBALL $SOURCE_TARBALL.asc; do |
|
150 |
printf "%-40s: %s\n" $ff "$(check_tarball_source $ff)" |
|
151 |
done |
|
152 |
||
153 |
$(ask_cont_abort_question "Is this ok?") || exit 0 |
|
154 |
||
155 |
# Try to download tar-ball from officiall mozilla-mirror |
|
156 |
if [ ! -e $SOURCE_TARBALL ]; then |
|
157 |
wget https://ftp.mozilla.org/pub/$PRODUCT/releases/$VERSION$VERSION_SUFFIX/source/$SOURCE_TARBALL |
|
158 |
fi |
|
159 |
# including signature |
|
160 |
if [ ! -e $SOURCE_TARBALL.asc ]; then |
|
161 |
wget https://ftp.mozilla.org/pub/$PRODUCT/releases/$VERSION$VERSION_SUFFIX/source/$SOURCE_TARBALL.asc |
|
162 |
fi |
|
163 |
||
1056
90e1f32cf034
several changes to make upstream tarballs a good neighbour for locale fetching and HG checkouts
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
1053
diff
changeset
|
164 |
# we might have an upstream archive already and can skip the checkout |
1097 | 165 |
if [ -e $SOURCE_TARBALL ]; then |
1098 | 166 |
if [ -z ${SKIP_LOCALES+x} ] && [ $LOCALES_CHANGED -ne 0 ]; then |
1097 | 167 |
# still need to extract the locale information from the archive |
168 |
echo "extract locale changesets" |
|
169 |
tar -xf $SOURCE_TARBALL $LOCALE_FILE |
|
170 |
fi |
|
1056
90e1f32cf034
several changes to make upstream tarballs a good neighbour for locale fetching and HG checkouts
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
1053
diff
changeset
|
171 |
else |
1097 | 172 |
# We are working on a version that is not yet published on the mozilla mirror |
173 |
# so we have to actually check out the repo |
|
174 |
||
1056
90e1f32cf034
several changes to make upstream tarballs a good neighbour for locale fetching and HG checkouts
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
1053
diff
changeset
|
175 |
# mozilla |
1097 | 176 |
if [ -d $PRODUCT-$VERSION ]; then |
177 |
pushd $PRODUCT-$VERSION || exit 1 |
|
1056
90e1f32cf034
several changes to make upstream tarballs a good neighbour for locale fetching and HG checkouts
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
1053
diff
changeset
|
178 |
_repourl=$(hg paths) |
90e1f32cf034
several changes to make upstream tarballs a good neighbour for locale fetching and HG checkouts
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
1053
diff
changeset
|
179 |
case "$_repourl" in |
90e1f32cf034
several changes to make upstream tarballs a good neighbour for locale fetching and HG checkouts
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
1053
diff
changeset
|
180 |
*$BRANCH*) |
90e1f32cf034
several changes to make upstream tarballs a good neighbour for locale fetching and HG checkouts
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
1053
diff
changeset
|
181 |
echo "updating previous tree" |
90e1f32cf034
several changes to make upstream tarballs a good neighbour for locale fetching and HG checkouts
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
1053
diff
changeset
|
182 |
hg pull |
1097 | 183 |
popd || exit 1 |
1056
90e1f32cf034
several changes to make upstream tarballs a good neighbour for locale fetching and HG checkouts
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
1053
diff
changeset
|
184 |
;; |
90e1f32cf034
several changes to make upstream tarballs a good neighbour for locale fetching and HG checkouts
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
1053
diff
changeset
|
185 |
* ) |
90e1f32cf034
several changes to make upstream tarballs a good neighbour for locale fetching and HG checkouts
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
1053
diff
changeset
|
186 |
echo "removing obsolete tree" |
1097 | 187 |
popd || exit 1 |
188 |
rm -rf $PRODUCT-$VERSION |
|
1056
90e1f32cf034
several changes to make upstream tarballs a good neighbour for locale fetching and HG checkouts
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
1053
diff
changeset
|
189 |
;; |
90e1f32cf034
several changes to make upstream tarballs a good neighbour for locale fetching and HG checkouts
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
1053
diff
changeset
|
190 |
esac |
90e1f32cf034
several changes to make upstream tarballs a good neighbour for locale fetching and HG checkouts
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
1053
diff
changeset
|
191 |
fi |
1097 | 192 |
if [ ! -d $PRODUCT-$VERSION ]; then |
1056
90e1f32cf034
several changes to make upstream tarballs a good neighbour for locale fetching and HG checkouts
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
1053
diff
changeset
|
193 |
echo "cloning new $BRANCH..." |
1097 | 194 |
hg clone http://hg.mozilla.org/$BRANCH $PRODUCT-$VERSION |
195 |
if [ "$PRODUCT" = "thunderbird" ]; then |
|
196 |
hg clone http://hg.mozilla.org/releases/comm-$CHANNEL thunderbird-$VERSION/comm |
|
197 |
fi |
|
1056
90e1f32cf034
several changes to make upstream tarballs a good neighbour for locale fetching and HG checkouts
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
1053
diff
changeset
|
198 |
fi |
1097 | 199 |
pushd $PRODUCT-$VERSION || exit 1 |
200 |
hg update --check $FF_RELEASE_TAG |
|
201 |
[ "$FF_RELEASE_TAG" == "default" ] || hg update -r $FF_RELEASE_TAG |
|
1056
90e1f32cf034
several changes to make upstream tarballs a good neighbour for locale fetching and HG checkouts
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
1053
diff
changeset
|
202 |
# get repo and source stamp |
90e1f32cf034
several changes to make upstream tarballs a good neighbour for locale fetching and HG checkouts
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
1053
diff
changeset
|
203 |
echo -n "REV=" > ../source-stamp.txt |
90e1f32cf034
several changes to make upstream tarballs a good neighbour for locale fetching and HG checkouts
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
1053
diff
changeset
|
204 |
hg -R . parent --template="{node|short}\n" >> ../source-stamp.txt |
90e1f32cf034
several changes to make upstream tarballs a good neighbour for locale fetching and HG checkouts
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
1053
diff
changeset
|
205 |
echo -n "REPO=" >> ../source-stamp.txt |
90e1f32cf034
several changes to make upstream tarballs a good neighbour for locale fetching and HG checkouts
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
1053
diff
changeset
|
206 |
hg showconfig paths.default 2>/dev/null | head -n1 | sed -e "s/^ssh:/http:/" >> ../source-stamp.txt |
1097 | 207 |
|
208 |
if [ "$PRODUCT" = "thunderbird" ]; then |
|
209 |
pushd comm || exit 1 |
|
210 |
hg update --check $TB_RELEASE_TAG |
|
211 |
popd || exit 1 |
|
212 |
rm -rf thunderbird-${VERSION}/{,comm/}other-licenses/7zstub |
|
213 |
fi |
|
214 |
popd || exit 1 |
|
1056
90e1f32cf034
several changes to make upstream tarballs a good neighbour for locale fetching and HG checkouts
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
1053
diff
changeset
|
215 |
|
90e1f32cf034
several changes to make upstream tarballs a good neighbour for locale fetching and HG checkouts
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
1053
diff
changeset
|
216 |
echo "creating archive..." |
1097 | 217 |
tar $compression -cf $PRODUCT-$VERSION$VERSION_SUFFIX.source.tar.xz --exclude=.hgtags --exclude=.hgignore --exclude=.hg --exclude=CVS $PRODUCT-$VERSION |
218 |
fi |
|
219 |
||
220 |
if [ ! -z ${SKIP_LOCALES+x} ]; then |
|
221 |
echo "Skipping locales-creation." |
|
222 |
exit 0 |
|
1056
90e1f32cf034
several changes to make upstream tarballs a good neighbour for locale fetching and HG checkouts
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
1053
diff
changeset
|
223 |
fi |
262
b680975515e0
probably last working Firefox-on-xulrunner build
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
224 |
|
1097 | 225 |
if [ $LOCALES_CHANGED -ne 0 ]; then |
226 |
# l10n |
|
227 |
echo "fetching locales..." |
|
228 |
test ! -d l10n && mkdir l10n |
|
229 |
jq -r 'to_entries[]| "\(.key) \(.value|.revision)"' $LOCALE_FILE | \ |
|
230 |
while read locale changeset ; do |
|
231 |
case $locale in |
|
232 |
ja-JP-mac|en-US) |
|
233 |
;; |
|
234 |
*) |
|
235 |
echo "reading changeset information for $locale" |
|
236 |
echo "fetching $locale changeset $changeset ..." |
|
237 |
if [ -d "l10n/$locale/.hg" ]; then |
|
238 |
pushd "l10n/$locale" || exit 1 |
|
239 |
hg pull |
|
240 |
popd || exit 1 |
|
241 |
else |
|
242 |
hg clone "http://hg.mozilla.org/l10n-central/$locale" "l10n/$locale" |
|
243 |
fi |
|
244 |
[ "$FF_RELEASE_TAG" == "default" ] || hg -R "l10n/$locale" up -C -r "$changeset" |
|
245 |
;; |
|
246 |
esac |
|
247 |
done |
|
248 |
echo "creating l10n archive..." |
|
1098 | 249 |
if [ "$PRODUCT" = "thunderbird" ]; then |
1097 | 250 |
TB_TAR_FLAGS="--exclude=browser --exclude=suite" |
1098 | 251 |
fi |
1097 | 252 |
tar $compression -cf l10n-$VERSION$VERSION_SUFFIX.tar.xz \ |
253 |
--exclude=.hgtags --exclude=.hgignore --exclude=.hg \ |
|
254 |
$TB_TAR_FLAGS \ |
|
255 |
l10n |
|
1098 | 256 |
elif [ -f "l10n-$PREV_VERSION$PREV_VERSION_SUFFIX.tar.xz" ]; then |
257 |
# Locales did not change, but the old tar-ball is in this directory |
|
258 |
# Simply rename it: |
|
259 |
echo "Moving l10n-$PREV_VERSION$PREV_VERSION_SUFFIX.tar.xz to l10n-$VERSION$VERSION_SUFFIX.tar.xz" |
|
260 |
mv "l10n-$PREV_VERSION$PREV_VERSION_SUFFIX.tar.xz" "l10n-$VERSION$VERSION_SUFFIX.tar.xz" |
|
1097 | 261 |
fi |
262
b680975515e0
probably last working Firefox-on-xulrunner build
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
262 |
|
b680975515e0
probably last working Firefox-on-xulrunner build
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
263 |
# compare-locales |
409 | 264 |
echo "creating compare-locales" |
1097 | 265 |
if [ -d compare-locales/.hg ]; then |
266 |
pushd compare-locales || exit 1 |
|
267 |
hg pull |
|
268 |
popd || exit 1 |
|
269 |
else |
|
270 |
hg clone http://hg.mozilla.org/build/compare-locales |
|
271 |
fi |
|
990
0d76004e9fa4
support parallel compression if available
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
986
diff
changeset
|
272 |
tar $compression -cf compare-locales.tar.xz --exclude=.hgtags --exclude=.hgignore --exclude=.hg compare-locales |
262
b680975515e0
probably last working Firefox-on-xulrunner build
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
273 |