If condition inside the %Files section on a SPEC file

后端 未结 4 1693
故里飘歌
故里飘歌 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:50

    This is how I solved my problem

    step 1 :

       In Build section .. somewhere I wrote :
     %build
      .....
      #check my condition here & if true define some macro
      %define is_valid %( if [ -f /usr/bin/myfile ]; then echo "1" ; else echo "0"; fi )
     #after his normal continuation
     .....
     ...
    

    Step 2: in install section

      %install
      ......
      #do something in that condition
      if %is_valid
      install -m 0644 
      %endif
      #rest all your stuff
      ................
    

    Step 3:in files section

       %files
       if %is_valid 
       %{_dir}/
       %endif
    

    That's it

    It works.

    PS : I cannot give you full code hence giving all useful snippet

提交回复
热议问题