summaryrefslogtreecommitdiffstats
path: root/tools/update-packaging
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /tools/update-packaging
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tools/update-packaging')
-rw-r--r--tools/update-packaging/README4
-rw-r--r--tools/update-packaging/app.mozbuild9
-rwxr-xr-xtools/update-packaging/common.sh201
-rwxr-xr-xtools/update-packaging/make_full_update.sh121
-rwxr-xr-xtools/update-packaging/make_incremental_update.sh313
-rw-r--r--tools/update-packaging/moz.build5
-rw-r--r--tools/update-packaging/moz.configure0
-rwxr-xr-xtools/update-packaging/test/buildrefmars.sh27
-rwxr-xr-xtools/update-packaging/test/common.sh202
-rwxr-xr-xtools/update-packaging/test/diffmar.sh48
-rw-r--r--tools/update-packaging/test/from-mac/Contents/MacOS/diff-patch-larger-than-file.txt1
-rw-r--r--tools/update-packaging/test/from-mac/Contents/MacOS/force.txt1
-rw-r--r--tools/update-packaging/test/from-mac/Contents/MacOS/removed.txt1
-rw-r--r--tools/update-packaging/test/from-mac/Contents/MacOS/same.binbin0 -> 200 bytes
-rw-r--r--tools/update-packaging/test/from-mac/Contents/MacOS/update.manifest1
-rw-r--r--tools/update-packaging/test/from-mac/Contents/MacOS/{foodir/diff-patch-larger-than-file.txt1
-rw-r--r--tools/update-packaging/test/from-mac/Contents/MacOS/{foodir/readme.txt1
-rw-r--r--tools/update-packaging/test/from-mac/Contents/MacOS/{foodir/removed.txt1
-rw-r--r--tools/update-packaging/test/from-mac/Contents/MacOS/{foodir/same.binbin0 -> 200 bytes
-rw-r--r--tools/update-packaging/test/from-mac/Contents/MacOS/{foodir/same.txt1
-rw-r--r--tools/update-packaging/test/from-mac/Contents/MacOS/{foodir/update.manifest1
-rw-r--r--tools/update-packaging/test/from-mac/Contents/Resources/application.ini5
-rw-r--r--tools/update-packaging/test/from-mac/Contents/Resources/chrome.manifest0
-rw-r--r--tools/update-packaging/test/from-mac/Contents/Resources/distribution/extensions/diff/diff-patch-larger-than-file.txt1
-rw-r--r--tools/update-packaging/test/from-mac/Contents/Resources/extensions/diff/diff-patch-larger-than-file.txt1
-rw-r--r--tools/update-packaging/test/from-mac/Contents/Resources/precomplete26
-rw-r--r--tools/update-packaging/test/from-mac/Contents/Resources/readme.txt2
-rw-r--r--tools/update-packaging/test/from-mac/Contents/Resources/removed-files8
-rw-r--r--tools/update-packaging/test/from-mac/Contents/Resources/removed.txt1
-rw-r--r--tools/update-packaging/test/from-mac/Contents/Resources/same.txt1
-rw-r--r--tools/update-packaging/test/from-mac/Contents/Resources/searchplugins/diff/diff-patch-larger-than-file.txt1
-rw-r--r--tools/update-packaging/test/from-mac/Contents/Resources/update-settings.ini1
-rw-r--r--tools/update-packaging/test/from-mac/Contents/Resources/{foodir/channel-prefs.js1
-rw-r--r--tools/update-packaging/test/from-mac/Contents/Resources/{foodir/force.txt1
-rw-r--r--tools/update-packaging/test/from/application.ini5
-rw-r--r--tools/update-packaging/test/from/chrome.manifest0
-rw-r--r--tools/update-packaging/test/from/diff-patch-larger-than-file.txt1
-rw-r--r--tools/update-packaging/test/from/distribution/extensions/diff/diff-patch-larger-than-file.txt1
-rw-r--r--tools/update-packaging/test/from/extensions/diff/diff-patch-larger-than-file.txt1
-rw-r--r--tools/update-packaging/test/from/force.txt1
-rw-r--r--tools/update-packaging/test/from/precomplete23
-rw-r--r--tools/update-packaging/test/from/readme.txt2
-rw-r--r--tools/update-packaging/test/from/removed-files8
-rw-r--r--tools/update-packaging/test/from/removed.txt1
-rw-r--r--tools/update-packaging/test/from/same.binbin0 -> 200 bytes
-rw-r--r--tools/update-packaging/test/from/same.txt1
-rw-r--r--tools/update-packaging/test/from/searchplugins/diff/diff-patch-larger-than-file.txt1
-rw-r--r--tools/update-packaging/test/from/update-settings.ini1
-rw-r--r--tools/update-packaging/test/from/update.manifest1
-rw-r--r--tools/update-packaging/test/from/{foodir/channel-prefs.js1
-rw-r--r--tools/update-packaging/test/from/{foodir/diff-patch-larger-than-file.txt1
-rw-r--r--tools/update-packaging/test/from/{foodir/force.txt1
-rw-r--r--tools/update-packaging/test/from/{foodir/readme.txt1
-rw-r--r--tools/update-packaging/test/from/{foodir/removed.txt1
-rw-r--r--tools/update-packaging/test/from/{foodir/same.binbin0 -> 200 bytes
-rw-r--r--tools/update-packaging/test/from/{foodir/same.txt1
-rw-r--r--tools/update-packaging/test/from/{foodir/update.manifest1
-rwxr-xr-xtools/update-packaging/test/make_full_update.sh112
-rwxr-xr-xtools/update-packaging/test/runtests.sh12
-rw-r--r--tools/update-packaging/test/testpatchfile.txt2
-rw-r--r--tools/update-packaging/test/to-mac/Contents/MacOS/addFeedPrefs.js1
-rw-r--r--tools/update-packaging/test/to-mac/Contents/MacOS/added.txt1
-rw-r--r--tools/update-packaging/test/to-mac/Contents/MacOS/diff-patch-larger-than-file.binbin0 -> 200 bytes
-rw-r--r--tools/update-packaging/test/to-mac/Contents/MacOS/diff-patch-larger-than-file.txt1
-rw-r--r--tools/update-packaging/test/to-mac/Contents/MacOS/force.txt1
-rw-r--r--tools/update-packaging/test/to-mac/Contents/MacOS/same.binbin0 -> 200 bytes
-rw-r--r--tools/update-packaging/test/to-mac/Contents/MacOS/update.manifest1
-rw-r--r--tools/update-packaging/test/to-mac/Contents/MacOS/{foodir/added.txt1
-rw-r--r--tools/update-packaging/test/to-mac/Contents/MacOS/{foodir/diff-patch-larger-than-file.txt1
-rw-r--r--tools/update-packaging/test/to-mac/Contents/MacOS/{foodir/readme.txt1
-rw-r--r--tools/update-packaging/test/to-mac/Contents/MacOS/{foodir/same.binbin0 -> 200 bytes
-rw-r--r--tools/update-packaging/test/to-mac/Contents/MacOS/{foodir/same.txt1
-rw-r--r--tools/update-packaging/test/to-mac/Contents/MacOS/{foodir/update.manifest1
-rw-r--r--tools/update-packaging/test/to-mac/Contents/Resources/application.ini5
-rw-r--r--tools/update-packaging/test/to-mac/Contents/Resources/chrome.manifest0
-rw-r--r--tools/update-packaging/test/to-mac/Contents/Resources/distribution/extensions/added/file.txt1
-rw-r--r--tools/update-packaging/test/to-mac/Contents/Resources/distribution/extensions/diff/diff-patch-larger-than-file.txt1
-rw-r--r--tools/update-packaging/test/to-mac/Contents/Resources/extensions/added/file.txt1
-rw-r--r--tools/update-packaging/test/to-mac/Contents/Resources/extensions/diff/diff-patch-larger-than-file.txt1
-rw-r--r--tools/update-packaging/test/to-mac/Contents/Resources/precomplete33
-rw-r--r--tools/update-packaging/test/to-mac/Contents/Resources/readme.txt1
-rw-r--r--tools/update-packaging/test/to-mac/Contents/Resources/removed-files14
-rw-r--r--tools/update-packaging/test/to-mac/Contents/Resources/same.txt1
-rw-r--r--tools/update-packaging/test/to-mac/Contents/Resources/searchplugins/added/file.txt1
-rw-r--r--tools/update-packaging/test/to-mac/Contents/Resources/searchplugins/diff/diff-patch-larger-than-file.txt1
-rw-r--r--tools/update-packaging/test/to-mac/Contents/Resources/update-settings.ini1
-rw-r--r--tools/update-packaging/test/to-mac/Contents/Resources/{foodir/channel-prefs.js1
-rw-r--r--tools/update-packaging/test/to-mac/Contents/Resources/{foodir/force.txt1
-rw-r--r--tools/update-packaging/test/to/addFeedPrefs.js1
-rw-r--r--tools/update-packaging/test/to/added.txt1
-rw-r--r--tools/update-packaging/test/to/application.ini5
-rw-r--r--tools/update-packaging/test/to/chrome.manifest0
-rw-r--r--tools/update-packaging/test/to/diff-patch-larger-than-file.binbin0 -> 200 bytes
-rw-r--r--tools/update-packaging/test/to/diff-patch-larger-than-file.txt1
-rw-r--r--tools/update-packaging/test/to/distribution/extensions/added/file.txt1
-rw-r--r--tools/update-packaging/test/to/distribution/extensions/diff/diff-patch-larger-than-file.txt1
-rw-r--r--tools/update-packaging/test/to/extensions/added/file.txt1
-rw-r--r--tools/update-packaging/test/to/extensions/diff/diff-patch-larger-than-file.txt1
-rw-r--r--tools/update-packaging/test/to/force.txt1
-rw-r--r--tools/update-packaging/test/to/precomplete30
-rw-r--r--tools/update-packaging/test/to/readme.txt1
-rw-r--r--tools/update-packaging/test/to/removed-files14
-rw-r--r--tools/update-packaging/test/to/same.binbin0 -> 200 bytes
-rw-r--r--tools/update-packaging/test/to/same.txt1
-rw-r--r--tools/update-packaging/test/to/searchplugins/added/file.txt1
-rw-r--r--tools/update-packaging/test/to/searchplugins/diff/diff-patch-larger-than-file.txt1
-rw-r--r--tools/update-packaging/test/to/update-settings.ini1
-rw-r--r--tools/update-packaging/test/to/update.manifest1
-rw-r--r--tools/update-packaging/test/to/{foodir/added.txt1
-rw-r--r--tools/update-packaging/test/to/{foodir/channel-prefs.js1
-rw-r--r--tools/update-packaging/test/to/{foodir/diff-patch-larger-than-file.txt1
-rw-r--r--tools/update-packaging/test/to/{foodir/force.txt1
-rw-r--r--tools/update-packaging/test/to/{foodir/readme.txt1
-rw-r--r--tools/update-packaging/test/to/{foodir/same.binbin0 -> 200 bytes
-rw-r--r--tools/update-packaging/test/to/{foodir/same.txt1
-rw-r--r--tools/update-packaging/test/to/{foodir/update.manifest1
116 files changed, 1311 insertions, 0 deletions
diff --git a/tools/update-packaging/README b/tools/update-packaging/README
new file mode 100644
index 0000000000..7029ffb8e5
--- /dev/null
+++ b/tools/update-packaging/README
@@ -0,0 +1,4 @@
+This directory contains a tool for generating update packages for
+the update system described here:
+
+ http://wiki.mozilla.org/Software_Update
diff --git a/tools/update-packaging/app.mozbuild b/tools/update-packaging/app.mozbuild
new file mode 100644
index 0000000000..92fd8822e7
--- /dev/null
+++ b/tools/update-packaging/app.mozbuild
@@ -0,0 +1,9 @@
+# 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/.
+
+DIRS += [
+ "/modules/libmar/src",
+ "/modules/libmar/tool",
+ "/other-licenses/bsdiff",
+]
diff --git a/tools/update-packaging/common.sh b/tools/update-packaging/common.sh
new file mode 100755
index 0000000000..397ed21e25
--- /dev/null
+++ b/tools/update-packaging/common.sh
@@ -0,0 +1,201 @@
+#!/bin/bash
+# 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/.
+
+#
+# Code shared by update packaging scripts.
+# Author: Darin Fisher
+#
+
+# -----------------------------------------------------------------------------
+QUIET=0
+
+# By default just assume that these tools exist on our path
+MAR=${MAR:-mar}
+MBSDIFF=${MBSDIFF:-mbsdiff}
+XZ=${XZ:-xz}
+$XZ --version > /dev/null 2>&1
+if [ $? -ne 0 ]; then
+ # If $XZ is not set and not found on the path then this is probably
+ # running on a windows buildbot. Some of the Windows build systems have
+ # xz.exe in topsrcdir/xz/. Look in the places this would be in both a
+ # mozilla-central and comm-central build.
+ XZ="$(dirname "$(dirname "$(dirname "$0")")")/xz/xz.exe"
+ $XZ --version > /dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ XZ="$(dirname "$(dirname "$(dirname "$(dirname "$0")")")")/xz/xz.exe"
+ $XZ --version > /dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ echo "xz was not found on this system!"
+ echo "exiting"
+ exit 1
+ fi
+ fi
+fi
+# Ensure that we're always using the right compression settings
+export XZ_OPT="-T1 -7e"
+
+# -----------------------------------------------------------------------------
+# Helper routines
+
+notice() {
+ echo "$*" 1>&2
+}
+
+verbose_notice() {
+ if [ $QUIET -eq 0 ]; then
+ notice "$*"
+ fi
+}
+
+get_file_size() {
+ info=($(ls -ln "$1"))
+ echo ${info[4]}
+}
+
+copy_perm() {
+ reference="$1"
+ target="$2"
+
+ if [ -x "$reference" ]; then
+ chmod 0755 "$target"
+ else
+ chmod 0644 "$target"
+ fi
+}
+
+make_add_instruction() {
+ f="$1"
+ filev3="$2"
+
+ # Used to log to the console
+ if [ $4 ]; then
+ forced=" (forced)"
+ else
+ forced=
+ fi
+
+ is_extension=$(echo "$f" | grep -c 'distribution/extensions/.*/')
+ if [ $is_extension = "1" ]; then
+ # Use the subdirectory of the extensions folder as the file to test
+ # before performing this add instruction.
+ testdir=$(echo "$f" | sed 's/\(.*distribution\/extensions\/[^\/]*\)\/.*/\1/')
+ verbose_notice " add-if \"$testdir\" \"$f\""
+ echo "add-if \"$testdir\" \"$f\"" >> "$filev3"
+ else
+ verbose_notice " add \"$f\"$forced"
+ echo "add \"$f\"" >> "$filev3"
+ fi
+}
+
+check_for_add_if_not_update() {
+ add_if_not_file_chk="$1"
+
+ if [ "$(basename "$add_if_not_file_chk")" = "channel-prefs.js" -o \
+ "$(basename "$add_if_not_file_chk")" = "update-settings.ini" ]; then
+ ## "true" *giggle*
+ return 0;
+ fi
+ ## 'false'... because this is bash. Oh yay!
+ return 1;
+}
+
+make_add_if_not_instruction() {
+ f="$1"
+ filev3="$2"
+
+ verbose_notice " add-if-not \"$f\" \"$f\""
+ echo "add-if-not \"$f\" \"$f\"" >> "$filev3"
+}
+
+make_patch_instruction() {
+ f="$1"
+ filev3="$2"
+
+ is_extension=$(echo "$f" | grep -c 'distribution/extensions/.*/')
+ if [ $is_extension = "1" ]; then
+ # Use the subdirectory of the extensions folder as the file to test
+ # before performing this add instruction.
+ testdir=$(echo "$f" | sed 's/\(.*distribution\/extensions\/[^\/]*\)\/.*/\1/')
+ verbose_notice " patch-if \"$testdir\" \"$f.patch\" \"$f\""
+ echo "patch-if \"$testdir\" \"$f.patch\" \"$f\"" >> "$filev3"
+ else
+ verbose_notice " patch \"$f.patch\" \"$f\""
+ echo "patch \"$f.patch\" \"$f\"" >> "$filev3"
+ fi
+}
+
+append_remove_instructions() {
+ dir="$1"
+ filev3="$2"
+
+ if [ -f "$dir/removed-files" ]; then
+ listfile="$dir/removed-files"
+ elif [ -f "$dir/Contents/Resources/removed-files" ]; then
+ listfile="$dir/Contents/Resources/removed-files"
+ fi
+ if [ -n "$listfile" ]; then
+ # Map spaces to pipes so that we correctly handle filenames with spaces.
+ files=($(cat "$listfile" | tr " " "|" | sort -r))
+ num_files=${#files[*]}
+ for ((i=0; $i<$num_files; i=$i+1)); do
+ # Map pipes back to whitespace and remove carriage returns
+ f=$(echo ${files[$i]} | tr "|" " " | tr -d '\r')
+ # Trim whitespace
+ f=$(echo $f)
+ # Exclude blank lines.
+ if [ -n "$f" ]; then
+ # Exclude comments
+ if [ ! $(echo "$f" | grep -c '^#') = 1 ]; then
+ if [ $(echo "$f" | grep -c '\/$') = 1 ]; then
+ verbose_notice " rmdir \"$f\""
+ echo "rmdir \"$f\"" >> "$filev3"
+ elif [ $(echo "$f" | grep -c '\/\*$') = 1 ]; then
+ # Remove the *
+ f=$(echo "$f" | sed -e 's:\*$::')
+ verbose_notice " rmrfdir \"$f\""
+ echo "rmrfdir \"$f\"" >> "$filev3"
+ else
+ verbose_notice " remove \"$f\""
+ echo "remove \"$f\"" >> "$filev3"
+ fi
+ fi
+ fi
+ done
+ fi
+}
+
+# List all files in the current directory, stripping leading "./"
+# Pass a variable name and it will be filled as an array.
+list_files() {
+ count=0
+ temp_filelist=$(mktemp)
+ find . -type f \
+ ! -name "update.manifest" \
+ ! -name "updatev2.manifest" \
+ ! -name "updatev3.manifest" \
+ | sed 's/\.\/\(.*\)/\1/' \
+ | sort -r > "${temp_filelist}"
+ while read file; do
+ eval "${1}[$count]=\"$file\""
+ (( count++ ))
+ done < "${temp_filelist}"
+ rm "${temp_filelist}"
+}
+
+# List all directories in the current directory, stripping leading "./"
+list_dirs() {
+ count=0
+ temp_dirlist=$(mktemp)
+ find . -type d \
+ ! -name "." \
+ ! -name ".." \
+ | sed 's/\.\/\(.*\)/\1/' \
+ | sort -r > "${temp_dirlist}"
+ while read dir; do
+ eval "${1}[$count]=\"$dir\""
+ (( count++ ))
+ done < "${temp_dirlist}"
+ rm "${temp_dirlist}"
+}
diff --git a/tools/update-packaging/make_full_update.sh b/tools/update-packaging/make_full_update.sh
new file mode 100755
index 0000000000..db2c5898ef
--- /dev/null
+++ b/tools/update-packaging/make_full_update.sh
@@ -0,0 +1,121 @@
+#!/bin/bash
+# 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/.
+
+#
+# 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 " -q be less verbose"
+ notice ""
+ exit 1
+fi
+
+if [ $1 = -q ]; then
+ QUIET=1
+ export QUIET
+ shift
+fi
+
+# -----------------------------------------------------------------------------
+
+mar_command="$MAR -V ${MOZ_PRODUCT_VERSION:?} -H ${MAR_CHANNEL_ID:?}"
+
+archive="$1"
+targetdir="$2"
+# 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
+workdir="$targetdir.work"
+updatemanifestv3="$workdir/updatev3.manifest"
+targetfiles="updatev3.manifest"
+
+mkdir -p "$workdir"
+
+# Generate a list of all files in the target directory.
+pushd "$targetdir"
+if test $? -ne 0 ; then
+ exit 1
+fi
+
+if [ ! -f "precomplete" ]; then
+ if [ ! -f "Contents/Resources/precomplete" ]; then
+ notice "precomplete file is missing!"
+ exit 1
+ fi
+fi
+
+list_files files
+
+popd
+
+# Add the type of update to the beginning of the update manifests.
+> "$updatemanifestv3"
+notice ""
+notice "Adding type instruction to update manifests"
+notice " type complete"
+echo "type \"complete\"" >> "$updatemanifestv3"
+
+notice ""
+notice "Adding file add instructions to update manifests"
+num_files=${#files[*]}
+
+for ((i=0; $i<$num_files; i=$i+1)); do
+ f="${files[$i]}"
+
+ if check_for_add_if_not_update "$f"; then
+ make_add_if_not_instruction "$f" "$updatemanifestv3"
+ else
+ make_add_instruction "$f" "$updatemanifestv3"
+ fi
+
+ dir=$(dirname "$f")
+ mkdir -p "$workdir/$dir"
+ $XZ $XZ_OPT --compress $BCJ_OPTIONS --lzma2 --format=xz --check=crc64 --force --stdout "$targetdir/$f" > "$workdir/$f"
+ copy_perm "$targetdir/$f" "$workdir/$f"
+
+ targetfiles="$targetfiles \"$f\""
+done
+
+# Append remove instructions for any dead files.
+notice ""
+notice "Adding file and directory remove instructions from file 'removed-files'"
+append_remove_instructions "$targetdir" "$updatemanifestv3"
+
+$XZ $XZ_OPT --compress $BCJ_OPTIONS --lzma2 --format=xz --check=crc64 --force "$updatemanifestv3" && mv -f "$updatemanifestv3.xz" "$updatemanifestv3"
+
+mar_command="$mar_command -C \"$workdir\" -c output.mar"
+eval "$mar_command $targetfiles"
+mv -f "$workdir/output.mar" "$archive"
+
+# cleanup
+rm -fr "$workdir"
+
+notice ""
+notice "Finished"
+notice ""
diff --git a/tools/update-packaging/make_incremental_update.sh b/tools/update-packaging/make_incremental_update.sh
new file mode 100755
index 0000000000..31b74813e5
--- /dev/null
+++ b/tools/update-packaging/make_incremental_update.sh
@@ -0,0 +1,313 @@
+#!/bin/bash
+# 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/.
+
+#
+# This tool generates incremental update packages for the update system.
+# Author: Darin Fisher
+#
+
+. $(dirname "$0")/common.sh
+
+# -----------------------------------------------------------------------------
+
+print_usage() {
+ notice "Usage: $(basename $0) [OPTIONS] ARCHIVE FROMDIR TODIR"
+ notice ""
+ notice "The differences between FROMDIR and TODIR will be stored in ARCHIVE."
+ notice ""
+ notice "Options:"
+ notice " -h show this help text"
+ notice " -f clobber this file in the installation"
+ notice " Must be a path to a file to clobber in the partial update."
+ notice " -q be less verbose"
+ notice ""
+}
+
+check_for_forced_update() {
+ force_list="$1"
+ forced_file_chk="$2"
+
+ local f
+
+ if [ "$forced_file_chk" = "precomplete" ]; then
+ ## "true" *giggle*
+ return 0;
+ fi
+
+ if [ "$forced_file_chk" = "Contents/Resources/precomplete" ]; then
+ ## "true" *giggle*
+ return 0;
+ fi
+
+ if [ "$forced_file_chk" = "removed-files" ]; then
+ ## "true" *giggle*
+ return 0;
+ fi
+
+ if [ "$forced_file_chk" = "Contents/Resources/removed-files" ]; then
+ ## "true" *giggle*
+ return 0;
+ fi
+
+ # notarization ticket
+ if [ "$forced_file_chk" = "Contents/CodeResources" ]; then
+ ## "true" *giggle*
+ return 0;
+ fi
+
+ if [ "${forced_file_chk##*.}" = "chk" ]; then
+ ## "true" *giggle*
+ return 0;
+ fi
+
+ for f in $force_list; do
+ #echo comparing $forced_file_chk to $f
+ if [ "$forced_file_chk" = "$f" ]; then
+ ## "true" *giggle*
+ return 0;
+ fi
+ done
+ ## 'false'... because this is bash. Oh yay!
+ return 1;
+}
+
+if [ $# = 0 ]; then
+ print_usage
+ exit 1
+fi
+
+requested_forced_updates='Contents/MacOS/firefox'
+
+while getopts "hqf:" flag
+do
+ case "$flag" in
+ h) print_usage; exit 0
+ ;;
+ q) QUIET=1
+ ;;
+ f) requested_forced_updates="$requested_forced_updates $OPTARG"
+ ;;
+ ?) print_usage; exit 1
+ ;;
+ esac
+done
+
+# -----------------------------------------------------------------------------
+
+mar_command="$MAR -V ${MOZ_PRODUCT_VERSION:?} -H ${MAR_CHANNEL_ID:?}"
+
+let arg_start=$OPTIND-1
+shift $arg_start
+
+archive="$1"
+olddir="$2"
+newdir="$3"
+# Prevent the workdir from being inside the targetdir so it isn't included in
+# the update mar.
+if [ $(echo "$newdir" | grep -c '\/$') = 1 ]; then
+ # Remove the /
+ newdir=$(echo "$newdir" | sed -e 's:\/$::')
+fi
+workdir="$(mktemp -d)"
+updatemanifestv3="$workdir/updatev3.manifest"
+archivefiles="updatev3.manifest"
+
+mkdir -p "$workdir"
+
+# Generate a list of all files in the target directory.
+pushd "$olddir"
+if test $? -ne 0 ; then
+ exit 1
+fi
+
+list_files oldfiles
+list_dirs olddirs
+
+popd
+
+pushd "$newdir"
+if test $? -ne 0 ; then
+ exit 1
+fi
+
+if [ ! -f "precomplete" ]; then
+ if [ ! -f "Contents/Resources/precomplete" ]; then
+ notice "precomplete file is missing!"
+ exit 1
+ fi
+fi
+
+list_dirs newdirs
+list_files newfiles
+
+popd
+
+# Add the type of update to the beginning of the update manifests.
+notice ""
+notice "Adding type instruction to update manifests"
+> $updatemanifestv3
+notice " type partial"
+echo "type \"partial\"" >> $updatemanifestv3
+
+notice ""
+notice "Adding file patch and add instructions to update manifests"
+
+num_oldfiles=${#oldfiles[*]}
+remove_array=
+num_removes=0
+
+for ((i=0; $i<$num_oldfiles; i=$i+1)); do
+ f="${oldfiles[$i]}"
+
+ # If this file exists in the new directory as well, then check if it differs.
+ if [ -f "$newdir/$f" ]; then
+
+ if check_for_add_if_not_update "$f"; then
+ # The full workdir may not exist yet, so create it if necessary.
+ mkdir -p "$(dirname "$workdir/$f")"
+ $XZ $XZ_OPT --compress $BCJ_OPTIONS --lzma2 --format=xz --check=crc64 --force --stdout "$newdir/$f" > "$workdir/$f"
+ copy_perm "$newdir/$f" "$workdir/$f"
+ make_add_if_not_instruction "$f" "$updatemanifestv3"
+ archivefiles="$archivefiles \"$f\""
+ continue 1
+ fi
+
+ if check_for_forced_update "$requested_forced_updates" "$f"; then
+ # The full workdir may not exist yet, so create it if necessary.
+ mkdir -p "$(dirname "$workdir/$f")"
+ $XZ $XZ_OPT --compress $BCJ_OPTIONS --lzma2 --format=xz --check=crc64 --force --stdout "$newdir/$f" > "$workdir/$f"
+ copy_perm "$newdir/$f" "$workdir/$f"
+ make_add_instruction "$f" "$updatemanifestv3" 1
+ archivefiles="$archivefiles \"$f\""
+ continue 1
+ fi
+
+ if ! diff "$olddir/$f" "$newdir/$f" > /dev/null; then
+ # Compute both the compressed binary diff and the compressed file, and
+ # compare the sizes. Then choose the smaller of the two to package.
+ dir=$(dirname "$workdir/$f")
+ mkdir -p "$dir"
+ verbose_notice "diffing \"$f\""
+ # MBSDIFF_HOOK represents the communication interface with funsize and,
+ # if enabled, caches the intermediate patches for future use and
+ # compute avoidance
+ #
+ # An example of MBSDIFF_HOOK env variable could look like this:
+ # export MBSDIFF_HOOK="myscript.sh -A https://funsize/api -c /home/user"
+ # where myscript.sh has the following usage:
+ # myscript.sh -A SERVER-URL [-c LOCAL-CACHE-DIR-PATH] [-g] [-u] \
+ # PATH-FROM-URL PATH-TO-URL PATH-PATCH SERVER-URL
+ #
+ # Note: patches are bzipped or xz stashed in funsize to gain more speed
+
+ # if service is not enabled then default to old behavior
+ if [ -z "$MBSDIFF_HOOK" ]; then
+ $MBSDIFF "$olddir/$f" "$newdir/$f" "$workdir/$f.patch"
+ $XZ $XZ_OPT --compress --lzma2 --format=xz --check=crc64 --force "$workdir/$f.patch"
+ else
+ # if service enabled then check patch existence for retrieval
+ if $MBSDIFF_HOOK -g "$olddir/$f" "$newdir/$f" "$workdir/$f.patch.xz"; then
+ verbose_notice "file \"$f\" found in funsize, diffing skipped"
+ else
+ # if not found already - compute it and cache it for future use
+ $MBSDIFF "$olddir/$f" "$newdir/$f" "$workdir/$f.patch"
+ $XZ $XZ_OPT --compress --lzma2 --format=xz --check=crc64 --force "$workdir/$f.patch"
+ $MBSDIFF_HOOK -u "$olddir/$f" "$newdir/$f" "$workdir/$f.patch.xz"
+ fi
+ fi
+ $XZ $XZ_OPT --compress $BCJ_OPTIONS --lzma2 --format=xz --check=crc64 --force --stdout "$newdir/$f" > "$workdir/$f"
+ copy_perm "$newdir/$f" "$workdir/$f"
+ patchfile="$workdir/$f.patch.xz"
+ patchsize=$(get_file_size "$patchfile")
+ fullsize=$(get_file_size "$workdir/$f")
+
+ if [ $patchsize -lt $fullsize ]; then
+ make_patch_instruction "$f" "$updatemanifestv3"
+ mv -f "$patchfile" "$workdir/$f.patch"
+ rm -f "$workdir/$f"
+ archivefiles="$archivefiles \"$f.patch\""
+ else
+ make_add_instruction "$f" "$updatemanifestv3"
+ rm -f "$patchfile"
+ archivefiles="$archivefiles \"$f\""
+ fi
+ fi
+ else
+ # remove instructions are added after add / patch instructions for
+ # consistency with make_incremental_updates.py
+ remove_array[$num_removes]=$f
+ (( num_removes++ ))
+ fi
+done
+
+# Newly added files
+notice ""
+notice "Adding file add instructions to update manifests"
+num_newfiles=${#newfiles[*]}
+
+for ((i=0; $i<$num_newfiles; i=$i+1)); do
+ f="${newfiles[$i]}"
+
+ # If we've already tested this file, then skip it
+ for ((j=0; $j<$num_oldfiles; j=$j+1)); do
+ if [ "$f" = "${oldfiles[j]}" ]; then
+ continue 2
+ fi
+ done
+
+ dir=$(dirname "$workdir/$f")
+ mkdir -p "$dir"
+
+ $XZ $XZ_OPT --compress $BCJ_OPTIONS --lzma2 --format=xz --check=crc64 --force --stdout "$newdir/$f" > "$workdir/$f"
+ copy_perm "$newdir/$f" "$workdir/$f"
+
+ if check_for_add_if_not_update "$f"; then
+ make_add_if_not_instruction "$f" "$updatemanifestv3"
+ else
+ make_add_instruction "$f" "$updatemanifestv3"
+ fi
+
+
+ archivefiles="$archivefiles \"$f\""
+done
+
+notice ""
+notice "Adding file remove instructions to update manifests"
+for ((i=0; $i<$num_removes; i=$i+1)); do
+ f="${remove_array[$i]}"
+ verbose_notice " remove \"$f\""
+ echo "remove \"$f\"" >> $updatemanifestv3
+done
+
+# Add remove instructions for any dead files.
+notice ""
+notice "Adding file and directory remove instructions from file 'removed-files'"
+append_remove_instructions "$newdir" "$updatemanifestv3"
+
+notice ""
+notice "Adding directory remove instructions for directories that no longer exist"
+num_olddirs=${#olddirs[*]}
+
+for ((i=0; $i<$num_olddirs; i=$i+1)); do
+ f="${olddirs[$i]}"
+ # If this dir doesn't exist in the new directory remove it.
+ if [ ! -d "$newdir/$f" ]; then
+ verbose_notice " rmdir $f/"
+ echo "rmdir \"$f/\"" >> $updatemanifestv3
+ fi
+done
+
+$XZ $XZ_OPT --compress $BCJ_OPTIONS --lzma2 --format=xz --check=crc64 --force "$updatemanifestv3" && mv -f "$updatemanifestv3.xz" "$updatemanifestv3"
+
+mar_command="$mar_command -C \"$workdir\" -c output.mar"
+eval "$mar_command $archivefiles"
+mv -f "$workdir/output.mar" "$archive"
+
+# cleanup
+rm -fr "$workdir"
+
+notice ""
+notice "Finished"
+notice ""
diff --git a/tools/update-packaging/moz.build b/tools/update-packaging/moz.build
new file mode 100644
index 0000000000..568f361a54
--- /dev/null
+++ b/tools/update-packaging/moz.build
@@ -0,0 +1,5 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# 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/.
diff --git a/tools/update-packaging/moz.configure b/tools/update-packaging/moz.configure
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tools/update-packaging/moz.configure
diff --git a/tools/update-packaging/test/buildrefmars.sh b/tools/update-packaging/test/buildrefmars.sh
new file mode 100755
index 0000000000..fd2d5384d7
--- /dev/null
+++ b/tools/update-packaging/test/buildrefmars.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+# Builds all the reference mars
+
+if [ -f "ref.mar" ]; then
+ rm "ref.mar"
+fi
+if [ -f "ref-mac.mar" ]; then
+ rm "ref-mac.mar"
+fi
+
+ ../make_incremental_update.sh ref.mar `pwd`/from `pwd`/to
+ ../make_incremental_update.sh ref-mac.mar `pwd`/from-mac `pwd`/to-mac
+
+if [ -f "product-1.0.lang.platform.complete.mar" ]; then
+ rm "product-1.0.lang.platform.complete.mar"
+fi
+if [ -f "product-2.0.lang.platform.complete.mar" ]; then
+ rm "product-2.0.lang.platform.complete.mar"
+fi
+if [ -f "product-2.0.lang.mac.complete.mar" ]; then
+ rm "product-2.0.lang.mac.complete.mar"
+fi
+
+./make_full_update.sh product-1.0.lang.platform.complete.mar "`pwd`/from"
+./make_full_update.sh product-2.0.lang.platform.complete.mar "`pwd`/to"
+./make_full_update.sh product-1.0.lang.mac.complete.mar "`pwd`/from-mac"
+./make_full_update.sh product-2.0.lang.mac.complete.mar "`pwd`/to-mac"
diff --git a/tools/update-packaging/test/common.sh b/tools/update-packaging/test/common.sh
new file mode 100755
index 0000000000..0e1857c8b2
--- /dev/null
+++ b/tools/update-packaging/test/common.sh
@@ -0,0 +1,202 @@
+#!/bin/bash
+# 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/.
+
+#
+# Code shared by update packaging scripts.
+# Author: Darin Fisher
+#
+# In here to use the local common.sh to allow the full mars to have unfiltered files
+
+# -----------------------------------------------------------------------------
+# By default just assume that these tools exist on our path
+MAR=${MAR:-mar}
+XZ=${XZ:-xz}
+MBSDIFF=${MBSDIFF:-mbsdiff}
+
+# -----------------------------------------------------------------------------
+# Helper routines
+
+notice() {
+ echo "$*" 1>&2
+}
+
+get_file_size() {
+ info=($(ls -ln "$1"))
+ echo ${info[4]}
+}
+
+copy_perm() {
+ reference="$1"
+ target="$2"
+
+ if [ -x "$reference" ]; then
+ chmod 0755 "$target"
+ else
+ chmod 0644 "$target"
+ fi
+}
+
+make_add_instruction() {
+ f="$1"
+ filev2="$2"
+ # The third param will be an empty string when a file add instruction is only
+ # needed in the version 2 manifest. This only happens when the file has an
+ # add-if-not instruction in the version 3 manifest. This is due to the
+ # precomplete file prior to the version 3 manifest having a remove instruction
+ # for this file so the file is removed before applying a complete update.
+ filev3="$3"
+
+ # Used to log to the console
+ if [ $4 ]; then
+ forced=" (forced)"
+ else
+ forced=
+ fi
+
+ is_extension=$(echo "$f" | grep -c 'distribution/extensions/.*/')
+ if [ $is_extension = "1" ]; then
+ # Use the subdirectory of the extensions folder as the file to test
+ # before performing this add instruction.
+ testdir=$(echo "$f" | sed 's/\(.*distribution\/extensions\/[^\/]*\)\/.*/\1/')
+ notice " add-if \"$testdir\" \"$f\""
+ echo "add-if \"$testdir\" \"$f\"" >> $filev2
+ if [ ! $filev3 = "" ]; then
+ echo "add-if \"$testdir\" \"$f\"" >> $filev3
+ fi
+ else
+ notice " add \"$f\"$forced"
+ echo "add \"$f\"" >> $filev2
+ if [ ! $filev3 = "" ]; then
+ echo "add \"$f\"" >> $filev3
+ fi
+ fi
+}
+
+check_for_add_if_not_update() {
+ add_if_not_file_chk="$1"
+
+ if [ "$(basename "$add_if_not_file_chk")" = "channel-prefs.js" -o \
+ "$(basename "$add_if_not_file_chk")" = "update-settings.ini" ]; then
+ ## "true" *giggle*
+ return 0;
+ fi
+ ## 'false'... because this is bash. Oh yay!
+ return 1;
+}
+
+check_for_add_to_manifestv2() {
+ add_if_not_file_chk="$1"
+
+ if [ "$(basename "$add_if_not_file_chk")" = "update-settings.ini" ]; then
+ ## "true" *giggle*
+ return 0;
+ fi
+ ## 'false'... because this is bash. Oh yay!
+ return 1;
+}
+
+make_add_if_not_instruction() {
+ f="$1"
+ filev3="$2"
+
+ notice " add-if-not \"$f\" \"$f\""
+ echo "add-if-not \"$f\" \"$f\"" >> $filev3
+}
+
+make_patch_instruction() {
+ f="$1"
+ filev2="$2"
+ filev3="$3"
+
+ is_extension=$(echo "$f" | grep -c 'distribution/extensions/.*/')
+ if [ $is_extension = "1" ]; then
+ # Use the subdirectory of the extensions folder as the file to test
+ # before performing this add instruction.
+ testdir=$(echo "$f" | sed 's/\(.*distribution\/extensions\/[^\/]*\)\/.*/\1/')
+ notice " patch-if \"$testdir\" \"$f.patch\" \"$f\""
+ echo "patch-if \"$testdir\" \"$f.patch\" \"$f\"" >> $filev2
+ echo "patch-if \"$testdir\" \"$f.patch\" \"$f\"" >> $filev3
+ else
+ notice " patch \"$f.patch\" \"$f\""
+ echo "patch \"$f.patch\" \"$f\"" >> $filev2
+ echo "patch \"$f.patch\" \"$f\"" >> $filev3
+ fi
+}
+
+append_remove_instructions() {
+ dir="$1"
+ filev2="$2"
+ filev3="$3"
+
+ if [ -f "$dir/removed-files" ]; then
+ listfile="$dir/removed-files"
+ elif [ -f "$dir/Contents/Resources/removed-files" ]; then
+ listfile="$dir/Contents/Resources/removed-files"
+ fi
+ if [ -n "$listfile" ]; then
+ # Map spaces to pipes so that we correctly handle filenames with spaces.
+ files=($(cat "$listfile" | tr " " "|" | sort -r))
+ num_files=${#files[*]}
+ for ((i=0; $i<$num_files; i=$i+1)); do
+ # Map pipes back to whitespace and remove carriage returns
+ f=$(echo ${files[$i]} | tr "|" " " | tr -d '\r')
+ # Trim whitespace
+ f=$(echo $f)
+ # Exclude blank lines.
+ if [ -n "$f" ]; then
+ # Exclude comments
+ if [ ! $(echo "$f" | grep -c '^#') = 1 ]; then
+ if [ $(echo "$f" | grep -c '\/$') = 1 ]; then
+ notice " rmdir \"$f\""
+ echo "rmdir \"$f\"" >> $filev2
+ echo "rmdir \"$f\"" >> $filev3
+ elif [ $(echo "$f" | grep -c '\/\*$') = 1 ]; then
+ # Remove the *
+ f=$(echo "$f" | sed -e 's:\*$::')
+ notice " rmrfdir \"$f\""
+ echo "rmrfdir \"$f\"" >> $filev2
+ echo "rmrfdir \"$f\"" >> $filev3
+ else
+ notice " remove \"$f\""
+ echo "remove \"$f\"" >> $filev2
+ echo "remove \"$f\"" >> $filev3
+ fi
+ fi
+ fi
+ done
+ fi
+}
+
+# List all files in the current directory, stripping leading "./"
+# Pass a variable name and it will be filled as an array.
+list_files() {
+ count=0
+
+ # Removed the exclusion cases here to allow for generation of testing mars
+ find . -type f \
+ | sed 's/\.\/\(.*\)/\1/' \
+ | sort -r > "$workdir/temp-filelist"
+ while read file; do
+ eval "${1}[$count]=\"$file\""
+ (( count++ ))
+ done < "$workdir/temp-filelist"
+ rm "$workdir/temp-filelist"
+}
+
+# List all directories in the current directory, stripping leading "./"
+list_dirs() {
+ count=0
+
+ find . -type d \
+ ! -name "." \
+ ! -name ".." \
+ | sed 's/\.\/\(.*\)/\1/' \
+ | sort -r > "$workdir/temp-dirlist"
+ while read dir; do
+ eval "${1}[$count]=\"$dir\""
+ (( count++ ))
+ done < "$workdir/temp-dirlist"
+ rm "$workdir/temp-dirlist"
+}
diff --git a/tools/update-packaging/test/diffmar.sh b/tools/update-packaging/test/diffmar.sh
new file mode 100755
index 0000000000..4b16ffb77a
--- /dev/null
+++ b/tools/update-packaging/test/diffmar.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+# Compares two mars
+
+marA="$1"
+marB="$2"
+testDir="$3"
+workdir="/tmp/diffmar/$testDir"
+fromdir="$workdir/0"
+todir="$workdir/1"
+
+# On Windows, creation time can be off by a second or more between the files in
+# the fromdir and todir due to them being extracted synchronously so use
+# time-style and exclude seconds from the creation time.
+lsargs="-algR"
+unamestr=`uname`
+if [ ! "$unamestr" = 'Darwin' ]; then
+ unamestr=`uname -o`
+ if [ "$unamestr" = 'Msys' -o "$unamestr" = "Cygwin" ]; then
+ lsargs="-algR --time-style=+%Y-%m-%d-%H:%M"
+ fi
+fi
+
+rm -rf "$workdir"
+mkdir -p "$fromdir"
+mkdir -p "$todir"
+
+cp "$1" "$fromdir"
+cp "$2" "$todir"
+
+cd "$fromdir"
+mar -x "$1"
+rm "$1"
+rm -f updatev2.manifest # Older files may contain this
+mv updatev3.manifest updatev3.manifest.xz
+xz -d updatev3.manifest.xz
+ls $lsargs > files.txt
+
+cd "$todir"
+mar -x "$2"
+rm "$2"
+mv updatev3.manifest updatev3.manifest.xz
+xz -d updatev3.manifest.xz
+ls $lsargs > files.txt
+
+echo "diffing $fromdir and $todir"
+echo "on linux shell sort and python sort return different results"
+echo "which can cause differences in the manifest files"
+diff -ru "$fromdir" "$todir"
diff --git a/tools/update-packaging/test/from-mac/Contents/MacOS/diff-patch-larger-than-file.txt b/tools/update-packaging/test/from-mac/Contents/MacOS/diff-patch-larger-than-file.txt
new file mode 100644
index 0000000000..8098d25853
--- /dev/null
+++ b/tools/update-packaging/test/from-mac/Contents/MacOS/diff-patch-larger-than-file.txt
@@ -0,0 +1 @@
+from file
diff --git a/tools/update-packaging/test/from-mac/Contents/MacOS/force.txt b/tools/update-packaging/test/from-mac/Contents/MacOS/force.txt
new file mode 100644
index 0000000000..0ed0d50124
--- /dev/null
+++ b/tools/update-packaging/test/from-mac/Contents/MacOS/force.txt
@@ -0,0 +1 @@
+file is same
diff --git a/tools/update-packaging/test/from-mac/Contents/MacOS/removed.txt b/tools/update-packaging/test/from-mac/Contents/MacOS/removed.txt
new file mode 100644
index 0000000000..2c3f0b3406
--- /dev/null
+++ b/tools/update-packaging/test/from-mac/Contents/MacOS/removed.txt
@@ -0,0 +1 @@
+removed
diff --git a/tools/update-packaging/test/from-mac/Contents/MacOS/same.bin b/tools/update-packaging/test/from-mac/Contents/MacOS/same.bin
new file mode 100644
index 0000000000..a9ee7258cc
--- /dev/null
+++ b/tools/update-packaging/test/from-mac/Contents/MacOS/same.bin
Binary files differ
diff --git a/tools/update-packaging/test/from-mac/Contents/MacOS/update.manifest b/tools/update-packaging/test/from-mac/Contents/MacOS/update.manifest
new file mode 100644
index 0000000000..d3e8ed851b
--- /dev/null
+++ b/tools/update-packaging/test/from-mac/Contents/MacOS/update.manifest
@@ -0,0 +1 @@
+from file shouldn't go in update
diff --git a/tools/update-packaging/test/from-mac/Contents/MacOS/{foodir/diff-patch-larger-than-file.txt b/tools/update-packaging/test/from-mac/Contents/MacOS/{foodir/diff-patch-larger-than-file.txt
new file mode 100644
index 0000000000..8098d25853
--- /dev/null
+++ b/tools/update-packaging/test/from-mac/Contents/MacOS/{foodir/diff-patch-larger-than-file.txt
@@ -0,0 +1 @@
+from file
diff --git a/tools/update-packaging/test/from-mac/Contents/MacOS/{foodir/readme.txt b/tools/update-packaging/test/from-mac/Contents/MacOS/{foodir/readme.txt
new file mode 100644
index 0000000000..d7c40c63cd
--- /dev/null
+++ b/tools/update-packaging/test/from-mac/Contents/MacOS/{foodir/readme.txt
@@ -0,0 +1 @@
+This from file should be ignored
diff --git a/tools/update-packaging/test/from-mac/Contents/MacOS/{foodir/removed.txt b/tools/update-packaging/test/from-mac/Contents/MacOS/{foodir/removed.txt
new file mode 100644
index 0000000000..2c3f0b3406
--- /dev/null
+++ b/tools/update-packaging/test/from-mac/Contents/MacOS/{foodir/removed.txt
@@ -0,0 +1 @@
+removed
diff --git a/tools/update-packaging/test/from-mac/Contents/MacOS/{foodir/same.bin b/tools/update-packaging/test/from-mac/Contents/MacOS/{foodir/same.bin
new file mode 100644
index 0000000000..a9ee7258cc
--- /dev/null
+++ b/tools/update-packaging/test/from-mac/Contents/MacOS/{foodir/same.bin
Binary files differ
diff --git a/tools/update-packaging/test/from-mac/Contents/MacOS/{foodir/same.txt b/tools/update-packaging/test/from-mac/Contents/MacOS/{foodir/same.txt
new file mode 100644
index 0000000000..0ed0d50124
--- /dev/null
+++ b/tools/update-packaging/test/from-mac/Contents/MacOS/{foodir/same.txt
@@ -0,0 +1 @@
+file is same
diff --git a/tools/update-packaging/test/from-mac/Contents/MacOS/{foodir/update.manifest b/tools/update-packaging/test/from-mac/Contents/MacOS/{foodir/update.manifest
new file mode 100644
index 0000000000..d3e8ed851b
--- /dev/null
+++ b/tools/update-packaging/test/from-mac/Contents/MacOS/{foodir/update.manifest
@@ -0,0 +1 @@
+from file shouldn't go in update
diff --git a/tools/update-packaging/test/from-mac/Contents/Resources/application.ini b/tools/update-packaging/test/from-mac/Contents/Resources/application.ini
new file mode 100644
index 0000000000..942e91a16a
--- /dev/null
+++ b/tools/update-packaging/test/from-mac/Contents/Resources/application.ini
@@ -0,0 +1,5 @@
+[App]
+Vendor=Mozilla
+Name=MarTest
+Version=1
+BuildID=20120101010101
diff --git a/tools/update-packaging/test/from-mac/Contents/Resources/chrome.manifest b/tools/update-packaging/test/from-mac/Contents/Resources/chrome.manifest
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tools/update-packaging/test/from-mac/Contents/Resources/chrome.manifest
diff --git a/tools/update-packaging/test/from-mac/Contents/Resources/distribution/extensions/diff/diff-patch-larger-than-file.txt b/tools/update-packaging/test/from-mac/Contents/Resources/distribution/extensions/diff/diff-patch-larger-than-file.txt
new file mode 100644
index 0000000000..8098d25853
--- /dev/null
+++ b/tools/update-packaging/test/from-mac/Contents/Resources/distribution/extensions/diff/diff-patch-larger-than-file.txt
@@ -0,0 +1 @@
+from file
diff --git a/tools/update-packaging/test/from-mac/Contents/Resources/extensions/diff/diff-patch-larger-than-file.txt b/tools/update-packaging/test/from-mac/Contents/Resources/extensions/diff/diff-patch-larger-than-file.txt
new file mode 100644
index 0000000000..8098d25853
--- /dev/null
+++ b/tools/update-packaging/test/from-mac/Contents/Resources/extensions/diff/diff-patch-larger-than-file.txt
@@ -0,0 +1 @@
+from file
diff --git a/tools/update-packaging/test/from-mac/Contents/Resources/precomplete b/tools/update-packaging/test/from-mac/Contents/Resources/precomplete
new file mode 100644
index 0000000000..2d9068d372
--- /dev/null
+++ b/tools/update-packaging/test/from-mac/Contents/Resources/precomplete
@@ -0,0 +1,26 @@
+remove "Contents/MacOS/{foodir/update.manifest"
+remove "Contents/MacOS/{foodir/same.txt"
+remove "Contents/MacOS/{foodir/same.bin"
+remove "Contents/MacOS/{foodir/removed.txt"
+remove "Contents/MacOS/{foodir/readme.txt"
+remove "Contents/MacOS/{foodir/force.txt"
+remove "Contents/MacOS/{foodir/diff-patch-larger-than-file.txt"
+remove "Contents/MacOS/update.manifest"
+remove "Contents/MacOS/searchplugins/diff/diff-patch-larger-than-file.txt"
+remove "Contents/MacOS/same.txt"
+remove "Contents/MacOS/same.bin"
+remove "Contents/MacOS/removed.txt"
+remove "Contents/MacOS/readme.txt"
+remove "Contents/MacOS/force.txt"
+remove "Contents/MacOS/extensions/diff/diff-patch-larger-than-file.txt"
+remove "Contents/MacOS/diff-patch-larger-than-file.txt"
+remove "Contents/MacOS/application.ini"
+remove "Contents/Resources/precomplete"
+rmdir "Contents/MacOS/{foodir/"
+rmdir "Contents/MacOS/searchplugins/diff/"
+rmdir "Contents/MacOS/searchplugins/"
+rmdir "Contents/MacOS/extensions/diff/"
+rmdir "Contents/MacOS/extensions/"
+rmdir "Contents/MacOS/"
+rmdir "Contents/Resources/"
+rmdir "Contents/"
diff --git a/tools/update-packaging/test/from-mac/Contents/Resources/readme.txt b/tools/update-packaging/test/from-mac/Contents/Resources/readme.txt
new file mode 100644
index 0000000000..b1a96f1fea
--- /dev/null
+++ b/tools/update-packaging/test/from-mac/Contents/Resources/readme.txt
@@ -0,0 +1,2 @@
+This from file should be ignored
+
diff --git a/tools/update-packaging/test/from-mac/Contents/Resources/removed-files b/tools/update-packaging/test/from-mac/Contents/Resources/removed-files
new file mode 100644
index 0000000000..5bbdac6f62
--- /dev/null
+++ b/tools/update-packaging/test/from-mac/Contents/Resources/removed-files
@@ -0,0 +1,8 @@
+Contents/Resources/removed1.txt
+Contents/MacOS/removed2.bin
+Contents/MacOS/recursivedir/meh/*
+Contents/Resources/dir/
+Contents/MacOS/this file has spaces
+
+
+Contents/MacOS/extra-spaces
diff --git a/tools/update-packaging/test/from-mac/Contents/Resources/removed.txt b/tools/update-packaging/test/from-mac/Contents/Resources/removed.txt
new file mode 100644
index 0000000000..2c3f0b3406
--- /dev/null
+++ b/tools/update-packaging/test/from-mac/Contents/Resources/removed.txt
@@ -0,0 +1 @@
+removed
diff --git a/tools/update-packaging/test/from-mac/Contents/Resources/same.txt b/tools/update-packaging/test/from-mac/Contents/Resources/same.txt
new file mode 100644
index 0000000000..0ed0d50124
--- /dev/null
+++ b/tools/update-packaging/test/from-mac/Contents/Resources/same.txt
@@ -0,0 +1 @@
+file is same
diff --git a/tools/update-packaging/test/from-mac/Contents/Resources/searchplugins/diff/diff-patch-larger-than-file.txt b/tools/update-packaging/test/from-mac/Contents/Resources/searchplugins/diff/diff-patch-larger-than-file.txt
new file mode 100644
index 0000000000..8098d25853
--- /dev/null
+++ b/tools/update-packaging/test/from-mac/Contents/Resources/searchplugins/diff/diff-patch-larger-than-file.txt
@@ -0,0 +1 @@
+from file
diff --git a/tools/update-packaging/test/from-mac/Contents/Resources/update-settings.ini b/tools/update-packaging/test/from-mac/Contents/Resources/update-settings.ini
new file mode 100644
index 0000000000..5fa6a9909e
--- /dev/null
+++ b/tools/update-packaging/test/from-mac/Contents/Resources/update-settings.ini
@@ -0,0 +1 @@
+add-if-not from complete file
diff --git a/tools/update-packaging/test/from-mac/Contents/Resources/{foodir/channel-prefs.js b/tools/update-packaging/test/from-mac/Contents/Resources/{foodir/channel-prefs.js
new file mode 100644
index 0000000000..5fa6a9909e
--- /dev/null
+++ b/tools/update-packaging/test/from-mac/Contents/Resources/{foodir/channel-prefs.js
@@ -0,0 +1 @@
+add-if-not from complete file
diff --git a/tools/update-packaging/test/from-mac/Contents/Resources/{foodir/force.txt b/tools/update-packaging/test/from-mac/Contents/Resources/{foodir/force.txt
new file mode 100644
index 0000000000..0ed0d50124
--- /dev/null
+++ b/tools/update-packaging/test/from-mac/Contents/Resources/{foodir/force.txt
@@ -0,0 +1 @@
+file is same
diff --git a/tools/update-packaging/test/from/application.ini b/tools/update-packaging/test/from/application.ini
new file mode 100644
index 0000000000..942e91a16a
--- /dev/null
+++ b/tools/update-packaging/test/from/application.ini
@@ -0,0 +1,5 @@
+[App]
+Vendor=Mozilla
+Name=MarTest
+Version=1
+BuildID=20120101010101
diff --git a/tools/update-packaging/test/from/chrome.manifest b/tools/update-packaging/test/from/chrome.manifest
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tools/update-packaging/test/from/chrome.manifest
diff --git a/tools/update-packaging/test/from/diff-patch-larger-than-file.txt b/tools/update-packaging/test/from/diff-patch-larger-than-file.txt
new file mode 100644
index 0000000000..8098d25853
--- /dev/null
+++ b/tools/update-packaging/test/from/diff-patch-larger-than-file.txt
@@ -0,0 +1 @@
+from file
diff --git a/tools/update-packaging/test/from/distribution/extensions/diff/diff-patch-larger-than-file.txt b/tools/update-packaging/test/from/distribution/extensions/diff/diff-patch-larger-than-file.txt
new file mode 100644
index 0000000000..8098d25853
--- /dev/null
+++ b/tools/update-packaging/test/from/distribution/extensions/diff/diff-patch-larger-than-file.txt
@@ -0,0 +1 @@
+from file
diff --git a/tools/update-packaging/test/from/extensions/diff/diff-patch-larger-than-file.txt b/tools/update-packaging/test/from/extensions/diff/diff-patch-larger-than-file.txt
new file mode 100644
index 0000000000..8098d25853
--- /dev/null
+++ b/tools/update-packaging/test/from/extensions/diff/diff-patch-larger-than-file.txt
@@ -0,0 +1 @@
+from file
diff --git a/tools/update-packaging/test/from/force.txt b/tools/update-packaging/test/from/force.txt
new file mode 100644
index 0000000000..0ed0d50124
--- /dev/null
+++ b/tools/update-packaging/test/from/force.txt
@@ -0,0 +1 @@
+file is same
diff --git a/tools/update-packaging/test/from/precomplete b/tools/update-packaging/test/from/precomplete
new file mode 100644
index 0000000000..e27f4fc31c
--- /dev/null
+++ b/tools/update-packaging/test/from/precomplete
@@ -0,0 +1,23 @@
+remove "{foodir/update.manifest"
+remove "{foodir/same.txt"
+remove "{foodir/same.bin"
+remove "{foodir/removed.txt"
+remove "{foodir/readme.txt"
+remove "{foodir/force.txt"
+remove "{foodir/diff-patch-larger-than-file.txt"
+remove "update.manifest"
+remove "searchplugins/diff/diff-patch-larger-than-file.txt"
+remove "same.txt"
+remove "same.bin"
+remove "removed.txt"
+remove "readme.txt"
+remove "precomplete"
+remove "force.txt"
+remove "extensions/diff/diff-patch-larger-than-file.txt"
+remove "diff-patch-larger-than-file.txt"
+remove "application.ini"
+rmdir "{foodir/"
+rmdir "searchplugins/diff/"
+rmdir "searchplugins/"
+rmdir "extensions/diff/"
+rmdir "extensions/"
diff --git a/tools/update-packaging/test/from/readme.txt b/tools/update-packaging/test/from/readme.txt
new file mode 100644
index 0000000000..b1a96f1fea
--- /dev/null
+++ b/tools/update-packaging/test/from/readme.txt
@@ -0,0 +1,2 @@
+This from file should be ignored
+
diff --git a/tools/update-packaging/test/from/removed-files b/tools/update-packaging/test/from/removed-files
new file mode 100644
index 0000000000..73b348d9c4
--- /dev/null
+++ b/tools/update-packaging/test/from/removed-files
@@ -0,0 +1,8 @@
+removed1.txt
+removed2.bin
+recursivedir/meh/*
+dir/
+this file has spaces
+
+
+extra-spaces
diff --git a/tools/update-packaging/test/from/removed.txt b/tools/update-packaging/test/from/removed.txt
new file mode 100644
index 0000000000..2c3f0b3406
--- /dev/null
+++ b/tools/update-packaging/test/from/removed.txt
@@ -0,0 +1 @@
+removed
diff --git a/tools/update-packaging/test/from/same.bin b/tools/update-packaging/test/from/same.bin
new file mode 100644
index 0000000000..a9ee7258cc
--- /dev/null
+++ b/tools/update-packaging/test/from/same.bin
Binary files differ
diff --git a/tools/update-packaging/test/from/same.txt b/tools/update-packaging/test/from/same.txt
new file mode 100644
index 0000000000..0ed0d50124
--- /dev/null
+++ b/tools/update-packaging/test/from/same.txt
@@ -0,0 +1 @@
+file is same
diff --git a/tools/update-packaging/test/from/searchplugins/diff/diff-patch-larger-than-file.txt b/tools/update-packaging/test/from/searchplugins/diff/diff-patch-larger-than-file.txt
new file mode 100644
index 0000000000..8098d25853
--- /dev/null
+++ b/tools/update-packaging/test/from/searchplugins/diff/diff-patch-larger-than-file.txt
@@ -0,0 +1 @@
+from file
diff --git a/tools/update-packaging/test/from/update-settings.ini b/tools/update-packaging/test/from/update-settings.ini
new file mode 100644
index 0000000000..5fa6a9909e
--- /dev/null
+++ b/tools/update-packaging/test/from/update-settings.ini
@@ -0,0 +1 @@
+add-if-not from complete file
diff --git a/tools/update-packaging/test/from/update.manifest b/tools/update-packaging/test/from/update.manifest
new file mode 100644
index 0000000000..d3e8ed851b
--- /dev/null
+++ b/tools/update-packaging/test/from/update.manifest
@@ -0,0 +1 @@
+from file shouldn't go in update
diff --git a/tools/update-packaging/test/from/{foodir/channel-prefs.js b/tools/update-packaging/test/from/{foodir/channel-prefs.js
new file mode 100644
index 0000000000..5fa6a9909e
--- /dev/null
+++ b/tools/update-packaging/test/from/{foodir/channel-prefs.js
@@ -0,0 +1 @@
+add-if-not from complete file
diff --git a/tools/update-packaging/test/from/{foodir/diff-patch-larger-than-file.txt b/tools/update-packaging/test/from/{foodir/diff-patch-larger-than-file.txt
new file mode 100644
index 0000000000..8098d25853
--- /dev/null
+++ b/tools/update-packaging/test/from/{foodir/diff-patch-larger-than-file.txt
@@ -0,0 +1 @@
+from file
diff --git a/tools/update-packaging/test/from/{foodir/force.txt b/tools/update-packaging/test/from/{foodir/force.txt
new file mode 100644
index 0000000000..0ed0d50124
--- /dev/null
+++ b/tools/update-packaging/test/from/{foodir/force.txt
@@ -0,0 +1 @@
+file is same
diff --git a/tools/update-packaging/test/from/{foodir/readme.txt b/tools/update-packaging/test/from/{foodir/readme.txt
new file mode 100644
index 0000000000..d7c40c63cd
--- /dev/null
+++ b/tools/update-packaging/test/from/{foodir/readme.txt
@@ -0,0 +1 @@
+This from file should be ignored
diff --git a/tools/update-packaging/test/from/{foodir/removed.txt b/tools/update-packaging/test/from/{foodir/removed.txt
new file mode 100644
index 0000000000..2c3f0b3406
--- /dev/null
+++ b/tools/update-packaging/test/from/{foodir/removed.txt
@@ -0,0 +1 @@
+removed
diff --git a/tools/update-packaging/test/from/{foodir/same.bin b/tools/update-packaging/test/from/{foodir/same.bin
new file mode 100644
index 0000000000..a9ee7258cc
--- /dev/null
+++ b/tools/update-packaging/test/from/{foodir/same.bin
Binary files differ
diff --git a/tools/update-packaging/test/from/{foodir/same.txt b/tools/update-packaging/test/from/{foodir/same.txt
new file mode 100644
index 0000000000..0ed0d50124
--- /dev/null
+++ b/tools/update-packaging/test/from/{foodir/same.txt
@@ -0,0 +1 @@
+file is same
diff --git a/tools/update-packaging/test/from/{foodir/update.manifest b/tools/update-packaging/test/from/{foodir/update.manifest
new file mode 100644
index 0000000000..d3e8ed851b
--- /dev/null
+++ b/tools/update-packaging/test/from/{foodir/update.manifest
@@ -0,0 +1 @@
+from file shouldn't go in update
diff --git a/tools/update-packaging/test/make_full_update.sh b/tools/update-packaging/test/make_full_update.sh
new file mode 100755
index 0000000000..cdcdae3c3b
--- /dev/null
+++ b/tools/update-packaging/test/make_full_update.sh
@@ -0,0 +1,112 @@
+#!/bin/bash
+# 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/.
+
+#
+# This tool generates full update packages for the update system.
+# Author: Darin Fisher
+#
+# In here to use the local common.sh to allow the full mars to have unfiltered files
+
+. $(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"
+# 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
+workdir="$targetdir.work"
+updatemanifestv3="$workdir/updatev3.manifest"
+targetfiles="updatev3.manifest"
+
+mkdir -p "$workdir"
+
+# Generate a list of all files in the target directory.
+pushd "$targetdir"
+if test $? -ne 0 ; then
+ exit 1
+fi
+
+if [ ! -f "precomplete" ]; then
+ if [ ! -f "Contents/Resources/precomplete" ]; then
+ notice "precomplete file is missing!"
+ exit 1
+ fi
+fi
+
+list_files files
+
+popd
+
+# Add the type of update to the beginning of the update manifests.
+> $updatemanifestv3
+notice ""
+notice "Adding type instruction to update manifests"
+notice " type complete"
+echo "type \"complete\"" >> $updatemanifestv3
+
+notice ""
+notice "Adding file add instructions to update manifests"
+num_files=${#files[*]}
+
+for ((i=0; $i<$num_files; i=$i+1)); do
+ f="${files[$i]}"
+
+ if check_for_add_if_not_update "$f"; then
+ make_add_if_not_instruction "$f" "$updatemanifestv3"
+ else
+ make_add_instruction "$f" "$updatemanifestv3"
+ fi
+
+ dir=$(dirname "$f")
+ mkdir -p "$workdir/$dir"
+ $XZ $XZ_OPT --compress --x86 --lzma2 --format=xz --check=crc64 --force --stdout "$targetdir/$f" > "$workdir/$f"
+ copy_perm "$targetdir/$f" "$workdir/$f"
+
+ targetfiles="$targetfiles \"$f\""
+done
+
+# Append remove instructions for any dead files.
+notice ""
+notice "Adding file and directory remove instructions from file 'removed-files'"
+append_remove_instructions "$targetdir" "$updatemanifestv3"
+
+$XZ $XZ_OPT --compress --x86 --lzma2 --format=xz --check=crc64 --force "$updatemanifestv3" && mv -f "$updatemanifestv3.xz" "$updatemanifestv3"
+
+eval "$MAR -C \"$workdir\" -c output.mar $targetfiles"
+mv -f "$workdir/output.mar" "$archive"
+
+# cleanup
+rm -fr "$workdir"
+
+notice ""
+notice "Finished"
+notice ""
diff --git a/tools/update-packaging/test/runtests.sh b/tools/update-packaging/test/runtests.sh
new file mode 100755
index 0000000000..c66e54eaa6
--- /dev/null
+++ b/tools/update-packaging/test/runtests.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+echo "testing make_incremental_updates.py"
+python ../make_incremental_updates.py -f testpatchfile.txt
+
+echo ""
+echo "diffing ref.mar and test.mar"
+./diffmar.sh ref.mar test.mar test
+
+echo ""
+echo "diffing ref-mac.mar and test-mac.mar"
+./diffmar.sh ref-mac.mar test-mac.mar test-mac
diff --git a/tools/update-packaging/test/testpatchfile.txt b/tools/update-packaging/test/testpatchfile.txt
new file mode 100644
index 0000000000..a19c831eb4
--- /dev/null
+++ b/tools/update-packaging/test/testpatchfile.txt
@@ -0,0 +1,2 @@
+product-1.0.lang.platform.complete.mar,product-2.0.lang.platform.complete.mar,test.mar,""
+product-1.0.lang.mac.complete.mar,product-2.0.lang.mac.complete.mar,test-mac.mar,""
diff --git a/tools/update-packaging/test/to-mac/Contents/MacOS/addFeedPrefs.js b/tools/update-packaging/test/to-mac/Contents/MacOS/addFeedPrefs.js
new file mode 100644
index 0000000000..3b2aed8e02
--- /dev/null
+++ b/tools/update-packaging/test/to-mac/Contents/MacOS/addFeedPrefs.js
@@ -0,0 +1 @@
+this is a new file
diff --git a/tools/update-packaging/test/to-mac/Contents/MacOS/added.txt b/tools/update-packaging/test/to-mac/Contents/MacOS/added.txt
new file mode 100644
index 0000000000..b242c36062
--- /dev/null
+++ b/tools/update-packaging/test/to-mac/Contents/MacOS/added.txt
@@ -0,0 +1 @@
+added file
diff --git a/tools/update-packaging/test/to-mac/Contents/MacOS/diff-patch-larger-than-file.bin b/tools/update-packaging/test/to-mac/Contents/MacOS/diff-patch-larger-than-file.bin
new file mode 100644
index 0000000000..a9ee7258cc
--- /dev/null
+++ b/tools/update-packaging/test/to-mac/Contents/MacOS/diff-patch-larger-than-file.bin
Binary files differ
diff --git a/tools/update-packaging/test/to-mac/Contents/MacOS/diff-patch-larger-than-file.txt b/tools/update-packaging/test/to-mac/Contents/MacOS/diff-patch-larger-than-file.txt
new file mode 100644
index 0000000000..a61ffbb5e0
--- /dev/null
+++ b/tools/update-packaging/test/to-mac/Contents/MacOS/diff-patch-larger-than-file.txt
@@ -0,0 +1 @@
+file to
diff --git a/tools/update-packaging/test/to-mac/Contents/MacOS/force.txt b/tools/update-packaging/test/to-mac/Contents/MacOS/force.txt
new file mode 100644
index 0000000000..0ed0d50124
--- /dev/null
+++ b/tools/update-packaging/test/to-mac/Contents/MacOS/force.txt
@@ -0,0 +1 @@
+file is same
diff --git a/tools/update-packaging/test/to-mac/Contents/MacOS/same.bin b/tools/update-packaging/test/to-mac/Contents/MacOS/same.bin
new file mode 100644
index 0000000000..a9ee7258cc
--- /dev/null
+++ b/tools/update-packaging/test/to-mac/Contents/MacOS/same.bin
Binary files differ
diff --git a/tools/update-packaging/test/to-mac/Contents/MacOS/update.manifest b/tools/update-packaging/test/to-mac/Contents/MacOS/update.manifest
new file mode 100644
index 0000000000..73364fdca1
--- /dev/null
+++ b/tools/update-packaging/test/to-mac/Contents/MacOS/update.manifest
@@ -0,0 +1 @@
+to file shouldn't go in update
diff --git a/tools/update-packaging/test/to-mac/Contents/MacOS/{foodir/added.txt b/tools/update-packaging/test/to-mac/Contents/MacOS/{foodir/added.txt
new file mode 100644
index 0000000000..b242c36062
--- /dev/null
+++ b/tools/update-packaging/test/to-mac/Contents/MacOS/{foodir/added.txt
@@ -0,0 +1 @@
+added file
diff --git a/tools/update-packaging/test/to-mac/Contents/MacOS/{foodir/diff-patch-larger-than-file.txt b/tools/update-packaging/test/to-mac/Contents/MacOS/{foodir/diff-patch-larger-than-file.txt
new file mode 100644
index 0000000000..a61ffbb5e0
--- /dev/null
+++ b/tools/update-packaging/test/to-mac/Contents/MacOS/{foodir/diff-patch-larger-than-file.txt
@@ -0,0 +1 @@
+file to
diff --git a/tools/update-packaging/test/to-mac/Contents/MacOS/{foodir/readme.txt b/tools/update-packaging/test/to-mac/Contents/MacOS/{foodir/readme.txt
new file mode 100644
index 0000000000..b5f7004cc9
--- /dev/null
+++ b/tools/update-packaging/test/to-mac/Contents/MacOS/{foodir/readme.txt
@@ -0,0 +1 @@
+This to file should be ignored
diff --git a/tools/update-packaging/test/to-mac/Contents/MacOS/{foodir/same.bin b/tools/update-packaging/test/to-mac/Contents/MacOS/{foodir/same.bin
new file mode 100644
index 0000000000..a9ee7258cc
--- /dev/null
+++ b/tools/update-packaging/test/to-mac/Contents/MacOS/{foodir/same.bin
Binary files differ
diff --git a/tools/update-packaging/test/to-mac/Contents/MacOS/{foodir/same.txt b/tools/update-packaging/test/to-mac/Contents/MacOS/{foodir/same.txt
new file mode 100644
index 0000000000..0ed0d50124
--- /dev/null
+++ b/tools/update-packaging/test/to-mac/Contents/MacOS/{foodir/same.txt
@@ -0,0 +1 @@
+file is same
diff --git a/tools/update-packaging/test/to-mac/Contents/MacOS/{foodir/update.manifest b/tools/update-packaging/test/to-mac/Contents/MacOS/{foodir/update.manifest
new file mode 100644
index 0000000000..73364fdca1
--- /dev/null
+++ b/tools/update-packaging/test/to-mac/Contents/MacOS/{foodir/update.manifest
@@ -0,0 +1 @@
+to file shouldn't go in update
diff --git a/tools/update-packaging/test/to-mac/Contents/Resources/application.ini b/tools/update-packaging/test/to-mac/Contents/Resources/application.ini
new file mode 100644
index 0000000000..7bdc78819f
--- /dev/null
+++ b/tools/update-packaging/test/to-mac/Contents/Resources/application.ini
@@ -0,0 +1,5 @@
+[App]
+Vendor=Mozilla
+Name=MarTest
+Version=2
+BuildID=20130101010101
diff --git a/tools/update-packaging/test/to-mac/Contents/Resources/chrome.manifest b/tools/update-packaging/test/to-mac/Contents/Resources/chrome.manifest
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tools/update-packaging/test/to-mac/Contents/Resources/chrome.manifest
diff --git a/tools/update-packaging/test/to-mac/Contents/Resources/distribution/extensions/added/file.txt b/tools/update-packaging/test/to-mac/Contents/Resources/distribution/extensions/added/file.txt
new file mode 100644
index 0000000000..4bbc6747ec
--- /dev/null
+++ b/tools/update-packaging/test/to-mac/Contents/Resources/distribution/extensions/added/file.txt
@@ -0,0 +1 @@
+extfile
diff --git a/tools/update-packaging/test/to-mac/Contents/Resources/distribution/extensions/diff/diff-patch-larger-than-file.txt b/tools/update-packaging/test/to-mac/Contents/Resources/distribution/extensions/diff/diff-patch-larger-than-file.txt
new file mode 100644
index 0000000000..b779d9648a
--- /dev/null
+++ b/tools/update-packaging/test/to-mac/Contents/Resources/distribution/extensions/diff/diff-patch-larger-than-file.txt
@@ -0,0 +1 @@
+to file
diff --git a/tools/update-packaging/test/to-mac/Contents/Resources/extensions/added/file.txt b/tools/update-packaging/test/to-mac/Contents/Resources/extensions/added/file.txt
new file mode 100644
index 0000000000..4bbc6747ec
--- /dev/null
+++ b/tools/update-packaging/test/to-mac/Contents/Resources/extensions/added/file.txt
@@ -0,0 +1 @@
+extfile
diff --git a/tools/update-packaging/test/to-mac/Contents/Resources/extensions/diff/diff-patch-larger-than-file.txt b/tools/update-packaging/test/to-mac/Contents/Resources/extensions/diff/diff-patch-larger-than-file.txt
new file mode 100644
index 0000000000..b779d9648a
--- /dev/null
+++ b/tools/update-packaging/test/to-mac/Contents/Resources/extensions/diff/diff-patch-larger-than-file.txt
@@ -0,0 +1 @@
+to file
diff --git a/tools/update-packaging/test/to-mac/Contents/Resources/precomplete b/tools/update-packaging/test/to-mac/Contents/Resources/precomplete
new file mode 100644
index 0000000000..7af8bfd769
--- /dev/null
+++ b/tools/update-packaging/test/to-mac/Contents/Resources/precomplete
@@ -0,0 +1,33 @@
+remove "Contents/MacOS/{foodir/update.manifest"
+remove "Contents/MacOS/{foodir/same.txt"
+remove "Contents/MacOS/{foodir/same.bin"
+remove "Contents/MacOS/{foodir/readme.txt"
+remove "Contents/MacOS/{foodir/force.txt"
+remove "Contents/MacOS/{foodir/diff-patch-larger-than-file.txt"
+remove "Contents/MacOS/{foodir/added.txt"
+remove "Contents/MacOS/update.manifest"
+remove "Contents/MacOS/searchplugins/diff/diff-patch-larger-than-file.txt"
+remove "Contents/MacOS/searchplugins/added/file.txt"
+remove "Contents/MacOS/same.txt"
+remove "Contents/MacOS/same.bin"
+remove "Contents/MacOS/removed-files"
+remove "Contents/MacOS/readme.txt"
+remove "Contents/MacOS/force.txt"
+remove "Contents/MacOS/extensions/diff/diff-patch-larger-than-file.txt"
+remove "Contents/MacOS/extensions/added/file.txt"
+remove "Contents/MacOS/diff-patch-larger-than-file.txt"
+remove "Contents/MacOS/diff-patch-larger-than-file.bin"
+remove "Contents/MacOS/application.ini"
+remove "Contents/MacOS/added.txt"
+remove "Contents/MacOS/addFeedPrefs.js"
+remove "Contents/Resources/precomplete"
+rmdir "Contents/MacOS/{foodir/"
+rmdir "Contents/MacOS/searchplugins/diff/"
+rmdir "Contents/MacOS/searchplugins/added/"
+rmdir "Contents/MacOS/searchplugins/"
+rmdir "Contents/MacOS/extensions/diff/"
+rmdir "Contents/MacOS/extensions/added/"
+rmdir "Contents/MacOS/extensions/"
+rmdir "Contents/MacOS/"
+rmdir "Contents/Resources/"
+rmdir "Contents/"
diff --git a/tools/update-packaging/test/to-mac/Contents/Resources/readme.txt b/tools/update-packaging/test/to-mac/Contents/Resources/readme.txt
new file mode 100644
index 0000000000..b5f7004cc9
--- /dev/null
+++ b/tools/update-packaging/test/to-mac/Contents/Resources/readme.txt
@@ -0,0 +1 @@
+This to file should be ignored
diff --git a/tools/update-packaging/test/to-mac/Contents/Resources/removed-files b/tools/update-packaging/test/to-mac/Contents/Resources/removed-files
new file mode 100644
index 0000000000..a756cc560b
--- /dev/null
+++ b/tools/update-packaging/test/to-mac/Contents/Resources/removed-files
@@ -0,0 +1,14 @@
+Contents/Resources/removed1.txt
+Contents/MacOS/removed2.bin
+Contents/MacOS/recursivedir/meh/*
+Contents/MacOS/removed3-foo.txt
+Contents/Resources/dir/
+Contents/MacOS/this file has spaces
+Contents/MacOS/notherdir/
+
+
+Contents/Resources/extra-spaces
+
+Contents/MacOS/lastFile
+
+
diff --git a/tools/update-packaging/test/to-mac/Contents/Resources/same.txt b/tools/update-packaging/test/to-mac/Contents/Resources/same.txt
new file mode 100644
index 0000000000..0ed0d50124
--- /dev/null
+++ b/tools/update-packaging/test/to-mac/Contents/Resources/same.txt
@@ -0,0 +1 @@
+file is same
diff --git a/tools/update-packaging/test/to-mac/Contents/Resources/searchplugins/added/file.txt b/tools/update-packaging/test/to-mac/Contents/Resources/searchplugins/added/file.txt
new file mode 100644
index 0000000000..4bbc6747ec
--- /dev/null
+++ b/tools/update-packaging/test/to-mac/Contents/Resources/searchplugins/added/file.txt
@@ -0,0 +1 @@
+extfile
diff --git a/tools/update-packaging/test/to-mac/Contents/Resources/searchplugins/diff/diff-patch-larger-than-file.txt b/tools/update-packaging/test/to-mac/Contents/Resources/searchplugins/diff/diff-patch-larger-than-file.txt
new file mode 100644
index 0000000000..b779d9648a
--- /dev/null
+++ b/tools/update-packaging/test/to-mac/Contents/Resources/searchplugins/diff/diff-patch-larger-than-file.txt
@@ -0,0 +1 @@
+to file
diff --git a/tools/update-packaging/test/to-mac/Contents/Resources/update-settings.ini b/tools/update-packaging/test/to-mac/Contents/Resources/update-settings.ini
new file mode 100644
index 0000000000..5fa6a9909e
--- /dev/null
+++ b/tools/update-packaging/test/to-mac/Contents/Resources/update-settings.ini
@@ -0,0 +1 @@
+add-if-not from complete file
diff --git a/tools/update-packaging/test/to-mac/Contents/Resources/{foodir/channel-prefs.js b/tools/update-packaging/test/to-mac/Contents/Resources/{foodir/channel-prefs.js
new file mode 100644
index 0000000000..d6ada4591d
--- /dev/null
+++ b/tools/update-packaging/test/to-mac/Contents/Resources/{foodir/channel-prefs.js
@@ -0,0 +1 @@
+add-if-not from partial file
diff --git a/tools/update-packaging/test/to-mac/Contents/Resources/{foodir/force.txt b/tools/update-packaging/test/to-mac/Contents/Resources/{foodir/force.txt
new file mode 100644
index 0000000000..0ed0d50124
--- /dev/null
+++ b/tools/update-packaging/test/to-mac/Contents/Resources/{foodir/force.txt
@@ -0,0 +1 @@
+file is same
diff --git a/tools/update-packaging/test/to/addFeedPrefs.js b/tools/update-packaging/test/to/addFeedPrefs.js
new file mode 100644
index 0000000000..3b2aed8e02
--- /dev/null
+++ b/tools/update-packaging/test/to/addFeedPrefs.js
@@ -0,0 +1 @@
+this is a new file
diff --git a/tools/update-packaging/test/to/added.txt b/tools/update-packaging/test/to/added.txt
new file mode 100644
index 0000000000..b242c36062
--- /dev/null
+++ b/tools/update-packaging/test/to/added.txt
@@ -0,0 +1 @@
+added file
diff --git a/tools/update-packaging/test/to/application.ini b/tools/update-packaging/test/to/application.ini
new file mode 100644
index 0000000000..7bdc78819f
--- /dev/null
+++ b/tools/update-packaging/test/to/application.ini
@@ -0,0 +1,5 @@
+[App]
+Vendor=Mozilla
+Name=MarTest
+Version=2
+BuildID=20130101010101
diff --git a/tools/update-packaging/test/to/chrome.manifest b/tools/update-packaging/test/to/chrome.manifest
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tools/update-packaging/test/to/chrome.manifest
diff --git a/tools/update-packaging/test/to/diff-patch-larger-than-file.bin b/tools/update-packaging/test/to/diff-patch-larger-than-file.bin
new file mode 100644
index 0000000000..a9ee7258cc
--- /dev/null
+++ b/tools/update-packaging/test/to/diff-patch-larger-than-file.bin
Binary files differ
diff --git a/tools/update-packaging/test/to/diff-patch-larger-than-file.txt b/tools/update-packaging/test/to/diff-patch-larger-than-file.txt
new file mode 100644
index 0000000000..a61ffbb5e0
--- /dev/null
+++ b/tools/update-packaging/test/to/diff-patch-larger-than-file.txt
@@ -0,0 +1 @@
+file to
diff --git a/tools/update-packaging/test/to/distribution/extensions/added/file.txt b/tools/update-packaging/test/to/distribution/extensions/added/file.txt
new file mode 100644
index 0000000000..4bbc6747ec
--- /dev/null
+++ b/tools/update-packaging/test/to/distribution/extensions/added/file.txt
@@ -0,0 +1 @@
+extfile
diff --git a/tools/update-packaging/test/to/distribution/extensions/diff/diff-patch-larger-than-file.txt b/tools/update-packaging/test/to/distribution/extensions/diff/diff-patch-larger-than-file.txt
new file mode 100644
index 0000000000..b779d9648a
--- /dev/null
+++ b/tools/update-packaging/test/to/distribution/extensions/diff/diff-patch-larger-than-file.txt
@@ -0,0 +1 @@
+to file
diff --git a/tools/update-packaging/test/to/extensions/added/file.txt b/tools/update-packaging/test/to/extensions/added/file.txt
new file mode 100644
index 0000000000..4bbc6747ec
--- /dev/null
+++ b/tools/update-packaging/test/to/extensions/added/file.txt
@@ -0,0 +1 @@
+extfile
diff --git a/tools/update-packaging/test/to/extensions/diff/diff-patch-larger-than-file.txt b/tools/update-packaging/test/to/extensions/diff/diff-patch-larger-than-file.txt
new file mode 100644
index 0000000000..b779d9648a
--- /dev/null
+++ b/tools/update-packaging/test/to/extensions/diff/diff-patch-larger-than-file.txt
@@ -0,0 +1 @@
+to file
diff --git a/tools/update-packaging/test/to/force.txt b/tools/update-packaging/test/to/force.txt
new file mode 100644
index 0000000000..0ed0d50124
--- /dev/null
+++ b/tools/update-packaging/test/to/force.txt
@@ -0,0 +1 @@
+file is same
diff --git a/tools/update-packaging/test/to/precomplete b/tools/update-packaging/test/to/precomplete
new file mode 100644
index 0000000000..c2700dd972
--- /dev/null
+++ b/tools/update-packaging/test/to/precomplete
@@ -0,0 +1,30 @@
+remove "{foodir/update.manifest"
+remove "{foodir/same.txt"
+remove "{foodir/same.bin"
+remove "{foodir/readme.txt"
+remove "{foodir/force.txt"
+remove "{foodir/diff-patch-larger-than-file.txt"
+remove "{foodir/added.txt"
+remove "update.manifest"
+remove "searchplugins/diff/diff-patch-larger-than-file.txt"
+remove "searchplugins/added/file.txt"
+remove "same.txt"
+remove "same.bin"
+remove "removed-files"
+remove "readme.txt"
+remove "precomplete"
+remove "force.txt"
+remove "extensions/diff/diff-patch-larger-than-file.txt"
+remove "extensions/added/file.txt"
+remove "diff-patch-larger-than-file.txt"
+remove "diff-patch-larger-than-file.bin"
+remove "application.ini"
+remove "added.txt"
+remove "addFeedPrefs.js"
+rmdir "{foodir/"
+rmdir "searchplugins/diff/"
+rmdir "searchplugins/added/"
+rmdir "searchplugins/"
+rmdir "extensions/diff/"
+rmdir "extensions/added/"
+rmdir "extensions/"
diff --git a/tools/update-packaging/test/to/readme.txt b/tools/update-packaging/test/to/readme.txt
new file mode 100644
index 0000000000..b5f7004cc9
--- /dev/null
+++ b/tools/update-packaging/test/to/readme.txt
@@ -0,0 +1 @@
+This to file should be ignored
diff --git a/tools/update-packaging/test/to/removed-files b/tools/update-packaging/test/to/removed-files
new file mode 100644
index 0000000000..4fdfff7fd5
--- /dev/null
+++ b/tools/update-packaging/test/to/removed-files
@@ -0,0 +1,14 @@
+removed1.txt
+removed2.bin
+recursivedir/meh/*
+removed3-foo.txt
+dir/
+this file has spaces
+notherdir/
+
+
+extra-spaces
+
+lastFile
+
+
diff --git a/tools/update-packaging/test/to/same.bin b/tools/update-packaging/test/to/same.bin
new file mode 100644
index 0000000000..a9ee7258cc
--- /dev/null
+++ b/tools/update-packaging/test/to/same.bin
Binary files differ
diff --git a/tools/update-packaging/test/to/same.txt b/tools/update-packaging/test/to/same.txt
new file mode 100644
index 0000000000..0ed0d50124
--- /dev/null
+++ b/tools/update-packaging/test/to/same.txt
@@ -0,0 +1 @@
+file is same
diff --git a/tools/update-packaging/test/to/searchplugins/added/file.txt b/tools/update-packaging/test/to/searchplugins/added/file.txt
new file mode 100644
index 0000000000..4bbc6747ec
--- /dev/null
+++ b/tools/update-packaging/test/to/searchplugins/added/file.txt
@@ -0,0 +1 @@
+extfile
diff --git a/tools/update-packaging/test/to/searchplugins/diff/diff-patch-larger-than-file.txt b/tools/update-packaging/test/to/searchplugins/diff/diff-patch-larger-than-file.txt
new file mode 100644
index 0000000000..b779d9648a
--- /dev/null
+++ b/tools/update-packaging/test/to/searchplugins/diff/diff-patch-larger-than-file.txt
@@ -0,0 +1 @@
+to file
diff --git a/tools/update-packaging/test/to/update-settings.ini b/tools/update-packaging/test/to/update-settings.ini
new file mode 100644
index 0000000000..5fa6a9909e
--- /dev/null
+++ b/tools/update-packaging/test/to/update-settings.ini
@@ -0,0 +1 @@
+add-if-not from complete file
diff --git a/tools/update-packaging/test/to/update.manifest b/tools/update-packaging/test/to/update.manifest
new file mode 100644
index 0000000000..73364fdca1
--- /dev/null
+++ b/tools/update-packaging/test/to/update.manifest
@@ -0,0 +1 @@
+to file shouldn't go in update
diff --git a/tools/update-packaging/test/to/{foodir/added.txt b/tools/update-packaging/test/to/{foodir/added.txt
new file mode 100644
index 0000000000..b242c36062
--- /dev/null
+++ b/tools/update-packaging/test/to/{foodir/added.txt
@@ -0,0 +1 @@
+added file
diff --git a/tools/update-packaging/test/to/{foodir/channel-prefs.js b/tools/update-packaging/test/to/{foodir/channel-prefs.js
new file mode 100644
index 0000000000..5fa6a9909e
--- /dev/null
+++ b/tools/update-packaging/test/to/{foodir/channel-prefs.js
@@ -0,0 +1 @@
+add-if-not from complete file
diff --git a/tools/update-packaging/test/to/{foodir/diff-patch-larger-than-file.txt b/tools/update-packaging/test/to/{foodir/diff-patch-larger-than-file.txt
new file mode 100644
index 0000000000..a61ffbb5e0
--- /dev/null
+++ b/tools/update-packaging/test/to/{foodir/diff-patch-larger-than-file.txt
@@ -0,0 +1 @@
+file to
diff --git a/tools/update-packaging/test/to/{foodir/force.txt b/tools/update-packaging/test/to/{foodir/force.txt
new file mode 100644
index 0000000000..0ed0d50124
--- /dev/null
+++ b/tools/update-packaging/test/to/{foodir/force.txt
@@ -0,0 +1 @@
+file is same
diff --git a/tools/update-packaging/test/to/{foodir/readme.txt b/tools/update-packaging/test/to/{foodir/readme.txt
new file mode 100644
index 0000000000..b5f7004cc9
--- /dev/null
+++ b/tools/update-packaging/test/to/{foodir/readme.txt
@@ -0,0 +1 @@
+This to file should be ignored
diff --git a/tools/update-packaging/test/to/{foodir/same.bin b/tools/update-packaging/test/to/{foodir/same.bin
new file mode 100644
index 0000000000..a9ee7258cc
--- /dev/null
+++ b/tools/update-packaging/test/to/{foodir/same.bin
Binary files differ
diff --git a/tools/update-packaging/test/to/{foodir/same.txt b/tools/update-packaging/test/to/{foodir/same.txt
new file mode 100644
index 0000000000..0ed0d50124
--- /dev/null
+++ b/tools/update-packaging/test/to/{foodir/same.txt
@@ -0,0 +1 @@
+file is same
diff --git a/tools/update-packaging/test/to/{foodir/update.manifest b/tools/update-packaging/test/to/{foodir/update.manifest
new file mode 100644
index 0000000000..73364fdca1
--- /dev/null
+++ b/tools/update-packaging/test/to/{foodir/update.manifest
@@ -0,0 +1 @@
+to file shouldn't go in update