openSUSE / zypper

World's most powerful command line package manager
http://en.opensuse.org/Portal:Zypper
Other
403 stars 110 forks source link

zypper writes logs relative to the --root directory and not in the default location #466

Closed dcermak closed 1 year ago

dcermak commented 1 year ago

We've hit a small issue with zypper & kiwi when building container images with kiwi on OBS that do not contain zypper themself, but where zypper is used to install the packages. Kiwi invokes zypper with the --root option to write the packages into a chroot that is then converted into the container image. The issue is that zypper then writes its logs into the chroot as well, so you end up with zypper logs in /var/log/ in your container image, despite there not even being a zypper inside it.

Could the behavior be changed so that the logfile location is not changed by --root?

For further info, see: https://github.com/OSInside/kiwi/issues/2127

mlandres commented 1 year ago

No. The zypp/history belongs to the system. It is the history of package installs and removals performed by libzypp (i.e. zypper, YAST, PK, .. ) on that system. It would not make sense to store this outside the system. It's kind of similar to the rpm database, which is present even if you don't install rpm itself in the chroot.

The zypper.log file is stored as expected in the system where zypper was called, and not in the target system.

mlandres commented 1 year ago

It is also intended that the file stays on the system even if libzypp itself is removed. There is no convenient way to disable this, but mabe kiwi already uses a custom zypp .conf:

Try creating a custom zypp.conf and set history.logfile=/dev/null in the [main] section. To use the custom zypp.conf export ZYPP_CONF=<the location of the custom zypp.conf>.

@dcermak Does this work for you?

dcermak commented 1 year ago

Try creating a custom zypp.conf and set history.logfile=/dev/null in the [main] section. To use the custom zypp.conf export ZYPP_CONF=<the location of the custom zypp.conf>.

@schaefi wdyt about doing something like that?

mlandres commented 1 year ago

Closing it.