rpm-software-management / mock

Mock is a tool for a reproducible build of RPM packages.
GNU General Public License v2.0
381 stars 226 forks source link

Entangled cleaning options #1277

Open mikem23 opened 9 months ago

mikem23 commented 9 months ago

Short description of the problem

Override of cleanup_on_success setting triggers mock to run rpmbuild with --noclean, which can break builds in certain situations.

cleanup_on_success defaults to True, but is forced to False when is_in_dir(config_resultdir, basechrootdir). This check seems to be True in default invocations. The basechrootdir value here is {basedir}/{root}, not the actual chroot directory ({basedir}/{root}/root).

It certainly makes sense to avoid deleting the results, but passing --noclean to rpmbuild is really a separate question and certainly isn't required to avoid deleting the mock resultdir.

I would suggest:

Output of rpm -q mock

mock-5.2-1.el8eng.noarch

Steps to reproduce issue

  1. use mock with a buildroot that supports rpmbuild --noclean
  2. leave cleanup_on_success=True
  3. perform a mock build and observe that --noclean is being passed

Do not forget to mention full commandline with the mock command you executed.

mock -r mikem-RHELBLD-14264 --old-chroot --no-clean --target x86_64 --rebuild /tmp/fake-1.1-33.src.rpm

Any additional notes

Related -- https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=2105393

praiskup commented 9 months ago

Thank you for the report!

Override of cleanup_on_success setting triggers mock to run rpmbuild with --noclean, which can break builds in certain situations.

This is interesting. Isn't such a build failure a bug in the package?

It certainly makes sense to avoid deleting the results, but passing --noclean to rpmbuild is really a separate question and certainly isn't required to avoid deleting the mock resultdir.

Mock uses rpmbuild --noclean to keep %builddir (not resultdir). The definition (e.g. in manpage):

       -n, --no-clean
              Do not clean chroot before building a package.
praiskup commented 9 months ago

Somewhat related is #999.

mikem23 commented 8 months ago

This is interesting. Isn't such a build failure a bug in the package?

Arguably yes. That said, it's a documented part of the rpmbuild process and ultimately a separate question from the mock-level full chroot clean.