Skip to content

Conversation

@fpfcmsr
Copy link

@fpfcmsr fpfcmsr commented Apr 26, 2025

No description provided.

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. documentation Improvements or additions to documentation labels Apr 26, 2025
@hanthor
Copy link
Contributor

hanthor commented Apr 27, 2025

What are you doing/what image are you using where /opt isn't writable on the build?

@fpfcmsr
Copy link
Author

fpfcmsr commented Apr 28, 2025

Pulling in an aurora image. /opt is a symlink to /var/opt so its a file not a directory. As such trying to install packages to it fails.

@hanthor
Copy link
Contributor

hanthor commented Apr 28, 2025

lrwxrwxrwx@ - root  1 Jan  1970 opt -> var/opt
/🔒 
❯ cd /opt/

/opt🔒 
❯ sudo touch wood

/opt🔒 
❯ ls
containerd  wood

/opt🔒 
❯ ll
drwx--x--x@ - root 11 Apr 11:26  containerd
.rw-r--r--@ 0 root 28 Apr 11:57  wood

/opt🔒 
❯ 

I'm on Bluefin and it's writable.

@fpfcmsr
Copy link
Author

fpfcmsr commented Apr 29, 2025

I'm on Bluefin and it's writable.

At least when I try to install certain packages, say brother printers as an example, the github build fails if I do not do the process I described above.
This is the error:
[ 6/187] Installing brscan4-0:0.4.11-1 100% | 149.9 MiB/s | 306.9 KiB | 00m00s

[RPM] failed to open dir opt of /opt/brother/: cpio: mkdir failed - File exi
[RPM] unpacking of archive failed on file /opt/brother/scanner: cpio: mkdir
Unpack error: brscan4-0:0.4.11-1.x86_64
[ 1/187] Installing brscan-skey-0:0.3. 100% | 0.0 B/s | 204.6 KiB | 00m00s
[RPM] brscan4-0.4.11-1.x86_64: install failed
[RPM] failed to open dir opt of /opt/brother/scanner/: cpio: mkdir failed -
[RPM] unpacking of archive failed on file /opt/brother/scanner/brscan-skey:
Unpack error: brscan-skey-0:0.3.2-0.x86_64
[ 1/187] Installing brmfcfaxdrv-0:2.0. 100% | 129.0 MiB/s | 132.1 KiB | 00m00s
[RPM] brscan-skey-0.3.2-0.x86_64: install failed
[RPM] failed to open dir opt of /opt/: cpio: mkdir failed - File exists
[RPM] unpacking of archive failed on file /opt/brother: cpio: mkdir failed -
Unpack error: brmfcfaxdrv-0:2.0.2-1.x86_64

@m2Giles
Copy link
Member

m2Giles commented Jun 9, 2025

I can see why this is useful. /var/opt doesn't exist at build time and this puts it into the share factory.

I'm not sure, auto papering this over for people makes the most amount of sense though.

@Zeglius
Copy link
Collaborator

Zeglius commented Jun 24, 2025

There is already /usr/share/factory, which systemd-tmpfiles already use as fallback for any copy related operations.

Per example:

C+    /var/opt        -    -    -    -

With this tmpfile entry, /usr/share/factory/var/opt would be copied over /var/opt.
Reference

With this, we can recreate
the destination directory to the symlink (aka /var/opt), and copy it over /usr/share/factory as the final step.

@nickfraser
Copy link

Just saying that I definitely would appreciate this being documented in build.sh. I hit the identical issue today, which I seemed to have "worked-around" incorrectly.

@fpfcmsr
Copy link
Author

fpfcmsr commented Oct 10, 2025

There is already /usr/share/factory, which systemd-tmpfiles already use as fallback for any copy related operations.

Per example:

C+    /var/opt        -    -    -    -

With this tmpfile entry, /usr/share/factory/var/opt would be copied over /var/opt. Reference

With this, we can recreate the destination directory to the symlink (aka /var/opt), and copy it over /usr/share/factory as the final step.

I am interested in learning more about this. When installing ie bitwarden, I had to copy the files from /usr/share/factory to /var/opt manually. From my understanding your example would do this automatically. Would you be able to provide a way to have this configured out of the box? I am unsure how to proceed with the creation of the systemd-tmpfile.

@stevensko
Copy link
Contributor

stevensko commented Oct 12, 2025

There is already /usr/share/factory, which systemd-tmpfiles already use as fallback for any copy related operations.

Per example:

C+    /var/opt        -    -    -    -

With this tmpfile entry, /usr/share/factory/var/opt would be copied over /var/opt. Reference

With this, we can recreate the destination directory to the symlink (aka /var/opt), and copy it over /usr/share/factory as the final step.

that entry is missing a target path, which you're saying should be /var/opt/ but that would be putting the static package files on the writable persistent layer of /var/. updating the package on the image would break the package's install on the system.

@stevensko
Copy link
Contributor

# /opt is symlinked to /var/opt
# for packages that require it to be writeable do the following:
rm /opt # this is a file not a directory currently
mkdir /opt # create the opt directory so files can be installed to it
# install package (dnf5 -y install .....)
mv /opt /usr/share/factory # move files installed to /opt to /usr/share/factory so they will be in the final image
ln -s /var/opt /opt # restore symlink between /var/opt and /opt again

if you turn the symlink /opt/ into a real directory, you must delete it to symlink it again, else /opt/ won't point to /var/opt/ instead there will be a link /opt/opt/ pointing to /var/opt/

@stevensko
Copy link
Contributor

stevensko commented Oct 12, 2025

on fedora atomic, nothing on the base image is in /opt/. they simply did what they assumed was best practice and symlinked it to /var/opt/. /opt/ should only be used for static installation files of third party applications and /var/opt/ is used for dynamic runtimes. nothing should be written to /opt/ on atomic/ublue regardless of it being real or a symlink. therefore I propose the solution to this problem is simply to delete the symlink /opt/ and make it a real directory.

@mqzabin
Copy link

mqzabin commented Nov 22, 2025

I was having issues with this. Specifically, I was trying to install Brave and 1Password.

The instructions in the PR didn't work for me. The image built succesfully, but the programs were not available in the GNOME UI.

Maybe (I didn't check) the resulting files were in the image, but it would requires extra setup to make it work afterwards (maybe symlinking files to ~/local/share/application, etc?).

The @stevensko proposal worked for me:

therefore I propose the solution to this problem is simply to delete the symlink /opt/ and make it a real directory

i.e. just:

rm /opt
mkdir /opt

without moving the resulting /opt to /usr/share/factory or recreating the symlink.

@ EDIT
Just in case, my build.sh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants