I am using a spec file to create an RPM package. I want to package only those files which are present on my system. In my %files
section, I am writing the files which I want to include in my package. The conditional and non conditional packages are included in the following manner.
%files
%if "%is_file1_present"
%attr (-, root, root) /location/to/file1
%attr (-, root, root) /location/to/file2
%endif
%attr (-, root, root) /location/to/file3
%attr (-, root, root) /location/to/file4
%is_file1_present
is defined in the %build
section like this.
%build
%define is_file1_present %( if [ -f /location/to/file1 ]; then echo "1" ; else echo "0"; fi )`
While trying to build RPM package, it seems to ignore the if condition. What am I doing wrong ?