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.
11 . $
(dirname "$0")/common.sh
13 # -----------------------------------------------------------------------------
16 notice
"Usage: $(basename $0) [OPTIONS] ARCHIVE DIRECTORY"
27 notice
"The contents of DIRECTORY will be stored in ARCHIVE."
30 notice
" -h show this help text"
31 notice
" -q be less verbose"
42 # -----------------------------------------------------------------------------
44 mar_command
="$MAR -V ${MOZ_PRODUCT_VERSION:?} -H ${MAR_CHANNEL_ID:?}"
48 # Prevent the workdir from being inside the targetdir so it isn't included in
50 if [ $
(echo "$targetdir" |
grep -c '\/$') = 1 ]; then
52 targetdir
=$
(echo "$targetdir" |
sed -e 's:\/$::')
54 workdir
="$targetdir.work"
55 updatemanifestv3
="$workdir/updatev3.manifest"
56 targetfiles
="updatev3.manifest"
60 # Generate a list of all files in the target directory.
62 if test $?
-ne 0 ; then
66 if [ ! -f "precomplete" ]; then
67 if [ ! -f "Contents/Resources/precomplete" ]; then
68 notice
"precomplete file is missing!"
77 # Add the type of update to the beginning of the update manifests.
80 notice
"Adding type instruction to update manifests"
81 notice
" type complete"
82 echo "type \"complete\"" >> "$updatemanifestv3"
85 notice
"Adding file add instructions to update manifests"
86 num_files
=${#files[*]}
88 for ((i
=0; $i<$num_files; i
=$i+1)); do
91 if check_for_add_if_not_update
"$f"; then
92 make_add_if_not_instruction
"$f" "$updatemanifestv3"
94 make_add_instruction
"$f" "$updatemanifestv3"
98 mkdir
-p "$workdir/$dir"
99 $XZ $XZ_OPT --compress $BCJ_OPTIONS --lzma2 --format=xz
--check=crc64
--force --stdout "$targetdir/$f" > "$workdir/$f"
100 copy_perm
"$targetdir/$f" "$workdir/$f"
102 targetfiles
="$targetfiles \"$f\""
105 # Append remove instructions for any dead files.
107 notice
"Adding file and directory remove instructions from file 'removed-files'"
108 append_remove_instructions
"$targetdir" "$updatemanifestv3"
110 $XZ $XZ_OPT --compress $BCJ_OPTIONS --lzma2 --format=xz
--check=crc64
--force "$updatemanifestv3" && mv -f "$updatemanifestv3.xz" "$updatemanifestv3"
112 mar_command
="$mar_command -C \"$workdir\" -c output.mar"
113 eval "$mar_command $targetfiles"
114 mv -f "$workdir/output.mar" "$archive"