Are brackets around macros required?
In a package review recently I was asked to put brackets around all
macro usages. That is, writing %{name}.desktop rather than %name.desktop I personally think these superfluous brackets clutter the spec file and reduce the readability. So when they are not necessary I always omit them. To me it somewhat strange that using brackets is more common than not doing so. The situation is quite analogous to shell scripts. In (ba)sh it is always ALLOWED to have brackets around variables, but only rarely REQUIRED. Exactly as it is for macros in spec files. But while you almost never see a shell script with brackets where they are not needed, it is quite common in spec files. Should the packaging guidelines have a ruling on this? There isn't any as far as I can find. The closest I found was the choice between %{buildroot} and ${RPM_BUILD_ROOT}, and in that case the only requirement was consistency. Is consistency the only requirement in the choice between %{name} and %name too? Or is the use of %{name} with brackets actually required? -- packaging mailing list packaging@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/packaging |
Are brackets around macros required?
On 08/15/2011 12:02 PM, Göran Uddeborg wrote:
> In a package review recently I was asked to put brackets around all > macro usages. That is, writing > %{name}.desktop > rather than > %name.desktop imho, using brackets is near-universally safer, but I doubt we need to mandate it. If anyone's non-use of brackets ever does break anything, that's their responsibility to fix I suppose. -- rex -- packaging mailing list packaging@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/packaging |
Are brackets around macros required?
Am 15.08.2011 19:12, schrieb Rex Dieter:
> On 08/15/2011 12:02 PM, Göran Uddeborg wrote: >> In a package review recently I was asked to put brackets around all >> macro usages. That is, writing >> %{name}.desktop >> rather than >> %name.desktop > > imho, using brackets is near-universally safer, but I doubt we need to > mandate it. If anyone's non-use of brackets ever does break anything, > that's their responsibility to fix I suppose. > I'm the package reviewer who has critizized the missing brackets [1]. First, it is usual in almost all packages to use them. However, that's not reason enough to make them mandatory. Actually, I wrote about the readability. I'm using Gedit for writing and viewing the spec files, which uses gtksourceview for syntax highlighting. Gedit doesn't recognize any macros without brackets and doesn't highlight them. That's my experience regarding the readability, and I would strongly recommend to use the brackets. Either mandatory, or as a fully-or-nowhere choice, means, either always in a certain spec file, or nowhere. Best Regards, Mario [1] https://bugzilla.redhat.com/show_bug.cgi?id=730426 -- packaging mailing list packaging@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/packaging |
Are brackets around macros required?
On Mon, Aug 15, 2011 at 12:12:24PM -0500, Rex Dieter wrote:
> On 08/15/2011 12:02 PM, Göran Uddeborg wrote: > > In a package review recently I was asked to put brackets around all > > macro usages. That is, writing > > %{name}.desktop > > rather than > > %name.desktop > > imho, using brackets is near-universally safer, but I doubt we need to > mandate it. If anyone's non-use of brackets ever does break anything, > that's their responsibility to fix I suppose. > To expand on this, just like shell, you can get into trouble if you write something like (contrived example): Source0: %namer%version.tar.gz But earlier in the spec file (or from one of rpmn's system-wide configs): %define namer foo One counter example is when the macro is itself a little script that needs to take arguments. In that case rpmbuild will hand the arguments to the macro when you do not use the curly braces but won't when you do (unless you include the arguments inside of the curly braces). See %py_byte_compile for an example of this. -Toshio -- packaging mailing list packaging@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/packaging |
Are brackets around macros required?
Mario Blättermann:
> I'm using Gedit for writing and viewing the spec files, > which uses gtksourceview for syntax highlighting. Gedit doesn't > recognize any macros without brackets and doesn't highlight them. That must be a a bug. Regardless of Fedora's packaging guidelines, macros without brackets is legal purely syntactically. https://bugzilla.gnome.org/show_bug.cgi?id=656671 (I'm using emacs, and its SPEC mode works correctly in this case.) > either always in a certain spec file, or nowhere. I assume everyone would agree that consistency should be a requirement. I will make it consistent in "mindless.spec". I just wanted to wait for this discussion to see in which direction I would change it. -- packaging mailing list packaging@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/packaging |
Are brackets around macros required?
On 08/16/2011 12:23 PM, Göran Uddeborg wrote:
> That must be a a bug. Regardless of Fedora's packaging guidelines, > macros without brackets is legal purely syntactically. How would it be able to identify macros without brackets? Say you have: %namev%version Is the macro %namev? %name? %na? It is sloppy form. It is impossible to parse. Just because rpm will accept it doesn't mean you should use it. ~tom == Fedora Project -- packaging mailing list packaging@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/packaging |
Are brackets around macros required?
On Tue, 16 Aug 2011 13:18:05 -0400, TC (Tom) wrote:
> On 08/16/2011 12:23 PM, Göran Uddeborg wrote: > > That must be a a bug. Regardless of Fedora's packaging guidelines, > > macros without brackets is legal purely syntactically. > > How would it be able to identify macros without brackets? > > Say you have: > > %namev%version > > Is the macro %namev? %name? %na? > > It is sloppy form. It is impossible to parse. Just because rpm will > accept it doesn't mean you should use it. RPM may accept it, but it cannot always parse it correctly either: echo "a=b" > %nameconfig.cfg won't do the right thing even with %name being defined by default. For echo "a=b" > %{name}config.cfg to break similary, %name would need to be undefined. -- packaging mailing list packaging@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/packaging |
Are brackets around macros required?
Tom Callaway:
> %namev%version > > Is the macro %namev? %name? %na? Michael Schwendt: > RPM may accept it, but it cannot always parse it correctly either: > > echo "a=b" > %nameconfig.cfg > > won't do the right thing even with %name being defined by default. Are you joking? Or am I missing something? Of course, it means %namev and %nameconfig respectively. Reusing the analogy with the shell, if you in a shell script see the code echo $PATHTYPE would you be unsure if that meant the value of the variable PATH followed by the string "TYPE", or if it meant the value of the variable PATHTYPE? I don't think you would. Save for Fortran, in all programming languages I can recall the parser takes the longest sequence of characters that is a valid token to be the next token from the input. I don't understand what you find so different in the spec file case. Tom Callaway: > It is sloppy form. Oh, come on! I understand you prefer the style with brackets. And your opinion certainly has much more weight than mine in Fedora. I do have a different preference. Not because I am sloppy and wish to type a few characters less. Because I do find it easier to read without brackets that don't carry any information. I find that accusation unfair. -- packaging mailing list packaging@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/packaging |
Are brackets around macros required?
On 08/18/2011 12:57 PM, Göran Uddeborg wrote:
> Tom Callaway: >> %namev%version >> >> Is the macro %namev? %name? %na? > > Michael Schwendt: >> RPM may accept it, but it cannot always parse it correctly either: >> >> echo "a=b"> %nameconfig.cfg >> >> won't do the right thing even with %name being defined by default. > > Are you joking? Or am I missing something? Of course, it means > %namev and %nameconfig respectively. The point is that many specs need something like %{name}v%{version} or %{name}config but NOT %{namev}%{version} or %{nameconfig}. Without brackets, they would be parsed as the latter which would not be the intended result (don't forget many packagers are not programmers by nature). I would support explicitly making usage of brackets on macros a SHOULD item for packaging guidelines/reviews. -- packaging mailing list packaging@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/packaging |
Are brackets around macros required?
On 18 August 2011 21:49, Christopher Aillon <caillon@redhat.com> wrote:
> The point is that many specs need something like %{name}v%{version} or > %{name}config but NOT %{namev}%{version} or %{nameconfig}. *Without > brackets, they would be parsed as the latter which would not be the > intended result (don't forget many packagers are not programmers by nature). > > I would support explicitly making usage of brackets on macros a SHOULD > item for packaging guidelines/reviews. Fully agree, fwiw. IMO, the guiding principle should be the answer to the question "what style would most enable another packager to pick up the spec file and fix problems with it". Knowing the intimate low-level workings of the spec file parser should not be a requirement for maintaining any package in Fedora when there are available syntaxes which negate the need for that intimate low-level knowledge. -- packaging mailing list packaging@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/packaging |
| All times are GMT. The time now is 11:06 PM. |
VBulletin, Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.