Re: [Rpm-maint] [rpm-software-management/rpm] Parametric macro arguments are not expanded (#127)
thank you for heads up/ -- Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/issues/127#issuecomment-1280712224 You are receiving this because you are subscribed to this thread. Message ID: ___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Parametric macro arguments are not expanded (#127)
For reference, I've found an ugly hack to work around some of these issues on RPM 4.11.3 (RHEL7). Example macros that work in current RPM but break in RPM 4.11.3: ``` %define nested() %{echo:%{?1}} %define outer() %{nested -- %{?1}} %{outer -- test} ``` (In 4.11.3, `%{?1}` in the `nested` macro expands to `%{?1}` which leads to an infinite loop of expansion) Hack to make it work in RPM 4.11.3: ``` %define preExpand(-) %{expand:%%{%**}} %define nested() %{echo:%{?1}} %define outer() %{preExpand nested -- %{?1}} %{outer -- test} ``` (The `preExpand` macro in `outer` expands `%(?1}` before expanding `%{nested -- ...}`, which avoids the infinite loop.) The `(-)` in the `preExpand` macro definition is a hack to get it to read the options into `%**` (which is an undocumented macro containing the unparsed options list) without parsing the options and overwriting %1, %2, etc. This causes `rpmbuild` in 4.11.3 to print "error: Unknown option" every time it expands the "preExpand" macro, although that error message is harmless. If "--" is always used when passing arguments to parameterized macros then this `sed` regex can be used to inject `preExpand` into all of the outer macros in the spec file: `s/{\([^ {]\+\) -- /{preExpand \1 -- /g` -- Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/issues/127#issuecomment-1279258225 You are receiving this because you are subscribed to this thread. Message ID: ___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Parametric macro arguments are not expanded (#127)
Impossible to say without specific information. While most things can be written in a backwards compatible way, it's entirely possible some things cannot. I'd leave the older versions alone... -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/issues/127#issuecomment-325302818___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Parametric macro arguments are not expanded (#127)
Hi again. I enhanced the f27+f28 as we agreed here, and they works fine. However, when I backported the changes to f25+f26, the construct which was sending in the $variable in build and install is not expanded at all. Do you have some hint how to backport the changes to older rpmbuild? -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/issues/127#issuecomment-324711600___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Parametric macro arguments are not expanded (#127)
Max limit bumped to 64 now (commit 609adaa75855717548a8298b93d0a31a25be7083) -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/issues/127#issuecomment-323746121___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Parametric macro arguments are not expanded (#127)
Yup, that version did not complained about recursive macros. The increased limit would be nice. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/issues/127#issuecomment-323380570___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Parametric macro arguments are not expanded (#127)
It's easy to cause a recursive definition by mistake, but after seeing the jdk spec... the macros nest deeper than anything else I've seen in rpm macro usage. It's quite possible that you're running into the artificial limit of 16 nesting levels. I initiated a scratch-build where the limit is raised to 64 if you want to try it out: https://koji.fedoraproject.org/koji/taskinfo?taskID=21305568 -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/issues/127#issuecomment-323361629___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Parametric macro arguments are not expanded (#127)
hmmm. Moving in that, and started to slowly get in same maze where I was when deffine was used instead of global - error: Too many levels of recursion in macro expansion. It is likely caused by recursive macro declaration. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/issues/127#issuecomment-323350739___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Parametric macro arguments are not expanded (#127)
I consider the \\ syntax as easy to make an error and easy to oferlook when readed. So i would prefer matching bracket rather. Thanx. hmm, the build failed. %1 leaked in again. Looks my small steps do not work as I hoped... -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/issues/127#issuecomment-323346235___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Parametric macro arguments are not expanded (#127)
Not really, the surrounding %{ ... } will end up in the macro body literally which is unlikely to be what you want. It's not a general block construct in the sense you'd find in eg C. Use the line-continuations instead, eg ``` %define sdkbindir()\ %{_jvmdir}/%{sdkdir %1}/bin\ %{_jvmdir}/%{sdkdir %1}/bin ``` -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/issues/127#issuecomment-323344835___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Parametric macro arguments are not expanded (#127)
The: %define sdkbindir() %{ %{_jvmdir}/%{sdkdir %1}/bin %{_jvmdir}/%{sdkdir %1}/bin } Is correct right? -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/issues/127#issuecomment-323340280___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Parametric macro arguments are not expanded (#127)
> I'd recommend trying to eliminate those leftover %expand's and double %%-s > necessiated by %global use, those only make reading Thats plan to do. But in small steps. It may be easy to cause some really hard to find issues. > and understanding the whole thing more difficult. Thats long term goal! With rpm development in progress and some hidden stuff documentation not exactly easy t find... neverending goal:) -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/issues/127#issuecomment-323339947___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Parametric macro arguments are not expanded (#127)
Yes, things actually become more natural when empty arguments are handled as such. But even positive change can be a major PITA if it comes at the wrong time, know the feeling... I'd recommend trying to eliminate those leftover %expand's and double %%-s necessiated by %global use, those only make reading and understanding the whole thing more difficult. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/issues/127#issuecomment-323336778___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Parametric macro arguments are not expanded (#127)
Thank you. They can be nil, so ? approach is clear way. Now building withmost direct: https://src.fedoraproject.org/rpms/java-9-openjdk/c/abdb6134df8fd6e458e41d9a020274dd441ed2e7?branch=f27 lets see again. The approach, once tuned here, will need to be backport to jdk8 -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/issues/127#issuecomment-323334867___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Parametric macro arguments are not expanded (#127)
``` %define mymacro() \ echo foo\ echo bar ``` ...is the line-continuation syntax. As for the rest, it depends on what you need to do with it. If the arguments are always non-%{nil} then there's nothing you need to do. If arguments can be %{nil} (or otherwise empty), then you have two choices: 1) escape the argument in the *caller*, eg "%sdkbindir %%{nil}". If you need to pass unexpanded macros through several layers of macros as seems to be the case, then you need to escape them at each caller. So in the sdkbindir() case, you'd use %%{1} in the calls to %sdkdir. 2) handle the "missing" argument in the parametric macro (ie callee, instead of caller, basically), by using ?-conditionals. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/issues/127#issuecomment-32471___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Parametric macro arguments are not expanded (#127)
Sorry, to clarify again: %global sdkbindir() %{expand: %{_jvmdir}/%{sdkdir %%1}/bin %{_jvmdir}/%{sdkdir %%1}/bin } == %define sdkbindir() %{expand: %{_jvmdir}/%{sdkdir %%1}/bin %{_jvmdir}/%{sdkdir %%1}/bin } == %define sdkbindir()\ %{_jvmdir}/%{sdkdir %1}/bin \ %{_jvmdir}/%{sdkdir %1}/bin == %define sdkbindir() %{ %{_jvmdir}/%{sdkdir %1}/bin %{_jvmdir}/%{sdkdir %1}/bin } where the initial global is missused right? -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/issues/127#issuecomment-323330018___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Parametric macro arguments are not expanded (#127)
No, you just need to use trailing ```\``` to indicate line-continuation which is not necessary inside %{...} "block scope". -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/issues/127#issuecomment-323327478___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Parametric macro arguments are not expanded (#127)
I see. I guess when macro is multiline, I still need to use %{expand } oook? -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/issues/127#issuecomment-323325762___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Parametric macro arguments are not expanded (#127)
The crucial difference is right there in the part you quoted: ``` %global does not work correctly with parametric macros in any version of rpm, since the body is expanded at the time of definition instead of time of use as is the case with %defines. ``` So basically you *can* use %global instead of %define, but doing that requires an extra escaping all the macros that are used. And then you need the %expand{} around them because it was already expanded. So lots of unnecessary work and complexity in the spec because of that wholly unnecessary switch to %global. AFAICS the general pattern is: ``` %global sdkbindir() %{expand:%{_jvmdir}/%{sdkdir %%1}/bin} ``` ...which is the rather hard way to say: ``` %define sdkbindir() %{_jvmdir}/%{sdkdir %1}/bin ``` For most cases both will work fine with the new rpm too. The biggest difference is the case where %1 might expand to nothing, in which case you need to either escape it with an extra % (so in %global case, there would now be three %-characters!) or have the relevant macro(s) handle the case where %1 is effectively not passed, ie %{?1}. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/issues/127#issuecomment-323323618___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Parametric macro arguments are not expanded (#127)
O, and thank you very much for helping me out! -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/issues/127#issuecomment-323321338___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Parametric macro arguments are not expanded (#127)
"%global does not work correctly with parametric macros in any version of rpm, since the body is expanded at the time of definition instead of time of use as is the case with %defines. And the spec is full of those, combined with some strange %{expand}s and whatnot. This is a sad example of what the misguided "%define is evil and must be replaced by %global" campaign in Fedora has done :(" I see. Originally there was deffined, and yes, based on that campaign I put global everywhere. What are the crucial differences then? What change will be achived when simply replacing or expandable %global var() by %deffine() var? -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/issues/127#issuecomment-323321239___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Parametric macro arguments are not expanded (#127)
Thats baa... Very bad.You killed dinamic specfiles. What I have is: for suffix in %{build_loop} ; do mkdir -p %{buildoutputdir $suffix} pushd %{buildoutputdir $suffix} done You see that expansion as is odnenow killed it. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/issues/127#issuecomment-323320201___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Parametric macro arguments are not expanded (#127)
So... start by changing the %global's of parametric macros to %define(). Many/most of the accompanying %{expand:}s are likely unnecessary and unwanted too. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/issues/127#issuecomment-323318856___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Parametric macro arguments are not expanded (#127)
%{?1} is the same as %{?1:%1}, yes. And sure it works, eg: ``` [pmatilai@sopuli ~]$ rpm --define "foo() %{?1}" --eval "%foo %{nil}" [pmatilai@sopuli ~]$ rpm --define "foo() %{?1}" --eval "%foo %{_lib}" lib64 ``` However looking at https://src.fedoraproject.org/rpms/java-9-openjdk/blob/6dd07923a5203651059e28f4c1422a2d862e2d84/f/java-9-openjdk.spec... ``` %global post_headless() %{expand: ``` %global does not work correctly with parametric macros in any version of rpm, since the body is expanded at the time of definition instead of time of use as is the case with %defines. And the spec is full of those, combined with some strange %{expand}s and whatnot. This is a sad example of what the misguided "%define is evil and must be replaced by %global" campaign in Fedora has done :( -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/issues/127#issuecomment-323318485___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Parametric macro arguments are not expanded (#127)
hmm %{?1} did not work. It did not never expanded. is still valid that simple %{?1} is same as %{?1:%1} ? -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/issues/127#issuecomment-323315256___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Parametric macro arguments are not expanded (#127)
Ok will try. I'm wonderng how my hackich sending of parameter's parameter (%%1) will work Running test build with https://src.fedoraproject.org/rpms/java-9-openjdk/c/6dd07923a5203651059e28f4c1422a2d862e2d84?branch=f27 now. TY! -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/issues/127#issuecomment-323084967___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Parametric macro arguments are not expanded (#127)
Yes this will force changes to some existing macros, that is unavoidable. There are basically two ways to deal with it, which: a) escape macros in the arguments to prevent expansion, eg %%{nil} b) adjust the parametrized macro itself, eg in some situations it would be more natural to test for the argument existence instead (eg %{?1} instead of assuming it always exists) b) is actually the one that allows some level of compatibility between former and new behavior, as %{?1} will do the right thing in both cases if you just drop the "placeholder" %{nil} argument from the caller. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/issues/127#issuecomment-323048510___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Parametric macro arguments are not expanded (#127)
Hello! I have suspicion, that this could raise an regression. If i had parametrised macro , which wasusin %1 or so, and I sent %{nil} to that macro, then %1 evaluated as nothing. Now, %{nil} is evaluated first, and so nothing goes ot my macro, and so %1 habve nothing to evaluate in. So it stays as %1. Thhoughs? -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/issues/127#issuecomment-322801010___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Parametric macro arguments are not expanded (#127)
Fixed in commit 5adc56897b9da5dac49701f704ef54390db57c59 but that actually depends on the three preceding macro changes, there are all sorts of funnies involved. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/issues/127#issuecomment-284709287___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Parametric macro arguments are not expanded (#127)
Closed #127. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/issues/127#event-989475151___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint