From 8389c68ddf3e9d38d6a5609980eb165c3966782e Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Sun, 12 Jan 2020 06:01:36 +0100
Subject: [PATCH] Refactor.

---
 buster/setup_scripts/copy_dirtree.sh  | 1 +
 buster/setup_scripts/setup.sh         | 9 +++++----
 buster/setup_scripts/setup_desktop.sh | 4 ++--
 buster/setup_scripts/setup_server.sh  | 4 +---
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/buster/setup_scripts/copy_dirtree.sh b/buster/setup_scripts/copy_dirtree.sh
index ff4d5b4..af5bfc0 100755
--- a/buster/setup_scripts/copy_dirtree.sh
+++ b/buster/setup_scripts/copy_dirtree.sh
@@ -26,6 +26,7 @@ for target_module in "$@"; do
         target_path="${target_root}"$(echo "${path}" | cut -c2-)
         source_path=$(realpath "${path}")
         dir=$(dirname "${target_path}")
+        mkdir -p "${source_path}"
         mkdir -p "${dir}"
         cp "${source_path}" "${target_path}"
     done
diff --git a/buster/setup_scripts/setup.sh b/buster/setup_scripts/setup.sh
index ad3b3a9..adc229f 100755
--- a/buster/setup_scripts/setup.sh
+++ b/buster/setup_scripts/setup.sh
@@ -3,11 +3,12 @@ set -e
 
 # Provide maximum input for set_hostname_and_fqdn.sh.
 if [ "$#" -ne 2 ]; then
-    echo 'Need exactly two arguments (hostname, FQDN).'
+    echo 'Need at least two arguments (hostname, FQDN).'
     false
 fi
 hostname="$1"
 fqdn="$2"
+shift 2
 
 config_tree_prefix="${HOME}/config/buster"
 setup_scripts_dir="${config_tree_prefix}/setup_scripts"
@@ -16,7 +17,7 @@ cd "${setup_scripts_dir}"
 # Adapt /etc/ to our needs by copying from ./etc_files. This will set
 # basic configurations affecting following steps, such as setup of APT
 # and the locale selection, so needs to be right at the beginning.
-./copy_dirtree.sh "${config_tree_prefix}/etc_files" "" all
+./copy_dirtree.sh "${config_tree_prefix}/etc_files" "" all "@"
 
 # Set hostname and FQDN.
 ./set_hostname_and_fqdn.sh "${hostname}" "${fqdn}"
@@ -24,8 +25,8 @@ cd "${setup_scripts_dir}"
 # Ensure package installation state as defined by what packages are
 # defined as required by Debian policy and by settings in ./apt-mark/.
 apt update
-./install_for_target.sh all
-./purge_nonrequireds.sh all
+./install_for_target.sh all "@"
+./purge_nonrequireds.sh all "@"
 
 # Ensure our desired locale is available.
 locale-gen
diff --git a/buster/setup_scripts/setup_desktop.sh b/buster/setup_scripts/setup_desktop.sh
index c6eef8b..cea34a1 100755
--- a/buster/setup_scripts/setup_desktop.sh
+++ b/buster/setup_scripts/setup_desktop.sh
@@ -15,8 +15,8 @@ system_name="$1"
 config_tree_prefix="${HOME}/config/buster"
 setup_scripts_dir="${config_tree_prefix}/setup_scripts"
 cd "${setup_scripts_dir}"
-./setup.sh "${system_name}" ""
-./copy_dirtree.sh "${config_tree_prefix}/etc_files" "" user "${system_name}"
+./setup.sh "${system_name}" "" user desktop "${system_name}"
+./copy_dirtree.sh "${config_tree_prefix}/etc_files" "" user desktop "${system_name}"
 ./install_for_target.sh user desktop "${system_name}"
 
 # Set up printer.
diff --git a/buster/setup_scripts/setup_server.sh b/buster/setup_scripts/setup_server.sh
index b7a60e8..6d92c7c 100755
--- a/buster/setup_scripts/setup_server.sh
+++ b/buster/setup_scripts/setup_server.sh
@@ -15,6 +15,4 @@ fqdn="$2"
 config_tree_prefix="${HOME}/config/buster"
 setup_scripts_dir="${config_tree_prefix}/setup_scripts"
 cd "${setup_scripts_dir}"
-./setup.sh "${hostname}" "${fqdn}"
-./copy_dirtree.sh "${config_tree_prefix}/etc_files" "" server
-./install_for_target.sh server
+./setup.sh "${hostname}" "${fqdn}" server
-- 
2.30.2