Move is_whitelisted to the common script so that all users get the previous fix

Fix typo to enable preinst scripts to run

Review URL: http://codereview.chromium.org/542097
This commit is contained in:
Steve VanDeBogart 2010-01-15 19:45:30 -08:00
parent 6a76c4d9b4
commit 8174ba0782
3 changed files with 17 additions and 27 deletions

View File

@ -190,3 +190,17 @@ function install_if_missing {
sudo apt-get --yes --force-yes install $PKG_NAME sudo apt-get --yes --force-yes install $PKG_NAME
fi fi
} }
# Returns true if the input file is whitelisted.
#
# $1 - The file to check
is_whitelisted() {
local file=$1
local whitelist="$FLAGS_whitelist"
test -f "$whitelist" || (echo "Whitelist file missing ($whitelist)" && exit 1)
local checksum=$(md5sum "$file" | awk '{ print $1 }')
local count=$(sed -e "s/#.*$//" "${whitelist}" | grep -c "$checksum" \
|| /bin/true)
test $count -ne 0
}

View File

@ -26,6 +26,8 @@ DEFINE_boolean dpkg_fallback $FLAGS_TRUE \
"Run normal dpkg if maintainer scripts are not whitelisted." "Run normal dpkg if maintainer scripts are not whitelisted."
DEFINE_string status_fd "" \ DEFINE_string status_fd "" \
"The file descriptor to report status on; ignored." "The file descriptor to report status on; ignored."
DEFINE_string whitelist "${SRC_ROOT}/package_scripts/package.whitelist" \
"The whitelist file to use."
DEFINE_boolean unpack $FLAGS_FALSE "Is the action 'unpack'?" DEFINE_boolean unpack $FLAGS_FALSE "Is the action 'unpack'?"
DEFINE_boolean configure $FLAGS_FALSE "Is the action 'configure'?" DEFINE_boolean configure $FLAGS_FALSE "Is the action 'configure'?"
DEFINE_boolean remove $FLAGS_FALSE "Is the action 'remove'?" DEFINE_boolean remove $FLAGS_FALSE "Is the action 'remove'?"
@ -45,19 +47,6 @@ eval set -- "${FLAGS_ARGV}"
# Die on any errors. # Die on any errors.
set -e set -e
# Returns true if the input file is whitelisted.
#
# $1 - The file to check
is_whitelisted() {
local whitelist="${SRC_ROOT}/package_scripts/package.whitelist"
test -f "$whitelist" || return
local checksum=$(md5sum "$1" | awk '{ print $1 }')
local count=$(sed -e "s/#.*$//" "${whitelist}" | grep -c "$checksum" \
|| /bin/true)
test $count -ne 0
}
# Returns true if either of the two given files exist and are not whitelisted. # Returns true if either of the two given files exist and are not whitelisted.
# #
# $1 - The package name. # $1 - The package name.
@ -157,7 +146,7 @@ do_unpack() {
rm -rf "$tmpdir" rm -rf "$tmpdir"
# Run our maintainer script for this package if we have one. # Run our maintainer script for this package if we have one.
local chromium_postinst="${SRC_ROOT}/package_scripts/${package}.preinst" local chromium_preinst="${SRC_ROOT}/package_scripts/${package}.preinst"
if [ -f "$chromium_preinst" ]; then if [ -f "$chromium_preinst" ]; then
echo "Running: ${chromium_preinst}" echo "Running: ${chromium_preinst}"
ROOT="$FLAGS_root" SRC_ROOT="$SRC_ROOT" $chromium_preinst ROOT="$FLAGS_root" SRC_ROOT="$SRC_ROOT" $chromium_preinst

View File

@ -47,19 +47,6 @@ following commands:
FLAGS "$@" || exit 1 FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}" eval set -- "${FLAGS_ARGV}"
# Returns true if the input file is whitelisted.
#
# $1 - The file to check
is_whitelisted() {
local file=$1
local whitelist="$FLAGS_whitelist"
test -f "$whitelist" || return
local checksum=$(md5sum "$file" | awk '{ print $1 }')
local count=$(grep -c "$checksum" "${whitelist}" || /bin/true)
test $count -ne 0
}
# Adds a the file at the given path to the whitelist. # Adds a the file at the given path to the whitelist.
# #
# $1 - Path to file to add to whitelist. # $1 - Path to file to add to whitelist.