-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJVLA+iAAoJEBu5sftaTG2thdgP/0PGSacDpMpQa1h84C9VCGqK
 +B1ofJajKk5QEbEkdkU3YDqT/k9FEgRh650a6T1Nt+N3bGB30wGnpaZoGxeR0dfr
 3Th4aC9aRaf9klOjxUA3E+qYFVdkhEEX1/gvhlFnop2MiPtXr8K5pEbSwYEl1Rza
 Jks64ORdfEIJPfW5GbCH+5q+Vc9LsxzV1+f6KEx0Z2aWvlhALrs4zt5rRz1GWTfe
 +lq8p1ZfUb//LJOIvUaMkhCJIy5mfJbfJH+v9BNR2yC+j6sFfhvN/x4jbTCF8b3q
 Kmwtc1REQTFlTreZ7+ro27sxrDca4ydNtAGSQkVIKBajcpqdwHaTrwnn+Dcb/qtL
 eosN2l1y+HRUdt6Bwak4ep5oUyNSR5elkGAunuSPdURORACIHPuE+cJdwGRH6pEK
 pyGHEyGleIsrTCBSVbPEpAsbEVwHWnpGhDKsYOxCjDL87dmnAaXzw+c56Nucp7xI
 hndtrj6GprFkcq0wJ3LTl061lUKx53s0k4RCNWKKY/cyuwNqkl3Rh1al224ahooP
 UHKlppGYgIJHe9nilpm12+XG2EpfmofLBQD9nLZ3jMti08OLvt4YApCEGVn5f4aF
 O86nD+HWBWqSZBErnNLZSEDnm0IKzXITLtFCUkf2LXKs18oINNEz/T6sViEEUL+b
 1pqj8zq79YfouB+nJgu2
 =ZW2k
 -----END PGP SIGNATURE-----

Merge tag 'jm_2fa8a641'

Tag for commit 2fa8a641a0

# gpg: Signature made Mon Apr 13 20:49:06 2015 CEST using RSA key ID 5A4C6DAD
# gpg: Good signature from "Jason Mehring (Qubes OS Signing Key) <nrgaway@gmail.com>"
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: E0E3 2283 FDCA C1A5 1007  8F27 1BB9 B1FB 5A4C 6DAD

* tag 'jm_2fa8a641':
  Added comment about GLOBAL_CACHE and how it is later renamed
  Reworked the way template flavor files are found to allow flavors
pull/1/head mm_8ed287f1
Marek Marczykowski-Górecki 9 years ago
commit 8ed287f166

