#693 Wiki:Packaging:RPMMacros
Closed: fixed a month ago by decathorpe. Opened 2 years ago by mschorm.

Please update to reflect current set of macros.
For example, %{_rundir} macro can be used, but is not listed (anywhere).

I'd suggest to mention, that all macros can be shown by "rpm --showrc". (But I'm not sure, how much it can differ in Koji)


Honestly I have never liked this page. The idea, I believe, was to list macros which can be used in preference to raw pathnames, because older versions of the guidelines required their use. Today that's not a hard requirement and personally I prefer to never use such things when there is no benefit. Certainly "%{_rundir}" is of negative benefit, since typing /run is shorter and clearer. I can't think of a reason why we would even suggest to people that they use it.

So personally I would be happy if that page ceased to exist, but I know others might disagree. I don't see it ever being complete because any package can add random macros. It would be insane to list everything that you get with rpm --showrc, and I think it would be rather negative to suggest to people that they should even be using things they see while running rpm --showrc. (Also, that's would be incomplete advice because the rpm --showrc output depends on what you have installed.)

Also, that page is unintentionally hilarious in mentioning EPEL4. I've taken those references out, but the reference to Fedora 13 remains.

Also, there's no draft here. I do not intend to write one.

Metadata Update from @tibbs:
- Issue tagged with: meeting

2 years ago

We discussed this at this weeks meeting (http://meetbot.fedoraproject.org/fedora-meeting-1/2017-06-22/fpc.2017-06-22-10.00.txt):

  • x#693 Wiki:Packaging:RPMMacros (geppetto, 16:36:15)
  • LINK: https://fedoraproject.org/wiki/Packaging:Guidelines#Macros is
    the section of the guidelines I'm talking about. (tibbs, 16:45:04)
  • Everyone mostly agrees we need to get this out of packaging, and
    probably delete a bunch of data so it'll maybe help people
    (geppetto, 17:05:31)

We discussed this at this weeks meeting (https://meetbot-raw.fedoraproject.org/fedora-meeting-2/2017-06-28/fpc.2017-06-28-17.13.txt):

  • x#693 Wiki:Packaging:RPMMacros (geppetto, 17:28:43)
  • ACTION: tibbs try to leave out definitions for things we know will
    change, or aren't something which anyone should care about
    (geppetto, 17:44:20)

Metadata Update from @ignatenkobrain:
- Issue assigned to tibbs

6 months ago

We talked about this in this weeks meeting (https://meetbot-raw.fedoraproject.org/fedora-meeting-1/2018-10-04/fpc.2018-10-04-16.00.txt):

  • #693 Wiki:Packaging:RPMMacros (geppetto, 16:17:26)
  • ACTION: decathorpe will clean up the page (geppetto, 16:28:03)

Metadata Update from @decathorpe:
- Issue untagged with: meeting
- Issue assigned to decathorpe (was: tibbs)
- Issue tagged with: draftneeded

5 months ago

I just finished a rough first draft of an updated RPM Macros page. My intent is to provide a bit of rationale why and when macros should and can be used, and how to evaluate them on the command line for debug purposes. And the list of macros is actually up-to-date now (fedora 28, and not fedora 13 i686).

The changes can be viewed at https://pagure.io/fork/decathorpe/packaging-committee/c/b744d9c29899006f2dc32c10eba5731a7276a323?branch=rpmmacros

An approximation of what it would look like when it is rendered can be viewed at
if you don't want to clone my fork and run weird containers.

(The formatting of code in tables looks nicer when doing in the "real antora thing".)

By the way, not a fan of asciidoc, especially because I had to type a lot of things like `+%{buildroot}+` ...

I have a one thing to add.

You can search through the macros by grep.
$ grep -r "/usr/lib/system" /usr/lib/rpm/

getting something like that:
/usr/lib/rpm/macros.d/macros.systemd:%_unitdir /usr/lib/systemd/system
/usr/lib/rpm/macros.d/macros.systemd:%_userunitdir /usr/lib/systemd/user
/usr/lib/rpm/macros.d/macros.systemd:%_presetdir /usr/lib/systemd/system-preset

That's something I didn't know and totally changed my abilities. Please add it to the documentation. I strongly believe packages can find it very handy.

You can go to IRC and as "what macro is for this path .... ?". You'll get the macro from somebody who remembers it, but in a 2 years, nobody ever showed me this trick, until recently.

@mschorm I didn't know that was possible (but what do I know about grep ...).

The reverse search is really nice (checking if there's a macro for a given directory). I don't think it works recursively, though - so if a macro is defined in terms of another macro, it won't show up in this query?

I gave it a while to find out some simple solution, but AFAIK that's what the (f.e.) BASH is for. I don't think there is any simple way not involving a simple script.

However If you'd know this trick, you:
will be able to grep more complex regexp
can try to search the shortest right side.
f.e. /var/lib/rpm first search for "/rpm" then for "/lib/rpm" ... because macros are ussually used as a prefix. (A %{_var}/lib/rpm in this case )
* will know that it is actually written somewhere and where - and that's the most important part

Still, some macros could be quite difficult:
If you are looking f.e. "Is there a macro for /usr/lib64" ?
And all you find is this:
%_prefix /usr
%_exec_prefix %{_prefix}
%_lib lib
%_libdir %{_exec_prefix}/%{_lib}

But atleast a short adition about this trick would be worth anyway :)

well, you can just execute rpm --showrc and see all expanded macro ;)

Looked through the draft; it seems quite reasonable to me and certainly better than what we had.

We agreed to merge my proposed overhaul of the RPMMacros page.

It has already been deployed: https://docs.fedoraproject.org/en-US/packaging-guidelines/RPMMacros/

I hope this fixes most of the issues that the old page had.

Metadata Update from @decathorpe:
- Issue close_status updated to: fixed
- Issue status updated to: Closed (was: Open)

a month ago

Login to comment on this ticket.