feat: Control device nodes #382

feat: Control device nodes #382
This commit is contained in:
Kroese 2023-11-17 15:16:36 +01:00 committed by GitHub
commit f0ce992a27

View File

@ -1,6 +1,8 @@
#!/usr/bin/env bash
set -Eeuo pipefail
: ${DEV:='Y'} # Controls whether device nodes are created.
if [ -f "$STORAGE"/dsm.ver ]; then
BASE=$(cat "${STORAGE}/dsm.ver")
else
@ -107,8 +109,14 @@ if [ -f "${RDC}" ]; then
{ xz -dc <"$RDC" >"$TMP/rd" 2>/dev/null; rc=$?; } || :
(( rc != 1 )) && error "Failed to unxz $RDC, reason $rc" && exit 91
{ (cd "$TMP" && cpio -idm <"$TMP/rd" 2>/dev/null); rc=$?; } || :
(( rc != 0 )) && error "Failed to cpio $RDC, reason $rc" && exit 92
if [[ "${DEV}" == [Nn]* ]]; then
# Exclude dev/ from cpio extract
{ (cd "$TMP" && cpio -it < "$TMP/rd" | grep -Ev 'dev/' | while read -r entry; do cpio -idm "$entry" < "$TMP/rd" 2>/dev/null; done); rc=$?; } || :
(( rc != 0 )) && error "Failed to extract $RDC, reason $rc" && exit 92
else
{ (cd "$TMP" && cpio -idm <"$TMP/rd" 2>/dev/null); rc=$?; } || :
(( rc != 0 )) && error "Failed to cpio $RDC, reason $rc" && exit 92
fi
mkdir -p /run/extract
for file in $TMP/usr/lib/libcurl.so.4 \
@ -240,7 +248,13 @@ MOUNT="$TMP/system"
rm -rf "$MOUNT" && mkdir -p "$MOUNT"
mv "$HDA.tgz" "$HDA.txz"
tar xpfJ "$HDA.txz" --absolute-names -C "$MOUNT/"
if [[ "${DEV}" == [Nn]* ]]; then
# Exclude dev/ from tar extract
tar xpfJ "$HDA.txz" --absolute-names --exclude="dev" -C "$MOUNT/"
else
tar xpfJ "$HDA.txz" --absolute-names -C "$MOUNT/"
fi
[ -d "$PKG" ] && mv "$PKG/" "$MOUNT/.SynoUpgradePackages/"
rm -f "$MOUNT/.SynoUpgradePackages/ActiveInsight-"*