edera-dev / krata

krata is a Xen control plane in Rust.
GNU General Public License v2.0
269 stars 12 forks source link

bug: issues with squashify tool with complex OCI images #10

Closed luna-xenia closed 6 months ago

luna-xenia commented 7 months ago

I'm trying to convert this image into a squashfs.

I've come across an issue where kratart-squashify will complain that a file already exists when creating the symlink, for example here:

Error: failed to unpack `/var/tmp/krata/krata-compile-66879995-6340-4376-9ea9-75435305fba1/image/bin`

Caused by:
    File exists (os error 17) when symlinking usr/bin to /var/tmp/krata/krata-compile-66879995-6340-4376-9ea9-75435305fba1/image/bin

The odd thing is that /var/tmp/krata/krata-compile-66879995-6340-4376-9ea9-75435305fba1/image/bin is already a symlink to usr/bin.

I wonder if it would be possible to just overwrite in case of the file already existing?

luna-xenia commented 6 months ago

Most recent error:

$ sudo TMPDIR=/var/tmp/krata ./target/x86_64-unknown-linux-gnu/release/examples/krataoci-squashify registry.gitlab.com/xenia-group/images/gnome-systemd:main

Error: failed to unpack `/var/tmp/krata/krata-compile-06febd3a-10f4-4169-8d6e-c48021e2ad52/image/usr/lib/python3.11/site-packages/gtweak/tweaks/__pycache__/tweak_group_appearance.cpython-311.pyc`

Caused by:
    No such file or directory (os error 2) while canonicalizing /var/tmp/krata/krata-compile-06febd3a-10f4-4169-8d6e-c48021e2ad52/image/usr/lib/python3.11/site-packages/gtweak/tweaks/__pycache__/tweak_group_appearance.cpython-311.opt-1.
kaniini commented 6 months ago

This is probably caused by the symlink coming before the target. We can solve this by deferring symlink creation until after the physical files are unpacked from an image.