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+lljKf8JCxwbsxJItDCRrYy/OEY/y7THjPU16Y7fqUbE
 MQNVTKDbWNvfCpsBpjaje3R65KuM9axT+UzUHWE8bEnsy/ndWJ6uuj58YKbP8v8s
 qyL39QEhXbnTU6+NRfKs4tvKBfwfqeEXNz17HkJGoGtMcleojyythp7QBf4cRUqt
 9kSD4dAptrGHEWI3nKREQI9wxcEtReoZD4X8zEKNlGgXNOlLjkGKZEqgbkQ4I6+x
 tGLEh+RjR3TP/rA8f78jgqtv6VL2lGUjhaYubCdpgPGOBfFmDoenMLxGZGYC591U
 qWOv9OvffgOBZElOm09zRyGmzuqpvhrxLnDyihKGkmFCZkpz1xtLfv72mjQ/zg5c
 vonYzvjnsR/ZdyCnNQV0lTDFrC400I9bgDfR6aDfF+JzQ4pt3+wPVRqhPH+emjJa
 iOtHTI44Ddj9kQnkn+n9PVz0ivqLWukb1PyssaTbjqAdQ9DtLX0iQKaBoPAn0mjG
 Ffp7NmFaj1FJlZcn2wZg
 =VdWX
 -----END PGP SIGNATURE-----

Merge tag 'jm_09af4b94'

Tag for commit 09af4b9433

# gpg: Signature made Thu 24 Dec 2015 10:52:48 AM CET 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_09af4b94':
  functions.sh: Allow generic TEMPLATE_FLAVOR_DIR that matches all flavors, or even no flavors
  functions.sh: unset "build_step_files" var to prevent loading same files if no files found on another run
  function.sh:  Allow multiple template directories to be searched
pull/1/head mm_f7a3ce03
Marek Marczykowski-Górecki 8 years ago
commit f7a3ce03e3

