【问题标题】:what is the '0' meaning in rpm conditional macrosrpm 条件宏中的 \'0\' 是什么意思
【发布时间】:2023-02-09 10:02:42
【问题描述】:

在阅读一些 rpmbuild 规范文件时,我遇到了一些令我困惑的条件宏。

  • 示例 1

    %if 0%{?rhel} > 7
      blah blah
    %endif
    
    # I understand the above block tries to check if the
    # red hat enterprise linux version is above 7, then blah blah
    # But what is the usage of the '0'? 
    
  • 示例 2

    %if 0%{!?pkg_name:1}
      %define pkg_name foo
    %endif
    
    # I understand the above block tries to check if the pkg_name
    # is not defined, then define it with the value foo.
    # But what is the usage of the '0'? 
    

我的猜测是“0”表示下一个表达式是“nil”或数字,这样 rpm 会将它们视为数字(例如上面示例中的 06、0 或 01)而不是字符串或空字符串。但我不确定。

不幸的是,大多数在线教程材料都没有涵盖这个主题。

【问题讨论】:

    标签: rpmbuild rpm-spec


    【解决方案1】:

    你做对了;这是一种保障。 %{?rhel} 表示“替换为 rhel如果它存在如果没有(?)也没关系。”

    所以,如果 rpmbuild 什么都不替换,那么生成的 if > 7 就会呕吐。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-03-21
      • 2014-04-25
      • 2015-03-20
      • 2020-01-07
      • 2014-11-21
      • 1970-01-01
      • 2018-09-10
      相关资源
      最近更新 更多