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
Add support for special system-level %include path #685
Conversation
On forced spec parse (spec query or --force'd build) we already allow sources and patches to be missing. %include differs from sources and patches in that a missing include might make the spec unparseable, but then we lose nothing by trying, as quite often the spec is parseable enough to get at least some info out of it. Doesn't seem any worse than allowing build without sources present... Helps a bit in cases like RhBug:1658292 and RhBug:1547897.
When %include argument is enclosed in <> (ie similar to C includes), look for the file in system-level %_rpmincludedir path instead %_sourcedir, and treat these as build-dependencies that get recorded in the src.rpm.
*(endFileName-1) = '\0'; | ||
sysinc = rpmGetPath("%{_rpmincludedir}/", fileName + 1, NULL); | ||
addReqProv(spec->sourcePackage, RPMTAG_REQUIRENAME, | ||
sysinc, NULL, 0, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this one, because you are technically do not depend on exact /usr/lib/rpm/include/…
file, but rather that path will be present...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point is that other tooling knows how to look at buildrequires, but they dont (and should not) try to parse rpmbuild output for missing files.
I wish What is the use case anyway? I can imagine using this for including pre-generated changelogs, but again, it would need to be configurable ... |
Please can you add a test case that ends successfully? Note that:
|
Just to make it clear, this is more for discussion about the feature and not something to be merged just because it's technically correct. |
Lets see where the discussion goes. Creating that case is rather tedious as the included file needs to be packaged for the test to work.
Well, creating a second type of include is kinda the whole point. |
It's a macro. You can --define it to whatever you like.
Sorry, I assumed it was kinda obvious: to share whatever common pieces between packages in an ecosystem, to put it broadly. An ecosystem could be a programming language, or extension to a specific program/library, etc. Currently such things are stuffed into macro files in /usr/lib/rpm/macros.d/ but there are various problems with this:
So the idea is that, say, Python 3 package on a distro would do something like |
Oh, yes, probably. But is there way to extend it? E.g.:
That makes sense. But while "those macros are loaded on every single rpm invocation for no good reason", then every Python .spec file would need to have this include. It is not necessarily wrong ... |
No, this is not a search path, it's just a single directory. I'm not sure a search path is (reasonably) doable in the spec parser realm.
That's exactly the intention! Like I noted in an earlier comment, the current scheme is fundamentally flawed and this is an attempt to improve it. Take any programming language you like, and imagine it without explicit include/import/use statements and contemplate on that for a while 🙂 FWIW, alternatively (or additionally) we could have a similar syntax to load system macro files instead of spec snippets. Macro files are a much more predictable format that can actually be validated, and this would allow (re)use of the existing macro files in distros instead of having to convert them to spec syntax. |
Hmm, the more I think about it, the more favorable going for macro-file includes (instead of spec parts) seems. Macro files can of course already be loaded with %load, but that's a low-level macro-primitive, for spec we'd want something more high-level that can also affect buildrequires etc. Could also be a nice opportunity to start introducing namespaces to macros... |
Thinking about this, I am not sure this provides any benefit. If I have to have the include explicitly in the .spec file, then I don't know why I should not have it including full path, because this must be documented somewhere anyway. Why for example Ruby should put some "include" file into RPM directory and not keep it somewhere else? |
Why does every single programming language have a built-in path for looking up includes/imports instead of using a hardcoded path? |
But then every single programming language allows to extend the search paths, which is not part of this proposal apparently. Also every programming language supports portability to different platforms, but the %includes in RPM world are IMO bound to the distribution, so there is no need to fiddle with the paths, because they are pretty static IMO. |
Yes, but we still allow changing the path. Also, part of the reason to have a special syntax is to enable that build-dependency tracking. If it's just %include /some/path/somewhere rpm cannot make assumptions about it being packaged. |
I could imagine that assumption about being available/installed was useful (but then the file would have to be shipped by RPM itself), but I can't see what is this assumption good for? |
When %include argument is enclosed in <> (ie similar to C includes), look for the file in system-level %_rpmincludedir path instead %_sourcedir, and treat these as build-dependencies that get recorded
in the src.rpm.
Depends on #684