[Rpm-maint] [rpm-software-management/rpm] RFE: add variable named scoping to rpm (#1150)

nim-nim notifications at github.com
Wed Apr 1 08:48:35 UTC 2020


Thanks for the feedback! It makes me realise, that I forgot to emphasise things that were obvious to me (as a packager).

A scope needs an explicit name/anchor to be useful packaging side. It’s not a local vs global thing, it’s a “I do build things for context X now” and an later “I do checks for the same context X”, etc. Because a spec is not structured by subpackages, it is structured by phases, so at each phase you need to load and work with the same variables. Without an anchor to load the correct set of variables, you *will* make mistakes and things will fail (badly).

With a named scope thing you could do things like

```rpm
%{scope(sourceA):
%global source sourceA.tar.gz
%global patch1 xxx.patch
%global patch2 yyy.patch
%global topdir foobar-32
}

%{scope(sourceB):
%global source sourceB.tar.gz
%global patch1 aaa.patch
%global patch2 bbb.patch
}

…

%prep
%{scope(sourceA):
%autosetup
}
%{scope(sourceB):
%autosetup
}
```
And each autosetup call only sees the set of variables corresponding to its own scope, and things just work without needing to find unique variable names and trying to pass them to %autosetup without mistakes.

It could also enable things like

```
%{scope(subpackage1):
%global name %{scope}
%global version ....
%global summary ....
%global description ....
}

%{scope(subpackage2):
%global name %{scope}
%global version ....
%global summary ....
%global description ....

%global filelist %{scope}.lst
}

…

%install
%{scope(subpackage2):
#do things for subpackage2, with all the associated variables available
… >> %{filelist}
}

...
%{scope(subpackage2):
%files -f %{filelist}
}
```

So, a very basic need, that is kludged today via -n flags, special Tags, an repeated argument passing at all steps of the spec.

Of course that makes the whole `%global` verb awkward. More automation means more variables, so maybe it‘s time to simplify variable declaration syntax in rpm.

-- 
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/1150#issuecomment-607120006
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20200401/88305f08/attachment.html>


More information about the Rpm-maint mailing list