Package layering fails due to missing log file

I am trying to install an .rpm package with rpm-ostree install /var/mnt/data/repo/nch.rpm, and it fails with the following error messages:

error: Running %post for nch: bwrap(/bin/sh): Child process killed by signal 1; run `journalctl -t 'rpm-ostree(nch.post)'` for more information

Calling journalctl -t 'rpm-ostree(nch.post)' shows this:

Feb 09 16:59:53 rpm-ostree(nch.post)[32467]: /proc/self/fd/5: line 1: /var/log/nch.install.log: No such file or directory
Feb 09 16:59:53 rpm-ostree(nch.post)[32463]: /proc/self/fd/5: line 2: /var/log/nch.install.log: No such file or directory
Feb 09 16:59:53 rpm-ostree(nch.post)[32463]: /proc/self/fd/5: line 122: /var/log/nch.install.log: No such file or directory

The error is being caused by these strings of %post script:

date +"%Y-%m-%d %T" >> /var/log/nch.install.log #error at line 1
echo "Post section started" >> /var/log/nch.install.log #error at line 2
#...
echo "Post section completed" >> /var/log/nch.install.log #error at line 122

I tried to run echo "Test" >> /var/log/test.log as superuser (through sudo -i), and it worked. But running rpm-ostree install /var/mnt/data/repo/nch.rpm in such way still produced described error.

Is it possible to work around it somehow? I could repackage the .rpm with changed script, but what changes should I make? I still need logging.

This is not a Fedora RPM. Is it one you built?

Suggest you fix the RPM to remove the log file writing.
Looks like debug code to me, so just remove it.

1 Like

RPM scriplets should not write to /var on rpm-ostree systems.

1 Like

Thank you. Understood. Can you please give a link to the doc where this rule is specified?

There is no official docs yet: Propose Fedora policy prohibiting scriptlets from writing to `/var` · Issue #1067 · coreos/fedora-coreos-tracker · GitHub

1 Like