From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pve-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
	by lore.proxmox.com (Postfix) with ESMTPS id 003A71FF191
	for <inbox@lore.proxmox.com>; Mon,  2 Jun 2025 11:48:38 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 6D9711F050;
	Mon,  2 Jun 2025 11:48:31 +0200 (CEST)
From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: pbs-devel@lists.proxmox.com,
	pve-devel@lists.proxmox.com
Date: Mon,  2 Jun 2025 11:47:51 +0200
Message-Id: <20250602094756.519927-2-s.ivanov@proxmox.com>
X-Mailer: git-send-email 2.39.5
In-Reply-To: <20250602094756.519927-1-s.ivanov@proxmox.com>
References: <20250602094756.519927-1-s.ivanov@proxmox.com>
MIME-Version: 1.0
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.063 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DMARC_MISSING             0.1 Missing DMARC policy
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
Subject: [pve-devel] [PATCH proxmox-backup-restore-image 1/5] build
 initramfs: usr-merge initramfs
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: pve-devel-bounces@lists.proxmox.com
Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com>

usr-merged systems are default since bookworm [0].
the proxmox-restore-daemon otoh uses absolute paths to execute
commands inside the initramfs, without having a PATH set (which would
be used by Command::new (and execvpe(2) to resolve a relative
command).

merging all directories as on regular debian system ensures that the
restore-daemon does not need adapations based on the paths used in
upstream (and our) debian packages.

Found while looking through potential pitfalls due to ZFS usrmerge.

The change to the dpkg-deb invocation is based on what a quick look
through dpkg-sources [1] say dpkg does to unpack archives, as
`dpkg-deb -x` removed the symlinks to create a directory.

[0] https://wiki.debian.org/UsrMerge
[1] https://salsa.debian.org/dpkg-team/dpkg/-/blob/main/src/main/unpack.c?ref_type=heads#L1544

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
 src/build_initramfs.sh | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/build_initramfs.sh b/src/build_initramfs.sh
index 1ed0177..52a50c3 100755
--- a/src/build_initramfs.sh
+++ b/src/build_initramfs.sh
@@ -15,7 +15,12 @@ if [ -d pkgs ]; then
     NO_DOWNLOAD="1"
 fi
 cd "$BUILDDIR"
-mkdir "$ROOT"
+mkdir -p "$ROOT/usr"
+
+for dir in "bin" "sbin" "lib" "lib32" "lib64" ; do
+    mkdir "$ROOT/usr/$dir"
+    ln -sr "$ROOT/usr/$dir" "$ROOT/$dir"
+done
 
 # adds necessary packages to initramfs build root folder
 add_pkgs() {
@@ -44,7 +49,7 @@ add_pkgs() {
     fi
     if [ -z "$DOWNLOAD_ONLY" ]; then
         for deb in pkgs/$debdir/*.deb; do
-            dpkg-deb -x "$deb" "$ROOT"
+            dpkg-deb --fsys-tarfile "$deb" |tar -C "$ROOT" --keep-directory-symlink -x
         done
     fi
 }
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel