From 30e5461b8d8e6a3c44d50fe1d04aa125870f1401 Mon Sep 17 00:00:00 2001 From: databreach <30411237+databreach@users.noreply.github.com> Date: Fri, 17 Nov 2023 14:39:53 +0100 Subject: [PATCH] Control device nodes Add control over whether device nodes are created. --- src/install.sh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/install.sh b/src/install.sh index 27f822b8..581a5a24 100644 --- a/src/install.sh +++ b/src/install.sh @@ -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-"*