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.
10 # In here to use the local common.sh to allow the full mars to have unfiltered files
12 # -----------------------------------------------------------------------------
13 # By default just assume that these tools exist on our path
16 MBSDIFF
=${MBSDIFF:-mbsdiff}
18 # -----------------------------------------------------------------------------
34 if [ -x "$reference" ]; then
41 make_add_instruction
() {
44 # The third param will be an empty string when a file add instruction is only
45 # needed in the version 2 manifest. This only happens when the file has an
46 # add-if-not instruction in the version 3 manifest. This is due to the
47 # precomplete file prior to the version 3 manifest having a remove instruction
48 # for this file so the file is removed before applying a complete update.
51 # Used to log to the console
58 is_extension
=$
(echo "$f" |
grep -c 'distribution/extensions/.*/')
59 if [ $is_extension = "1" ]; then
60 # Use the subdirectory of the extensions folder as the file to test
61 # before performing this add instruction.
62 testdir
=$
(echo "$f" |
sed 's/\(.*distribution\/extensions\/[^\/]*\)\/.*/\1/')
63 notice
" add-if \"$testdir\" \"$f\""
64 echo "add-if \"$testdir\" \"$f\"" >> $filev2
65 if [ ! $filev3 = "" ]; then
66 echo "add-if \"$testdir\" \"$f\"" >> $filev3
69 notice
" add \"$f\"$forced"
70 echo "add \"$f\"" >> $filev2
71 if [ ! $filev3 = "" ]; then
72 echo "add \"$f\"" >> $filev3
77 check_for_add_if_not_update
() {
78 add_if_not_file_chk
="$1"
80 if [ "$(basename "$add_if_not_file_chk")" = "channel-prefs.js" -o \
81 "$(basename "$add_if_not_file_chk")" = "update-settings.ini" ]; then
85 ## 'false'... because this is bash. Oh yay!
89 check_for_add_to_manifestv2
() {
90 add_if_not_file_chk
="$1"
92 if [ "$(basename "$add_if_not_file_chk")" = "update-settings.ini" ]; then
96 ## 'false'... because this is bash. Oh yay!
100 make_add_if_not_instruction
() {
104 notice
" add-if-not \"$f\" \"$f\""
105 echo "add-if-not \"$f\" \"$f\"" >> $filev3
108 make_patch_instruction
() {
113 is_extension
=$
(echo "$f" |
grep -c 'distribution/extensions/.*/')
114 if [ $is_extension = "1" ]; then
115 # Use the subdirectory of the extensions folder as the file to test
116 # before performing this add instruction.
117 testdir
=$
(echo "$f" |
sed 's/\(.*distribution\/extensions\/[^\/]*\)\/.*/\1/')
118 notice
" patch-if \"$testdir\" \"$f.patch\" \"$f\""
119 echo "patch-if \"$testdir\" \"$f.patch\" \"$f\"" >> $filev2
120 echo "patch-if \"$testdir\" \"$f.patch\" \"$f\"" >> $filev3
122 notice
" patch \"$f.patch\" \"$f\""
123 echo "patch \"$f.patch\" \"$f\"" >> $filev2
124 echo "patch \"$f.patch\" \"$f\"" >> $filev3
128 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 notice
" rmdir \"$f\""
153 echo "rmdir \"$f\"" >> $filev2
154 echo "rmdir \"$f\"" >> $filev3
155 elif [ $
(echo "$f" |
grep -c '\/\*$') = 1 ]; then
157 f
=$
(echo "$f" |
sed -e 's:\*$::')
158 notice
" rmrfdir \"$f\""
159 echo "rmrfdir \"$f\"" >> $filev2
160 echo "rmrfdir \"$f\"" >> $filev3
162 notice
" remove \"$f\""
163 echo "remove \"$f\"" >> $filev2
164 echo "remove \"$f\"" >> $filev3
172 # List all files in the current directory, stripping leading "./"
173 # Pass a variable name and it will be filled as an array.
177 # Removed the exclusion cases here to allow for generation of testing mars
179 |
sed 's/\.\/\(.*\)/\1/' \
180 |
sort -r > "$workdir/temp-filelist"
182 eval "${1}[$count]=\"$file\""
184 done < "$workdir/temp-filelist"
185 rm "$workdir/temp-filelist"
188 # List all directories in the current directory, stripping leading "./"
195 |
sed 's/\.\/\(.*\)/\1/' \
196 |
sort -r > "$workdir/temp-dirlist"
198 eval "${1}[$count]=\"$dir\""
200 done < "$workdir/temp-dirlist"
201 rm "$workdir/temp-dirlist"