summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Bauer2019-11-29 12:01:54 +0100
committerJonathan Bauer2019-11-29 12:01:54 +0100
commita59da382e2751c02febd504c97f7ba968845d8b6 (patch)
tree313ba16e931bf9b67a6093d13929598b241ec68b
parent[slx-addons] log ld.so.cache stuff (diff)
downloadsystemd-init-a59da382e2751c02febd504c97f7ba968845d8b6.tar.gz
systemd-init-a59da382e2751c02febd504c97f7ba968845d8b6.tar.xz
systemd-init-a59da382e2751c02febd504c97f7ba968845d8b6.zip
[conf-tgz] simplify unpacking script
-rwxr-xr-xbuilder/modules.d/conf-tgz/hooks/unpack-config-tgz.sh74
1 files changed, 27 insertions, 47 deletions
diff --git a/builder/modules.d/conf-tgz/hooks/unpack-config-tgz.sh b/builder/modules.d/conf-tgz/hooks/unpack-config-tgz.sh
index a2d550ce..5cc074bc 100755
--- a/builder/modules.d/conf-tgz/hooks/unpack-config-tgz.sh
+++ b/builder/modules.d/conf-tgz/hooks/unpack-config-tgz.sh
@@ -1,9 +1,6 @@
#!/usr/bin/env bash
# -*- coding: utf-8 -*-
-source '/usr/lib/rebash/core.sh'
-core.import exceptions
-core.import logging
type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh
# tarcopy <source_dir> <target_dir>
@@ -17,52 +14,35 @@ tarcopy() {
cd - &>/dev/null
}
-# this module unpacks the config.tgz
-temporary_extract_directory="$(mktemp -d)"
-exceptions.try
-{
- exceptions.activate
- if [[ -e "/etc/config.tgz" ]]; then
- tar --extract --preserve-permissions \
- --file="/etc/config.tgz" \
- --directory="$temporary_extract_directory"
+unpack_config_tgz() {
+ local config_tgz="/etc/config.tgz"
+ local extract_dir="$(mktemp -d)"
+ tar --extract --preserve-permissions \
+ --file="/etc/config.tgz" \
+ --directory="$extract_dir"
+ if [ "$?" -ne 0 ]; then
+ warn "Failed to extract '$config_tgz' to '$extract_dir'."
+ return 1
fi
-}
-exceptions.catch
-{
- logging.error "Failed to extract '/etc/config.tgz' to '$temporary_extract_directory'."
- logging.error "$exceptions_last_traceback"
-}
-# extracted to temporary directory, now check for SLX_LOCAL_CONFIGURATION
-source "/etc/openslx"
-if [[ -n "$SLX_LOCAL_CONFIGURATION" ]]; then
- exceptions.try
- {
- exceptions.activate
- if [[ ! -d "${temporary_extract_directory}/openslx-configs/${SLX_LOCAL_CONFIGURATION}" ]]; then
- logging.warn "SLX_LOCAL_CONFIGURATION is set but no corresponding folder found in '/etc/config.tgz'. Ignoring..."
+ # check SLX_LOCAL_CONFIGURATION
+ source "/etc/openslx"
+ if [ -n "$SLX_LOCAL_CONFIGURATION" ]; then
+ if [ ! -d "${extract_dir}/openslx-configs/${SLX_LOCAL_CONFIGURATION}" ]; then
+ logging.warn "Ignoring missing SLX_LOCAL_CONFIGURATION in '/etc/config.tgz'."
else
- tarcopy "${temporary_extract_directory}/openslx-configs/${SLX_LOCAL_CONFIGURATION}" "${temporary_extract_directory}"
+ tarcopy \
+ "${temporary_extract_directory}/openslx-configs/${SLX_LOCAL_CONFIGURATION}" \
+ "${temporary_extract_directory}"
fi
- }
- exceptions.catch
- {
- # errors here are not critical, so no emergency shell
- logging.error "Failed to merge local configuration files for '$SLX_LOCAL_CONFIGURATION'."
- logging.error "$exceptions_last_traceback"
- }
-fi
-# now just copy everything from the temporary_extract_directory to the future root
-exceptions.try
-{
- exceptions.activate
- # purge openslx-configs/
+ fi
+ # always purge openslx-configs/
rm -rf "${temporary_extract_directory}/openslx-configs"
- tarcopy "${temporary_extract_directory}" "$NEWROOT"
-}
-exceptions.catch
-{
- # errors here are not critical, so no emergency shell
- logging.error "Failed to copy extracted configuration files to '$NEWROOT'."
- logging.error "$exceptions_last_traceback"
+
+ # finally copy the rest into stage4
+ if ! tarcopy "${temporary_extract_directory}" "$NEWROOT"; then
+ warn "'tarcopy' from '$temporary_extract_directory' to '$NEWROOT' failed."
+ fi
}
+
+unpack_config_tgz
+: