2005-09-22 22:18:27 +04:00
|
|
|
#!/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() {
|
2006-03-02 09:34:22 +03:00
|
|
|
info=($(ls -ln "$1"))
|
|
|
|
echo ${info[4]}
|
2005-09-22 22:18:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
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/.*/')
|
2006-03-07 03:33:07 +03:00
|
|
|
is_search_plugin=$(echo "$f" | grep -c 'searchplugins/.*')
|
2005-09-22 22:18:27 +04:00
|
|
|
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\""
|
2006-03-07 03:33:07 +03:00
|
|
|
elif [ $is_search_plugin = "1" ]; then
|
|
|
|
echo "patch-if \"$f\" \"$f.patch\" \"$f\""
|
2005-09-22 22:18:27 +04:00
|
|
|
else
|
|
|
|
echo "patch \"$f.patch\" \"$f\""
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
append_remove_instructions() {
|
2005-10-17 19:26:50 +04:00
|
|
|
dir="$1"
|
|
|
|
if [ -f "$dir/removed-files" ]; then
|
|
|
|
prefix=
|
|
|
|
listfile="$dir/removed-files"
|
|
|
|
elif [ -f "$dir/Contents/MacOS/removed-files" ]; then
|
|
|
|
prefix=Contents/MacOS/
|
|
|
|
listfile="$dir/Contents/MacOS/removed-files"
|
|
|
|
fi
|
|
|
|
if [ -n "$listfile" ]; then
|
2005-09-22 22:18:27 +04:00
|
|
|
# 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
|
2005-10-05 01:07:13 +04:00
|
|
|
# Trim whitespace (including trailing carriage returns)
|
|
|
|
f=$(echo ${files[$i]} | tr "|" " " | sed 's/^ *\(.*\) *$/\1/' | tr -d '\r')
|
2005-09-22 22:18:27 +04:00
|
|
|
# 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
|
2005-10-17 19:26:50 +04:00
|
|
|
echo "remove \"$prefix$f\""
|
2005-09-22 22:18:27 +04:00
|
|
|
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
|
2007-03-29 18:11:40 +04:00
|
|
|
# generated MAR files (see bug 306077). Pass a variable name and it will be
|
|
|
|
# filled as an array.
|
2005-09-22 22:18:27 +04:00
|
|
|
list_files() {
|
2007-03-29 18:11:40 +04:00
|
|
|
count=0
|
|
|
|
|
2005-10-07 04:44:41 +04:00
|
|
|
find . -type f \
|
|
|
|
! -name "channel-prefs.js" \
|
|
|
|
! -name "update.manifest" \
|
2008-01-10 23:59:46 +03:00
|
|
|
! -name "temp-filelist" \
|
2007-03-29 18:11:40 +04:00
|
|
|
| sed 's/\.\/\(.*\)/\1/' \
|
2008-01-10 23:59:46 +03:00
|
|
|
| sort > "temp-filelist"
|
2007-03-29 18:11:40 +04:00
|
|
|
while read file; do
|
|
|
|
eval "${1}[$count]=\"$file\""
|
|
|
|
(( count++ ))
|
2008-01-10 23:59:46 +03:00
|
|
|
done < "temp-filelist"
|
|
|
|
rm "temp-filelist"
|
2005-09-22 22:18:27 +04:00
|
|
|
}
|