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 # -----------------------------------------------------------------------------
12 # By default just assume that these tools exist on our path
15 MBSDIFF
=${MBSDIFF:-mbsdiff}
17 # -----------------------------------------------------------------------------
31 # check whether we can call the mar executable
32 "$MAR" --version > /dev
/null
2>&1
34 notice
"Could not find a valid mar executable in the path or in the MAR environment variable"
38 # check whether we can access the bzip2 executable
39 "$BZIP2" --help > /dev
/null
2>&1
41 notice
"Could not find a valid bzip2 executable in the PATH or in the BZIP2 environment variable"
50 if [ -x "$reference" ]; then
57 make_add_instruction
() {
60 # The third param will be an empty string when a file add instruction is only
61 # needed in the version 2 manifest. This only happens when the file has an
62 # add-if-not instruction in the version 3 manifest. This is due to the
63 # precomplete file prior to the version 3 manifest having a remove instruction
64 # for this file so the file is removed before applying a complete update.
67 # Used to log to the console
74 is_extension
=$
(echo "$f" |
grep -c 'distribution/extensions/.*/')
75 if [ $is_extension = "1" ]; then
76 # Use the subdirectory of the extensions folder as the file to test
77 # before performing this add instruction.
78 testdir
=$
(echo "$f" |
sed 's/\(.*distribution\/extensions\/[^\/]*\)\/.*/\1/')
79 notice
" add-if \"$testdir\" \"$f\""
80 echo "add-if \"$testdir\" \"$f\"" >> $filev2
81 if [ ! $filev3 = "" ]; then
82 echo "add-if \"$testdir\" \"$f\"" >> $filev3
85 notice
" add \"$f\"$forced"
86 echo "add \"$f\"" >> $filev2
87 if [ ! $filev3 = "" ]; then
88 echo "add \"$f\"" >> $filev3
93 check_for_add_if_not_update
() {
94 add_if_not_file_chk
="$1"
96 if [ `basename $add_if_not_file_chk` = "channel-prefs.js" -o \
97 `basename $add_if_not_file_chk` = "update-settings.ini" ]; then
101 ## 'false'... because this is bash. Oh yay!
105 check_for_add_to_manifestv2
() {
106 add_if_not_file_chk
="$1"
108 if [ `basename $add_if_not_file_chk` = "update-settings.ini" ]; then
112 ## 'false'... because this is bash. Oh yay!
116 make_add_if_not_instruction
() {
120 notice
" add-if-not \"$f\" \"$f\""
121 echo "add-if-not \"$f\" \"$f\"" >> $filev3
124 make_patch_instruction
() {
129 is_extension
=$
(echo "$f" |
grep -c 'distribution/extensions/.*/')
130 if [ $is_extension = "1" ]; then
131 # Use the subdirectory of the extensions folder as the file to test
132 # before performing this add instruction.
133 testdir
=$
(echo "$f" |
sed 's/\(.*distribution\/extensions\/[^\/]*\)\/.*/\1/')
134 notice
" patch-if \"$testdir\" \"$f.patch\" \"$f\""
135 echo "patch-if \"$testdir\" \"$f.patch\" \"$f\"" >> $filev2
136 echo "patch-if \"$testdir\" \"$f.patch\" \"$f\"" >> $filev3
138 notice
" patch \"$f.patch\" \"$f\""
139 echo "patch \"$f.patch\" \"$f\"" >> $filev2
140 echo "patch \"$f.patch\" \"$f\"" >> $filev3
144 append_remove_instructions
() {
149 if [ -f "$dir/removed-files" ]; then
150 listfile
="$dir/removed-files"
151 elif [ -f "$dir/Contents/Resources/removed-files" ]; then
152 listfile
="$dir/Contents/Resources/removed-files"
154 if [ -n "$listfile" ]; then
155 # Map spaces to pipes so that we correctly handle filenames with spaces.
156 files
=($
(cat "$listfile" |
tr " " "|" |
sort -r))
157 num_files
=${#files[*]}
158 for ((i
=0; $i<$num_files; i
=$i+1)); do
159 # Map pipes back to whitespace and remove carriage returns
160 f
=$
(echo ${files[$i]} |
tr "|" " " |
tr -d '\r')
163 # Exclude blank lines.
166 if [ ! $
(echo "$f" |
grep -c '^#') = 1 ]; then
167 if [ $
(echo "$f" |
grep -c '\/$') = 1 ]; then
168 notice
" rmdir \"$f\""
169 echo "rmdir \"$f\"" >> $filev2
170 echo "rmdir \"$f\"" >> $filev3
171 elif [ $
(echo "$f" |
grep -c '\/\*$') = 1 ]; then
173 f
=$
(echo "$f" |
sed -e 's:\*$::')
174 notice
" rmrfdir \"$f\""
175 echo "rmrfdir \"$f\"" >> $filev2
176 echo "rmrfdir \"$f\"" >> $filev3
178 notice
" remove \"$f\""
179 echo "remove \"$f\"" >> $filev2
180 echo "remove \"$f\"" >> $filev3
188 # List all files in the current directory, stripping leading "./"
189 # Pass a variable name and it will be filled as an array.
194 ! -name "update.manifest" \
195 ! -name "updatev2.manifest" \
196 ! -name "updatev3.manifest" \
197 ! -name "temp-dirlist" \
198 ! -name "temp-filelist" \
199 |
sed 's/\.\/\(.*\)/\1/' \
200 |
sort -r > "temp-filelist"
202 eval "${1}[$count]=\"$file\""
204 done < "temp-filelist"
208 # List all directories in the current directory, stripping leading "./"
215 |
sed 's/\.\/\(.*\)/\1/' \
216 |
sort -r > "temp-dirlist"
218 eval "${1}[$count]=\"$dir\""
220 done < "temp-dirlist"