blob: 7bc93a690bb185778c6b88073ca669cafc145172 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#!/bin/ash
# -*- coding: utf-8 -*-
# tarcopy <source_dir> <target_dir>
tarcopy() (
if ! [ -d "$1" ] || ! [ -d "$2" ]; then
echo "'$1' or '$2' is not a directory"
return 1
fi
cd "$1" || return 1
local filelist="$(mktemp)"
find . \! -type d > "$filelist"
if [ -s "$filelist" ]; then
tar -c -p -T "$filelist" | tar -xp -C "$2" || return 1
fi
rm -f -- "$filelist"
return 0
)
config_tgz="/etc/config.tgz"
[ -e "$config_tgz" ] || exit 1
# create list of overwritten files for debugging purposes
mkdir -p "${NEWROOT}/opt/openslx"
tar \
--list \
--verbose \
--file="$config_tgz" \
> "${NEWROOT}/opt/openslx/config.tgz.list" 2>&1
extract_dir="$(mktemp -d)"
if ! tar \
--extract \
--preserve-permissions \
--file="$config_tgz" \
--directory="$extract_dir"; then
echo "Failed to extract '$config_tgz' to '$extract_dir'."
exit 1
fi
# check SLX_LOCAL_CONFIG
. "/etc/openslx"
if [ -n "$SLX_LOCAL_CONFIG" ]; then
for mod in $SLX_LOCAL_CONFIG; do
if [ ! -d "${extract_dir}/openslx-configs/${mod}" ]; then
echo "Ignoring missing mod '$mod' in config.tgz"
else
tarcopy \
"${extract_dir}/openslx-configs/${mod}" \
"${extract_dir}"
fi
done
fi
# always purge openslx-configs/
rm -rf -- "${extract_dir}/openslx-configs"
# finally copy the rest into stage4
if ! tarcopy "${extract_dir}" "$NEWROOT"; then
echo "'tarcopy' from '$extract_dir' to '$NEWROOT' failed."
exit 1
fi
exit 0
|