diff --git a/functions.sh b/functions.sh index b5171ff..a3437cc 100755 --- a/functions.sh +++ b/functions.sh @@ -140,146 +140,148 @@ splitPath() { setArrayAsGlobal PARTS $return_global_var } +templateFlavor() { + echo ${TEMPLATE_FLAVOR} +} -customStepExec() { - local calling_script="$1" - local step="$2" - local template_flavor="$3" - local template_flavor_dir="$4" - local template_flavor_prefix="$5" - - [[ -z $TEST ]] && debug "Calling script: ${calling_script}" || : - [[ -z $TEST ]] && debug "Step: ${step}" || : - [[ -z $TEST ]] && debug "Template Flavor: ${template_flavor}" || : - [[ -z $TEST ]] && debug "Template Dir: ${template_flavor_dir}" || : - [[ -z $TEST ]] && debug "Template Prefix: ${template_flavor_prefix}" || : +templateFlavorPrefix() { + local template_flavor=${1-$(templateFlavor)} + for element in "${TEMPLATE_FLAVOR_PREFIX[@]}" + do + if [ "${element%;*}" == "${DIST}+${template_flavor}" ]; then + echo ${element#*;} + return + fi + done + + echo "${DIST}${template_flavor:++}" +} - splitPath "${calling_script}" path_parts +templateDir() { + local template_flavor=${1-$(templateFlavor)} + for element in "${TEMPLATE_FLAVOR_DIR[@]}" + do + if [ "${element%;*}" == "$(templateFlavorPrefix ${template_flavor})${template_flavor}" ]; then + echo ${element#*;} + return + fi + done - # Step: [pre] | [post] (or custom inserted step) - if [ "${step}" ]; then - script_name="${path_parts[base]}_${step}${path_parts[dotext]}" + if [ -n "${template_flavor}" ]; then + local template_flavor_prefix="$(templateFlavorPrefix ${template_flavor})" + local dir="${SCRIPTSDIR}/${template_flavor_prefix}${template_flavor}" else - script_name="${path_parts[base]}${path_parts[dotext]}" + local dir="${SCRIPTSDIR}" fi - if [ -n "${template_flavor}" ]; then - script="${template_flavor_dir}/${template_flavor_prefix}${template_flavor}/${script_name}" + echo "${dir}" +} + +templateFile() { + local file="$1" + local suffix="$2" + local template_flavor="$3" + local template_dir="$(templateDir ${template_flavor})" + + splitPath "${file}" path_parts + + # Append suffix to filename (before extension) + if [ "${suffix}" ]; then + file="${template_dir}/${path_parts[base]}_${suffix}${path_parts[dotext]}" else - script="${template_flavor_dir}/${template_flavor_prefix}/${script_name}" + file="${template_dir}/${path_parts[base]}${path_parts[dotext]}" fi - if [ -f "$script" ]; then + if [ -f "${file}" ]; then + echo "${file}" + fi +} + +buildStepExec() { + local filename="$1" + local suffix="$2" + local template_flavor="$3" + + script="$(templateFile "${filename}" "${suffix}" "${template_flavor}")" + + if [ -f "${script}" ]; then [[ -n $TEST ]] && echo "${script}" || echo "${bold}${under}INFO: Currently running script: ${script}${reset}" - "$script" - else - [[ -z $TEST ]] && debug "${bold}INFO: No CustomStep found for: ${script}${reset}" || : + # Execute $script + "${script}" fi } -customCopy() { +copyTreeExec() { local calling_script="$1" local dir="$2" local template_flavor="$3" - local template_flavor_dir="$4" - local template_flavor_prefix="$5" - local install_dir="$(readlink -m ${INSTALLDIR})" - info "copy_dirs(): ${install_dir}" - if [ -n "${template_flavor}" ]; then - custom_dir="${template_flavor_dir}/${template_flavor_prefix}${template_flavor}/${dir}" - else - custom_dir="${template_flavor_dir}/${template_flavor_prefix}/${dir}" - fi + local template_dir="$(templateDir ${template_flavor})" + local source_dir="$(readlink -m ${template_dir}/${dir})" + local install_dir="$(readlink -m ${INSTALLDIR})" - if [ -d "${custom_dir}" ]; then - dir="${custom_dir}/" - elif [ -d "${template_flavor_dir}/${dir}" ]; then - dir="${template_flavor_dir}/${dir}/" - else + if ! [ -d "${source_dir}" ]; then debug "No extra files to copy for ${dir}" - return 0 + return 0 fi - dir="$(readlink -m $dir)" - debug "Copying ${dir}/* ${install_dir}" - cp -rp "${dir}/"* "${install_dir}" + debug "Copying ${source_dir}/* ${install_dir}" + cp -rp "${source_dir}/"* "${install_dir}" - if [ -f "${dir}/.facl" ]; then + if [ -f "${source_dir}/.facl" ]; then debug "Restoring file permissions..." pushd "$install_dir" { - setfacl --restore="${dir}/.facl" 2>/dev/null ||: + setfacl --restore="${source_dir}/.facl" 2>/dev/null ||: } popd fi } -templateFlavor() { - echo ${TEMPLATE_FLAVOR} -} - -templateFlavorPrefix() { - local template=${1-${TEMPLATE_FLAVOR}} - for element in "${TEMPLATE_FLAVOR_PREFIX[@]}" - do - if [ "${element%;*}" == "${DIST}+${template}" ]; then - echo ${element#*;} - return - fi - done - - echo "${DIST}${TEMPLATE_FLAVOR:++}" -} - -templateFlavorDir() { - local template=${1-${TEMPLATE_FLAVOR}} - for element in "${TEMPLATE_FLAVOR_DIR[@]}" - do - if [ "${element%;*}" == "${DIST}+${template}" ]; then - echo ${element#*;} - return - fi - done - - echo "${SCRIPTSDIR}" -} - -customParse() { +callTemplateFunction() { local calling_script="$1" - local step="$2" + local calling_arg="$2" local functionExec="$3" local template_flavor="$(templateFlavor)" - local template_flavor_dir="$(templateFlavorDir ${template_flavor})" - local template_flavor_prefix="$(templateFlavorPrefix ${template_flavor})" ${functionExec} "${calling_script}" \ - "${step}" \ - "${template_flavor}" \ - "${template_flavor_dir}" \ - "${template_flavor_prefix}" - + "${calling_arg}" \ + "${template_flavor}" - for template in ${TEMPLATE_OPTIONS[@]} + for option in ${TEMPLATE_OPTIONS[@]} do - template_flavor="$(templateFlavor)+${template}" - template_flavor_dir="$(templateFlavorDir ${template_flavor})" - template_flavor_prefix="$(templateFlavorPrefix ${template_flavor})" - ${functionExec} "${calling_script}" \ - "${step}" \ - "${template_flavor}" \ - "${template_flavor_dir}" \ - "${template_flavor_prefix}" + "${calling_arg}" \ + "$(templateFlavor)+${option}" done } +# ------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ +getFileLocations() { + local return_global_var=$1 + local filename="$2" + local suffix="$3" + local function="templateFile" + + + IFS_orig="${IFS}}"; IFS=$'\n' + files=( $(callTemplateFunction "${filename}" "${suffix}" "${function}") ) + setArrayAsGlobal files $return_global_var + + IFS="${IFS_orig}" +} + # ------------------------------------------------------------------------------ # Executes any additional optional configuration steps if the configuration # scripts exist # ------------------------------------------------------------------------------ -customStep() { - customParse "$1" "$2" "customStepExec" +buildStep() { + local filename="$1" + local suffix="$2" + local function="buildStepExec" + + callTemplateFunction "${filename}" "${suffix}" "${function}" } # ------------------------------------------------------------------------------ @@ -298,8 +300,12 @@ customStep() { # they get copied over to $INSTALLDIR # NOTE: Don't forget to redo this process if you add -OR- remove files # ------------------------------------------------------------------------------ -copy_dirs() { - customParse "" "$1" "customCopy" +copyTree() { + local not_used="" + local dir="$1" + local function="copyTreeExec" + + callTemplateFunction "${not_used}" "${dir}" "${function}" } # $0 is module that sourced vars.sh diff --git a/scripts_debian/00_prepare.sh b/scripts_debian/00_prepare.sh index e4eaad1..1dcc836 100755 --- a/scripts_debian/00_prepare.sh +++ b/scripts_debian/00_prepare.sh @@ -19,9 +19,9 @@ INSTALLDIR="$(readlink -m mnt)" umount_kill "$INSTALLDIR" || : # ------------------------------------------------------------------------------ -# Execute any custom pre configuration scripts +# Execute any template flavor or sub flavor 'pre' scripts # ------------------------------------------------------------------------------ -customStep "$0" "pre" +buildStep "$0" "pre" # ------------------------------------------------------------------------------ # Force overwrite of an existing image for now if debootstrap did not seem to complete... @@ -40,7 +40,7 @@ if [ -f "$IMG" ]; then fi # ------------------------------------------------------------------------------ -# Execute any custom post configuration scripts +# Execute any template flavor or sub flavor 'post' scripts # ------------------------------------------------------------------------------ -customStep "$0" "post" +buildStep "$0" "post" diff --git a/scripts_debian/01_install_core.sh b/scripts_debian/01_install_core.sh index 177da2b..cd742f5 100755 --- a/scripts_debian/01_install_core.sh +++ b/scripts_debian/01_install_core.sh @@ -16,9 +16,9 @@ else fi # ------------------------------------------------------------------------------ -# Execute any custom pre configuration scripts +# Execute any template flavor or sub flavor 'pre' scripts # ------------------------------------------------------------------------------ -customStep "$0" "pre" +buildStep "$0" "pre" # ------------------------------------------------------------------------------ # Install base debian system @@ -33,6 +33,6 @@ if ! [ -f "$INSTALLDIR/tmp/.prepared_debootstrap" ]; then fi # ------------------------------------------------------------------------------ -# Execute any custom post configuration scripts +# Execute any template flavor or sub flavor 'post' scripts # ------------------------------------------------------------------------------ -customStep "$0" "post" +buildStep "$0" "post" diff --git a/scripts_debian/02_install_groups.sh b/scripts_debian/02_install_groups.sh index de52e80..b60a8d4 100755 --- a/scripts_debian/02_install_groups.sh +++ b/scripts_debian/02_install_groups.sh @@ -31,9 +31,9 @@ fi for fs in /dev /dev/pts /proc /sys /run; do mount -B $fs "$INSTALLDIR/$fs"; done # ------------------------------------------------------------------------------ -# Execute any custom pre configuration scripts +# Execute any template flavor or sub flavor 'pre' scripts # ------------------------------------------------------------------------------ -customStep "$0" "pre" +buildStep "$0" "pre" if ! [ -f "$INSTALLDIR/tmp/.prepared_groups" ]; then # ------------------------------------------------------------------------------ @@ -98,29 +98,26 @@ EOF # ------------------------------------------------------------------------------ # Install extra packages in script_$DEBIANVERSION/packages.list file + # -and / or- TEMPLATE_FLAVOR directories # ------------------------------------------------------------------------------ - if [ -n "${TEMPLATE_FLAVOR}" ]; then - PKGLISTFILE="$SCRIPTSDIR/packages_${DIST}_${TEMPLATE_FLAVOR}.list" - if ! [ -r "${PKGLISTFILE}" ]; then - error "ERROR: ${PKGLISTFILE} does not exists!" - umount_kill "$INSTALLDIR" || : - exit 1 - fi - elif [ -r "$SCRIPTSDIR/packages_${DIST}.list" ]; then - PKGLISTFILE="$SCRIPTSDIR/packages_${DIST}.list" - else - PKGLISTFILE="$SCRIPTSDIR/packages.list" + getFileLocations packages_list "packages.list" "${DIST}" + if [ -z "${packages_list}" ]; then + error "Can not locate a package.list file!" + umount_kill "$INSTALLDIR" || : + exit 1 fi - debug "Installing extra packages" - DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \ - xargs chroot $INSTALLDIR apt-get -y --force-yes install < "$PKGLISTFILE" + for package_list in "${packages_list[@]}"; do + debug "Installing extra packages from: ${package_list}" + DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \ + xargs chroot $INSTALLDIR apt-get -y --force-yes install < "$package_list" + done # ------------------------------------------------------------------------------ - # Execute any custom configuration scripts after file packages installed + # Execute any template flavor or sub flavor scripts after packages are installed # (Whonix needs dependancies installed before installation) # ------------------------------------------------------------------------------ - customStep "$0" "packages_installed" + buildStep "$0" "packages_installed" # ------------------------------------------------------------------------------ # Install systemd @@ -194,7 +191,7 @@ EOF fi # ------------------------------------------------------------------------------ -# Execute any custom post configuration scripts +# Execute any template flavor or sub flavor 'post' scripts # ------------------------------------------------------------------------------ -customStep "$0" "post" +buildStep "$0" "post" diff --git a/scripts_debian/04_install_qubes.sh b/scripts_debian/04_install_qubes.sh index 88a7612..6c94531 100755 --- a/scripts_debian/04_install_qubes.sh +++ b/scripts_debian/04_install_qubes.sh @@ -30,9 +30,9 @@ fi for fs in /dev /dev/pts /proc /sys /run; do mount -B $fs "$INSTALLDIR/$fs"; done # ------------------------------------------------------------------------------ -# Execute any custom pre configuration scripts +# Execute any template flavor or sub flavor 'pre' scripts # ------------------------------------------------------------------------------ -customStep "$0" "pre" +buildStep "$0" "pre" # ------------------------------------------------------------------------------ # Install Qubes Packages @@ -188,15 +188,15 @@ EOF # $SCRIPT_DIR/extra-qubes-files # -------------------------------------------------------------------------- debug "Copy extra files..." - copy_dirs "extra-qubes-files" + copyTree "extra-qubes-files" touch "$INSTALLDIR/tmp/.prepared_qubes" fi # ------------------------------------------------------------------------------ -# Execute any custom post configuration scripts +# Execute any template flavor or sub flavor 'post' scripts # ------------------------------------------------------------------------------ -customStep "$0" "post" +buildStep "$0" "post" # ------------------------------------------------------------------------------ # Kill all processes and umount all mounts within $INSTALLDIR, but not diff --git a/scripts_debian/09_cleanup.sh b/scripts_debian/09_cleanup.sh index d2b6f2b..dce636e 100755 --- a/scripts_debian/09_cleanup.sh +++ b/scripts_debian/09_cleanup.sh @@ -16,9 +16,9 @@ else fi # ------------------------------------------------------------------------------ -# Execute any custom pre configuration scripts +# Execute any template flavor or sub flavor 'pre' scripts # ------------------------------------------------------------------------------ -customStep "$0" "pre" +buildStep "$0" "pre" # ------------------------------------------------------------------------------ # Cleanup any left over files from installation @@ -31,6 +31,6 @@ rm -f "$INSTALLDIR/etc/apt/trusted.gpg.d/qubes-builder.gpg" rm -rf buildchroot # ------------------------------------------------------------------------------ -# Execute any custom post configuration scripts +# Execute any template flavor or sub flavor 'post' scripts # ------------------------------------------------------------------------------ -customStep "$0" "post" +buildStep "$0" "post" diff --git a/scripts_debian/packages.list b/scripts_debian/packages.list deleted file mode 120000 index 525a06f..0000000 --- a/scripts_debian/packages.list +++ /dev/null @@ -1 +0,0 @@ -packages_jessie.list \ No newline at end of file diff --git a/scripts_debian/packages_wheezy_whonix-gateway.list b/scripts_debian/packages_wheezy_whonix-gateway.list deleted file mode 120000 index d2bd272..0000000 --- a/scripts_debian/packages_wheezy_whonix-gateway.list +++ /dev/null @@ -1 +0,0 @@ -packages_wheezy_whonix.list \ No newline at end of file diff --git a/scripts_debian/packages_wheezy_whonix-workstation.list b/scripts_debian/packages_wheezy_whonix-workstation.list deleted file mode 120000 index d2bd272..0000000 --- a/scripts_debian/packages_wheezy_whonix-workstation.list +++ /dev/null @@ -1 +0,0 @@ -packages_wheezy_whonix.list \ No newline at end of file diff --git a/scripts_debian/wheezy+whonix-gateway/packages_wheezy.list b/scripts_debian/wheezy+whonix-gateway/packages_wheezy.list new file mode 120000 index 0000000..d5dfb50 --- /dev/null +++ b/scripts_debian/wheezy+whonix-gateway/packages_wheezy.list @@ -0,0 +1 @@ +../wheezy+whonix/packages_wheezy.list \ No newline at end of file diff --git a/scripts_debian/wheezy+whonix-workstation/packages_wheezy.list b/scripts_debian/wheezy+whonix-workstation/packages_wheezy.list new file mode 120000 index 0000000..d5dfb50 --- /dev/null +++ b/scripts_debian/wheezy+whonix-workstation/packages_wheezy.list @@ -0,0 +1 @@ +../wheezy+whonix/packages_wheezy.list \ No newline at end of file diff --git a/scripts_debian/wheezy+whonix/02_install_groups_packages_installed.sh b/scripts_debian/wheezy+whonix/02_install_groups_packages_installed.sh index 186efd6..36e22f0 100755 --- a/scripts_debian/wheezy+whonix/02_install_groups_packages_installed.sh +++ b/scripts_debian/wheezy+whonix/02_install_groups_packages_installed.sh @@ -323,9 +323,9 @@ if ! [ -f "$INSTALLDIR/tmp/.prepared_whonix" ]; then fi # ------------------------------------------------------------------------------ -# Execute any custom configuration scripts +# Execute any template flavor or sub flavor scripts # ------------------------------------------------------------------------------ -customStep "99_custom_configuration.sh" +buildStep "99_custom_configuration.sh" # XXX: Why do I need to move them out of the way? Lets try keeping them # in place (modify post script too) diff --git a/scripts_debian/wheezy+whonix/04_install_qubes_post.sh b/scripts_debian/wheezy+whonix/04_install_qubes_post.sh index 11d7e32..b69a760 100755 --- a/scripts_debian/wheezy+whonix/04_install_qubes_post.sh +++ b/scripts_debian/wheezy+whonix/04_install_qubes_post.sh @@ -48,7 +48,7 @@ fi # ------------------------------------------------------------------------------ # Copy over any extra files # ------------------------------------------------------------------------------ -copy_dirs "extra-whonix-files" +copyTree "extra-whonix-files" # ------------------------------------------------------------------------------ # Cleanup Whonix Installation diff --git a/scripts_debian/packages_wheezy_whonix.list b/scripts_debian/wheezy+whonix/packages_wheezy.list similarity index 100% rename from scripts_debian/packages_wheezy_whonix.list rename to scripts_debian/wheezy+whonix/packages_wheezy.list diff --git a/tests/template-flavors/another_location/whonix gw/packages.list b/tests/template-flavors/another_location/whonix gw/packages.list new file mode 100644 index 0000000..e69de29 diff --git a/tests/template-flavors/another_location/wheezy+whonix-gateway+gnome/test_pre.sh b/tests/template-flavors/another_location/whonix gw/test_pre.sh similarity index 100% rename from tests/template-flavors/another_location/wheezy+whonix-gateway+gnome/test_pre.sh rename to tests/template-flavors/another_location/whonix gw/test_pre.sh diff --git a/tests/template-flavors/another_location/wheezy+whonix-gateway/test_pre.sh b/tests/template-flavors/another_location/whonix-gw/test_pre.sh similarity index 100% rename from tests/template-flavors/another_location/wheezy+whonix-gateway/test_pre.sh rename to tests/template-flavors/another_location/whonix-gw/test_pre.sh diff --git a/tests/template-flavors/another_location/whonix_gnome/packages.list b/tests/template-flavors/another_location/whonix_gnome/packages.list new file mode 100644 index 0000000..e69de29 diff --git a/tests/template-flavors/another_location/whonix_gnome/test_pre.sh b/tests/template-flavors/another_location/whonix_gnome/test_pre.sh new file mode 100755 index 0000000..9a4e120 --- /dev/null +++ b/tests/template-flavors/another_location/whonix_gnome/test_pre.sh @@ -0,0 +1,4 @@ +#!/bin/sh +# vim: set ts=4 sw=4 sts=4 et : + +: diff --git a/tests/template-flavors/packages.list b/tests/template-flavors/packages.list new file mode 100644 index 0000000..e69de29 diff --git a/tests/template-flavors/packages_wheezy.list b/tests/template-flavors/packages_wheezy.list new file mode 100644 index 0000000..e69de29 diff --git a/tests/template-flavors/test.sh b/tests/template-flavors/test.sh index f7365a7..bc1c50d 100755 --- a/tests/template-flavors/test.sh +++ b/tests/template-flavors/test.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # vim: set ts=4 sw=4 sts=4 et : VERBOSE=2 @@ -42,7 +42,7 @@ assertTest(){ assertEnd() { printf "${bold}${red}" - assert_end "$1" + [[ -n "$1" ]] && assert_end "$1" || assert_end printf "${reset}" } @@ -60,22 +60,24 @@ debug 'export SCRIPTSDIR="tests/template-flavors"' debug 'export DIST="wheezy"' debug 'export TEMPLATE_FLAVOR="whonix-gateway"' debug 'export TEMPLATE_FLAVOR_PREFIX=""' -#debug "TEST=\"${TEST}\"" # ------------------------------------------------------------------------------ -head " 1. With TEMPLATE_FOLDER - \n tests/template-flavors/wheezy+whonix-gateway/test_pre.sh" -customStep "$0" "pre" -assertTest "customStep $0 pre" "tests/template-flavors/wheezy+whonix-gateway/test_pre.sh" -assertEnd "Test 1" +head " 1. With TEMPLATE_FLAVOR + \n export SCRIPTSDIR=tests/template-flavors \ + \n export DIST=wheezy \ + \n export TEMPLATE_FLAVOR=whonix-gateway \ + \n export TEMPLATE_FLAVOR_PREFIX=" +buildStep "$0" "pre" +assertTest "buildStep $0 pre" "tests/template-flavors/wheezy+whonix-gateway/test_pre.sh" +assertEnd # ------------------------------------------------------------------------------ -head " 2. Without TEMPLATE_FOLDER - \n tests/template-flavors/wheezy/test_pre.sh" +head " 2. Without TEMPLATE_FLAVOR + \n export TEMPLATE_FLAVOR= " export TEMPLATE_FLAVOR="" -customStep "$0" "pre" -assertTest "customStep $0 pre" "tests/template-flavors/wheezy/test_pre.sh" -assertEnd "Test 2" +buildStep "$0" "pre" +assertTest "buildStep $0 pre" "tests/template-flavors/test_pre.sh" +assertEnd # ------------------------------------------------------------------------------ head " 3. Template Options @@ -85,10 +87,10 @@ head " 3. Template Options # export TEMPLATE_FLAVOR="whonix-gateway" export TEMPLATE_OPTIONS=('gnome' 'kde') -customStep "$0" "pre" +buildStep "$0" "pre" debug "Not supposed to find wheezy+whonix-gateway+kde" -assertTest "customStep $0 pre" "tests/template-flavors/wheezy+whonix-gateway/test_pre.sh\ntests/template-flavors/wheezy+whonix-gateway+gnome/test_pre.sh" -assertEnd "Test 3" +assertTest "buildStep $0 pre" "tests/template-flavors/wheezy+whonix-gateway/test_pre.sh\ntests/template-flavors/wheezy+whonix-gateway+gnome/test_pre.sh" +assertEnd # ------------------------------------------------------------------------------ head " 4. Template Options with custom prefix @@ -101,10 +103,10 @@ export TEMPLATE_FLAVOR_PREFIX=( 'wheezy+whonix-gateway;debian+' 'wheezy+whonix-workstation;debian+' ) -customStep "$0" "pre" +buildStep "$0" "pre" debug "Not supposed to find debian+whonix-gateway+kde" -assertTest "customStep $0 pre" "tests/template-flavors/debian+whonix-gateway/test_pre.sh\ntests/template-flavors/wheezy+whonix-gateway+gnome/test_pre.sh" -assertEnd "Test 4" +assertTest "buildStep $0 pre" "tests/template-flavors/debian+whonix-gateway/test_pre.sh\ntests/template-flavors/wheezy+whonix-gateway+gnome/test_pre.sh" +assertEnd # ------------------------------------------------------------------------------ head " 5. Template Options with NO prefix @@ -117,46 +119,95 @@ export TEMPLATE_FLAVOR_PREFIX=( 'wheezy+whonix-gateway;' 'wheezy+whonix-workstation;' ) -customStep "$0" "pre" +buildStep "$0" "pre" debug "Not supposed to find whonix-gateway+kde" -assertTest "customStep $0 pre" "tests/template-flavors/whonix-gateway/test_pre.sh\ntests/template-flavors/wheezy+whonix-gateway+gnome/test_pre.sh" -assertEnd "Test 5" +assertTest "buildStep $0 pre" "tests/template-flavors/whonix-gateway/test_pre.sh\ntests/template-flavors/wheezy+whonix-gateway+gnome/test_pre.sh" +assertEnd # ------------------------------------------------------------------------------ head " 6. Custom template directory \n unset TEMPLATE_FLAVOR_PREFIX \ \n unset TEMPLATE_OPTIONS \ - \n TEMPLATE_FLAVOR_DIR=wheezy+whonix-gateway;tests/template-flavors/another_location" + \n TEMPLATE_FLAVOR_DIR=wheezy+whonix-gateway;tests/template-flavors/another_location/whonix-gw" unset TEMPLATE_FLAVOR_PREFIX unset TEMPLATE_OPTIONS -TEMPLATE_FLAVOR_DIR="wheezy+whonix-gateway;tests/template-flavors/another_location" -customStep "$0" "pre" -assertTest "customStep $0 pre" "tests/template-flavors/another_location/wheezy+whonix-gateway/test_pre.sh" -assertEnd "Test 6" +TEMPLATE_FLAVOR_DIR="wheezy+whonix-gateway;tests/template-flavors/another_location/whonix-gw" +buildStep "$0" "pre" +assertTest "buildStep $0 pre" "tests/template-flavors/another_location/whonix-gw/test_pre.sh" +assertEnd # ------------------------------------------------------------------------------ -head " 7. Custom template directory for options +head " 7. Custom template directory with space in name \n unset TEMPLATE_FLAVOR_PREFIX \ \n unset TEMPLATE_OPTIONS \ - \n TEMPLATE_FLAVOR_DIR=wheezy+whonix-gateway+gnome;tests/template-flavors/another_location" + \n TEMPLATE_FLAVOR_DIR=wheezy+whonix-gateway;tests/template-flavors/another_location/whonix gw" +TEMPLATE_FLAVOR_DIR="wheezy+whonix-gateway;tests/template-flavors/another_location/whonix gw" +buildStep "$0" "pre" +assertTest "buildStep $0 pre" "tests/template-flavors/another_location/whonix gw/test_pre.sh" +assertEnd + +# ------------------------------------------------------------------------------ +head " 8. Custom template directory for options + \n unset TEMPLATE_FLAVOR_PREFIX \ + \n unset TEMPLATE_OPTIONS \ + \n TEMPLATE_FLAVOR_DIR=wheezy+whonix-gateway+gnome;tests/template-flavors/another_location/whonix_gnome" unset TEMPLATE_FLAVOR_PREFIX export TEMPLATE_OPTIONS=('gnome') -TEMPLATE_FLAVOR_DIR="wheezy+whonix-gateway+gnome;tests/template-flavors/another_location" -customStep "$0" "pre" -assertTest "customStep $0 pre" "tests/template-flavors/wheezy+whonix-gateway/test_pre.sh\ntests/template-flavors/another_location/wheezy+whonix-gateway+gnome/test_pre.sh" -assertEnd "Test 7" +TEMPLATE_FLAVOR_DIR="wheezy+whonix-gateway+gnome;tests/template-flavors/another_location/whonix_gnome" +buildStep "$0" "pre" +assertTest "buildStep $0 pre" "tests/template-flavors/wheezy+whonix-gateway/test_pre.sh\ntests/template-flavors/another_location/whonix_gnome/test_pre.sh" +assertEnd + +# ------------------------------------------------------------------------------ +head " 9. Configuration Files + \n Find packages.list for every template available" +TEMPLATE_FLAVOR_DIR="wheezy+whonix-gateway;tests/template-flavors/another_location/whonix gw" +getFileLocations filelist 'packages.list' +for file in "${filelist[@]}"; do + echo "Configuration: ${file}" +done +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" +assertEnd + +# ------------------------------------------------------------------------------ +head "10. Configuration Files - No Template + \n Find packages.list for every template available" +TEMPLATE_FLAVOR= +TEMPLATE_FLAVOR_DIR= +getFileLocations filelist 'packages.list' +for file in "${filelist[@]}"; do + echo "Configuration: ${file}" +done +result="$(echo $(printf "'%s' " "${filelist[@]}"))" +assertTest "echo ${result}" "tests/template-flavors/packages.list" +assertEnd + +# ------------------------------------------------------------------------------ +head "11. Configuration Files - No Template - with suffix + \n Find packages.list for every template available" +TEMPLATE_FLAVOR= +TEMPLATE_FLAVOR_DIR= +getFileLocations filelist 'packages.list' 'wheezy' +for file in "${filelist[@]}"; do + echo "Configuration: ${file}" +done +result="$(echo $(printf "'%s' " "${filelist[@]}"))" +assertTest "echo ${result}" "tests/template-flavors/packages_wheezy.list" +assertEnd # ------------------------------------------------------------------------------ export INSTALLDIR="${SCRIPTSDIR}/test_copy_location" -head " 8. Copy files +head "12. Copy files \n Just test copying from here to ${INSTALLDIR}" +TEMPLATE_FLAVOR="whonix-gateway" TEMPLATE_FLAVOR_DIR="" TEMPLATE_OPTIONS="" rm -rf "$INSTALLDIR"/* -copy_dirs "files" +copyTree "files" ls -l "$INSTALLDIR" assertTest "ls $INSTALLDIR" "test1\ntest2\ntest3" -assertEnd "Test 8" +assertEnd # Done popd diff --git a/tests/template-flavors/wheezy+whonix-gateway+gnome/packages.list b/tests/template-flavors/wheezy+whonix-gateway+gnome/packages.list new file mode 100644 index 0000000..e69de29 diff --git a/tests/template-flavors/wheezy+whonix-gateway/packages.list b/tests/template-flavors/wheezy+whonix-gateway/packages.list new file mode 100644 index 0000000..e69de29