2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 # Code shared by update packaging scripts.
11 # -----------------------------------------------------------------------------
14 # By default just assume that these tools exist on our path
16 MBSDIFF
=${MBSDIFF:-mbsdiff}
18 $XZ --version > /dev
/null
2>&1
20 # If $XZ is not set and not found on the path then this is probably
21 # running on a windows buildbot. Some of the Windows build systems have
22 # xz.exe in topsrcdir/xz/. Look in the places this would be in both a
23 # mozilla-central and comm-central build.
24 XZ
="$(dirname "$
(dirname "$(dirname "$0")")")/xz/xz.exe"
25 $XZ --version > /dev
/null
2>&1
27 XZ
="$(dirname "$
(dirname "$(dirname "$
(dirname "$0")")")")/xz/xz.exe"
28 $XZ --version > /dev
/null
2>&1
30 echo "xz was not found on this system!"
36 # Ensure that we're always using the right compression settings
37 export XZ_OPT
="-T1 -7e"
39 # -----------------------------------------------------------------------------
47 if [ $QUIET -eq 0 ]; then
61 if [ -x "$reference" ]; then
68 make_add_instruction
() {
72 # Used to log to the console
79 is_extension
=$
(echo "$f" |
grep -c 'distribution/extensions/.*/')
80 if [ $is_extension = "1" ]; then
81 # Use the subdirectory of the extensions folder as the file to test
82 # before performing this add instruction.
83 testdir
=$
(echo "$f" |
sed 's/\(.*distribution\/extensions\/[^\/]*\)\/.*/\1/')
84 verbose_notice
" add-if \"$testdir\" \"$f\""
85 echo "add-if \"$testdir\" \"$f\"" >> "$filev3"
87 verbose_notice
" add \"$f\"$forced"
88 echo "add \"$f\"" >> "$filev3"
92 check_for_add_if_not_update
() {
93 add_if_not_file_chk
="$1"
95 if [ `basename $add_if_not_file_chk` = "channel-prefs.js" -o \
96 `basename $add_if_not_file_chk` = "update-settings.ini" ]; then
100 ## 'false'... because this is bash. Oh yay!
104 make_add_if_not_instruction
() {
108 verbose_notice
" add-if-not \"$f\" \"$f\""
109 echo "add-if-not \"$f\" \"$f\"" >> "$filev3"
112 make_patch_instruction
() {
116 is_extension
=$
(echo "$f" |
grep -c 'distribution/extensions/.*/')
117 if [ $is_extension = "1" ]; then
118 # Use the subdirectory of the extensions folder as the file to test
119 # before performing this add instruction.
120 testdir
=$
(echo "$f" |
sed 's/\(.*distribution\/extensions\/[^\/]*\)\/.*/\1/')
121 verbose_notice
" patch-if \"$testdir\" \"$f.patch\" \"$f\""
122 echo "patch-if \"$testdir\" \"$f.patch\" \"$f\"" >> "$filev3"
124 verbose_notice
" patch \"$f.patch\" \"$f\""
125 echo "patch \"$f.patch\" \"$f\"" >> "$filev3"
129 append_remove_instructions
() {
133 if [ -f "$dir/removed-files" ]; then
134 listfile
="$dir/removed-files"
135 elif [ -f "$dir/Contents/Resources/removed-files" ]; then
136 listfile
="$dir/Contents/Resources/removed-files"
138 if [ -n "$listfile" ]; then
139 # Map spaces to pipes so that we correctly handle filenames with spaces.
140 files
=($
(cat "$listfile" |
tr " " "|" |
sort -r))
141 num_files
=${#files[*]}
142 for ((i
=0; $i<$num_files; i
=$i+1)); do
143 # Map pipes back to whitespace and remove carriage returns
144 f
=$
(echo ${files[$i]} |
tr "|" " " |
tr -d '\r')
147 # Exclude blank lines.
150 if [ ! $
(echo "$f" |
grep -c '^#') = 1 ]; then
151 if [ $
(echo "$f" |
grep -c '\/$') = 1 ]; then
152 verbose_notice
" rmdir \"$f\""
153 echo "rmdir \"$f\"" >> "$filev3"
154 elif [ $
(echo "$f" |
grep -c '\/\*$') = 1 ]; then
156 f
=$
(echo "$f" |
sed -e 's:\*$::')
157 verbose_notice
" rmrfdir \"$f\""
158 echo "rmrfdir \"$f\"" >> "$filev3"
160 verbose_notice
" remove \"$f\""
161 echo "remove \"$f\"" >> "$filev3"
169 # List all files in the current directory, stripping leading "./"
170 # Pass a variable name and it will be filled as an array.
173 temp_filelist
=$
(mktemp
)
175 ! -name "update.manifest" \
176 ! -name "updatev2.manifest" \
177 ! -name "updatev3.manifest" \
178 |
sed 's/\.\/\(.*\)/\1/' \
179 |
sort -r > "${temp_filelist}"
181 eval "${1}[$count]=\"$file\""
183 done < "${temp_filelist}"
184 rm "${temp_filelist}"
187 # List all directories in the current directory, stripping leading "./"
190 temp_dirlist
=$
(mktemp
)
194 |
sed 's/\.\/\(.*\)/\1/' \
195 |
sort -r > "${temp_dirlist}"
197 eval "${1}[$count]=\"$dir\""
199 done < "${temp_dirlist}"