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