If condition inside the %Files section on a SPEC file

后端 未结 4 1646
故里飘歌
故里飘歌 2021-01-13 08:14

I\'m kinda a new to writing spec files and building RPM\'s. Currently I have one RPM that is supposed to deploy some files in 1 of 2 possible directories that will vary with

4条回答
  •  伪装坚强ぢ
    2021-01-13 08:26

    Forrest suggests the best solution, but if that is not possible practical you can detect the OS version at runtime in the post-install section, move the script to the appropriate location, and then delete it post-uninstall, eg:

    # rpm spec snippets
    %define OS_version %(hacky os detection)
    ...
    Source2: script.sh
    ...
    %install
    install %{_sourcedir}/script.sh %{buildroot}/some/known/location
    ...
    %post
    
    %if %{OS_version} == "..."
      mv /some/known/location/script.sh /distro/specific/script.sh
    %elif %{OS_version} == "..."
    ...
    
    %preun
    rm -rf /all/script/locations
    

    Much more error prone than building different RPMs on different OSes, but will scale a little better if you need to support many different OSes.

提交回复
热议问题