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

RFE Please add a verb to inhibit macro expansion #569

Closed
nim-nim opened this issue Oct 7, 2018 · 8 comments
Closed

RFE Please add a verb to inhibit macro expansion #569

nim-nim opened this issue Oct 7, 2018 · 8 comments

Comments

@nim-nim
Copy link

nim-nim commented Oct 7, 2018

So I have a versy large shell macro, inside an %{expand} because it’s full of rpm variables that need interpetation, and I’m sick of the \ game.

Among lots of other things, this macro needs to generale a %license <somefile> in file lists.

And of course that won't work because rpm will try to replace the %license tag with the content of the package %{license} variable.

My current hack is to do

while read -r -d $'\\n' f ; do
 (echo -n "%" ; echo "license '${f}'")             >> "%{currenfilelist}"
done <<< ${licensefiles}

But it is quite hackish and ugly. An unexpand verb would be much cleaner, and useful elsewhere besides.

@ignatenkobrain
Copy link
Contributor

doesn't it work if you add more percent signs?

@nim-nim
Copy link
Author

nim-nim commented Oct 7, 2018

Unfortunately, no, '%%license gives the same result as %license and %%%license just prepends a % to the licensing tag value

@nim-nim
Copy link
Author

nim-nim commented Oct 7, 2018

(I should say that by the time rpm reaches this part in the code flow it has probably several levels of imbricated expands to deal with)

@pmatilai
Copy link
Member

A reproducer please.

@jasontibbitts
Copy link

I though this might show it, but to me it looks like it works as expected; using either three or four percent signs seems correct. (That's kind of a fun result on its own, though.) Maybe your situation is more complicated or more nesting is required or something. That's why it's really important to include some instructions for showing the issue.

ἐπιθυμία:~❯ cat *spec
%global try1 echo "%license try1"
%global try2 echo "%%license try2"
%global try3 echo "%%%license try3"
%global try4 echo "%%%%license try4"
%global try5 echo "%%%%%license try5"

Name: pkgname
Version: pkgversion
Release: pkgrelease
Summary: pkgsummary

License: pkglicense

%description
pkgdescription

%prep
%try1
%try2
%try3
%try4
%try5

ἐπιθυμία:~❯ rpmspec -P foo.spec
Name: pkgname
Version: pkgversion
Release: pkgrelease
Summary: pkgsummary

License: pkglicense

%description
pkgdescription

%prep
echo "pkglicense try1"
echo "pkglicense try2"
echo "%license try3"
echo "%license try4"
echo "%pkglicense try5"

@nim-nim
Copy link
Author

nim-nim commented Feb 11, 2019

@jasontibbitts you're missing the expand part in your test

One example of real-world code are
https://pagure.io/go-rpm-macros/blob/master/f/rpm/macros.d/macros.go-rpm.internal#_96

(I really should push it so work can focus on improving the code and making workarounds unnecessary, at least for the fonts sister macro project which is a lot less scary than the golang one, but it's stuck on the remaining small bits of https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/51)

@pmatilai
Copy link
Member

pmatilai commented Mar 4, 2019

@jasontibbitts you're missing the expand part in your test

@nim-nim and this is exactly why you need to provide an actual reproducer. Pointers to macros someplace on the net with random mumblings attached is not a reproducer.

@ignatenkobrain
Copy link
Contributor

I think this has been long enough in waiting-for-info state. Closing.

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

No branches or pull requests

4 participants