author | Wolfgang Rosenauer <wr@rosenauer.org> |
Sun, 26 Mar 2023 12:50:07 +0200 | |
branch | firefox111 |
changeset 1185 | da29365b0b2c |
parent 1184 | 1c3d3217d679 |
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 |
|
1184 | 3 |
function main() { |
4 |
# Exit script on CTRL+C |
|
5 |
trap "exit" INT |
|
6 |
||
7 |
if [ $# -ne 1 ]; then |
|
8 |
print_usage_and_exit |
|
9 |
fi |
|
10 |
||
11 |
check_required_tools |
|
12 |
||
13 |
# Sourcing the given tar_stamps-file to have the variables available |
|
14 |
TAR_STAMP="$1" |
|
15 |
source "$TAR_STAMP" || print_usage_and_exit |
|
16 |
||
17 |
set_internal_variables |
|
18 |
||
19 |
check_what_to_do_with_source_tarballs |
|
20 |
download_upstream_source_tarballs |
|
21 |
||
22 |
if [ -z ${SKIP_LOCALES+x} ]; then |
|
23 |
check_what_to_do_with_locales_tarballs |
|
24 |
create_locales_tarballs |
|
25 |
else |
|
26 |
printf "%-40s: User forced skip (SKIP_LOCALES set)\n" "locales" |
|
27 |
fi |
|
28 |
||
29 |
clean_up_old_tarballs |
|
30 |
} |
|
31 |
||
1097 | 32 |
function print_usage_and_exit() { |
1111 | 33 |
echo "Usage: create-tar.sh tar_stamps" |
1097 | 34 |
echo "" |
1111 | 35 |
echo "Where tar_stamps should look like this:" |
1097 | 36 |
echo "" |
37 |
cat << EOF |
|
38 |
# Node ID: 64ee63facd4ff96b3e8590cff559d7e97ac6b061 |
|
39 |
PRODUCT="firefox" # "firefox" or "thunderbird" |
|
40 |
CHANNEL="esr60" |
|
41 |
VERSION="60.7.0" |
|
42 |
VERSION_SUFFIX="esr" |
|
1111 | 43 |
RELEASE_TAG="" # Needs only to be set if no tar-ball can be downloaded |
1097 | 44 |
PREV_VERSION="60.6.3" # Prev. version only needed for locales (leave empty to force l10n-generation) |
45 |
PREV_VERSION_SUFFIX="esr" |
|
1119 | 46 |
#SKIP_LOCALES="" # Uncomment to skip l10n-generation |
1097 | 47 |
EOF |
48 |
||
1184 | 49 |
exit 1 |
50 |
} |
|
51 |
||
52 |
function check_required_tools() { |
|
53 |
# check required tools |
|
54 |
check_for_binary /usr/bin/hg "mercurial" |
|
55 |
check_for_binary /usr/bin/jq "jq" |
|
56 |
which python3 > /dev/null || exit 1 |
|
57 |
||
58 |
# use parallel compression, if available |
|
59 |
compression='-J' |
|
60 |
pixz -h > /dev/null 2>&1 |
|
61 |
if (($? != 127)); then |
|
62 |
compression='-Ipixz' |
|
63 |
fi |
|
1097 | 64 |
} |
65 |
||
1184 | 66 |
function set_internal_variables() { |
67 |
# Internal variables |
|
68 |
BRANCH="releases/mozilla-$CHANNEL" |
|
69 |
if [ "$PRODUCT" = "firefox" ]; then |
|
70 |
FF_LOCALE_FILE="firefox-$VERSION/browser/locales/l10n-changesets.json" |
|
71 |
else |
|
72 |
FF_LOCALE_FILE="thunderbird-$VERSION/browser/locales/l10n-changesets.json" |
|
73 |
TB_LOCALE_FILE="thunderbird-$VERSION/comm/mail/locales/l10n-changesets.json" |
|
1185 | 74 |
FF_PREV_LOCALE_FILE="thunderbird-$PREV_VERSION/browser/locales/l10n-changesets.json" |
75 |
TB_PREV_LOCALE_FILE="thunderbird-$PREV_VERSION/comm/mail/locales/l10n-changesets.json" |
|
76 |
L10N_STRING_PATTERNS="thunderbird-$VERSION/comm/python/l10n/tbxchannel/l10n_merge.py" |
|
1184 | 77 |
fi |
1097 | 78 |
|
1184 | 79 |
SOURCE_TARBALL="$PRODUCT-$VERSION$VERSION_SUFFIX.source.tar.xz" |
80 |
PREV_SOURCE_TARBALL="$PRODUCT-$PREV_VERSION$PREV_VERSION_SUFFIX.source.tar.xz" |
|
81 |
FTP_URL="https://ftp.mozilla.org/pub/$PRODUCT/releases/$VERSION$VERSION_SUFFIX/source" |
|
82 |
FTP_CANDIDATES_BASE_URL="https://ftp.mozilla.org/pub/%s/candidates" |
|
83 |
LOCALES_URL="https://product-details.mozilla.org/1.0/l10n" |
|
84 |
PRODUCT_URL="https://product-details.mozilla.org/1.0" |
|
85 |
ALREADY_EXTRACTED_LOCALES_FILE=0 |
|
86 |
} |
|
1097 | 87 |
|
1114 | 88 |
function get_ftp_candidates_url() { |
1184 | 89 |
local CURR_PRODUCT="$1" |
90 |
local VERSION_WITH_SUFFIX="$2" |
|
91 |
printf "$FTP_CANDIDATES_BASE_URL/$VERSION_WITH_SUFFIX-candidates" "$CURR_PRODUCT" |
|
1114 | 92 |
} |
93 |
||
1097 | 94 |
function check_tarball_source () { |
95 |
TARBALL=$1 |
|
96 |
# Print out what is going to be done: |
|
1184 | 97 |
if [ -e "$TARBALL" ]; then |
1097 | 98 |
echo "Reuse existing file" |
1184 | 99 |
elif wget --spider "$FTP_URL/$TARBALL" 2> /dev/null; then |
1097 | 100 |
echo "Download file" |
1184 | 101 |
else |
102 |
local CANDIDATE_TARBALL_LOCATION="" |
|
103 |
CANDIDATE_TARBALL_LOCATION="$(printf "%s/%s/source/%s" "$(get_ftp_candidates_url "$PRODUCT" "$VERSION$VERSION_SUFFIX")" "$BUILD_ID" "$TARBALL" )" |
|
104 |
if wget --spider "$CANDIDATE_TARBALL_LOCATION" 2> /dev/null; then |
|
1185 | 105 |
echo "Download UNRELEASED candidate ($BUILD_ID)" |
1184 | 106 |
else |
107 |
echo "Mercurial checkout" |
|
108 |
fi |
|
1097 | 109 |
fi |
110 |
} |
|
909 | 111 |
|
1097 | 112 |
function ask_cont_abort_question() { |
113 |
while true; do |
|
1184 | 114 |
read -r -p "$1 [(c)ontinue/(a)bort] " ca |
1097 | 115 |
case $ca in |
116 |
[Cc]* ) return 0 ;; |
|
117 |
[Aa]* ) return 1 ;; |
|
118 |
* ) echo "Please answer c or a.";; |
|
119 |
esac |
|
120 |
done |
|
121 |
} |
|
122 |
||
123 |
function check_for_binary() { |
|
1184 | 124 |
if ! test -x "$1"; then |
1097 | 125 |
echo "$1 is missing: execute zypper in $2" |
126 |
exit 5 |
|
127 |
fi |
|
128 |
} |
|
129 |
||
1114 | 130 |
function get_source_stamp() { |
1184 | 131 |
local CURR_BUILD_ID="$1" |
132 |
local FTP_CANDIDATES_BASE_URL=$(get_ftp_candidates_url "$PRODUCT" "$VERSION$VERSION_SUFFIX") |
|
133 |
local FTP_CANDIDATES_JSON_SUFFIX="${CURR_BUILD_ID}/linux-x86_64/en-US/$PRODUCT-$VERSION$VERSION_SUFFIX.json" |
|
134 |
local BUILD_JSON=$(curl --silent --fail "$FTP_CANDIDATES_BASE_URL/$FTP_CANDIDATES_JSON_SUFFIX") || return 1; |
|
135 |
local REV=$(echo "$BUILD_JSON" | jq .moz_source_stamp) |
|
136 |
local SOURCE_REPO=$(echo "$BUILD_JSON" | jq .moz_source_repo) |
|
137 |
local TIMESTAMP=$(echo "$BUILD_JSON" | jq .buildid) |
|
1114 | 138 |
echo "Extending $TAR_STAMP with:" |
139 |
echo "RELEASE_REPO=${SOURCE_REPO}" |
|
140 |
echo "RELEASE_TAG=${REV}" |
|
141 |
echo "RELEASE_TIMESTAMP=${TIMESTAMP}" |
|
142 |
# We "remove and add" instead of "replace" in case the entries are not there yet |
|
143 |
# Removing the old RELEASE_-tags |
|
144 |
sed -i "/RELEASE_\(TAG\|REPO\|TIMESTAMP\)=.*/d" "$TAR_STAMP" |
|
145 |
# Appending the new |
|
146 |
echo "RELEASE_REPO=$SOURCE_REPO" >> "$TAR_STAMP" |
|
147 |
echo "RELEASE_TAG=$REV" >> "$TAR_STAMP" |
|
148 |
echo "RELEASE_TIMESTAMP=$TIMESTAMP" >> "$TAR_STAMP" |
|
149 |
} |
|
1097 | 150 |
|
1114 | 151 |
function get_build_number() { |
1184 | 152 |
local LAST_FOUND="" |
153 |
local CURR_PRODUCT="$1" |
|
154 |
local VERSION_WITH_SUFFIX="$2" |
|
155 |
local CURR_BUILD_ID="" |
|
156 |
local CURR_FTP_BASE_URL="" |
|
157 |
CURR_BUILD_ID=$(curl --silent "$PRODUCT_URL/$CURR_PRODUCT.json" | jq -e '.["releases"] | .["'$CURR_PRODUCT-$VERSION_WITH_SUFFIX'"] | .["build_number"]') |
|
1117 | 158 |
|
159 |
# Slow fall-back |
|
160 |
if [ $? -ne 0 ]; then |
|
161 |
echo "Build number not found in product URL, falling back to slow FTP-parsing." 1>&2 |
|
1184 | 162 |
CURR_FTP_BASE_URL=$(get_ftp_candidates_url "$CURR_PRODUCT" "$VERSION_WITH_SUFFIX") |
1117 | 163 |
# Unfortunately, locales-files are not associated to releases, but to builds. |
164 |
# And since we don't know which build was the final build, we grep them all from |
|
165 |
# the candidates-page, sort them and take the last one which should be the oldest |
|
166 |
# Error only if not even the first one exists |
|
1184 | 167 |
LAST_FOUND=$(curl --silent --fail "$CURR_FTP_BASE_URL/" | grep -o "build[0-9]*/" | sort | uniq | tail -n 1 | cut -d "/" -f 1) |
1117 | 168 |
else |
1184 | 169 |
LAST_FOUND="build$CURR_BUILD_ID" |
1117 | 170 |
fi |
1098 | 171 |
|
172 |
if [ "$LAST_FOUND" != "" ]; then |
|
173 |
echo "$LAST_FOUND" |
|
174 |
return 0 |
|
175 |
else |
|
1184 | 176 |
echo "Error: Could not find build-number for $CURR_PRODUCT $VERSION_WITH_SUFFIX !" 1>&2 |
1114 | 177 |
return 1 |
178 |
fi |
|
179 |
} |
|
180 |
||
181 |
function locales_get() { |
|
1184 | 182 |
local CURR_PRODUCT="$1" |
183 |
local TMP_VERSION="$2" |
|
184 |
local CURR_BUILD_ID="$3" |
|
185 |
# Make first letter of CURR_PRODUCT upper case |
|
186 |
CURR_PRODUCT_CAP="${CURR_PRODUCT^}" |
|
187 |
URL_TO_CHECK="${LOCALES_URL}/${CURR_PRODUCT_CAP}-${TMP_VERSION}" |
|
188 |
FINAL_URL="${URL_TO_CHECK}-${CURR_BUILD_ID}.json" |
|
1114 | 189 |
if wget --quiet --spider "$FINAL_URL"; then |
190 |
echo "$FINAL_URL" |
|
191 |
return 0 |
|
192 |
else |
|
1098 | 193 |
echo "Error: Could not find locales-file (json) for Firefox $TMP_VERSION !" 1>&2 |
194 |
return 1 |
|
195 |
fi |
|
1097 | 196 |
} |
197 |
||
1184 | 198 |
function locales_parse_file() { |
199 |
FILE="$1" |
|
200 |
python3 -c "import json; import sys; \ |
|
201 |
print('\n'.join(['{} {}'.format(key, value['revision']) \ |
|
202 |
for key, value in sorted(json.load(sys.stdin).items())]));" < "$FILE" |
|
203 |
} |
|
204 |
||
205 |
function locales_parse_url() { |
|
1097 | 206 |
URL="$1" |
1184 | 207 |
curl -s "$URL" | python3 -c "import json; import sys; \ |
1097 | 208 |
print('\n'.join(['{} {}'.format(key, value['changeset']) \ |
209 |
for key, value in sorted(json.load(sys.stdin)['locales'].items())]));" |
|
210 |
} |
|
211 |
||
1184 | 212 |
function extract_locales_file() { |
213 |
if [ $ALREADY_EXTRACTED_LOCALES_FILE -ne 1 ]; then |
|
214 |
# still need to extract the locale information from the archive |
|
215 |
echo "extract locale changesets" |
|
216 |
if [ "$PRODUCT" = "thunderbird" ]; then |
|
217 |
tar -xf "$SOURCE_TARBALL" "$FF_LOCALE_FILE" "$TB_LOCALE_FILE" "$L10N_STRING_PATTERNS" |
|
218 |
else |
|
219 |
tar -xf "$SOURCE_TARBALL" "$FF_LOCALE_FILE" |
|
220 |
fi |
|
221 |
ALREADY_EXTRACTED_LOCALES_FILE=1 |
|
222 |
else |
|
223 |
echo "Skipping locale changeset extraction, as it was already done." |
|
224 |
fi |
|
225 |
} |
|
226 |
||
1097 | 227 |
function locales_unchanged() { |
1184 | 228 |
local CURR_PRODUCT="$1" |
229 |
local CURR_BUILD_ID="$2" |
|
230 |
local PREV_BUILD_ID=$(get_build_number "$CURR_PRODUCT" "$PREV_VERSION$PREV_VERSION_SUFFIX") |
|
1097 | 231 |
# If no json-file for one of the versions can be found, we say "they changed" |
1184 | 232 |
prev_url=$(locales_get "$CURR_PRODUCT" "$PREV_VERSION$PREV_VERSION_SUFFIX" "$PREV_BUILD_ID") || return 1 |
233 |
prev_content=$(locales_parse_url "$prev_url") || exit 1 |
|
1097 | 234 |
|
1184 | 235 |
curr_url=$(locales_get "$CURR_PRODUCT" "$VERSION$VERSION_SUFFIX" "$CURR_BUILD_ID") |
236 |
if [ $? -ne 0 ]; then |
|
237 |
# We did not find a locales file upstream on the servers |
|
238 |
if [ -e "$SOURCE_TARBALL" ]; then |
|
239 |
# We can find out what the locales are, by extracting the json-file from the tar-ball |
|
240 |
# instead of getting it from the server |
|
241 |
extract_locales_file || return 1 |
|
242 |
curr_content=$(locales_parse_file "$FF_LOCALE_FILE") || exit 1 |
|
243 |
else |
|
244 |
# We can't know what the locales are in the current version |
|
245 |
return 1 |
|
246 |
fi |
|
247 |
else |
|
248 |
curr_content=$(locales_parse_url "$curr_url") || exit 1 |
|
249 |
fi |
|
1097 | 250 |
|
251 |
diff -y --suppress-common-lines -d <(echo "$prev_content") <(echo "$curr_content") |
|
252 |
} |
|
262
b680975515e0
probably last working Firefox-on-xulrunner build
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
253 |
|
1184 | 254 |
function get_locales_directories() { |
255 |
pattern="$1" |
|
1032
8220ea23b47d
remove obsolete patches
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
1031
diff
changeset
|
256 |
|
1184 | 257 |
# This file contains a list of directories, upstream uses to build locales |
258 |
# If it is there, use it. If not, default to all FF + 3 TB-dirs. |
|
259 |
if [ -e "$L10N_STRING_PATTERNS" ]; then |
|
260 |
python3 -c "import os; import sys; \ |
|
261 |
sys.path.append(os.path.dirname(\"$L10N_STRING_PATTERNS\")); \ |
|
262 |
from l10n_merge import $pattern; \ |
|
263 |
print(\" \".join([p.strip('*') for p in $pattern]));" |
|
264 |
else |
|
265 |
if [ "$pattern" = "GECKO_STRINGS_PATTERNS" ]; then |
|
266 |
# Default of Firefox: Take all |
|
267 |
echo "{lang}/" |
|
268 |
else |
|
269 |
# Default of Thunderbird: Take those 3 dirs |
|
270 |
echo "{lang}/calendar/" "{lang}/chat/" "{lang}/mail/" |
|
271 |
fi |
|
272 |
fi |
|
273 |
} |
|
274 |
||
275 |
function create_and_copy_locales() { |
|
276 |
locale="$1" |
|
277 |
source_base="$2" |
|
278 |
source_template="$3" |
|
279 |
final_dest="$4" |
|
990
0d76004e9fa4
support parallel compression if available
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
986
diff
changeset
|
280 |
|
1184 | 281 |
# Replace {lang} with the actual language-basedir |
282 |
for template in $source_template; do |
|
283 |
locale_source=$(echo "$template" | sed "s|{lang}|./$source_base/$locale|g") |
|
284 |
locale_dest=$(echo "$template" | sed "s|{lang}|./$final_dest/$locale|g") |
|
1114 | 285 |
|
1184 | 286 |
# Create intermediary folders |
287 |
for destdir in $locale_dest; do |
|
288 |
mkdir -p "$destdir" |
|
289 |
done |
|
290 |
||
291 |
# Copy over FF-files |
|
292 |
cp -r "$locale_source"/* "$locale_dest" |
|
293 |
done |
|
294 |
} |
|
295 |
||
296 |
function check_what_to_do_with_source_tarballs() { |
|
297 |
# Get ID |
|
298 |
BUILD_ID=$(get_build_number "$PRODUCT" "$VERSION$VERSION_SUFFIX") |
|
299 |
||
300 |
# Check what is going to be done and ask for consent |
|
301 |
for ff in $SOURCE_TARBALL $SOURCE_TARBALL.asc; do |
|
302 |
printf "%-40s: %s\n" "$ff" "$(check_tarball_source $ff)" |
|
303 |
done |
|
304 |
||
305 |
ask_cont_abort_question "Is this ok?" || exit 0 |
|
306 |
} |
|
1097 | 307 |
|
1184 | 308 |
function check_what_to_do_with_locales_tarballs() { |
309 |
LOCALES_CHANGED=1 |
|
1097 | 310 |
|
1184 | 311 |
extract_locales_file |
1097 | 312 |
|
1184 | 313 |
if [ "$PREV_VERSION" != "" ]; then |
314 |
# If we have a previous version, check either FF or (TB and FF) |
|
315 |
if [ "$PRODUCT" = "firefox" ]; then |
|
316 |
locales_unchanged "$PRODUCT" "$BUILD_ID" |
|
317 |
else |
|
1185 | 318 |
# Currently, upstream 'forgets' which Firefox-locales get used for which Thunderbird-release upon release |
319 |
# so, instead of parsing upstream JSON-files, we rely on the previous tarball being there and comparing |
|
320 |
# the lang-files directly |
|
321 |
# FF_BUILD_ID=$(get_build_number "firefox" "$VERSION$VERSION_SUFFIX") |
|
322 |
# locales_unchanged "$PRODUCT" "$BUILD_ID" && locales_unchanged "firefox" "$FF_BUILD_ID" |
|
323 |
if [ -e "$PREV_SOURCE_TARBALL" ]; then |
|
324 |
echo "extract previous locale changesets" |
|
325 |
tar -xf "$PREV_SOURCE_TARBALL" "$FF_PREV_LOCALE_FILE" "$TB_PREV_LOCALE_FILE" |
|
326 |
||
327 |
curr_ff_content=$(locales_parse_file "$FF_LOCALE_FILE") || exit 1 |
|
328 |
prev_ff_content=$(locales_parse_file "$FF_PREV_LOCALE_FILE") || exit 1 |
|
329 |
curr_tb_content=$(locales_parse_file "$TB_LOCALE_FILE") || exit 1 |
|
330 |
prev_tb_content=$(locales_parse_file "$TB_PREV_LOCALE_FILE") || exit 1 |
|
331 |
||
332 |
diff -y --suppress-common-lines -d <(echo "$prev_ff_content") <(echo "$curr_ff_content") || |
|
333 |
diff -y --suppress-common-lines -d <(echo "$prev_tb_content") <(echo "$curr_tb_content") |
|
334 |
fi |
|
1184 | 335 |
fi |
336 |
LOCALES_CHANGED=$? |
|
337 |
fi |
|
338 |
||
339 |
# New line for better visibility |
|
340 |
echo "" |
|
341 |
if [ $LOCALES_CHANGED -eq 1 ]; then |
|
342 |
printf "%-40s: Need to download.\n" "locales" |
|
343 |
ask_cont_abort_question "Is this ok?" || exit 0 |
|
344 |
else |
|
345 |
printf "%-40s: Did not change. Skipping.\n" "locales" |
|
346 |
fi |
|
347 |
} |
|
1097 | 348 |
|
1184 | 349 |
function download_release_or_candidate_file() { |
350 |
local upstream_file="$1" |
|
351 |
if [ -e "$upstream_file" ]; then |
|
352 |
return; |
|
353 |
fi |
|
354 |
||
355 |
if ! wget --quiet --show-progress --progress=bar "$FTP_URL/$upstream_file"; then |
|
356 |
local CANDIDATE_TARBALL_LOCATION="" |
|
357 |
CANDIDATE_TARBALL_LOCATION="$(printf "%s/%s/source/%s" "$(get_ftp_candidates_url "$PRODUCT" "$VERSION$VERSION_SUFFIX")" "$BUILD_ID" "$upstream_file" )" |
|
358 |
wget --quiet --show-progress --progress=bar "$CANDIDATE_TARBALL_LOCATION" |
|
1097 | 359 |
fi |
1184 | 360 |
} |
361 |
||
362 |
function download_upstream_source_tarballs() { |
|
363 |
# Try to download tar-ball from officiall mozilla-mirror |
|
364 |
download_release_or_candidate_file "$SOURCE_TARBALL" |
|
365 |
download_release_or_candidate_file "$SOURCE_TARBALL.asc" |
|
1097 | 366 |
|
1184 | 367 |
# we might have an upstream archive already and can skip the checkout |
368 |
if [ -e "$SOURCE_TARBALL" ]; then |
|
369 |
get_source_stamp "$BUILD_ID" |
|
370 |
else |
|
371 |
# We are working on a version that is not yet published on the mozilla mirror |
|
372 |
# so we have to actually check out the repo |
|
373 |
clone_and_repackage_sources |
|
374 |
fi |
|
375 |
} |
|
376 |
||
377 |
function clone_and_repackage_sources() { |
|
378 |
if [ -d "$PRODUCT-$VERSION" ]; then |
|
379 |
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
|
380 |
_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
|
381 |
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
|
382 |
*$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
|
383 |
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
|
384 |
hg pull |
1097 | 385 |
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
|
386 |
;; |
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
|
387 |
* ) |
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
|
388 |
echo "removing obsolete tree" |
1097 | 389 |
popd || exit 1 |
1184 | 390 |
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
|
391 |
;; |
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
|
392 |
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
|
393 |
fi |
1184 | 394 |
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
|
395 |
echo "cloning new $BRANCH..." |
1184 | 396 |
hg clone "https://hg.mozilla.org/$BRANCH $PRODUCT-$VERSION" |
1097 | 397 |
if [ "$PRODUCT" = "thunderbird" ]; then |
1184 | 398 |
hg clone "https://hg.mozilla.org/releases/comm-$CHANNEL" "$PRODUCT-$VERSION/comm" |
1097 | 399 |
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
|
400 |
fi |
1184 | 401 |
pushd "$PRODUCT-$VERSION" || exit 1 |
1111 | 402 |
|
403 |
# parse out the Firefox-release tag for this Thunderbird-checkout |
|
404 |
if [ "$PRODUCT" = "thunderbird" ]; then |
|
405 |
FF_RELEASE_TAG=$(grep ^GECKO_HEAD_REV ./comm/.gecko_rev.yml | awk -F ' ' '{print $2}') || exit 1 |
|
406 |
echo "Parsed Firefox base ID from .gecko_rev.yml: $FF_RELEASE_TAG" |
|
407 |
else |
|
408 |
FF_RELEASE_TAG="$RELEASE_TAG" |
|
409 |
fi |
|
410 |
||
1184 | 411 |
hg update --check "$FF_RELEASE_TAG" |
412 |
[ "$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
|
413 |
# get repo and source stamp |
1184 | 414 |
local REV=$(hg -R . parent --template="{node|short}\n") |
415 |
local SOURCE_REPO=$(hg showconfig paths.default 2>/dev/null | head -n1 | sed -e "s/^ssh:/https:/") |
|
416 |
local TIMESTAMP=$(date +%Y%m%d%H%M%S) |
|
1097 | 417 |
|
418 |
if [ "$PRODUCT" = "thunderbird" ]; then |
|
419 |
pushd comm || exit 1 |
|
1184 | 420 |
hg update --check "$RELEASE_TAG" |
1097 | 421 |
popd || exit 1 |
1184 | 422 |
rm -rf thunderbird-"${VERSION}"/{,comm/}other-licenses/7zstub |
1097 | 423 |
fi |
424 |
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
|
425 |
|
1117 | 426 |
echo "Extending $TAR_STAMP with:" |
427 |
echo "RELEASE_REPO=${SOURCE_REPO}" |
|
428 |
echo "RELEASE_TAG=${REV}" |
|
429 |
echo "RELEASE_TIMESTAMP=${TIMESTAMP}" |
|
430 |
||
431 |
# We "remove and add" instead of "replace" in case the entries are not there yet |
|
432 |
# Removing the old RELEASE_-tags |
|
433 |
sed -i "/RELEASE_\(TAG\|REPO\|TIMESTAMP\)=.*/d" "$TAR_STAMP" |
|
434 |
# Appending the new |
|
435 |
echo "RELEASE_REPO=$SOURCE_REPO" >> "$TAR_STAMP" |
|
436 |
echo "RELEASE_TAG=$REV" >> "$TAR_STAMP" |
|
437 |
echo "RELEASE_TIMESTAMP=$TIMESTAMP" >> "$TAR_STAMP" |
|
438 |
||
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
|
439 |
echo "creating archive..." |
1185 | 440 |
tar "$compression" -cf "$PRODUCT-$VERSION$VERSION_SUFFIX.source.tar.xz" --exclude-vcs "$PRODUCT-$VERSION" |
1184 | 441 |
ALREADY_EXTRACTED_LOCALES_FILE=1 |
442 |
} |
|
443 |
||
444 |
function create_locales_tarballs() { |
|
445 |
if [ ! -z ${SKIP_LOCALES+x} ]; then |
|
446 |
echo "Skipping locales-creation." |
|
447 |
exit 0 |
|
448 |
fi |
|
449 |
||
450 |
if [ "$LOCALES_CHANGED" -ne 0 ]; then |
|
451 |
clone_and_repackage_locales |
|
452 |
elif [ -f "l10n-$PREV_VERSION$PREV_VERSION_SUFFIX.tar.xz" ]; then |
|
453 |
# Locales did not change, but the old tar-ball is in this directory |
|
454 |
# Simply rename it: |
|
455 |
echo "Moving l10n-$PREV_VERSION$PREV_VERSION_SUFFIX.tar.xz to l10n-$VERSION$VERSION_SUFFIX.tar.xz" |
|
456 |
mv "l10n-$PREV_VERSION$PREV_VERSION_SUFFIX.tar.xz" "l10n-$VERSION$VERSION_SUFFIX.tar.xz" |
|
457 |
fi |
|
458 |
} |
|
459 |
||
460 |
function clone_and_repackage_locales() { |
|
461 |
# l10n |
|
462 |
FINAL_L10N_BASE="l10n" |
|
463 |
FF_L10N_BASE="l10n" # Only change this in TB-builds to a separate dir |
|
464 |
TB_L10N_BASE="l10n_tb" |
|
1097 | 465 |
|
1184 | 466 |
# If we are doing Thunderbird, we'll have to checkout both TB and FF l10n-repos |
467 |
# Thunderbird has one single mono-repo, FF has one for each language |
|
468 |
if [ "$PRODUCT" = "thunderbird" ]; then |
|
469 |
echo "Fetching Thunderbird locales..." |
|
470 |
if [ -d "$TB_L10N_BASE/.hg" ]; then |
|
471 |
pushd "$TB_L10N_BASE/" || exit 1 |
|
472 |
hg pull || exit 1 |
|
473 |
popd || exit 1 |
|
474 |
else |
|
475 |
hg clone "https://hg.mozilla.org/projects/comm-l10n/" "$TB_L10N_BASE/" || exit 1 |
|
476 |
fi |
|
477 |
# Just using the first entry here, as all languages have the same changeset |
|
478 |
tb_changeset=$(jq -r 'to_entries[0]| "\(.key) \(.value|.revision)"' "$TB_LOCALE_FILE" | cut -d " " -f 2) |
|
479 |
[ "$RELEASE_TAG" == "default" ] || hg -R "$TB_L10N_BASE/" up -C -r "$tb_changeset" || exit 1 |
|
480 |
FF_L10N_BASE="l10n_ff" |
|
481 |
fi |
|
262
b680975515e0
probably last working Firefox-on-xulrunner build
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff
changeset
|
482 |
|
1184 | 483 |
test ! -d $FF_L10N_BASE && mkdir $FF_L10N_BASE |
484 |
# No-op, if we are building FF: |
|
485 |
test ! -d $FINAL_L10N_BASE && mkdir $FINAL_L10N_BASE |
|
486 |
||
487 |
# This is only relevant for Thunderbird-builds |
|
488 |
# Here, the relevant directories we need to copy from FF and from TB |
|
489 |
# are specified in a python-file in the tarball |
|
490 |
# Is of form '{lang}/Foo/bar/ {lang}/Baz/bar/ ..' |
|
491 |
ff_locale_template=$(get_locales_directories "GECKO_STRINGS_PATTERNS") |
|
492 |
tb_locale_template=$(get_locales_directories "COMM_STRINGS_PATTERNS") |
|
493 |
||
494 |
echo "Fetching Browser locales..." |
|
495 |
jq -r 'to_entries[]| "\(.key) \(.value|.revision)"' "$FF_LOCALE_FILE" | \ |
|
496 |
while read -r locale changeset ; do |
|
1097 | 497 |
case $locale in |
498 |
ja-JP-mac|en-US) |
|
499 |
;; |
|
500 |
*) |
|
501 |
echo "reading changeset information for $locale" |
|
502 |
echo "fetching $locale changeset $changeset ..." |
|
1184 | 503 |
if [ -d "$FF_L10N_BASE/$locale/.hg" ]; then |
504 |
pushd "$FF_L10N_BASE/$locale" || exit 1 |
|
505 |
hg pull || exit 1 |
|
1097 | 506 |
popd || exit 1 |
507 |
else |
|
1184 | 508 |
hg clone "https://hg.mozilla.org/l10n-central/$locale" "$FF_L10N_BASE/$locale" || exit 1 |
1097 | 509 |
fi |
1184 | 510 |
[ "$RELEASE_TAG" == "default" ] || hg -R "$FF_L10N_BASE/$locale" up -C -r "$changeset" || exit 1 |
511 |
||
512 |
# If we are doing TB, we have to merge both l10n-repos |
|
513 |
if [ "$PRODUCT" = "thunderbird" ] && test -d "$TB_L10N_BASE/$locale/" ; then |
|
514 |
create_and_copy_locales "$locale" "$FF_L10N_BASE" "$ff_locale_template" "$FINAL_L10N_BASE" |
|
515 |
create_and_copy_locales "$locale" "$TB_L10N_BASE" "$tb_locale_template" "$FINAL_L10N_BASE" |
|
516 |
fi |
|
1097 | 517 |
;; |
518 |
esac |
|
519 |
done |
|
520 |
echo "creating l10n archive..." |
|
1185 | 521 |
local TAR_FLAGS="--exclude-vcs" |
1098 | 522 |
if [ "$PRODUCT" = "thunderbird" ]; then |
1185 | 523 |
TAR_FLAGS="$TAR_FLAGS --exclude=suite" |
1098 | 524 |
fi |
1185 | 525 |
tar "$compression" -cf "l10n-$VERSION$VERSION_SUFFIX.tar.xz" $TAR_FLAGS "$FINAL_L10N_BASE" |
1184 | 526 |
} |
527 |
||
528 |
function clean_up_old_tarballs() { |
|
529 |
if [ -e "$PREV_SOURCE_TARBALL" ]; then |
|
530 |
echo "" |
|
531 |
echo "Deleting old sources tarball $PREV_SOURCE_TARBALL" |
|
532 |
ask_cont_abort_question "Is this ok?" || exit 0 |
|
533 |
rm "$PREV_SOURCE_TARBALL" |
|
534 |
rm "$PREV_SOURCE_TARBALL.asc" |
|
535 |
# if old and new lang-tarball are there, delete the old one |
|
536 |
if [ -f "l10n-$PREV_VERSION$PREV_VERSION_SUFFIX.tar.xz" ] && [ -f "l10n-$VERSION$VERSION_SUFFIX.tar.xz" ]; then |
|
537 |
rm "l10n-$PREV_VERSION$PREV_VERSION_SUFFIX.tar.xz" |
|
538 |
fi |
|
539 |
fi |
|
540 |
} |
|
541 |
||
542 |
main "$@" |