Open rguenth opened 1 year ago
During almost +20 years of using rpm I've never had such needs.
%exclude
so far was enough.
👎
But I don't really want to rely on this bug in %exclude - see https://github.com/rpm-software-management/rpm/issues/994 which is acknowledged as a bug (but appearently hard to fix because of Fedora relying on this).
This sounds like a problem of package distribution, not package building.
As I understand it, your actual goal here is to avoid shipping a subpackage in the repositories. The current "workaround" as you described it therefore is the proper solution to this.
The contents of the buildroot is supposed to reflect what's being packaged one way or another. What follows from that is, any SPEC construct that would allow for excluding an already installed file would make no sense. The existence of the %exclude
directive really is just to allow for cherry-picking the individual files into subpackages, not to exclude them altogether, as discussed in #994 that you linked.
If you wish to avoid packaging certain files, then don't install them in the first place. Similarly, if you wish to avoid shipping a built package, then don't ship it.
Theoretically, if RPM supported this, treating an empty filelist as "don't build this subpackage" would be better as one could then reuse the existing -f
option to supply an empty file (through a filename stored in a macro). But like said, I don't see us adding what looks like a workaround for the limitations of a package distribution mechanism.
After discussing this with the team, we agreed that the idea behind this (to exclude certain (sub)packages from the build) is actually quite reasonable. It's just that the proposed way of abusing %files
for this isn't right. We'd rather have a preamble item (i.e. alongside Name:
, Version:
and the likes) that controls this.
I've moved this to our backlog so that somebody can actually pick this up later and have a closer look at how it could be implemented.
Please add a way to mark a %files list as listing files to be ignored, aka not complained about not belonging to any package. This should be a convenient way to exclude sub-packages from packaging without the need to explicitly rm the not packaged files. Example
%if ... %define without_foo -i %endif
%package foo ...
%files foo %{?without_foo} %dir /baz /baz/bar
Implementation-wise the easiest thing is to treat -i as overriding the sub-package name the %files list belongs to, assigning a special (empty?) name and later make sure to not emit the "empty" package. Otherwise full processing of the files should happen, so they are all expected to exist.
The actual use case is packaging of the GNU GCC compiler in openSUSE where shared library sub-packages are provided from the newest compiler version but multiple actual compilers are co-installable. For technical reasons having multiple source packages building same named sub-packages such as libstdc++6 isn't possible. The current workaround suffixes those so we have libstdc++6-gccN in addition to the main libstdc++6 package, but those suffixed packages have to be manually "removed" (or hidden) through special casing.
Explicitely rm-ing the files in those packages and not packaging the sub-packages would be an option but would also make the spec file even more difficult to follow, so a less intrusive way to make rpmbuild not build a sub-package is required.