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

Remove %ifarch-%endif from %debug_package macro #635

Closed
pavlinamv opened this issue Feb 19, 2019 · 3 comments
Closed

Remove %ifarch-%endif from %debug_package macro #635

pavlinamv opened this issue Feb 19, 2019 · 3 comments

Comments

@pavlinamv
Copy link
Contributor

In PR #625 Comment 6 Panu wrote:

"%if-%else-%endif is a spec-only construct, there's no support for them in the actual macro engine. Macro files are purely declarative and doesn't support any sort of conditionals."

In maco file macros.in there is macro

%debug_package \
%ifnarch noarch\
%global __debug_package 1\
%_debuginfo_template\
%{?_debugsource_packages:%_debugsource_template}\
%endif\
%{nil}

that contains %ifnarch and thus it should be corrected.
Currently after expanding of macro %debug_package (e.g. in some spec file) global definition

%global __debug_package 1\

is expanded in all cases.

@pmatilai
Copy link
Member

Err, what? You trimmed out the relevant part of that quote:

You can of course define a macro that contains and %if-%else-%endif but that will only work as expected when expanded in a spec.

That macro is part of automated debuginfo generation and is only ever invoked in spec context, where %if is perfectly fine. That macro snippet is there to avoid debuginfo generation on noarch packages.

@pavlinamv
Copy link
Contributor Author

Err, what? You trimmed out the relevant part of that quote:

You can of course define a macro that contains and %if-%else-%endif but that will only work as expected when expanded in a spec.

The problem is more complicated. Macro written in a macro file that contains %if-%else-%endif + %global inside will not work correctly even if it is expanded in spec file. For example use rpm sources and add into macro.in file :

%mymacro0 \
%if 0  \
%global bbb0 ccc0 \
%endif \
%{nil}

%mymacro1 \
%if 1  \
%global bbb1 ccc1 \
%endif \
%{nil}

then add into "tests/data/SPECS/replacetest.spec"
after the "%install" line two echos:

echo %mymacro0
echo %mymacro1

and change the line:

echo "%{filedata}" > $RPM_BUILD_ROOT/opt/foo

to the line:

 echo "%bbb0 --- %bbb1 --- %name --- %ohouhiuiu" > $RPM_BUILD_ROOT/opt/foo

run "make check". Then you can see that

%bbb0 --- %bbb1 --- %name --- %ohouhiuiu

was expanded into

ccc0 --- ccc1 --- replacetest --- %ohouhiuiu

you can check it in tests/rpmtests.dir/232/rpmtests.log.

@pavlinamv pavlinamv reopened this Feb 28, 2019
@pmatilai
Copy link
Member

pmatilai commented Feb 28, 2019

That's one helluva convoluted reproducer, hard to see the point in there. Shortened it a bit, execute rpmbuild -bp to see :

%prep
%mymacro0
%mymacro1

echo "%bbb0 --- %bbb1"

But true, those %globals are "executed", and come to think of what happens during the macro expansion, of course they are. Yet the %ifnarch -test in %debug_package does work as intended, so there's some non-obvious interaction there. Still, that macro does not need any fixing because it does what's is supposed to, feel free to try it out if you dont believe me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants