ofz#44991 don't skip over terminator
[LibreOffice.git] / bin / update / make_full_update.sh
blob4140ecae6d14819140066ff568bd3e1d12a463e4
1 #!/usr/bin/env 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 ""
32 exit 1
35 check_externals
36 # -----------------------------------------------------------------------------
38 archive="$1"
39 targetdir="$2"
40 # Prevent the workdir from being inside the targetdir so it isn't included in
41 # the update mar.
42 if [ $(echo "$targetdir" | grep -c '\/$') = 1 ]; then
43 # Remove the /
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"
51 mkdir -p "$workdir"
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.
56 pushd "$targetdir"
57 if test $? -ne 0 ; then
58 exit 1
61 # if [ ! -f "precomplete" ]; then
62 # if [ ! -f "Contents/Resources/precomplete" ]; then
63 # notice "precomplete file is missing!"
64 # exit 1
65 # fi
66 # fi
68 list_files files
70 popd
72 # Add the type of update to the beginning of the update manifests.
73 > $updatemanifestv2
74 > $updatemanifestv3
75 notice ""
76 notice "Adding type instruction to update manifests"
77 notice " type complete"
78 echo "type \"complete\"" >> $updatemanifestv2
79 echo "type \"complete\"" >> $updatemanifestv3
81 notice ""
82 notice "Adding file add instructions to update manifests"
83 num_files=${#files[*]}
85 for ((i=0; $i<$num_files; i=$i+1)); do
86 f="${files[$i]}"
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
93 else
94 make_add_instruction "$f" "$updatemanifestv2" "$updatemanifestv3"
97 dir=$(dirname "$f")
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
104 done
106 # Append remove instructions for any dead files.
107 notice ""
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"
117 # cleanup
118 rm -fr "$workdir"
120 notice ""
121 notice "Finished"
122 notice ""