Question about conditionally including files into the %files section

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I've been struggling my attempt to conditionally include files into %files section of one of our project spec files. I came across the libvirt spec file which seemed like a great example of what I'd like to do, so I thought I would mimic what the developers were doing there.

However, I'm obviously not using the correct syntax and wasn't able to find the specific information on the internet to
figure out what I'm doing wrong.

I'm trying to select files based on whether the system is set up for one of the three performance counter
interfaces. So, I created three defines at the top of the PAPI spec file we are creating. I tried two different versions
of each set of the defines using different syntax but neither version of the syntax appears to work.

%define _have_pfmon_macro %(test -a /usr/lib64/libpfm.so.3 ||
                            test -a /usr/include/perfmon/perfmon.h)

%define _have_pcl_macro %(test -a /lib/modules/%{os_vers}/source/include/linux/perf_counter.h ||
                          test -a /usr/src/linux-headers-%{os_vers}-generic/include/linux/perf_counter.h ||
                          test -a /lib/modules/%{os_vers}/source/include/linux/perf_event.h ||
                          test -a /usr/src/linux-headers-%{os_vers}-generic/include/linux/perf_event.h )

%define _have_perfctr_macro %(test -a /dev/perfctr)


AND

%define _have_pfmon_macro %(((test -e /usr/lib64/libpfm.so.3 || test -e /usr/include/perfmon/perfmon.h) && echo 1) ||
echo 0)

%define _have_pcl_macro %(((test -e /lib/modules/%{os_vers}/source/include/linux/perf_counter.h ||
                            test -e /usr/src/linux-headers-%{os_vers}-generic/include/linux/perf_counter.h ||
                            test -e /lib/modules/%{os_vers}/source/include/linux/perf_event.h ||
test -e /usr/src/linux-headers-%{os_vers}-generic/include/linux/perf_event.h ) && echo 1) || echo 0)

%define _have_perfctr_macro %((test -e /dev/perfctr && echo 1) || echo 0)


Then I tried to use the above define to set another define with a value of 0 or 1 to use in the %files section. Maybe I
could have used the _have_xxx version in the %files section, but I thought I needed a 0 or 1 value there?

%if 0%{_have_pfmon_macro}
%define _with_pfmon 1
%else
%define _with_pfmon 0
%endif

%if 0%{_have_perfctr_macro}
%define _with_perfctr 1
%else
%define _with_perfctr 0
%endif

%if 0%{_have_pcl_macro}
%define _with_pcl 1
%else
%define _with_pcl 0
%endif


I also tried this during my trial and error extravaganza...

%{?_have_pfmon_macro: %define _with_pfmon 1}
%{?_have_pcl_macro: %define _with_pcl 1}
%{?_have_perfctr_macro: %define _with_perfctr 1}

Then in the %files section I use the _with_xxx settings to selectively include files for packaging.

%if %{_with_pfmon}
%{prefix}/include/perfmon/perfmon_i386.h
%{prefix}/include/perfmon/perfmon_pebs_core_smpl.h
%{prefix}/include/perfmon/perfmon_pebs_p4_smpl.h
%{prefix}/include/perfmon/pfmlib_amd64.h
..
..
%endif

...
...

%if %{_with_perfctr}
%{prefix}/bin/perfex
%{prefix}/include/asm/perfctr.h
%{prefix}/include/libperfctr.h
...
...
%endif

I also tried:

%if 0%{_with_perfctr}


The problem is that all the macros/defines:

_with_pfmon
_with_perfctr
_with_pcl

become set to 1 even though only one of them should actually be set ( only one of the _have_xxx values should actually
be true ).

I'm obviously doing something wrong.

Any help would be greatly appreciated. I've been doing this on Ubuntu, Fedora, and SLES systems where the rpm versions are: 4.7.1 on Ubuntu, 4.7.9 on FC11, and 4.4.2.3 on SLES11.

Thanks much for your time,
Jim G

_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxxxxx
http://lists.rpm.org/mailman/listinfo/rpm-list

[Index of Archives]     [RPM Ecosystem]     [Linux Kernel]     [Red Hat Install]     [PAM]     [Red Hat Watch]     [Red Hat Development]     [Red Hat]     [Gimp]     [Yosemite News]     [IETF Discussion]

  Powered by Linux