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 # This tool generates full update packages for the update system.
10 # In here to use the local common.sh to allow the full mars to have unfiltered files
12 . $
(dirname "$0")/common.sh
14 # -----------------------------------------------------------------------------
17 notice
"Usage: $(basename $0) [OPTIONS] ARCHIVE DIRECTORY"
28 notice
"The contents of DIRECTORY will be stored in ARCHIVE."
31 notice
" -h show this help text"
36 # -----------------------------------------------------------------------------
40 # Prevent the workdir from being inside the targetdir so it isn't included in
42 if [ $
(echo "$targetdir" |
grep -c '\/$') = 1 ]; then
44 targetdir
=$
(echo "$targetdir" |
sed -e 's:\/$::')
46 workdir
="$targetdir.work"
47 updatemanifestv3
="$workdir/updatev3.manifest"
48 targetfiles
="updatev3.manifest"
52 # Generate a list of all files in the target directory.
54 if test $?
-ne 0 ; then
58 if [ ! -f "precomplete" ]; then
59 if [ ! -f "Contents/Resources/precomplete" ]; then
60 notice
"precomplete file is missing!"
69 # Add the type of update to the beginning of the update manifests.
72 notice
"Adding type instruction to update manifests"
73 notice
" type complete"
74 echo "type \"complete\"" >> $updatemanifestv3
77 notice
"Adding file add instructions to update manifests"
78 num_files
=${#files[*]}
80 for ((i
=0; $i<$num_files; i
=$i+1)); do
83 if check_for_add_if_not_update
"$f"; then
84 make_add_if_not_instruction
"$f" "$updatemanifestv3"
86 make_add_instruction
"$f" "$updatemanifestv3"
90 mkdir
-p "$workdir/$dir"
91 $XZ $XZ_OPT --compress --x86 --lzma2 --format=xz
--check=crc64
--force --stdout "$targetdir/$f" > "$workdir/$f"
92 copy_perm
"$targetdir/$f" "$workdir/$f"
94 targetfiles
="$targetfiles \"$f\""
97 # Append remove instructions for any dead files.
99 notice
"Adding file and directory remove instructions from file 'removed-files'"
100 append_remove_instructions
"$targetdir" "$updatemanifestv3"
102 $XZ $XZ_OPT --compress --x86 --lzma2 --format=xz
--check=crc64
--force "$updatemanifestv3" && mv -f "$updatemanifestv3.xz" "$updatemanifestv3"
104 eval "$MAR -C \"$workdir\" -c output.mar $targetfiles"
105 mv -f "$workdir/output.mar" "$archive"