2007-03-22 10:30:00 -07:00
|
|
|
#!/bin/bash
|
2012-05-21 04:12:37 -07:00
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#
|
|
|
|
# This tool generates full update packages for the update system.
|
|
|
|
# Author: Darin Fisher
|
|
|
|
#
|
|
|
|
|
|
|
|
. $(dirname "$0")/common.sh
|
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
print_usage() {
|
|
|
|
notice "Usage: $(basename $0) [OPTIONS] ARCHIVE DIRECTORY"
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ $# = 0 ]; then
|
|
|
|
print_usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $1 = -h ]; then
|
|
|
|
print_usage
|
|
|
|
notice ""
|
|
|
|
notice "The contents of DIRECTORY will be stored in ARCHIVE."
|
|
|
|
notice ""
|
|
|
|
notice "Options:"
|
|
|
|
notice " -h show this help text"
|
|
|
|
notice ""
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
archive="$1"
|
|
|
|
targetdir="$2"
|
2011-04-11 21:23:18 -07:00
|
|
|
# Prevent the workdir from being inside the targetdir so it isn't included in
|
|
|
|
# the update mar.
|
|
|
|
if [ $(echo "$targetdir" | grep -c '\/$') = 1 ]; then
|
|
|
|
# Remove the /
|
|
|
|
targetdir=$(echo "$targetdir" | sed -e 's:\/$::')
|
|
|
|
fi
|
2007-03-22 10:30:00 -07:00
|
|
|
workdir="$targetdir.work"
|
2011-04-11 21:23:18 -07:00
|
|
|
updatemanifestv1="$workdir/update.manifest"
|
|
|
|
updatemanifestv2="$workdir/updatev2.manifest"
|
|
|
|
targetfiles="update.manifest updatev2.manifest"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-03-29 07:11:40 -07:00
|
|
|
mkdir -p "$workdir"
|
|
|
|
|
2011-04-11 21:23:18 -07:00
|
|
|
# On Mac, the precomplete file added by Bug 386760 will cause OS X to reload the
|
|
|
|
# Info.plist so it launches the right architecture, bug 600098
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
# Generate a list of all files in the target directory.
|
|
|
|
pushd "$targetdir"
|
|
|
|
if test $? -ne 0 ; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2011-04-11 21:23:18 -07:00
|
|
|
if [ ! -f "precomplete" ]; then
|
|
|
|
notice "precomplete file is missing!"
|
|
|
|
exit 1
|
2010-10-01 09:33:47 -07:00
|
|
|
fi
|
|
|
|
|
2007-03-29 07:11:40 -07:00
|
|
|
list_files files
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
popd
|
|
|
|
|
2011-04-11 21:23:18 -07:00
|
|
|
notice ""
|
|
|
|
notice "Adding file add instructions to file 'update.manifest'"
|
|
|
|
> $updatemanifestv1
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
num_files=${#files[*]}
|
|
|
|
|
|
|
|
for ((i=0; $i<$num_files; i=$i+1)); do
|
2007-03-29 07:11:40 -07:00
|
|
|
f="${files[$i]}"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-04-11 21:23:18 -07:00
|
|
|
make_add_instruction "$f" >> $updatemanifestv1
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-04-11 21:23:18 -07:00
|
|
|
dir=$(dirname "$f")
|
|
|
|
mkdir -p "$workdir/$dir"
|
|
|
|
$BZIP2 -cz9 "$targetdir/$f" > "$workdir/$f"
|
|
|
|
copy_perm "$targetdir/$f" "$workdir/$f"
|
|
|
|
|
|
|
|
targetfiles="$targetfiles \"$f\""
|
|
|
|
done
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-04-11 21:23:18 -07:00
|
|
|
# Add the type of update to the beginning of and cat the contents of the version
|
|
|
|
# 1 update manifest to the version 2 update manifest.
|
|
|
|
> $updatemanifestv2
|
|
|
|
notice ""
|
|
|
|
notice "Adding type instruction to file 'updatev2.manifest'"
|
|
|
|
notice " type: complete"
|
|
|
|
echo "type \"complete\"" >> $updatemanifestv2
|
|
|
|
|
|
|
|
notice ""
|
|
|
|
notice "Concatenating file 'update.manifest' to file 'updatev2.manifest'"
|
|
|
|
cat $updatemanifestv1 >> $updatemanifestv2
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
# Append remove instructions for any dead files.
|
2011-04-11 21:23:18 -07:00
|
|
|
notice ""
|
|
|
|
notice "Adding file and directory remove instructions from file 'removed-files'"
|
|
|
|
append_remove_instructions "$targetdir" "$updatemanifestv1" "$updatemanifestv2"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-04-11 21:23:18 -07:00
|
|
|
$BZIP2 -z9 "$updatemanifestv1" && mv -f "$updatemanifestv1.bz2" "$updatemanifestv1"
|
|
|
|
$BZIP2 -z9 "$updatemanifestv2" && mv -f "$updatemanifestv2.bz2" "$updatemanifestv2"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
eval "$MAR -C \"$workdir\" -c output.mar $targetfiles"
|
|
|
|
mv -f "$workdir/output.mar" "$archive"
|
|
|
|
|
|
|
|
# cleanup
|
|
|
|
rm -fr "$workdir"
|
2011-04-11 21:23:18 -07:00
|
|
|
|
|
|
|
notice ""
|
|
|
|
notice "Finished"
|