summaryrefslogtreecommitdiffstats
path: root/builder
diff options
context:
space:
mode:
authorJonathan Bauer2019-08-26 15:51:01 +0200
committerJonathan Bauer2019-08-26 15:51:01 +0200
commit3e34238dc1ff3b6378d1dc1bb7dfc529c864d199 (patch)
tree7af172e069db8a0b296ad9ed00dffe48e672b3e6 /builder
parent[slx-network] make sure /opt/openslx/bin is directory (diff)
downloadsystemd-init-3e34238dc1ff3b6378d1dc1bb7dfc529c864d199.tar.gz
systemd-init-3e34238dc1ff3b6378d1dc1bb7dfc529c864d199.tar.xz
systemd-init-3e34238dc1ff3b6378d1dc1bb7dfc529c864d199.zip
[conf-tgz] do not overwrite directory permissions
Diffstat (limited to 'builder')
-rwxr-xr-xbuilder/modules.d/conf-tgz/hooks/unpack-config-tgz.sh20
1 files changed, 14 insertions, 6 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 588a65d3..86692fd2 100755
--- a/builder/modules.d/conf-tgz/hooks/unpack-config-tgz.sh
+++ b/builder/modules.d/conf-tgz/hooks/unpack-config-tgz.sh
@@ -6,6 +6,17 @@ core.import exceptions
core.import logging
type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh
+# tarcopy <source_dir> <target_dir>
+tarcopy() {
+ [ -d "$1" -a -d "$2" ] || return 1
+ cd "$1"
+ local filelist="$(mktemp)"
+ find . \! -type d > "$filelist"
+ tar -c -p -T /tmp/tctmp | tar -xp -C "$2"
+ rm -f -- "$filelist"
+ cd - &>/dev/null
+}
+
# this module unpacks the config.tgz
temporary_extract_directory="$(mktemp -d)"
exceptions.try
@@ -15,7 +26,6 @@ exceptions.try
tar --extract --preserve-permissions \
--file="/etc/config.tgz" \
--directory="$temporary_extract_directory"
- chown -R 0:0 "$temporary_extract_directory"
fi
}
exceptions.catch
@@ -32,8 +42,7 @@ if [[ -n "$SLX_LOCAL_CONFIGURATION" ]]; then
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..."
else
- cd "${temporary_extract_directory}/openslx-configs/${SLX_LOCAL_CONFIGURATION}"
- tar --create --preserve-permissions * | tar --extract --preserve-permissions --directory "${temporary_extract_directory}"
+ tarcopy "${temporary_extract_directory}/openslx-configs/${SLX_LOCAL_CONFIGURATION}" "${temporary_extract_directory}"
fi
}
exceptions.catch
@@ -47,10 +56,9 @@ fi
exceptions.try
{
exceptions.activate
- cd "${temporary_extract_directory}"
# purge openslx-configs/
- rm -rf "openslx-configs"
- tar --create --preserve-permissions * | tar --extract --preserve-permissions --directory "${NEWROOT}"
+ rm -rf "${temporary_extract_directory}/openslx-configs"
+ tarcopy "${temporary_extract_directory}" "$NEWROOT"
}
exceptions.catch
{