@ -189,8 +189,9 @@ splitPath() {
setArrayAsGlobal PARTS $return_global_var
}
templateDir() {
templateDirs() {
local template_flavor=${1-${TEMPLATE_FLAVOR}}
local match=0
# If TEMPLATE_FLAVOR_DIR is not already an array, make it one
if ! [[ "$(declare -p TEMPLATE_FLAVOR_DIR 2>/dev/null)" =~ ^declare\ -a.* ]] ; then
@ -202,14 +203,24 @@ templateDir() {
# (wheezy+whonix-gateway / wheezy+whonix-gateway+gnome[+++] / wheezy+gnome )
if [ "${element%:*}" == "$(templateName ${template_flavor})" ]; then
eval echo -e "${element#*:}"
return
match=1
# Very short name compare (+proxy)
elif [ "${element:0:1}" == "+" -a "${element%:*}" == "+${template_flavor}" ]; then
eval echo -e "${element#*:}"
return
match=1
# Generic template directory that matches all flavors, or even no flavors
elif [ "${element:0:1}" == "*" ]; then
eval echo -e "${element#*:}"
match=1
fi
done
if [ "${match}" -eq 1 ]; then
return
fi
local template_flavor_prefix="$(templateFlavorPrefix ${template_flavor})"
if [ -n "${template_flavor}" -a "${template_flavor}" == "+" ]; then
local dir="${SCRIPTSDIR}/${template_flavor_prefix}"
@ -241,55 +252,57 @@ templateFile() {
local file="$1"
local suffix="$2"
local template_flavor="$3"
local template_dir="$(templateDir "${template_flavor}")"
local template_dirs="$(templateDirs "${template_flavor}")"
splitPath "${file}" path_parts
# No template flavor
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
for template_dir in ${template_dirs[@]}; do
# No template flavor
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
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
# 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
# (TEMPLATE_FLAVOR_DIR/minimal/packages_qubes_suffix.list)
exists "${template_dir}/${template_flavor}/${path_parts[base]}_${suffix}${path_parts[dotext]}" || true
# (TEMPLATE_FLAVOR_DIR/minimal/packages_qubes_suffix.list)
exists "${template_dir}/${template_flavor}/${path_parts[base]}_${suffix}${path_parts[dotext]}" || true
# (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
# (TEMPLATE_FLAVOR_DIR/packages_qubes_suffix.list)
exists "${template_dir}/${path_parts[base]}_${suffix}${path_parts[dotext]}" || true
# (TEMPLATE_FLAVOR_DIR/packages_qubes_minimal_suffix.list)
exists "${template_dir}/${path_parts[base]}_${suffix}_${template_flavor}${path_parts[dotext]}" || true
# (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)
exists "${SCRIPTSDIR}/${path_parts[base]}_${suffix}_${template_flavor}${path_parts[dotext]}" || true
else
# (TEMPLATE_FLAVOR_DIR/minimal/packages_qubes.list)
exists "${template_dir}/${template_flavor}/${path_parts[base]}${path_parts[dotext]}" || true
# (SCRIPTSDIR/packages_qubes_minimal_suffix.list)
exists "${SCRIPTSDIR}/${path_parts[base]}_${suffix}_${template_flavor}${path_parts[dotext]}" || true
else
# (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/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
# (TEMPLATE_FLAVOR_DIR/packages_qubes.list)
exists "${template_dir}/${path_parts[base]}${path_parts[dotext]}" || true
# (TEMPLATE_FLAVOR_DIR/packages_qubes_minimal.list)
exists "${template_dir}/${path_parts[base]}_${template_flavor}${path_parts[dotext]}" || true
# (TEMPLATE_FLAVOR_DIR/packages_qubes_minimal.list)
exists "${template_dir}/${path_parts[base]}_${template_flavor}${path_parts[dotext]}" || true
# (SCRIPTSDIR/packages_qubes_minimal.list)
exists "${SCRIPTSDIR}/${path_parts[base]}_${template_flavor}${path_parts[dotext]}" || true
fi
# (SCRIPTSDIR/packages_qubes_minimal.list)
exists "${SCRIPTSDIR}/${path_parts[base]}_${template_flavor}${path_parts[dotext]}" || true
fi
done
}
copyTreeExec() {
@ -298,27 +311,30 @@ copyTreeExec() {
local template_flavor="$3"
local target_dir="$4"
local template_dir="$(templateDir ${template_flavor})"
local source_dir="$(readlink -m ${source_dir:-${template_dir}}/${dir})"
local target_dir="$(readlink -m ${target_dir:-${INSTALLDIR}})"
local template_dirs="$(templateDirs ${template_flavor})"
if ! [ -d "${source_dir}" ]; then
debug "No extra files to copy for ${dir}"
return 0
fi
for template_dir in ${template_dirs[@]}; do
local source_dir="$(readlink -m ${source_dir:-${template_dir}}/${dir})"
local target_dir="$(readlink -m ${target_dir:-${INSTALLDIR}})"
debug "Copying ${source_dir}/* ${target_dir}"
cp -rp "${source_dir}/." "${target_dir}"
if [ -f "${source_dir}/.facl" ]; then
debug "Restoring file permissions..."
pushd "${target_dir}"
{
setfacl --restore="${source_dir}/.facl" 2>/dev/null ||:
rm -f .facl
}
popd
fi
if ! [ -d "${source_dir}" ]; then
debug "No extra files to copy for ${dir}"
return 0
fi
debug "Copying ${source_dir}/* ${target_dir}"
cp -rp "${source_dir}/." "${target_dir}"
if [ -f "${source_dir}/.facl" ]; then
debug "Restoring file permissions..."
pushd "${target_dir}"
{
setfacl --restore="${source_dir}/.facl" 2>/dev/null ||:
rm -f .facl
}
popd
fi
done
}
callTemplateFunction() {
@ -408,6 +424,7 @@ getFileLocations() {
buildStep() {
local filename="$1"
local suffix="$2"
unset build_step_files
info "Locating buildStep files: ${filename##*/} suffix: ${suffix}"
getFileLocations "build_step_files" "${filename}" "${suffix}"

Loading…
Cancel
Save