Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure rpmbuild's cleanup doesn't fail due to permissions #3006

Merged
merged 2 commits into from Apr 4, 2024

Conversation

pmatilai
Copy link
Member

Details in the commit messages, but in short: packages can leave unremovable files in their build directory, run %_fixperms before and after to ensure sufficient permissions to remove %builddir.

%clean is redundant since 9d35c8d, drop default %clean sections and document as obsolete. We still honor a %clean in spec though.

Fixes: #2519

@pmatilai pmatilai added bug handsfree Packaging automation and convenience packaging Package building, SPEC files, etc. labels Mar 28, 2024
@pmatilai
Copy link
Member Author

pmatilai commented Apr 4, 2024

If this breaks something, we're not going to find it by studying this on a petri-dish.
I'll merge and if all hell breaks loose in testing, we'll just revert the damn thing.

In rpm < 4.8, %clean was needed to clean up the build root for packages
that used one (it was optional before 4.6). Since the introduction of
the new %builddir in 9d35c8d,
everything the package produces is collected in that one directory
that we can and do centrally clean up, making the separate %clean
section even more useless.

Document %clean as obsolete and drop all the now unnecessary default
%clean sections we've been adding for the packages.
Packages may contain files without write permissions, read-only sources
and whatnot. Run %_fixperms on the whole builddir before trying to
remove it to ensure we don't fail doing our household duties, both
on post-cleanup but also before trying to remove an old run, as
eg 'rpmbuild -bi' will not run cleanup.

It's worth noting that prior to b5f6c64
the build could similarly fail while running it's default %clean.
If we hadn't removeed the default %clean, we'd have to do this
permission fixup first redundantly for the build root and then for the
rest of the %builddir.

Also worth noting is that the added test doesn't actually reproduce the
issue in the test-suite because it runs as root and root is not bothered
by such petty issues as missing read/write permissions to remove. But
at least we have a reproducer for the case once rpm-software-management#3005 is done.

Fixes: rpm-software-management#2519
@pmatilai pmatilai merged commit c751b54 into rpm-software-management:master Apr 4, 2024
1 check passed
@pmatilai pmatilai deleted the ensureclean-pr branch April 4, 2024 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug handsfree Packaging automation and convenience packaging Package building, SPEC files, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ensure %clean always succeeds
1 participant