mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-06 22:53:08 +00:00
Patch for bug 300136 "Update archives may need to contain remove commands" r=chase
This commit is contained in:
parent
343315772e
commit
525bc228ca
88
tools/update-packaging/common.sh
Executable file
88
tools/update-packaging/common.sh
Executable file
@ -0,0 +1,88 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Code shared by update packaging scripts.
|
||||
# Author: Darin Fisher
|
||||
#
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# By default just assume that these tools exist on our path
|
||||
MAR=${MAR:-mar}
|
||||
BZIP2=${BZIP2:-bzip2}
|
||||
MBSDIFF=${MBSDIFF:-mbsdiff}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Helper routines
|
||||
|
||||
notice() {
|
||||
echo $* 1>&2
|
||||
}
|
||||
|
||||
get_file_size() {
|
||||
info=($(ls -l "$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"
|
||||
is_extension=$(echo "$f" | grep -c '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/\(extensions\/[^\/]*\)\/.*/\1/')
|
||||
echo "add-if \"$testdir\" \"$f\""
|
||||
else
|
||||
echo "add \"$f\""
|
||||
fi
|
||||
}
|
||||
|
||||
make_patch_instruction() {
|
||||
f="$1"
|
||||
is_extension=$(echo "$f" | grep -c '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/\(extensions\/[^\/]*\)\/.*/\1/')
|
||||
echo "patch-if \"$testdir\" \"$f.patch\" \"$f\""
|
||||
else
|
||||
echo "patch \"$f.patch\" \"$f\""
|
||||
fi
|
||||
}
|
||||
|
||||
append_remove_instructions() {
|
||||
listfile="$1"
|
||||
if [ -f "$listfile" ]; then
|
||||
# Map spaces to pipes so that we correctly handle filenames with spaces.
|
||||
files=($(cat "$listfile" | tr " " "|"))
|
||||
num_files=${#files[*]}
|
||||
for ((i=0; $i<$num_files; i=$i+1)); do
|
||||
f=$(echo ${files[$i]} | tr "|" " " | sed 's/^ *\(.*\) *$/\1/')
|
||||
# Exclude any blank lines or any lines ending with a slash, which indicate
|
||||
# directories. The updater doesn't know how to remove entire directories.
|
||||
if [ -n "$f" ]; then
|
||||
if [ $(echo "$f" | grep -c '\/$') = 0 ]; then
|
||||
echo "remove \"$f\""
|
||||
else
|
||||
notice "ignoring remove instruction for directory: $f"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
# List all files in the current directory, stripping leading "./"
|
||||
# Skip the channel-prefs.js file as it should not be included in any
|
||||
# generated MAR files (see bug 306077).
|
||||
list_files() {
|
||||
find . -type f ! -name "channel-prefs.js" | sed 's/\.\/\(.*\)/"\1"/'
|
||||
}
|
@ -4,15 +4,12 @@
|
||||
# Author: Darin Fisher
|
||||
#
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# By default just assume that these tools exist on our path
|
||||
MAR=${MAR:-mar}
|
||||
BZIP2=${BZIP2:-bzip2}
|
||||
. $(dirname "$0")/common.sh
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
print_usage() {
|
||||
echo "Usage: $(basename $0) [OPTIONS] ARCHIVE DIRECTORY"
|
||||
notice "Usage: $(basename $0) [OPTIONS] ARCHIVE DIRECTORY"
|
||||
}
|
||||
|
||||
if [ $# = 0 ]; then
|
||||
@ -22,48 +19,17 @@ fi
|
||||
|
||||
if [ $1 = -h ]; then
|
||||
print_usage
|
||||
echo ""
|
||||
echo "The contents of DIRECTORY will be stored in ARCHIVE."
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " -h show this help text"
|
||||
echo ""
|
||||
notice ""
|
||||
notice "The contents of DIRECTORY will be stored in ARCHIVE."
|
||||
notice ""
|
||||
notice "Options:"
|
||||
notice " -h show this help text"
|
||||
notice ""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
copy_perm() {
|
||||
reference="$1"
|
||||
target="$2"
|
||||
|
||||
if [ -x "$reference" ]; then
|
||||
chmod 0755 "$target"
|
||||
else
|
||||
chmod 0644 "$target"
|
||||
fi
|
||||
}
|
||||
|
||||
make_add_instruction() {
|
||||
f="$1"
|
||||
is_extension=$(echo "$f" | grep -c '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/\(extensions\/[^\/]*\)\/.*/\1/')
|
||||
echo "add-if \"$testdir\" \"$f\""
|
||||
else
|
||||
echo "add \"$f\""
|
||||
fi
|
||||
}
|
||||
|
||||
# List all files in the current directory, stripping leading "./"
|
||||
# Skip the channel-prefs.js file as it should not be included in any
|
||||
# generated MAR files (see bug 306077).
|
||||
list_files() {
|
||||
find . -type f ! -name "channel-prefs.js" | sed 's/\.\/\(.*\)/"\1"/'
|
||||
}
|
||||
|
||||
archive="$1"
|
||||
targetdir="$2"
|
||||
workdir="$targetdir.work"
|
||||
@ -82,7 +48,7 @@ num_files=${#files[*]}
|
||||
for ((i=0; $i<$num_files; i=$i+1)); do
|
||||
f=${files[$i]}
|
||||
|
||||
echo " processing $f"
|
||||
notice "processing $f"
|
||||
|
||||
make_add_instruction "$f" >> $manifest
|
||||
|
||||
@ -94,6 +60,9 @@ for ((i=0; $i<$num_files; i=$i+1)); do
|
||||
targetfiles="$targetfiles \"$f\""
|
||||
done
|
||||
|
||||
# Append remove instructions for any dead files.
|
||||
append_remove_instructions "$targetdir/removed-files" >> $manifest
|
||||
|
||||
$BZIP2 -z9 "$manifest" && mv -f "$manifest.bz2" "$manifest"
|
||||
|
||||
eval "$MAR -C \"$workdir\" -c output.mar $targetfiles"
|
||||
|
@ -4,16 +4,12 @@
|
||||
# Author: Darin Fisher
|
||||
#
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# By default just assume that these tools exist on our path
|
||||
MAR=${MAR:-mar}
|
||||
BZIP2=${BZIP2:-bzip2}
|
||||
MBSDIFF=${MBSDIFF:-mbsdiff}
|
||||
. $(dirname "$0")/common.sh
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
print_usage() {
|
||||
echo "Usage: $(basename $0) [OPTIONS] ARCHIVE FROMDIR TODIR"
|
||||
notice "Usage: $(basename $0) [OPTIONS] ARCHIVE FROMDIR TODIR"
|
||||
}
|
||||
|
||||
if [ $# = 0 ]; then
|
||||
@ -23,55 +19,17 @@ fi
|
||||
|
||||
if [ $1 = -h ]; then
|
||||
print_usage
|
||||
echo ""
|
||||
echo "The differences between FROMDIR and TODIR will be stored in ARCHIVE."
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " -h show this help text"
|
||||
echo ""
|
||||
notice ""
|
||||
notice "The differences between FROMDIR and TODIR will be stored in ARCHIVE."
|
||||
notice ""
|
||||
notice "Options:"
|
||||
notice " -h show this help text"
|
||||
notice ""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
get_file_size() {
|
||||
info=($(ls -l "$1"))
|
||||
echo ${info[4]}
|
||||
}
|
||||
|
||||
make_add_instruction() {
|
||||
f="$1"
|
||||
is_extension=$(echo "$f" | grep -c '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/\(extensions\/[^\/]*\)\/.*/\1/')
|
||||
echo "add-if \"$testdir\" \"$f\""
|
||||
else
|
||||
echo "add \"$f\""
|
||||
fi
|
||||
}
|
||||
|
||||
make_patch_instruction() {
|
||||
f="$1"
|
||||
is_extension=$(echo "$f" | grep -c '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/\(extensions\/[^\/]*\)\/.*/\1/')
|
||||
echo "patch-if \"$testdir\" \"$f.patch\" \"$f\""
|
||||
else
|
||||
echo "patch \"$f.patch\" \"$f\""
|
||||
fi
|
||||
}
|
||||
|
||||
# List all files in the current directory, stripping leading "./"
|
||||
# Skip the channel-prefs.js file as it should not be included in any
|
||||
# generated MAR files (see bug 306077).
|
||||
list_files() {
|
||||
find . -type f ! -name "channel-prefs.js" | sed 's/\.\/\(.*\)/"\1"/'
|
||||
}
|
||||
|
||||
archive="$1"
|
||||
olddir="$2"
|
||||
newdir="$3"
|
||||
@ -144,6 +102,9 @@ for ((i=0; $i<$num_newfiles; i=$i+1)); do
|
||||
archivefiles="$archivefiles \"$f\""
|
||||
done
|
||||
|
||||
# Append remove instructions for any dead files.
|
||||
append_remove_instructions "$newdir/removed-files" >> $manifest
|
||||
|
||||
$BZIP2 -z9 "$manifest" && mv -f "$manifest.bz2" "$manifest"
|
||||
|
||||
eval "$MAR -C \"$workdir\" -c output.mar $archivefiles"
|
||||
|
Loading…
x
Reference in New Issue
Block a user