blue-build / modules

BlueBuild standard modules used for building your Atomic Images
Apache License 2.0
22 stars 26 forks source link

docs: add warning about writing to /usr/local/ and other /var/ symlinks in files module #189

Closed michaelhaaf closed 2 months ago

michaelhaaf commented 3 months ago

Current Behavior

Using the files module, when writing to /usr/local/, the following build-error arises:

========== Start Files module ==========
Adding files to image
Copying /tmp/config/files/usr to /usr
cp: cannot overwrite non-directory '/usr/local' with directory '/tmp/config/files/usr/local'
Error: building at STEP "RUN --mount=type=tmpfs,target=/var --mount=type=bind,from=stage-config,src=/config,dst=/tmp/config,rw --mount=type=bind,from=stage-modules,src=/modules,dst=/tmp/modules,rw --mount=type=bind,from=ghcr.io/blue-build/cli:exports,src=/exports.sh,dst=/tmp/exports.sh --mount=type=cache,dst=/var/cache/rpm-ostree,id=rpm-ostree-cache-combined-nvidia-latest,sharing=locked echo "========== Start Files module =========="   && chmod +x /tmp/modules/files/files.sh   && source /tmp/exports.sh   && /tmp/modules/files/files.sh '{"type":"files","files":[{"usr":"/usr"}]}'   && echo "========== End Files module =========="   && ostree container commit": while running runtime: exit status 1
ERROR => Failed to build combined-nvidia:local-39

See:

Originally I reproduced this locally on a bluebuild-alpine distrobox (environment information follows below).

Expected Behavior

The successful build shows that the file module is capable of writing to /usr/share/ and /usr/etc/. My expectation is that /usr/local/ would work the same.

Example use case: manually adding system fonts that are not NerdFonts or GoogleFonts using a script. To my understanding, /usr/local/ is the recommended location, see Fonts#Manual_installation in ArchWiki

My expectation could be wrong, for e.g. it is known that /etc should not be written to and this is explained in the BlueBuild documentation and, I think, in the upstream ublueos & fedora documentation as well (at least, that's my memory... couldn't find an example actually).

Additional context/Screenshots

N/A

Possible Solution

Either a fix (not sure where to start) or a documentation update.

Environment

Shell

This is free software; you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

Rust

Recipe:

fiftydinar commented 3 months ago

/usr/local is a symlink to /var/usrlocal.

Writing to /var in build-time is currently not supported. This is an issue which needs to be solved in upstream.

fiftydinar commented 3 months ago

As a workaround, you may try to use tmpfiles.d, as Universal Blue uses it for exact same purpose of copying files that you can't in build-time. You may take a look at their SeLinux fixes for some of their packages, which I can't link right now, as an inspiration.

michaelhaaf commented 3 months ago

Ohhh okay that does make sense. Thanks @fiftydinar.

For other's reference here's the upstream documentation about /var/ symlinks and the some bluebuild documentation that discusses it too

I feel a note about /var/ and the common symlinks like /usr/local/ would be useful in the files module documentation next to the note about /etc/. I don't mind writing it.

fiftydinar commented 3 months ago

I feel a note about /var/ and the common symlinks like /usr/local/ would be useful in the files module documentation next to the note about /etc/. I don't mind writing it.

I agree, it would be nice to further document this.

Maybe making a workaround for copying files to /var could be even integrated into the files module through mentioned tmpfiles.d systemd service. But we would need to assure that implementation is good (at least better than optfix which is used in rpm-ostree & which can be clunky at times)

gmpinder commented 3 months ago

Should this be moved to the website repo? I feel like that's where general documentation would be done. What do you think @xynydev ?

xynydev commented 3 months ago

I think this is about documentation specifically for the files module, the docs of which are still currently in this repo IIRC, but in principle docs issues should go on the website. If I'm right about the docs being in this repo, you could just remove them, as IIRC we're using the bash files module in all images.

gmpinder commented 3 months ago

Yeah if you can update the website to point to the modules repo instead for files, I'll remove the docs from this repo. In which case I'll also move this ticket to modules since the docs would need to be updated there.

xynydev commented 2 months ago

The website already points to modules repo, cli just can override it.

fiftydinar commented 2 months ago

This is completed with the merged PR below:

https://github.com/blue-build/modules/pull/205