Bug 1671598 [wpt PR 26128] - [AspectRatio] Fix divide by zero with a small float...
[gecko.git] / tools / update-packaging / make_full_update.sh
blobdb2c5898efdc2f68a59ff58cafddedc3b7c6cb1f
1 #!/bin/bash
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.
8 # Author: Darin Fisher
11 . $(dirname "$0")/common.sh
13 # -----------------------------------------------------------------------------
15 print_usage() {
16 notice "Usage: $(basename $0) [OPTIONS] ARCHIVE DIRECTORY"
19 if [ $# = 0 ]; then
20 print_usage
21 exit 1
24 if [ $1 = -h ]; then
25 print_usage
26 notice ""
27 notice "The contents of DIRECTORY will be stored in ARCHIVE."
28 notice ""
29 notice "Options:"
30 notice " -h show this help text"
31 notice " -q be less verbose"
32 notice ""
33 exit 1
36 if [ $1 = -q ]; then
37 QUIET=1
38 export QUIET
39 shift
42 # -----------------------------------------------------------------------------
44 mar_command="$MAR -V ${MOZ_PRODUCT_VERSION:?} -H ${MAR_CHANNEL_ID:?}"
46 archive="$1"
47 targetdir="$2"
48 # Prevent the workdir from being inside the targetdir so it isn't included in
49 # the update mar.
50 if [ $(echo "$targetdir" | grep -c '\/$') = 1 ]; then
51 # Remove the /
52 targetdir=$(echo "$targetdir" | sed -e 's:\/$::')
54 workdir="$targetdir.work"
55 updatemanifestv3="$workdir/updatev3.manifest"
56 targetfiles="updatev3.manifest"
58 mkdir -p "$workdir"
60 # Generate a list of all files in the target directory.
61 pushd "$targetdir"
62 if test $? -ne 0 ; then
63 exit 1
66 if [ ! -f "precomplete" ]; then
67 if [ ! -f "Contents/Resources/precomplete" ]; then
68 notice "precomplete file is missing!"
69 exit 1
73 list_files files
75 popd
77 # Add the type of update to the beginning of the update manifests.
78 > "$updatemanifestv3"
79 notice ""
80 notice "Adding type instruction to update manifests"
81 notice " type complete"
82 echo "type \"complete\"" >> "$updatemanifestv3"
84 notice ""
85 notice "Adding file add instructions to update manifests"
86 num_files=${#files[*]}
88 for ((i=0; $i<$num_files; i=$i+1)); do
89 f="${files[$i]}"
91 if check_for_add_if_not_update "$f"; then
92 make_add_if_not_instruction "$f" "$updatemanifestv3"
93 else
94 make_add_instruction "$f" "$updatemanifestv3"
97 dir=$(dirname "$f")
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\""
103 done
105 # Append remove instructions for any dead files.
106 notice ""
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"
116 # cleanup
117 rm -fr "$workdir"
119 notice ""
120 notice "Finished"
121 notice ""