ganto/copr-lxc4

Template LOCAL is broken -- patch is here

0bi-w6n-K3nobi opened this issue · 2 comments

Hi.

I was trying create a fedora 40 beta with DistroBuilder tool.
Initially, I did think that problem is distro be Beta.
I did try again with files was previously generated, which have already worked.
Well... the problem did same!
I used something like:

lxc-create -n fedora -t local -- --metadata meta.tar.xz --fstree rootfs.tar.xz

and I receive the follow error:

lxc-create: fedora: ../src/lxc/parse.c: lxc_file_for_each_line_mmap: 78 No such file or directory - Failed to open file "LXC_TEMPLATE_CONFIG/common.conf"
lxc-create: fedora: ../src/lxc/parse.c: lxc_file_for_each_line_mmap: 129 Failed to parse config file "/var/lib/lxc/fedora/config" at line "lxc.include = LXC_TEMPLATE_CONFIG/common.conf"
lxc-create: fedora: ../src/lxc/tools/lxc_create.c: lxc_create_main: 318 Failed to create container fedora

After some tests and sometime after, so I did remember that templates are Shell scripts...
The problem was generated by set TEMPLATES_FILES before to set LXC_PATH!
I did make some tests... and create the follow patch:

--- a/usr/share/lxc/templates/lxc-local 2024-04-12 21:00:00.000000000 -0300
+++ b/usr/share/lxc/templates/lxc-local  2024-04-20 16:34:32.173400930 -0300
@@ -18,7 +18,8 @@
 COMPAT_LEVEL=5

 EXCLUDES=""
-TEMPLATE_FILES="${LXC_PATH}/config"
+# TEMPLATE_FILES="${LXC_PATH}/config;${LXC_ROOTFS}/etc/hostname;${LXC_ROOTFS}/etc/hosts"
+#  Set only after to define LC_PATH and LXC_ROOTFS ...


 # Make sure the usual locations are in PATH
@@ -93,6 +94,8 @@
   esac
 done

+TEMPLATE_FILES="${LXC_PATH}/config;${LXC_ROOTFS}/etc/hostname;${LXC_ROOTFS}/etc/hosts"
+
 # Check for required binaries
 for bin in tar xz; do
   if ! command -V "${bin}" >/dev/null 2>&1; then

Well... I took the opportunity to adjust too LXC_NAME at /etc/hosts and /etc/hostname at container.

I hoped to helped you.

Well... I will report to official LXC Git Repo.
Thanks.

Yes, that doesn't look like packaging issue. Please report this to upstream.