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"
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 updatemanifestv2
="$workdir/updatev2.manifest"
48 updatemanifestv3
="$workdir/updatev3.manifest"
49 targetfiles
="updatev2.manifest updatev3.manifest"
52 echo "updatev2.manifest" >> $workdir/files.txt
53 echo "updatev3.manifest" >> $workdir/files.txt
55 # Generate a list of all files in the target directory.
57 if test $?
-ne 0 ; then
61 # if [ ! -f "precomplete" ]; then
62 # if [ ! -f "Contents/Resources/precomplete" ]; then
63 # notice "precomplete file is missing!"
72 # Add the type of update to the beginning of the update manifests.
76 notice
"Adding type instruction to update manifests"
77 notice
" type complete"
78 echo "type \"complete\"" >> $updatemanifestv2
79 echo "type \"complete\"" >> $updatemanifestv3
82 notice
"Adding file add instructions to update manifests"
83 num_files
=${#files[*]}
85 for ((i
=0; $i<$num_files; i
=$i+1)); do
88 if check_for_add_if_not_update
"$f"; then
89 make_add_if_not_instruction
"$f" "$updatemanifestv3"
90 if check_for_add_to_manifestv2
"$f"; then
91 make_add_instruction
"$f" "$updatemanifestv2" "" 1
94 make_add_instruction
"$f" "$updatemanifestv2" "$updatemanifestv3"
98 mkdir
-p "$workdir/$dir"
99 $BZIP2 -cz9 "$targetdir/$f" > "$workdir/$f"
100 copy_perm
"$targetdir/$f" "$workdir/$f"
102 targetfiles
="$targetfiles \"$f\""
103 echo $f >> $workdir/files.txt
106 # Append remove instructions for any dead files.
108 notice
"Adding file and directory remove instructions from file 'removed-files'"
109 append_remove_instructions
"$targetdir" "$updatemanifestv2" "$updatemanifestv3"
111 $BZIP2 -z9 "$updatemanifestv2" && mv -f "$updatemanifestv2.bz2" "$updatemanifestv2"
112 $BZIP2 -z9 "$updatemanifestv3" && mv -f "$updatemanifestv3.bz2" "$updatemanifestv3"
114 eval "$MAR -C \"$workdir\" -c output.mar -f $workdir/files.txt"
115 mv -f "$workdir/output.mar" "$archive"