distrobuilder icon indicating copy to clipboard operation
distrobuilder copied to clipboard

--compression should apply to both metadata and data tarballs

Open stribika opened this issue 6 months ago • 3 comments

Steps to reproduce:

# using any valid yaml config
sudo sudo distrobuilder build-lxc $distro.yaml $distro --compression=zstd
# this works but creates $distro/meta.tar.xz and $distro/rootfs.tar.zst

sudo lxc-create --name $container --template local -- --metadata $distro/meta.tar.xz --fstree $distro/rootfs.tar.zst

This does not work:

Using local temporary directory /tmp/tmp.EcnkdZdAKI
Using metadata file: devuan/meta.tar.xz
Unpacked metadata file: devuan/meta.tar.xz
Extracted network config to: /var/lib/lxc/velociraptor/config-network
lxc.net.0.type = veth
lxc.net.0.link = lxcbr0
lxc.net.0.flags = up
Extracted additional config to: /var/lib/lxc/velociraptor/config-extra
lxc.apparmor.profile = generated
lxc.apparmor.allow_nesting = 1
lxc.rootfs.path = btrfs:/var/lib/lxc/velociraptor/rootfs
Using rootfs file: devuan/rootfs.tar.zst
xz: (stdin): File format not recognized
tar: Child returned status 1
tar: Error is not recoverable: exiting now
lxc-create: velociraptor: ../src/lxc/lxccontainer.c: create_run_template: 1601 Failed to create container from template
lxc-create: velociraptor: ../src/lxc/tools/lxc_create.c: lxc_create_main: 318 Failed to create container velociraptor

Possibly the local template script is confused by the different compression methods.

distrobuilder version: 3.2 lxc-create version: 6.0.4

stribika avatar Oct 12 '25 21:10 stribika

The LXC local template only supports XZ.

stgraber avatar Oct 13 '25 03:10 stgraber

It certainly would still make sense for distrobuilder to be consistent about what it uses for compression across both files, but for use with the LXC local provider, only xz will work.

I suspect --compression was primarily added for the generation of the Incus images which do support most compression mechanism but where the metadata is typically always shipped as tar.xz regardless of the compression of the rootfs.

stgraber avatar Oct 13 '25 03:10 stgraber

I modified my lxc-local script to autodetect compression, it just involves using tar -a instead of tar -J, but I'm not sure of the portability implications.

PR is here: https://github.com/lxc/lxc/pull/4590

stribika avatar Oct 13 '25 11:10 stribika