mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-22 22:21:10 +02:00
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:
parent
6a76c4d9b4
commit
8174ba0782
14
common.sh
14
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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user