@ -118,7 +118,7 @@ setXtrace() {
# ------------------------------------------------------------------------------
# Only output text under certain conditions
output() {
if [ "${VERBOSE}" -ge 1 ]; then
if [ "${VERBOSE}" -ge 1 ] && [[ -z ${TEST} ]]; then
# Don't echo if -x is set since it will already be displayed via true
[[ ${-/x} != $- ]] || echo -e ""$@""
fi
@ -246,8 +246,14 @@ templateDir() {
exists() {
filename="${1}"
if [ -e "${filename}" ]; then
echo "${filename}"
if [ -e "${filename}" ] && ! elementIn "${filename}" "${GLOBAL_CACHE[@]}"; then
# Cache $script
#
# GLOBAL_CACHE is declared in the `getFileLocations` function and is later
# renamed to a name passed into the function as $1 to allow scripts using
# the function to have access to the array
GLOBAL_CACHE["${#GLOBAL_CACHE[@]}"]="${filename}"
return 0
fi
return 1
@ -262,61 +268,52 @@ templateFile() {
splitPath "${file}" path_parts
# No template flavor
if [ "X{template_flavor}" == "X" ]; then
if [ -e "${file}" ]; then
echo "${file}"
fi
if [ -z "${template_flavor}" ]; then
if [ "${suffix}" ]; then
exists "${SCRIPTSDIR}/${path_parts[base]}_${suffix}${path_parts[dotext]}" || true
else
exists "${SCRIPTSDIR}/${path_parts[base]}${path_parts[dotext]}" || true
fi
return
fi
# Locate file in directory named after flavor
if [ "${suffix}" ]; then
# Append suffix to filename (before extension)
# `minimal` is the template_flavor being used in comment example
# (TEMPLATE_FLAVOR_DIR/minimal/packages_qubes_suffix.list)
exists "${template_dir}/${template_flavor}/${path_parts[base]}_${suffix}${path_parts[dotext]}" || true
# (../SCRIPTSDIR/minimal/packages_qubes_suffix.list)
# (TEMPLATE_FLAVOR_DIR/minimal/packages_qubes_suffix.list)
exists "${template_dir}/${template_flavor}/${path_parts[base]}_${suffix}${path_parts[dotext]}" || true
# (TEMPLATE_FLAVOR_DIR/packages_qubes_suffix.list)
exists "${template_dir}/${path_parts[base]}_${suffix}${path_parts[dotext]}" || true
# (../SCRIPTSDIR/minimal/packages_qubes_minimal_suffix.list)
# (TEMPLATE_FLAVOR_DIR/packages_qubes_minimal_suffix.list)
exists "${template_dir}/${path_parts[base]}_${suffix}_${template_flavor}${path_parts[dotext]}" || true
# (../SCRIPTSDIR/packages_qubes_minimal_suffix.list)
# (SCRIPTSDIR/packages_qubes_minimal_suffix.list)
exists "${SCRIPTSDIR}/${path_parts[base]}_${suffix}_${template_flavor}${path_parts[dotext]}" || true
else
# (../SCRIPTSDIR/minimal/packages_qubes.list)
# (TEMPLATE_FLAVOR_DIR/minimal/packages_qubes.list)
exists "${template_dir}/${template_flavor}/${path_parts[base]}${path_parts[dotext]}" || true
# (TEMPLATE_FLAVOR_DIR/minimal/packages_qubes_minimal.list)
exists "${template_dir}/${template_flavor}/${path_parts[base]}_${template_flavor}${path_parts[dotext]}" || true
# (TEMPLATE_FLAVOR_DIR/packages_qubes.list)
exists "${template_dir}/${path_parts[base]}${path_parts[dotext]}" || true
# (../SCRIPTSDIR/minimal/packages_qubes_minimal.list)
# (TEMPLATE_FLAVOR_DIR/packages_qubes_minimal.list)
exists "${template_dir}/${path_parts[base]}_${template_flavor}${path_parts[dotext]}" || true
# (../SCRIPTSDIR/packages_qubes_minimal.list)
# (SCRIPTSDIR/packages_qubes_minimal.list)
exists "${SCRIPTSDIR}/${path_parts[base]}_${template_flavor}${path_parts[dotext]}" || true
fi
}
buildStepExec() {
local filename="$1"
local suffix="$2"
local template_flavor="$3"
script="$(templateFile "${filename}" "${suffix}" "${template_flavor}")"
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
"${script}"
fi
}
copyTreeExec() {
local source_dir="$1"
local dir="$2"
@ -347,10 +344,6 @@ copyTreeExec() {
}
callTemplateFunction() {
# Reset Cache
unset GLOBAL_CACHE
declare -A -g GLOBAL_CACHE
local calling_script="$1"
local calling_arg="$2"
local functionExec="$3"
@ -404,13 +397,18 @@ getFileLocations() {
local suffix="$3"
local function="templateFile"
files="$(callTemplateFunction "${filename}" "${suffix}" "${function}")"
unset GLOBAL_CACHE
declare -A -g GLOBAL_CACHE
IFS_orig="${IFS}}"; IFS=$'\n'
files=( "${files}" )
setArrayAsGlobal files $return_global_var
callTemplateFunction "${filename}" "${suffix}" "${function}"
setArrayAsGlobal GLOBAL_CACHE $return_global_var
IFS="${IFS_orig}"
if [ ! ${#GLOBAL_CACHE[@]} -eq 0 ]; then
debug "Smart files located for: '${filename##*/}' (suffix: ${suffix}):"
for filename in "${GLOBAL_CACHE[@]}"; do
debug "${filename}"
done
fi
}
# ------------------------------------------------------------------------------
@ -432,9 +430,23 @@ getFileLocations() {
buildStep() {
local filename="$1"
local suffix="$2"
local function="buildStepExec"
callTemplateFunction "${filename}" "${suffix}" "${function}"
info "Locating buildStep files: ${filename##*/} suffix: ${suffix}"
getFileLocations "build_step_files" "${filename}" "${suffix}"
for script in "${build_step_files[@]}"; do
if [ -e "${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
# Execute $script
"${script}"
fi
done
}
# ------------------------------------------------------------------------------
@ -460,8 +472,13 @@ copyTree() {
local target_dir="$3"
local function="copyTreeExec"
if [ "x${source_dir}" == "x" ]; then
callTemplateFunction "" "${dir}" "${function}"
if [ -z "${source_dir}" ]; then
splitPath "${0}" path_parts
if [ -d "${path_parts[dir]}/${dir}" ]; then
copyTreeExec "${path_parts[dir]}" "${dir}" "" ""
else
callTemplateFunction "" "${dir}" "${function}"
fi
else
copyTreeExec "${source_dir}" "${dir}" "" "${target_dir}"
fi

@ -200,7 +200,7 @@ header <<EOF
and in a bash file use single 'quotes' around string and \${SCRIPTSDIR}
EOF
buildStep "$0" "pre"
assertTest "buildStep $0 pre" "tests/template-flavors/wheezy+whonix-gateway/test_pre.sh\ntests/template-flavors/wheezy/test_pre.sh\ntests/template-flavors/another_location/whonix_gnome/test_pre.sh"
assertTest "buildStep $0 pre" "tests/template-flavors/wheezy+whonix-gateway/test_pre.sh\ntests/template-flavors/wheezy/test_pre.sh\ntests/template-flavors/another_location/whonix_gnome/test_pre.sh\ntests/template-flavors/test_pre.sh"
assertEnd
@ -222,7 +222,6 @@ buildStep "$0" "pre"
assertTest "buildStep $0 pre" "tests/template-flavors/another_location/whonix-gw/test_pre.sh\ntests/template-flavors/wheezy/test_pre.sh\ntests/template-flavors/test_pre.sh"
assertEnd
# ------------------------------------------------------------------------------
# 8. Custom template directory with space in name
# ------------------------------------------------------------------------------
@ -257,7 +256,7 @@ header <<EOF
9. Custom template directory for options
EOF
buildStep "$0" "pre"
assertTest "buildStep $0 pre" "tests/template-flavors/wheezy+whonix-gateway/test_pre.sh\ntests/template-flavors/wheezy/test_pre.sh\ntests/template-flavors/another_location/whonix_gnome/test_pre.sh"
assertTest "buildStep $0 pre" "tests/template-flavors/wheezy+whonix-gateway/test_pre.sh\ntests/template-flavors/wheezy/test_pre.sh\ntests/template-flavors/another_location/whonix_gnome/test_pre.sh\ntests/template-flavors/test_pre.sh"
assertEnd

Loading…
Cancel
Save