[Rpm-maint] [rpm-software-management/rpm] Macro Language - tips, best reference ? (Discussion #2094)

JVDptt notifications at github.com
Mon Jun 13 22:34:01 UTC 2022


Good day -
  
  Sorry my RPM skills are a bit rusty - could anyone please point me in the right direction to do:
  
  1. I know I can print different strings for instance a %{warn...} message (or shell command for that matter) by doing something
      like:
      
       $ rpm --eval '
       %global is_enabled() %{?%1:"Enabled"}%{!?%1:"Disabled"}
       %global a_var %{nil}
       %{warn %{is_enabled:%{a_var}}}
      '
      warning: "Disabled"
      $
      
      But what if I want to emit some string if and only if 'a_var' is  0, 1, 2, 3 - ie some value? This seems to be eluding me ...
      
      $ rpm --eval '
      %global is_enabled() %{?%1:"Enabled"}%{!?%1:"Disabled"}
      %global a_var 1
      %{warn %{is_enabled:%[%{a_var}==1]}}
      '
      warning: "Disabled"
      
      $ rpm --eval '
      %global is_enabled() %{?%1:"Enabled"}%{!?%1:"Disabled"}
      %global a_var 1
      %{warn:%{is_enabled:%{expr:"%{a_var}==1"}}}
      '
      warning: "Disabled"


 Please, how can I get a macro to return a conditional value like that without having to use %if .. %endif ?
 ie. ONLY if a_var is 1 (not %{nil} or 0 or any other value) do I want a macro to return a certain value.
 What is the best way of doing this?
 
 Is there a more complete / comprehensive / expansive reference to the RPM macro language other than :
   https://rpm-software-management.github.io/rpm/manual/macros.html  or
   https://docs.fedoraproject.org/en-US/packaging-guidelines/RPMMacros/
these days ?

Thanks in advance for any replies !
 Best Regards,
 Jason


-- 
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/discussions/2094
You are receiving this because you are subscribed to this thread.

Message ID: <rpm-software-management/rpm/repo-discussions/2094 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20220613/389c9cee/attachment.html>


More information about the Rpm-maint mailing list