lxc: fix decompression of rootfs tarballs
authorJohn Audia <therealgraysky@proton.me>
Tue, 16 Jul 2024 19:23:36 +0000 (15:23 -0400)
committerTianling Shen <cnsztl@gmail.com>
Mon, 24 Feb 2025 16:20:14 +0000 (00:20 +0800)
Modified 025-remove-unsupported-option.patch to both remove
the bsdtar command as it ends in errors, see below, and to
circumvent an error when extracting to overlayfs[1].

Error when extracting rootfs tarball with bsdtar:
tar --absolute-names --numeric-owner '--xattrs-include=*' -xpJf /var/cache/lxc//download/archlinux/current/amd64//default/rootfs.tar.xz -C /mnt/data/lxc/test/rootfs
./usr/bin/newgidmap: Cannot restore extended attributes on this system: Illegal byte sequence
lxc-create: test: ../src/lxc/lxccontainer.c: create_run_template: 1589 Failed to create container from template
lxc-create: test: ../src/lxc/tools/lxc_create.c: lxc_create_main: 318 Failed to create container test

1. https://github.com/openwrt/openwrt/issues/15888

Signed-off-by: John Audia <therealgraysky@proton.me>
Build system: x86/64
Build-tested: x86/64/AMD Cezanne
Run-tested: x86/64/AMD Cezanne

Signed-off-by: John Audia <therealgraysky@proton.me>
utils/lxc/Makefile
utils/lxc/patches/025-remove-unsupported-option.patch

index 90ff7f4b963d087b7de3f912cd827f73953486c4..e1fc688d4a3f9283bbace8d3b220373751f40057 100644 (file)
@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=lxc
 PKG_VERSION:=6.0.3
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://linuxcontainers.org/downloads/lxc/
index 7e7f4bffd8d908a19411d7f466c74381acb2f611..70eb12bbe60fc3d4f9c1d4b8b1908631684f5913 100644 (file)
@@ -1,9 +1,14 @@
 --- a/templates/lxc-download.in
 +++ b/templates/lxc-download.in
-@@ -380,26 +380,10 @@ if tar --version | grep -sq "bsdtar"; th
-     IS_BSD_TAR="true"
- fi
+@@ -375,32 +375,7 @@ fi
+ # Unpack the rootfs
+ echo "Unpacking the rootfs"
  
+-IS_BSD_TAR="false"
+-if tar --version | grep -sq "bsdtar"; then
+-    IS_BSD_TAR="true"
+-fi
+-
 -EXCLUDES=""
 -excludelist=$(relevant_file excludes)
 -if [ -f "${excludelist}" ]; then
 -# is to use a function wrapper, but the latter can't be used here as the args
 -# are dynamic. We thus need to ignore the warning brought by shellcheck.
 -# shellcheck disable=SC2086
- if [ "${IS_BSD_TAR}" = "true" ]; then
+-if [ "${IS_BSD_TAR}" = "true" ]; then
 -  tar ${EXCLUDES} --numeric-owner -xpJf "${LXC_CACHE_PATH}/rootfs.tar.xz" -C "${LXC_ROOTFS}"
-+  tar --numeric-owner -xpJf "${LXC_CACHE_PATH}/rootfs.tar.xz" -C "${LXC_ROOTFS}"
- else
+-else
 -  tar --anchored ${EXCLUDES} --numeric-owner --xattrs-include='*' -xpJf "${LXC_CACHE_PATH}/rootfs.tar.xz" -C "${LXC_ROOTFS}"
-+  tar --numeric-owner --xattrs-include='*' -xpJf "${LXC_CACHE_PATH}/rootfs.tar.xz" -C "${LXC_ROOTFS}"
- fi
+-fi
++tar --absolute-names --numeric-owner --xattrs-include='*' -xpJf "${LXC_CACHE_PATH}/rootfs.tar.xz" -C "${LXC_ROOTFS}"
  
  mkdir -p "${LXC_ROOTFS}/dev/pts/"