Created function to load package.list from proper directories. There can be multiple targets if TEMPLATE_FLAVOR and sub flavors are defined. All package.list files are kept within each flavor directory
Refactored some code to allow above to reduce duplication of code
This commit is contained in:
parent
7e4148a3b9
commit
f3a02b1251
214
functions.sh
214
functions.sh
@ -140,146 +140,148 @@ splitPath() {
|
|||||||
setArrayAsGlobal PARTS $return_global_var
|
setArrayAsGlobal PARTS $return_global_var
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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}" || :
|
|
||||||
|
|
||||||
splitPath "${calling_script}" path_parts
|
|
||||||
|
|
||||||
# Step: [pre] | [post] (or custom inserted step)
|
|
||||||
if [ "${step}" ]; then
|
|
||||||
script_name="${path_parts[base]}_${step}${path_parts[dotext]}"
|
|
||||||
else
|
|
||||||
script_name="${path_parts[base]}${path_parts[dotext]}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${template_flavor}" ]; then
|
|
||||||
script="${template_flavor_dir}/${template_flavor_prefix}${template_flavor}/${script_name}"
|
|
||||||
else
|
|
||||||
script="${template_flavor_dir}/${template_flavor_prefix}/${script_name}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
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}" || :
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
customCopy() {
|
|
||||||
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
|
|
||||||
|
|
||||||
if [ -d "${custom_dir}" ]; then
|
|
||||||
dir="${custom_dir}/"
|
|
||||||
elif [ -d "${template_flavor_dir}/${dir}" ]; then
|
|
||||||
dir="${template_flavor_dir}/${dir}/"
|
|
||||||
else
|
|
||||||
debug "No extra files to copy for ${dir}"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
dir="$(readlink -m $dir)"
|
|
||||||
debug "Copying ${dir}/* ${install_dir}"
|
|
||||||
cp -rp "${dir}/"* "${install_dir}"
|
|
||||||
|
|
||||||
if [ -f "${dir}/.facl" ]; then
|
|
||||||
debug "Restoring file permissions..."
|
|
||||||
pushd "$install_dir"
|
|
||||||
{
|
|
||||||
setfacl --restore="${dir}/.facl" 2>/dev/null ||:
|
|
||||||
}
|
|
||||||
popd
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
templateFlavor() {
|
templateFlavor() {
|
||||||
echo ${TEMPLATE_FLAVOR}
|
echo ${TEMPLATE_FLAVOR}
|
||||||
}
|
}
|
||||||
|
|
||||||
templateFlavorPrefix() {
|
templateFlavorPrefix() {
|
||||||
local template=${1-${TEMPLATE_FLAVOR}}
|
local template_flavor=${1-$(templateFlavor)}
|
||||||
for element in "${TEMPLATE_FLAVOR_PREFIX[@]}"
|
for element in "${TEMPLATE_FLAVOR_PREFIX[@]}"
|
||||||
do
|
do
|
||||||
if [ "${element%;*}" == "${DIST}+${template}" ]; then
|
if [ "${element%;*}" == "${DIST}+${template_flavor}" ]; then
|
||||||
echo ${element#*;}
|
echo ${element#*;}
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "${DIST}${TEMPLATE_FLAVOR:++}"
|
echo "${DIST}${template_flavor:++}"
|
||||||
}
|
}
|
||||||
|
|
||||||
templateFlavorDir() {
|
templateDir() {
|
||||||
local template=${1-${TEMPLATE_FLAVOR}}
|
local template_flavor=${1-$(templateFlavor)}
|
||||||
for element in "${TEMPLATE_FLAVOR_DIR[@]}"
|
for element in "${TEMPLATE_FLAVOR_DIR[@]}"
|
||||||
do
|
do
|
||||||
if [ "${element%;*}" == "${DIST}+${template}" ]; then
|
if [ "${element%;*}" == "$(templateFlavorPrefix ${template_flavor})${template_flavor}" ]; then
|
||||||
echo ${element#*;}
|
echo ${element#*;}
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "${SCRIPTSDIR}"
|
if [ -n "${template_flavor}" ]; then
|
||||||
|
local template_flavor_prefix="$(templateFlavorPrefix ${template_flavor})"
|
||||||
|
local dir="${SCRIPTSDIR}/${template_flavor_prefix}${template_flavor}"
|
||||||
|
else
|
||||||
|
local dir="${SCRIPTSDIR}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "${dir}"
|
||||||
}
|
}
|
||||||
|
|
||||||
customParse() {
|
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
|
||||||
|
file="${template_dir}/${path_parts[base]}${path_parts[dotext]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
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}"
|
||||||
|
# Execute $script
|
||||||
|
"${script}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
copyTreeExec() {
|
||||||
local calling_script="$1"
|
local calling_script="$1"
|
||||||
local step="$2"
|
local dir="$2"
|
||||||
|
local template_flavor="$3"
|
||||||
|
|
||||||
|
local template_dir="$(templateDir ${template_flavor})"
|
||||||
|
local source_dir="$(readlink -m ${template_dir}/${dir})"
|
||||||
|
local install_dir="$(readlink -m ${INSTALLDIR})"
|
||||||
|
|
||||||
|
if ! [ -d "${source_dir}" ]; then
|
||||||
|
debug "No extra files to copy for ${dir}"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
debug "Copying ${source_dir}/* ${install_dir}"
|
||||||
|
cp -rp "${source_dir}/"* "${install_dir}"
|
||||||
|
|
||||||
|
if [ -f "${source_dir}/.facl" ]; then
|
||||||
|
debug "Restoring file permissions..."
|
||||||
|
pushd "$install_dir"
|
||||||
|
{
|
||||||
|
setfacl --restore="${source_dir}/.facl" 2>/dev/null ||:
|
||||||
|
}
|
||||||
|
popd
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
callTemplateFunction() {
|
||||||
|
local calling_script="$1"
|
||||||
|
local calling_arg="$2"
|
||||||
local functionExec="$3"
|
local functionExec="$3"
|
||||||
local template_flavor="$(templateFlavor)"
|
local template_flavor="$(templateFlavor)"
|
||||||
local template_flavor_dir="$(templateFlavorDir ${template_flavor})"
|
|
||||||
local template_flavor_prefix="$(templateFlavorPrefix ${template_flavor})"
|
|
||||||
|
|
||||||
${functionExec} "${calling_script}" \
|
${functionExec} "${calling_script}" \
|
||||||
"${step}" \
|
"${calling_arg}" \
|
||||||
"${template_flavor}" \
|
"${template_flavor}"
|
||||||
"${template_flavor_dir}" \
|
|
||||||
"${template_flavor_prefix}"
|
|
||||||
|
|
||||||
|
for option in ${TEMPLATE_OPTIONS[@]}
|
||||||
for template in ${TEMPLATE_OPTIONS[@]}
|
|
||||||
do
|
do
|
||||||
template_flavor="$(templateFlavor)+${template}"
|
|
||||||
template_flavor_dir="$(templateFlavorDir ${template_flavor})"
|
|
||||||
template_flavor_prefix="$(templateFlavorPrefix ${template_flavor})"
|
|
||||||
|
|
||||||
${functionExec} "${calling_script}" \
|
${functionExec} "${calling_script}" \
|
||||||
"${step}" \
|
"${calling_arg}" \
|
||||||
"${template_flavor}" \
|
"$(templateFlavor)+${option}"
|
||||||
"${template_flavor_dir}" \
|
|
||||||
"${template_flavor_prefix}"
|
|
||||||
done
|
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
|
# Executes any additional optional configuration steps if the configuration
|
||||||
# scripts exist
|
# scripts exist
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
customStep() {
|
buildStep() {
|
||||||
customParse "$1" "$2" "customStepExec"
|
local filename="$1"
|
||||||
|
local suffix="$2"
|
||||||
|
local function="buildStepExec"
|
||||||
|
|
||||||
|
callTemplateFunction "${filename}" "${suffix}" "${function}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
@ -298,8 +300,12 @@ customStep() {
|
|||||||
# they get copied over to $INSTALLDIR
|
# they get copied over to $INSTALLDIR
|
||||||
# NOTE: Don't forget to redo this process if you add -OR- remove files
|
# NOTE: Don't forget to redo this process if you add -OR- remove files
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
copy_dirs() {
|
copyTree() {
|
||||||
customParse "" "$1" "customCopy"
|
local not_used=""
|
||||||
|
local dir="$1"
|
||||||
|
local function="copyTreeExec"
|
||||||
|
|
||||||
|
callTemplateFunction "${not_used}" "${dir}" "${function}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# $0 is module that sourced vars.sh
|
# $0 is module that sourced vars.sh
|
||||||
|
@ -19,9 +19,9 @@ INSTALLDIR="$(readlink -m mnt)"
|
|||||||
umount_kill "$INSTALLDIR" || :
|
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...
|
# Force overwrite of an existing image for now if debootstrap did not seem to complete...
|
||||||
@ -40,7 +40,7 @@ if [ -f "$IMG" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Execute any custom post configuration scripts
|
# Execute any template flavor or sub flavor 'post' scripts
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
customStep "$0" "post"
|
buildStep "$0" "post"
|
||||||
|
|
||||||
|
@ -16,9 +16,9 @@ else
|
|||||||
fi
|
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
|
# Install base debian system
|
||||||
@ -33,6 +33,6 @@ if ! [ -f "$INSTALLDIR/tmp/.prepared_debootstrap" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Execute any custom post configuration scripts
|
# Execute any template flavor or sub flavor 'post' scripts
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
customStep "$0" "post"
|
buildStep "$0" "post"
|
||||||
|
@ -31,9 +31,9 @@ fi
|
|||||||
for fs in /dev /dev/pts /proc /sys /run; do mount -B $fs "$INSTALLDIR/$fs"; done
|
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
|
if ! [ -f "$INSTALLDIR/tmp/.prepared_groups" ]; then
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
@ -98,29 +98,26 @@ EOF
|
|||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Install extra packages in script_$DEBIANVERSION/packages.list file
|
# Install extra packages in script_$DEBIANVERSION/packages.list file
|
||||||
|
# -and / or- TEMPLATE_FLAVOR directories
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
if [ -n "${TEMPLATE_FLAVOR}" ]; then
|
getFileLocations packages_list "packages.list" "${DIST}"
|
||||||
PKGLISTFILE="$SCRIPTSDIR/packages_${DIST}_${TEMPLATE_FLAVOR}.list"
|
if [ -z "${packages_list}" ]; then
|
||||||
if ! [ -r "${PKGLISTFILE}" ]; then
|
error "Can not locate a package.list file!"
|
||||||
error "ERROR: ${PKGLISTFILE} does not exists!"
|
umount_kill "$INSTALLDIR" || :
|
||||||
umount_kill "$INSTALLDIR" || :
|
exit 1
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
elif [ -r "$SCRIPTSDIR/packages_${DIST}.list" ]; then
|
|
||||||
PKGLISTFILE="$SCRIPTSDIR/packages_${DIST}.list"
|
|
||||||
else
|
|
||||||
PKGLISTFILE="$SCRIPTSDIR/packages.list"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
debug "Installing extra packages"
|
for package_list in "${packages_list[@]}"; do
|
||||||
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \
|
debug "Installing extra packages from: ${package_list}"
|
||||||
xargs chroot $INSTALLDIR apt-get -y --force-yes install < "$PKGLISTFILE"
|
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)
|
# (Whonix needs dependancies installed before installation)
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
customStep "$0" "packages_installed"
|
buildStep "$0" "packages_installed"
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Install systemd
|
# Install systemd
|
||||||
@ -194,7 +191,7 @@ EOF
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Execute any custom post configuration scripts
|
# Execute any template flavor or sub flavor 'post' scripts
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
customStep "$0" "post"
|
buildStep "$0" "post"
|
||||||
|
|
||||||
|
@ -30,9 +30,9 @@ fi
|
|||||||
for fs in /dev /dev/pts /proc /sys /run; do mount -B $fs "$INSTALLDIR/$fs"; done
|
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
|
# Install Qubes Packages
|
||||||
@ -188,15 +188,15 @@ EOF
|
|||||||
# $SCRIPT_DIR/extra-qubes-files
|
# $SCRIPT_DIR/extra-qubes-files
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
debug "Copy extra files..."
|
debug "Copy extra files..."
|
||||||
copy_dirs "extra-qubes-files"
|
copyTree "extra-qubes-files"
|
||||||
|
|
||||||
touch "$INSTALLDIR/tmp/.prepared_qubes"
|
touch "$INSTALLDIR/tmp/.prepared_qubes"
|
||||||
fi
|
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
|
# Kill all processes and umount all mounts within $INSTALLDIR, but not
|
||||||
|
@ -16,9 +16,9 @@ else
|
|||||||
fi
|
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
|
# 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
|
rm -rf buildchroot
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Execute any custom post configuration scripts
|
# Execute any template flavor or sub flavor 'post' scripts
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
customStep "$0" "post"
|
buildStep "$0" "post"
|
||||||
|
@ -1 +0,0 @@
|
|||||||
packages_jessie.list
|
|
@ -1 +0,0 @@
|
|||||||
packages_wheezy_whonix.list
|
|
@ -1 +0,0 @@
|
|||||||
packages_wheezy_whonix.list
|
|
1
scripts_debian/wheezy+whonix-gateway/packages_wheezy.list
Symbolic link
1
scripts_debian/wheezy+whonix-gateway/packages_wheezy.list
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../wheezy+whonix/packages_wheezy.list
|
1
scripts_debian/wheezy+whonix-workstation/packages_wheezy.list
Symbolic link
1
scripts_debian/wheezy+whonix-workstation/packages_wheezy.list
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../wheezy+whonix/packages_wheezy.list
|
@ -323,9 +323,9 @@ if ! [ -f "$INSTALLDIR/tmp/.prepared_whonix" ]; then
|
|||||||
fi
|
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
|
# XXX: Why do I need to move them out of the way? Lets try keeping them
|
||||||
# in place (modify post script too)
|
# in place (modify post script too)
|
||||||
|
@ -48,7 +48,7 @@ fi
|
|||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Copy over any extra files
|
# Copy over any extra files
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
copy_dirs "extra-whonix-files"
|
copyTree "extra-whonix-files"
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Cleanup Whonix Installation
|
# Cleanup Whonix Installation
|
||||||
|
4
tests/template-flavors/another_location/whonix_gnome/test_pre.sh
Executable file
4
tests/template-flavors/another_location/whonix_gnome/test_pre.sh
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# vim: set ts=4 sw=4 sts=4 et :
|
||||||
|
|
||||||
|
:
|
0
tests/template-flavors/packages.list
Normal file
0
tests/template-flavors/packages.list
Normal file
0
tests/template-flavors/packages_wheezy.list
Normal file
0
tests/template-flavors/packages_wheezy.list
Normal file
@ -1,4 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
# vim: set ts=4 sw=4 sts=4 et :
|
# vim: set ts=4 sw=4 sts=4 et :
|
||||||
|
|
||||||
VERBOSE=2
|
VERBOSE=2
|
||||||
@ -42,7 +42,7 @@ assertTest(){
|
|||||||
|
|
||||||
assertEnd() {
|
assertEnd() {
|
||||||
printf "${bold}${red}"
|
printf "${bold}${red}"
|
||||||
assert_end "$1"
|
[[ -n "$1" ]] && assert_end "$1" || assert_end
|
||||||
printf "${reset}"
|
printf "${reset}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,22 +60,24 @@ debug 'export SCRIPTSDIR="tests/template-flavors"'
|
|||||||
debug 'export DIST="wheezy"'
|
debug 'export DIST="wheezy"'
|
||||||
debug 'export TEMPLATE_FLAVOR="whonix-gateway"'
|
debug 'export TEMPLATE_FLAVOR="whonix-gateway"'
|
||||||
debug 'export TEMPLATE_FLAVOR_PREFIX=""'
|
debug 'export TEMPLATE_FLAVOR_PREFIX=""'
|
||||||
#debug "TEST=\"${TEST}\""
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
head " 1. With TEMPLATE_FOLDER
|
head " 1. With TEMPLATE_FLAVOR
|
||||||
\n tests/template-flavors/wheezy+whonix-gateway/test_pre.sh"
|
\n export SCRIPTSDIR=tests/template-flavors \
|
||||||
customStep "$0" "pre"
|
\n export DIST=wheezy \
|
||||||
assertTest "customStep $0 pre" "tests/template-flavors/wheezy+whonix-gateway/test_pre.sh"
|
\n export TEMPLATE_FLAVOR=whonix-gateway \
|
||||||
assertEnd "Test 1"
|
\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
|
head " 2. Without TEMPLATE_FLAVOR
|
||||||
\n tests/template-flavors/wheezy/test_pre.sh"
|
\n export TEMPLATE_FLAVOR= "
|
||||||
export TEMPLATE_FLAVOR=""
|
export TEMPLATE_FLAVOR=""
|
||||||
customStep "$0" "pre"
|
buildStep "$0" "pre"
|
||||||
assertTest "customStep $0 pre" "tests/template-flavors/wheezy/test_pre.sh"
|
assertTest "buildStep $0 pre" "tests/template-flavors/test_pre.sh"
|
||||||
assertEnd "Test 2"
|
assertEnd
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
head " 3. Template Options
|
head " 3. Template Options
|
||||||
@ -85,10 +87,10 @@ head " 3. Template Options
|
|||||||
#
|
#
|
||||||
export TEMPLATE_FLAVOR="whonix-gateway"
|
export TEMPLATE_FLAVOR="whonix-gateway"
|
||||||
export TEMPLATE_OPTIONS=('gnome' 'kde')
|
export TEMPLATE_OPTIONS=('gnome' 'kde')
|
||||||
customStep "$0" "pre"
|
buildStep "$0" "pre"
|
||||||
debug "Not supposed to find wheezy+whonix-gateway+kde"
|
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"
|
assertTest "buildStep $0 pre" "tests/template-flavors/wheezy+whonix-gateway/test_pre.sh\ntests/template-flavors/wheezy+whonix-gateway+gnome/test_pre.sh"
|
||||||
assertEnd "Test 3"
|
assertEnd
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
head " 4. Template Options with custom prefix
|
head " 4. Template Options with custom prefix
|
||||||
@ -101,10 +103,10 @@ export TEMPLATE_FLAVOR_PREFIX=(
|
|||||||
'wheezy+whonix-gateway;debian+'
|
'wheezy+whonix-gateway;debian+'
|
||||||
'wheezy+whonix-workstation;debian+'
|
'wheezy+whonix-workstation;debian+'
|
||||||
)
|
)
|
||||||
customStep "$0" "pre"
|
buildStep "$0" "pre"
|
||||||
debug "Not supposed to find debian+whonix-gateway+kde"
|
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"
|
assertTest "buildStep $0 pre" "tests/template-flavors/debian+whonix-gateway/test_pre.sh\ntests/template-flavors/wheezy+whonix-gateway+gnome/test_pre.sh"
|
||||||
assertEnd "Test 4"
|
assertEnd
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
head " 5. Template Options with NO prefix
|
head " 5. Template Options with NO prefix
|
||||||
@ -117,46 +119,95 @@ export TEMPLATE_FLAVOR_PREFIX=(
|
|||||||
'wheezy+whonix-gateway;'
|
'wheezy+whonix-gateway;'
|
||||||
'wheezy+whonix-workstation;'
|
'wheezy+whonix-workstation;'
|
||||||
)
|
)
|
||||||
customStep "$0" "pre"
|
buildStep "$0" "pre"
|
||||||
debug "Not supposed to find whonix-gateway+kde"
|
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"
|
assertTest "buildStep $0 pre" "tests/template-flavors/whonix-gateway/test_pre.sh\ntests/template-flavors/wheezy+whonix-gateway+gnome/test_pre.sh"
|
||||||
assertEnd "Test 5"
|
assertEnd
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
head " 6. Custom template directory
|
head " 6. Custom template directory
|
||||||
\n unset TEMPLATE_FLAVOR_PREFIX \
|
\n unset TEMPLATE_FLAVOR_PREFIX \
|
||||||
\n unset TEMPLATE_OPTIONS \
|
\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_FLAVOR_PREFIX
|
||||||
unset TEMPLATE_OPTIONS
|
unset TEMPLATE_OPTIONS
|
||||||
TEMPLATE_FLAVOR_DIR="wheezy+whonix-gateway;tests/template-flavors/another_location"
|
TEMPLATE_FLAVOR_DIR="wheezy+whonix-gateway;tests/template-flavors/another_location/whonix-gw"
|
||||||
customStep "$0" "pre"
|
buildStep "$0" "pre"
|
||||||
assertTest "customStep $0 pre" "tests/template-flavors/another_location/wheezy+whonix-gateway/test_pre.sh"
|
assertTest "buildStep $0 pre" "tests/template-flavors/another_location/whonix-gw/test_pre.sh"
|
||||||
assertEnd "Test 6"
|
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_FLAVOR_PREFIX \
|
||||||
\n unset TEMPLATE_OPTIONS \
|
\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
|
unset TEMPLATE_FLAVOR_PREFIX
|
||||||
export TEMPLATE_OPTIONS=('gnome')
|
export TEMPLATE_OPTIONS=('gnome')
|
||||||
TEMPLATE_FLAVOR_DIR="wheezy+whonix-gateway+gnome;tests/template-flavors/another_location"
|
TEMPLATE_FLAVOR_DIR="wheezy+whonix-gateway+gnome;tests/template-flavors/another_location/whonix_gnome"
|
||||||
customStep "$0" "pre"
|
buildStep "$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"
|
assertTest "buildStep $0 pre" "tests/template-flavors/wheezy+whonix-gateway/test_pre.sh\ntests/template-flavors/another_location/whonix_gnome/test_pre.sh"
|
||||||
assertEnd "Test 7"
|
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"
|
export INSTALLDIR="${SCRIPTSDIR}/test_copy_location"
|
||||||
head " 8. Copy files
|
head "12. Copy files
|
||||||
\n Just test copying from here to ${INSTALLDIR}"
|
\n Just test copying from here to ${INSTALLDIR}"
|
||||||
|
TEMPLATE_FLAVOR="whonix-gateway"
|
||||||
TEMPLATE_FLAVOR_DIR=""
|
TEMPLATE_FLAVOR_DIR=""
|
||||||
TEMPLATE_OPTIONS=""
|
TEMPLATE_OPTIONS=""
|
||||||
rm -rf "$INSTALLDIR"/*
|
rm -rf "$INSTALLDIR"/*
|
||||||
copy_dirs "files"
|
copyTree "files"
|
||||||
ls -l "$INSTALLDIR"
|
ls -l "$INSTALLDIR"
|
||||||
assertTest "ls $INSTALLDIR" "test1\ntest2\ntest3"
|
assertTest "ls $INSTALLDIR" "test1\ntest2\ntest3"
|
||||||
assertEnd "Test 8"
|
assertEnd
|
||||||
|
|
||||||
# Done
|
# Done
|
||||||
popd
|
popd
|
||||||
|
Loading…
Reference in New Issue
Block a user