From 8174ba0782bcb39913eb1f9efdfa5e96f43a6e95 Mon Sep 17 00:00:00 2001 From: Steve VanDeBogart Date: Fri, 15 Jan 2010 19:45:30 -0800 Subject: [PATCH] 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 --- common.sh | 14 ++++++++++++++ dpkg_no_scripts.sh | 17 +++-------------- package_script_whitelist.sh | 13 ------------- 3 files changed, 17 insertions(+), 27 deletions(-) diff --git a/common.sh b/common.sh index bad8dd42aa..2a3c5d25a5 100644 --- a/common.sh +++ b/common.sh @@ -190,3 +190,17 @@ function install_if_missing { sudo apt-get --yes --force-yes install $PKG_NAME 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 +} diff --git a/dpkg_no_scripts.sh b/dpkg_no_scripts.sh index 63c1942911..e4a57e5697 100755 --- a/dpkg_no_scripts.sh +++ b/dpkg_no_scripts.sh @@ -26,6 +26,8 @@ DEFINE_boolean dpkg_fallback $FLAGS_TRUE \ "Run normal dpkg if maintainer scripts are not whitelisted." DEFINE_string status_fd "" \ "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 configure $FLAGS_FALSE "Is the action 'configure'?" DEFINE_boolean remove $FLAGS_FALSE "Is the action 'remove'?" @@ -45,19 +47,6 @@ eval set -- "${FLAGS_ARGV}" # Die on any errors. 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. # # $1 - The package name. @@ -157,7 +146,7 @@ do_unpack() { rm -rf "$tmpdir" # 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 echo "Running: ${chromium_preinst}" ROOT="$FLAGS_root" SRC_ROOT="$SRC_ROOT" $chromium_preinst diff --git a/package_script_whitelist.sh b/package_script_whitelist.sh index 2d23fe0755..30b6f7aa61 100755 --- a/package_script_whitelist.sh +++ b/package_script_whitelist.sh @@ -47,19 +47,6 @@ following commands: FLAGS "$@" || exit 1 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. # # $1 - Path to file to add to whitelist.