OSInside / kiwi

KIWI - Appliance Builder Next Generation
https://osinside.github.io/kiwi
GNU General Public License v3.0
289 stars 145 forks source link

Allow to copy files to containers from image description without archive #1953

Closed fcrozat closed 1 month ago

fcrozat commented 2 years ago

Problem description

It is currently difficult to do the equivalent from Dockerfile COPY this_file / directly in kiwi image description.

This requires usage of "archive" or config.sh

Expected behaviour

Allowing to specific directly files in the kiwi description to be copied to a specific location on the image.

Vogtinator commented 2 years ago

Main motivation is to track such sources more easily, without the indirection of archives.

One complication is that unlike common archive types, it's not always possible to set the desired ownership/mode info on a raw file, unlike in an archive. So it might be necessary to allow overriding those.

schaefi commented 2 years ago

Hmm, why can't this be done with overlayfiles ?

The following is an example from some arbitrary image description

tree
.
├── appliance.kiwi
├── config.sh
├── disk.sh
└── root
    ├── etc
    │   ├── sysconfig
    │   │   └── network
    │   │       └── ifcfg-lan0
    │   └── udev
    │       └── rules.d
    │           └── 70-persistent-net.rules
    └── usr
        └── lib
            └── systemd
                └── system
                    ├── dracut_hostonly.service
                    └── grub_config.service

The files below root/ are copied (rsync) as they are into the image root tree

Any reason why you can't use this ?

dcermak commented 2 years ago

Marcus Schäfer @.***> writes:

Hmm, why can't this be done with overlayfiles ?

The following is an example from some arbitrary image description

tree
.
├── appliance.kiwi
├── config.sh
├── disk.sh
└── root
    ├── etc
    │   ├── sysconfig
    │   │   └── network
    │   │       └── ifcfg-lan0
    │   └── udev
    │       └── rules.d
    │           └── 70-persistent-net.rules
    └── usr
        └── lib
            └── systemd
                └── system
                    ├── dracut_hostonly.service
                    └── grub_config.service

The files below root/ are copied (rsync) as they are into the image root tree

Any reason why you can't use this ?

Because the UX of overlayfiles in the buildservice is comparably bad to just putting an archive into the package directly.

schaefi commented 2 years ago

Ah so this is about builds in obs. I usually go the git and source service way which would allow to just handle files as files

<service name="obs_scm">
        <param name="url">https://github.com/OSInside/kiwi.git</param>
        <param name="scm">git</param>
        <param name="subdir">build-tests/x86/tumbleweed/test-image-disk/root</param>
        <param name="filename">root</param>
        <param name="version">_none_</param>
        <param name="revision">master</param>
</service>

I assume you can't use this concept because OBS does not allow source services in the SUSE namespace. So latest at official submission time you would be back in a tarball.

What we can add to kiwi would be something like this

<packages type="image">
    <file name="some-file" target="target-in-root-tree"/>
</packages>

if "some-file" is a relative name it will be taken from the directory that contains the image description.

That way you should be able to osc add any file you need and reference it by its base name in the above way

Would that help ?

fcrozat commented 2 years ago

yes, this is exactly the kind of enhancement I had in mind

schaefi commented 1 month ago

adding this now

schaefi commented 1 month ago

@fcrozat It took a long time, sorry for the delay but now there is a PR open to address this