debian: honor verbose; fixed bug where base package.list was not being used
This commit is contained in:
parent
d8138a8f44
commit
422dcc9c24
62
functions.sh
62
functions.sh
@ -1,6 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# vim: set ts=4 sw=4 sts=4 et :
|
# vim: set ts=4 sw=4 sts=4 et :
|
||||||
|
|
||||||
|
# XXX
|
||||||
|
set -e
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Global functions
|
# Global functions
|
||||||
################################################################################
|
################################################################################
|
||||||
@ -72,20 +75,40 @@ fi
|
|||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Display messages in color
|
# Display messages in color
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
# Only output text under certain conditions
|
||||||
|
output() {
|
||||||
|
case ${VERBOSE} in
|
||||||
|
0)
|
||||||
|
true "${1}"
|
||||||
|
;;
|
||||||
|
1)
|
||||||
|
echo -e "${1}"
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
# Don't echo if -x is set since it will already be displayed via true
|
||||||
|
[[ ${-/x} != $- ]] || echo -e "${1}"
|
||||||
|
true "${1}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
true "${1}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
info() {
|
info() {
|
||||||
[[ -z ${TEST} ]] && echo -e "${bold}${blue}INFO: ${1}${reset}" || :
|
output "${bold}${blue}INFO: ${1}${reset}" || :
|
||||||
}
|
}
|
||||||
|
|
||||||
debug() {
|
debug() {
|
||||||
[[ -z ${TEST} ]] && echo -e "${bold}${green}DEBUG: ${1}${reset}" || :
|
output "${bold}${green}DEBUG: ${1}${reset}" || :
|
||||||
}
|
}
|
||||||
|
|
||||||
warn() {
|
warn() {
|
||||||
[[ -z ${TEST} ]] && echo -e "${stout}${yellow}WARNING: ${1}${reset}" || :
|
output "${stout}${yellow}WARNING: ${1}${reset}" || :
|
||||||
}
|
}
|
||||||
|
|
||||||
error() {
|
error() {
|
||||||
[[ -z ${TEST} ]] && echo -e "${bold}${red}ERROR: ${1}${reset}" || :
|
output "${bold}${red}ERROR: ${1}${reset}" || :
|
||||||
}
|
}
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
@ -254,7 +277,7 @@ templateFile() {
|
|||||||
local file="$1"
|
local file="$1"
|
||||||
local suffix="$2"
|
local suffix="$2"
|
||||||
local template_flavor="$3"
|
local template_flavor="$3"
|
||||||
local template_dir="$(templateDir ${template_flavor})"
|
local template_dir="$(templateDir "${template_flavor}")"
|
||||||
|
|
||||||
splitPath "${file}" path_parts
|
splitPath "${file}" path_parts
|
||||||
|
|
||||||
@ -277,9 +300,17 @@ buildStepExec() {
|
|||||||
|
|
||||||
script="$(templateFile "${filename}" "${suffix}" "${template_flavor}")"
|
script="$(templateFile "${filename}" "${suffix}" "${template_flavor}")"
|
||||||
|
|
||||||
if [ -f "${script}" ]; then
|
#if [ -f "${script}" ]; then
|
||||||
[[ -n ${TEST} ]] && echo "${script}" || echo "${bold}${under}INFO: Currently running script: ${script}${reset}"
|
if [ -f "${script}" ] && [ ! ${GLOBAL_CACHE[$script]+_} ]; then
|
||||||
|
# Test module expects raw output back only used to asser test results
|
||||||
|
if [[ -n ${TEST} ]]; then
|
||||||
|
echo "${script}"
|
||||||
|
else
|
||||||
|
output "${bold}${under}INFO: Currently running script: ${script}${reset}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Cache $script
|
||||||
|
GLOBAL_CACHE[$script]=1
|
||||||
# Execute $script
|
# Execute $script
|
||||||
"${script}"
|
"${script}"
|
||||||
fi
|
fi
|
||||||
@ -308,12 +339,17 @@ copyTreeExec() {
|
|||||||
pushd "${target_dir}"
|
pushd "${target_dir}"
|
||||||
{
|
{
|
||||||
setfacl --restore="${source_dir}/.facl" 2>/dev/null ||:
|
setfacl --restore="${source_dir}/.facl" 2>/dev/null ||:
|
||||||
|
rm -f .facl
|
||||||
}
|
}
|
||||||
popd
|
popd
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
callTemplateFunction() {
|
callTemplateFunction() {
|
||||||
|
# Reset Cache
|
||||||
|
unset GLOBAL_CACHE
|
||||||
|
declare -A -g GLOBAL_CACHE
|
||||||
|
|
||||||
local calling_script="$1"
|
local calling_script="$1"
|
||||||
local calling_arg="$2"
|
local calling_arg="$2"
|
||||||
local functionExec="$3"
|
local functionExec="$3"
|
||||||
@ -335,6 +371,12 @@ callTemplateFunction() {
|
|||||||
"${calling_arg}" \
|
"${calling_arg}" \
|
||||||
"${option}"
|
"${option}"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# If template_flavor exists, also check on base distro
|
||||||
|
if [ -n "${template_flavor}" ]; then
|
||||||
|
${functionExec} "${calling_script}" \
|
||||||
|
"${calling_arg}"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
@ -350,7 +392,9 @@ getFileLocations() {
|
|||||||
#files=( $(callTemplateFunction "${filename}" "${suffix}" "${function}") )
|
#files=( $(callTemplateFunction "${filename}" "${suffix}" "${function}") )
|
||||||
#setArrayAsGlobal files $return_global_var
|
#setArrayAsGlobal files $return_global_var
|
||||||
|
|
||||||
files=$(callTemplateFunction "${filename}" "${suffix}" "${function}")
|
# XXX
|
||||||
|
#files=$(callTemplateFunction "${filename}" "${suffix}" "${function}")
|
||||||
|
files="$(callTemplateFunction "${filename}" "${suffix}" "${function}")"
|
||||||
|
|
||||||
IFS_orig="${IFS}}"; IFS=$'\n'
|
IFS_orig="${IFS}}"; IFS=$'\n'
|
||||||
files=( "${files}" )
|
files=( "${files}" )
|
||||||
@ -402,4 +446,4 @@ copyTree() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# $0 is module that sourced vars.sh
|
# $0 is module that sourced vars.sh
|
||||||
echo "${bold}${under}INFO: Currently running script: ${0}${reset}"
|
output "${bold}${under}INFO: Currently running script: ${0}${reset}"
|
||||||
|
@ -112,7 +112,7 @@ EOF
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for package_list in "${packages_list[@]}"; do
|
for package_list in ${packages_list[@]}; do
|
||||||
debug "Installing extra packages from: ${package_list}"
|
debug "Installing extra packages from: ${package_list}"
|
||||||
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \
|
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \
|
||||||
xargs chroot ${INSTALLDIR} apt-get -y --force-yes install < "${package_list}"
|
xargs chroot ${INSTALLDIR} apt-get -y --force-yes install < "${package_list}"
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# vim: set ts=4 sw=4 sts=4 et :
|
# vim: set ts=4 sw=4 sts=4 et :
|
||||||
|
|
||||||
VERBOSE=2
|
VERBOSE=1
|
||||||
DEBUG=1
|
|
||||||
|
|
||||||
pushd ../..
|
pushd ../..
|
||||||
ROOT_DIR=$(readlink -m .)
|
ROOT_DIR=$(readlink -m .)
|
||||||
@ -45,7 +44,6 @@ declare -A VALUES=(
|
|||||||
)
|
)
|
||||||
|
|
||||||
values() {
|
values() {
|
||||||
[[ -z ${TEST} ]] && {
|
|
||||||
label=${1}
|
label=${1}
|
||||||
value="${1}[@]"
|
value="${1}[@]"
|
||||||
value="${!value}"
|
value="${!value}"
|
||||||
@ -55,17 +53,15 @@ values() {
|
|||||||
else
|
else
|
||||||
printf " ${bold}${black}%-22s = ${value}${reset}\n" "${label}" || :
|
printf " ${bold}${black}%-22s = ${value}${reset}\n" "${label}" || :
|
||||||
fi
|
fi
|
||||||
#printf "${bold}${black}%s=\"${value}\"${reset}\n" "${label}" || :
|
|
||||||
VALUES[$label]="${value}"
|
VALUES[$label]="${value}"
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
info() {
|
info() {
|
||||||
[[ -z ${TEST} ]] && echo "${bold}${blue}${1}${reset}" || :
|
output "${bold}${blue}${1}${reset}" || :
|
||||||
}
|
}
|
||||||
|
|
||||||
debug() {
|
debug() {
|
||||||
[[ -z ${TEST} ]] && echo -e "${magenta}${1}${reset}" || :
|
output "${magenta}${1}${reset}" || :
|
||||||
}
|
}
|
||||||
|
|
||||||
assertTest(){
|
assertTest(){
|
||||||
@ -97,7 +93,7 @@ header <<EOF
|
|||||||
1. With TEMPLATE_FLAVOR
|
1. With TEMPLATE_FLAVOR
|
||||||
EOF
|
EOF
|
||||||
buildStep "$0" "pre"
|
buildStep "$0" "pre"
|
||||||
assertTest "buildStep $0 pre" "tests/template-flavors/wheezy+whonix-gateway/test_pre.sh"
|
assertTest "buildStep $0 pre" "tests/template-flavors/wheezy+whonix-gateway/test_pre.sh\ntests/template-flavors/test_pre.sh"
|
||||||
assertEnd
|
assertEnd
|
||||||
|
|
||||||
|
|
||||||
@ -137,7 +133,7 @@ header <<EOF
|
|||||||
EOF
|
EOF
|
||||||
buildStep "$0" "pre"
|
buildStep "$0" "pre"
|
||||||
debug "Not supposed to find wheezy+whonix-gateway+kde"
|
debug "Not supposed to find wheezy+whonix-gateway+kde"
|
||||||
assertTest "buildStep $0 pre" "tests/template-flavors/wheezy+whonix-gateway/test_pre.sh\ntests/template-flavors/wheezy+whonix-gateway+gnome/test_pre.sh"
|
assertTest "buildStep $0 pre" "tests/template-flavors/wheezy+whonix-gateway/test_pre.sh\ntests/template-flavors/wheezy+whonix-gateway+gnome/test_pre.sh\ntests/template-flavors/test_pre.sh"
|
||||||
assertEnd
|
assertEnd
|
||||||
|
|
||||||
|
|
||||||
@ -159,7 +155,7 @@ header <<EOF
|
|||||||
EOF
|
EOF
|
||||||
buildStep "$0" "pre"
|
buildStep "$0" "pre"
|
||||||
debug "Not supposed to find debian+whonix-gateway+kde"
|
debug "Not supposed to find debian+whonix-gateway+kde"
|
||||||
assertTest "buildStep $0 pre" "tests/template-flavors/debian+whonix-gateway/test_pre.sh\ntests/template-flavors/wheezy+whonix-gateway+gnome/test_pre.sh"
|
assertTest "buildStep $0 pre" "tests/template-flavors/debian+whonix-gateway/test_pre.sh\ntests/template-flavors/wheezy+whonix-gateway+gnome/test_pre.sh\ntests/template-flavors/test_pre.sh"
|
||||||
assertEnd
|
assertEnd
|
||||||
|
|
||||||
|
|
||||||
@ -181,7 +177,7 @@ header <<EOF
|
|||||||
EOF
|
EOF
|
||||||
buildStep "$0" "pre"
|
buildStep "$0" "pre"
|
||||||
debug "Not supposed to find whonix-gateway+kde"
|
debug "Not supposed to find whonix-gateway+kde"
|
||||||
assertTest "buildStep $0 pre" "tests/template-flavors/whonix-gateway/test_pre.sh\ntests/template-flavors/wheezy+whonix-gateway+gnome/test_pre.sh"
|
assertTest "buildStep $0 pre" "tests/template-flavors/whonix-gateway/test_pre.sh\ntests/template-flavors/wheezy+whonix-gateway+gnome/test_pre.sh\ntests/template-flavors/test_pre.sh"
|
||||||
assertEnd
|
assertEnd
|
||||||
|
|
||||||
|
|
||||||
@ -278,7 +274,7 @@ header <<EOF
|
|||||||
10. Template directory for options within ${SCRIPTSDIR} using short name filter
|
10. Template directory for options within ${SCRIPTSDIR} using short name filter
|
||||||
EOF
|
EOF
|
||||||
buildStep "$0" "pre"
|
buildStep "$0" "pre"
|
||||||
assertTest "buildStep $0 pre" "tests/template-flavors/wheezy+whonix-gateway/test_pre.sh\ntests/template-flavors/proxy/test_pre.sh"
|
assertTest "buildStep $0 pre" "tests/template-flavors/wheezy+whonix-gateway/test_pre.sh\ntests/template-flavors/proxy/test_pre.sh\ntests/template-flavors/test_pre.sh"
|
||||||
assertEnd
|
assertEnd
|
||||||
|
|
||||||
|
|
||||||
@ -297,7 +293,7 @@ header <<EOF
|
|||||||
11. Template directory for options within using VERY short name filter (+proxy)
|
11. Template directory for options within using VERY short name filter (+proxy)
|
||||||
EOF
|
EOF
|
||||||
buildStep "$0" "pre"
|
buildStep "$0" "pre"
|
||||||
assertTest "buildStep $0 pre" "tests/template-flavors/wheezy+whonix-gateway/test_pre.sh\ntests/template-flavors/proxy/test_pre.sh"
|
assertTest "buildStep $0 pre" "tests/template-flavors/wheezy+whonix-gateway/test_pre.sh\ntests/template-flavors/proxy/test_pre.sh\ntests/template-flavors/test_pre.sh"
|
||||||
assertEnd
|
assertEnd
|
||||||
|
|
||||||
|
|
||||||
@ -387,7 +383,7 @@ for file in "${filelist[@]}"; do
|
|||||||
echo "Configuration: ${file}"
|
echo "Configuration: ${file}"
|
||||||
done
|
done
|
||||||
result="$(echo $(printf "'%s' " "${filelist[@]}"))"
|
result="$(echo $(printf "'%s' " "${filelist[@]}"))"
|
||||||
assertTest "echo ${result}" "tests/template-flavors/another_location/whonix gw/packages.list tests/template-flavors/wheezy+whonix-gateway+gnome/packages.list"
|
assertTest "echo ${result}" "tests/template-flavors/another_location/whonix gw/packages.list tests/template-flavors/wheezy+whonix-gateway+gnome/packages.list tests/template-flavors/packages.list"
|
||||||
assertEnd
|
assertEnd
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user