gecko-dev/tools/update-packaging/common.sh

206 строки
5.6 KiB
Bash
Исходник Обычный вид История

#!/bin/bash
2012-05-21 15:12:37 +04: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/.
#
# 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 -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"
Mac v2 signing - Bug 1059567 - Packaging changes for the move of removed-files file from Contents/MacOS to Contents/Resources. r=bbondy, r=nthomas --HG-- rename : tools/update-packaging/test/from-mac/Contents/MacOS/application.ini => tools/update-packaging/test/from-mac/Contents/Resources/application.ini rename : tools/update-packaging/test/from-mac/Contents/MacOS/distribution/extensions/diff/diff-patch-larger-than-file.txt => tools/update-packaging/test/from-mac/Contents/Resources/distribution/extensions/diff/diff-patch-larger-than-file.txt rename : tools/update-packaging/test/from-mac/Contents/MacOS/extensions/diff/diff-patch-larger-than-file.txt => tools/update-packaging/test/from-mac/Contents/Resources/extensions/diff/diff-patch-larger-than-file.txt rename : tools/update-packaging/test/from-mac/Contents/MacOS/readme.txt => tools/update-packaging/test/from-mac/Contents/Resources/readme.txt rename : tools/update-packaging/test/from-mac/Contents/MacOS/removed.txt => tools/update-packaging/test/from-mac/Contents/Resources/removed.txt rename : tools/update-packaging/test/from-mac/Contents/MacOS/same.txt => tools/update-packaging/test/from-mac/Contents/Resources/same.txt rename : tools/update-packaging/test/from-mac/Contents/MacOS/searchplugins/diff/diff-patch-larger-than-file.txt => tools/update-packaging/test/from-mac/Contents/Resources/searchplugins/diff/diff-patch-larger-than-file.txt rename : tools/update-packaging/test/from-mac/Contents/MacOS/update-settings.ini => tools/update-packaging/test/from-mac/Contents/Resources/update-settings.ini rename : tools/update-packaging/test/from-mac/Contents/MacOS/{foodir/channel-prefs.js => tools/update-packaging/test/from-mac/Contents/Resources/{foodir/channel-prefs.js rename : tools/update-packaging/test/from-mac/Contents/MacOS/{foodir/force.txt => tools/update-packaging/test/from-mac/Contents/Resources/{foodir/force.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/application.ini => tools/update-packaging/test/to-mac/Contents/Resources/application.ini rename : tools/update-packaging/test/to-mac/Contents/MacOS/distribution/extensions/added/file.txt => tools/update-packaging/test/to-mac/Contents/Resources/distribution/extensions/added/file.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/distribution/extensions/diff/diff-patch-larger-than-file.txt => tools/update-packaging/test/to-mac/Contents/Resources/distribution/extensions/diff/diff-patch-larger-than-file.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/extensions/added/file.txt => tools/update-packaging/test/to-mac/Contents/Resources/extensions/added/file.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/extensions/diff/diff-patch-larger-than-file.txt => tools/update-packaging/test/to-mac/Contents/Resources/extensions/diff/diff-patch-larger-than-file.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/readme.txt => tools/update-packaging/test/to-mac/Contents/Resources/readme.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/removed-files => tools/update-packaging/test/to-mac/Contents/Resources/removed-files rename : tools/update-packaging/test/to-mac/Contents/MacOS/same.txt => tools/update-packaging/test/to-mac/Contents/Resources/same.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/searchplugins/added/file.txt => tools/update-packaging/test/to-mac/Contents/Resources/searchplugins/added/file.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/searchplugins/diff/diff-patch-larger-than-file.txt => tools/update-packaging/test/to-mac/Contents/Resources/searchplugins/diff/diff-patch-larger-than-file.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/update-settings.ini => tools/update-packaging/test/to-mac/Contents/Resources/update-settings.ini rename : tools/update-packaging/test/to-mac/Contents/MacOS/{foodir/channel-prefs.js => tools/update-packaging/test/to-mac/Contents/Resources/{foodir/channel-prefs.js rename : tools/update-packaging/test/to-mac/Contents/MacOS/{foodir/force.txt => tools/update-packaging/test/to-mac/Contents/Resources/{foodir/force.txt
2014-09-29 22:52:04 +04:00
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
Mac v2 signing - Bug 1059567 - Packaging changes for the move of removed-files file from Contents/MacOS to Contents/Resources. r=bbondy, r=nthomas --HG-- rename : tools/update-packaging/test/from-mac/Contents/MacOS/application.ini => tools/update-packaging/test/from-mac/Contents/Resources/application.ini rename : tools/update-packaging/test/from-mac/Contents/MacOS/distribution/extensions/diff/diff-patch-larger-than-file.txt => tools/update-packaging/test/from-mac/Contents/Resources/distribution/extensions/diff/diff-patch-larger-than-file.txt rename : tools/update-packaging/test/from-mac/Contents/MacOS/extensions/diff/diff-patch-larger-than-file.txt => tools/update-packaging/test/from-mac/Contents/Resources/extensions/diff/diff-patch-larger-than-file.txt rename : tools/update-packaging/test/from-mac/Contents/MacOS/readme.txt => tools/update-packaging/test/from-mac/Contents/Resources/readme.txt rename : tools/update-packaging/test/from-mac/Contents/MacOS/removed.txt => tools/update-packaging/test/from-mac/Contents/Resources/removed.txt rename : tools/update-packaging/test/from-mac/Contents/MacOS/same.txt => tools/update-packaging/test/from-mac/Contents/Resources/same.txt rename : tools/update-packaging/test/from-mac/Contents/MacOS/searchplugins/diff/diff-patch-larger-than-file.txt => tools/update-packaging/test/from-mac/Contents/Resources/searchplugins/diff/diff-patch-larger-than-file.txt rename : tools/update-packaging/test/from-mac/Contents/MacOS/update-settings.ini => tools/update-packaging/test/from-mac/Contents/Resources/update-settings.ini rename : tools/update-packaging/test/from-mac/Contents/MacOS/{foodir/channel-prefs.js => tools/update-packaging/test/from-mac/Contents/Resources/{foodir/channel-prefs.js rename : tools/update-packaging/test/from-mac/Contents/MacOS/{foodir/force.txt => tools/update-packaging/test/from-mac/Contents/Resources/{foodir/force.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/application.ini => tools/update-packaging/test/to-mac/Contents/Resources/application.ini rename : tools/update-packaging/test/to-mac/Contents/MacOS/distribution/extensions/added/file.txt => tools/update-packaging/test/to-mac/Contents/Resources/distribution/extensions/added/file.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/distribution/extensions/diff/diff-patch-larger-than-file.txt => tools/update-packaging/test/to-mac/Contents/Resources/distribution/extensions/diff/diff-patch-larger-than-file.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/extensions/added/file.txt => tools/update-packaging/test/to-mac/Contents/Resources/extensions/added/file.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/extensions/diff/diff-patch-larger-than-file.txt => tools/update-packaging/test/to-mac/Contents/Resources/extensions/diff/diff-patch-larger-than-file.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/readme.txt => tools/update-packaging/test/to-mac/Contents/Resources/readme.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/removed-files => tools/update-packaging/test/to-mac/Contents/Resources/removed-files rename : tools/update-packaging/test/to-mac/Contents/MacOS/same.txt => tools/update-packaging/test/to-mac/Contents/Resources/same.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/searchplugins/added/file.txt => tools/update-packaging/test/to-mac/Contents/Resources/searchplugins/added/file.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/searchplugins/diff/diff-patch-larger-than-file.txt => tools/update-packaging/test/to-mac/Contents/Resources/searchplugins/diff/diff-patch-larger-than-file.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/update-settings.ini => tools/update-packaging/test/to-mac/Contents/Resources/update-settings.ini rename : tools/update-packaging/test/to-mac/Contents/MacOS/{foodir/channel-prefs.js => tools/update-packaging/test/to-mac/Contents/Resources/{foodir/channel-prefs.js rename : tools/update-packaging/test/to-mac/Contents/MacOS/{foodir/force.txt => tools/update-packaging/test/to-mac/Contents/Resources/{foodir/force.txt
2014-09-29 22:52:04 +04:00
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:\*$::')
Mac v2 signing - Bug 1059567 - Packaging changes for the move of removed-files file from Contents/MacOS to Contents/Resources. r=bbondy, r=nthomas --HG-- rename : tools/update-packaging/test/from-mac/Contents/MacOS/application.ini => tools/update-packaging/test/from-mac/Contents/Resources/application.ini rename : tools/update-packaging/test/from-mac/Contents/MacOS/distribution/extensions/diff/diff-patch-larger-than-file.txt => tools/update-packaging/test/from-mac/Contents/Resources/distribution/extensions/diff/diff-patch-larger-than-file.txt rename : tools/update-packaging/test/from-mac/Contents/MacOS/extensions/diff/diff-patch-larger-than-file.txt => tools/update-packaging/test/from-mac/Contents/Resources/extensions/diff/diff-patch-larger-than-file.txt rename : tools/update-packaging/test/from-mac/Contents/MacOS/readme.txt => tools/update-packaging/test/from-mac/Contents/Resources/readme.txt rename : tools/update-packaging/test/from-mac/Contents/MacOS/removed.txt => tools/update-packaging/test/from-mac/Contents/Resources/removed.txt rename : tools/update-packaging/test/from-mac/Contents/MacOS/same.txt => tools/update-packaging/test/from-mac/Contents/Resources/same.txt rename : tools/update-packaging/test/from-mac/Contents/MacOS/searchplugins/diff/diff-patch-larger-than-file.txt => tools/update-packaging/test/from-mac/Contents/Resources/searchplugins/diff/diff-patch-larger-than-file.txt rename : tools/update-packaging/test/from-mac/Contents/MacOS/update-settings.ini => tools/update-packaging/test/from-mac/Contents/Resources/update-settings.ini rename : tools/update-packaging/test/from-mac/Contents/MacOS/{foodir/channel-prefs.js => tools/update-packaging/test/from-mac/Contents/Resources/{foodir/channel-prefs.js rename : tools/update-packaging/test/from-mac/Contents/MacOS/{foodir/force.txt => tools/update-packaging/test/from-mac/Contents/Resources/{foodir/force.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/application.ini => tools/update-packaging/test/to-mac/Contents/Resources/application.ini rename : tools/update-packaging/test/to-mac/Contents/MacOS/distribution/extensions/added/file.txt => tools/update-packaging/test/to-mac/Contents/Resources/distribution/extensions/added/file.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/distribution/extensions/diff/diff-patch-larger-than-file.txt => tools/update-packaging/test/to-mac/Contents/Resources/distribution/extensions/diff/diff-patch-larger-than-file.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/extensions/added/file.txt => tools/update-packaging/test/to-mac/Contents/Resources/extensions/added/file.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/extensions/diff/diff-patch-larger-than-file.txt => tools/update-packaging/test/to-mac/Contents/Resources/extensions/diff/diff-patch-larger-than-file.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/readme.txt => tools/update-packaging/test/to-mac/Contents/Resources/readme.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/removed-files => tools/update-packaging/test/to-mac/Contents/Resources/removed-files rename : tools/update-packaging/test/to-mac/Contents/MacOS/same.txt => tools/update-packaging/test/to-mac/Contents/Resources/same.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/searchplugins/added/file.txt => tools/update-packaging/test/to-mac/Contents/Resources/searchplugins/added/file.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/searchplugins/diff/diff-patch-larger-than-file.txt => tools/update-packaging/test/to-mac/Contents/Resources/searchplugins/diff/diff-patch-larger-than-file.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/update-settings.ini => tools/update-packaging/test/to-mac/Contents/Resources/update-settings.ini rename : tools/update-packaging/test/to-mac/Contents/MacOS/{foodir/channel-prefs.js => tools/update-packaging/test/to-mac/Contents/Resources/{foodir/channel-prefs.js rename : tools/update-packaging/test/to-mac/Contents/MacOS/{foodir/force.txt => tools/update-packaging/test/to-mac/Contents/Resources/{foodir/force.txt
2014-09-29 22:52:04 +04:00
notice " rmrfdir \"$f\""
echo "rmrfdir \"$f\"" >> $filev2
echo "rmrfdir \"$f\"" >> $filev3
else
Mac v2 signing - Bug 1059567 - Packaging changes for the move of removed-files file from Contents/MacOS to Contents/Resources. r=bbondy, r=nthomas --HG-- rename : tools/update-packaging/test/from-mac/Contents/MacOS/application.ini => tools/update-packaging/test/from-mac/Contents/Resources/application.ini rename : tools/update-packaging/test/from-mac/Contents/MacOS/distribution/extensions/diff/diff-patch-larger-than-file.txt => tools/update-packaging/test/from-mac/Contents/Resources/distribution/extensions/diff/diff-patch-larger-than-file.txt rename : tools/update-packaging/test/from-mac/Contents/MacOS/extensions/diff/diff-patch-larger-than-file.txt => tools/update-packaging/test/from-mac/Contents/Resources/extensions/diff/diff-patch-larger-than-file.txt rename : tools/update-packaging/test/from-mac/Contents/MacOS/readme.txt => tools/update-packaging/test/from-mac/Contents/Resources/readme.txt rename : tools/update-packaging/test/from-mac/Contents/MacOS/removed.txt => tools/update-packaging/test/from-mac/Contents/Resources/removed.txt rename : tools/update-packaging/test/from-mac/Contents/MacOS/same.txt => tools/update-packaging/test/from-mac/Contents/Resources/same.txt rename : tools/update-packaging/test/from-mac/Contents/MacOS/searchplugins/diff/diff-patch-larger-than-file.txt => tools/update-packaging/test/from-mac/Contents/Resources/searchplugins/diff/diff-patch-larger-than-file.txt rename : tools/update-packaging/test/from-mac/Contents/MacOS/update-settings.ini => tools/update-packaging/test/from-mac/Contents/Resources/update-settings.ini rename : tools/update-packaging/test/from-mac/Contents/MacOS/{foodir/channel-prefs.js => tools/update-packaging/test/from-mac/Contents/Resources/{foodir/channel-prefs.js rename : tools/update-packaging/test/from-mac/Contents/MacOS/{foodir/force.txt => tools/update-packaging/test/from-mac/Contents/Resources/{foodir/force.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/application.ini => tools/update-packaging/test/to-mac/Contents/Resources/application.ini rename : tools/update-packaging/test/to-mac/Contents/MacOS/distribution/extensions/added/file.txt => tools/update-packaging/test/to-mac/Contents/Resources/distribution/extensions/added/file.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/distribution/extensions/diff/diff-patch-larger-than-file.txt => tools/update-packaging/test/to-mac/Contents/Resources/distribution/extensions/diff/diff-patch-larger-than-file.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/extensions/added/file.txt => tools/update-packaging/test/to-mac/Contents/Resources/extensions/added/file.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/extensions/diff/diff-patch-larger-than-file.txt => tools/update-packaging/test/to-mac/Contents/Resources/extensions/diff/diff-patch-larger-than-file.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/readme.txt => tools/update-packaging/test/to-mac/Contents/Resources/readme.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/removed-files => tools/update-packaging/test/to-mac/Contents/Resources/removed-files rename : tools/update-packaging/test/to-mac/Contents/MacOS/same.txt => tools/update-packaging/test/to-mac/Contents/Resources/same.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/searchplugins/added/file.txt => tools/update-packaging/test/to-mac/Contents/Resources/searchplugins/added/file.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/searchplugins/diff/diff-patch-larger-than-file.txt => tools/update-packaging/test/to-mac/Contents/Resources/searchplugins/diff/diff-patch-larger-than-file.txt rename : tools/update-packaging/test/to-mac/Contents/MacOS/update-settings.ini => tools/update-packaging/test/to-mac/Contents/Resources/update-settings.ini rename : tools/update-packaging/test/to-mac/Contents/MacOS/{foodir/channel-prefs.js => tools/update-packaging/test/to-mac/Contents/Resources/{foodir/channel-prefs.js rename : tools/update-packaging/test/to-mac/Contents/MacOS/{foodir/force.txt => tools/update-packaging/test/to-mac/Contents/Resources/{foodir/force.txt
2014-09-29 22:52:04 +04:00
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
find . -type f \
! -name "update.manifest" \
! -name "updatev2.manifest" \
! -name "updatev3.manifest" \
! -name "temp-dirlist" \
! -name "temp-filelist" \
| 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
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"
}