-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapply-patches.sh
executable file
·95 lines (83 loc) · 2.98 KB
/
apply-patches.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
#!/bin/bash
set -eo pipefail
VERSION="$1"
echo
echo "======================================================="
echo "Copying patches"
mkdir -p patches
find thunderbird-patches/$VERSION -type f -name *.patch -exec cp '{}' patches/ ';'
echo
echo "======================================================="
echo "Applying patch series for main repository"
while read -r line; do
patch=$(echo $line | cut -f1 -d'#' | sed 's/ *$//')
if [[ -n "${patch// }" ]]
then
if [[ -f patches/$patch ]]
then
echo Applying patch $patch ...
git apply --apply --allow-empty patches/$patch
else
echo Patch $patch not found. Exiting.
exit 1
fi
fi
done < <(grep -E "^[^#].*" thunderbird-patches/$VERSION/series-moz)
echo
echo "======================================================="
echo "Applying patch series for comm repository"
cd comm
while read -r line; do
patch=$(echo $line | cut -f1 -d'#' | sed 's/ *$//')
if [[ -n "${patch// }" ]]
then
if [[ -f ../patches/$patch ]]
then
echo Applying patch $patch ...
git apply --apply --allow-empty ../patches/$patch
else
echo Patch $patch not found. Exiting.
exit 1
fi
fi
done < <(grep -E "^[^#].*" ../thunderbird-patches/$VERSION/series)
cd ..
echo
echo "======================================================="
echo "Patching language packs"
if [ -d langpacks ]
then
cd langpacks
for langpack in *.xpi
do
lang=$(echo "$langpack" | sed -r 's#\langpack-([^@]+)@thunderbird.mozilla.org.xpi#\1#')
echo " -- $lang --"
mkdir $lang
cd $lang
echo " * extracting original lang pack"
unzip -q ../$langpack
rm -f ../$langpack
echo " * removing original branding"
rm -f chrome/$lang/locale/branding/*
rm -f localization/$lang/branding/*
echo " * modifying manifest.json"
sed -i -e 's/@thunderbird.mozilla.org/@betterbird.eu/' manifest.json
sed -i -e 's/Language pack for Thunderbird/Language pack for Betterbird/' manifest.json
echo " * copying Betterbird branding from en-US"
branding_source="../../comm/mail/branding/betterbird/locales/en-US"
cp "$branding_source/brand.ftl" localization/$lang/branding/
cp "$branding_source/brand.dtd" "$branding_source/brand.properties" chrome/$lang/locale/branding/
bb_string_patcher="../../thunderbird-patches/$VERSION/scripts/$lang.cmd"
if [[ -f "$bb_string_patcher" ]]
then
echo " * adding extra strings"
sed -ri 's/^(::|REM)/#/; s/%lecho%/lessecho/; s/\r$//; s/\$/\\\$/g; s/%%S/%S/g' "$bb_string_patcher"
perl -pi -e 's#\\(?=[^ ]+$)#/#g' "$bb_string_patcher"
. "$bb_string_patcher"
fi
echo " * packing modified language pack"
zip -qr "../[email protected]" manifest.json chrome localization
cd ..
rm -rf $lang
done
fi