]> git.pld-linux.org Git - packages/rpm.git/blob - rpm.macros
- added macros to extracting kernel version-release string
[packages/rpm.git] / rpm.macros
1 # PLD rpm macros
2
3 %_defaultdocdir  %{_usr}/share/doc
4 %_fixowner       [ `%{__id_u}` = '0' ] && %{__chown_Rhf} root.@ROOT_GROUP@
5 %_fixgroup       true
6 %_topdir         %(echo $HOME)/rpm
7 %_exec_prefix    %{_prefix}
8 %_bindir         %{_exec_prefix}/bin
9 %_sbindir        %{_exec_prefix}/sbin
10 %_libexecdir     %{_exec_prefix}/lib
11 %_datadir        %{_prefix}/share
12 %_sharedstatedir %{_prefix}/com
13 %_lib            lib
14 %_libdir         %{_exec_prefix}/%{_lib}
15 %_includedir     %{_prefix}/include
16 %_oldincludedir  /usr/include
17 %_sysconfdir     /etc
18 %_localstatedir  /var
19 %_infodir        /usr/share/info
20 %_mandir         %{_prefix}/share/man
21 #-----------------------------------------------------------------
22 # CFLAGS and LDFLAGS used to build
23
24 %debugcflags    -O0 -g
25 %rpmcflags      %{?debug:%debugcflags}%{!?debug:%optflags}
26 %rpmldflags     %{!?debug:-s}
27
28 # kernel compiler
29 %kgcc           kgcc
30 %kgcc_package   egcs
31
32 #-----------------------------------------------------------------
33 %configure2_13 { \
34  if [ -n "$LINGUAS" ]; then unset LINGUAS; fi; \
35  LDFLAGS="${LDFLAGS:-%rpmldflags}" ; export LDFLAGS ; \
36  CFLAGS="${CFLAGS:-%rpmcflags}" ; export CFLAGS ; \
37  CXXFLAGS="${CXXFLAGS:-%rpmcflags}" ; export CXXFLAGS ; \
38  FFLAGS="${FFLAGS:-%rpmcflags}" ; export FFLAGS ; \
39  %{?__cc:CC=%{__cc} ; export CC ; } \
40  %{?__cxx:CXX=%{__cxx} ; export CXX ; } \
41  ./configure \
42         --host=%{_target_platform} \
43         --prefix=%{_prefix} \
44         --exec-prefix=%{_exec_prefix} \
45         --bindir=%{_bindir} \
46         --sbindir=%{_sbindir} \
47         --sysconfdir=%{_sysconfdir} \
48         --datadir=%{_datadir} \
49         --includedir=%{_includedir} \
50         --libdir=%{_libdir} \
51         --libexecdir=%{_libexecdir} \
52         --localstatedir=%{_localstatedir} \
53         --sharedstatedir=%{_sharedstatedir} \
54         --mandir=%{_mandir} \
55         --infodir=%{_infodir} \
56 }
57
58 #----------------------------------------------------------------
59 %configure {./configure \
60         LDFLAGS="${LDFLAGS:-%rpmldflags}" \
61         CFLAGS="${CFLAGS:-%rpmcflags}" \
62         CXXFLAGS="${CXXFLAGS:-%rpmcflags}" \
63         FFLAGS="${FFLAGS:-%rpmcflags}" \
64         %{?__cc:CC=%{__cc}} \
65         %{?__cxx:CXX=%{__cxx}} \
66         --build=%{_target_platform} \
67         --prefix=%{_prefix} \
68         --exec-prefix=%{_exec_prefix} \
69         --bindir=%{_bindir} \
70         --sbindir=%{_sbindir} \
71         --sysconfdir=%{_sysconfdir} \
72         --datadir=%{_datadir} \
73         --includedir=%{_includedir} \
74         --libdir=%{_libdir} \
75         --libexecdir=%{_libexecdir} \
76         --localstatedir=%{_localstatedir} \
77         --sharedstatedir=%{_sharedstatedir} \
78         --mandir=%{_mandir} \
79         --infodir=%{_infodir} \
80 }
81
82 # Location of autoconf macros
83 %_aclocaldir    %(aclocal --print-ac-dir)
84
85 # Location of pkgconfig files
86 %_pkgconfigdir  /usr/lib/pkgconfig
87
88 # Location of top applink dir
89 %_applnkdir      /usr/X11R6/share/applnk
90
91 # Location pixmaps for applnk/desktop files
92 %_pixmapsdir    /usr/X11R6/share/pixmaps
93
94 # Location of fonts directories
95 %_fontsdir      /usr/share/fonts
96
97 # Current date
98 %date           %(LC_ALL="C" date +"%a %b %d %Y")
99
100 # tmp directory
101 %tmpdir         %(echo "${TMPDIR:-/tmp}")
102
103 # Example files, programs, scripts...
104 %_examplesdir   /usr/src/examples
105
106 # The directory holding Linux kernel sources
107 %_kernelsrcdir  /usr/src/linux
108
109 # If non-empty "debug" macro defined, add "dbg" suffix to release number
110 %_rpmfilename   %%{NAME}-%%{VERSION}-%%{RELEASE}%{?debug:dbg}.%%{ARCH}.rpm
111
112 # requires name = version-release
113 %requires_releq()               %(LC_ALL="C" rpm -q --queryformat 'Requires:%%{NAME} = %%{VERSION}-%%{RELEASE}' %1| grep -v "is not")
114 %requires_kernel_releq()        %(LC_ALL="C" rpm -q --queryformat 'Prereq:kernel = %%{VERSION}-%%{RELEASE}' kernel-headers | grep -v "is not")
115 %requires_releq_kernel_up()     %(LC_ALL="C" rpm -q --queryformat 'Prereq:kernel-up = %%{VERSION}-%%{RELEASE}' kernel-headers | grep -v "is not")
116 %requires_releq_kernel_smp()    %(LC_ALL="C" rpm -q --queryformat 'Prereq:kernel-smp = %%{VERSION}-%%{RELEASE}' kernel-headers | grep -v "is not")
117
118 # kernel version-release handling
119 %__kernel_ver    %(grep UTS_RELEASE %{_kernelsrcdir}/include/linux/version.h 2>/dev/null | cut -d'"' -f2)
120 %__kernel_rel    %(LC_ALL="C" rpm -qf %{_kernelsrcdir}/include/linux/version.h --queryformat "%{RELEASE}" | grep -v "is not")
121 %_kernel_ver     %(echo %{__kernel_ver}%{!?_without_dist_kernel:-%{__kernel_rel}})
122 %_kernel_ver_str %(echo %{_kernel_ver} | sed s/-/_/g)
123
124 #-----------------------------------------------------------------
125 # find and gzip all files in %{_mandir} and %{infodir}
126 #
127 # Requires: xargs, find
128 #
129 #%no_install_post_compress_docs 1
130 %__spec_install_post_compress_docs { \
131 echo "Compress man and info pages."; \
132 %{!?no_install_post_compress_docs: \
133         %{?verbose:set -x;} \
134         for i in /usr/share/man /usr/X11R6/man /usr/share/info; do \
135                 if [ -d "$RPM_BUILD_ROOT$i" ]; then \
136                         find "$RPM_BUILD_ROOT$i" -name \*.bz2 -print | xargs -r %{__bzip2} -df; \
137                         find "$RPM_BUILD_ROOT$i" -name \*.gz -print | xargs -r %{__gzip} -dnf; \
138                         find "$RPM_BUILD_ROOT$i" -type f -print | xargs -r %{__gzip} -9nf; \
139                 fi; \
140         done; \
141 } }
142
143 #-----------------------------------------------------------------
144 # Strip executable binaries and shared object files
145 #
146 # Requires: find, awk, strip, cut, xargs
147 #
148 #%no_install_post_strip 1
149 %__spec_install_post_strip {%{!?debug: \
150 %{!?no_install_post_strip: \
151         %{?verbose:set -x;} \
152         echo "Strip executable binaries and shared object files."; \
153         filelist=`find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*"`; \
154         elfexelist=`echo $filelist | xargs -r file | \
155                 awk '/ELF.*executable/ {print $1}' | cut -d: -f1`; \
156         elfsharedlist=`echo $filelist | xargs -r file | \
157                 awk '/LF.*shared object/ {print $1}' | cut -d: -f1`; \
158         if [ -n "$elfexelist" ]; then \
159                 strip --remove-section=.note  --remove-section=.comment $elfexelist; \
160         fi; \
161         if [ -n "$elfsharedlist" ]; then \
162                 strip --strip-unneeded --remove-section=.note  --remove-section=.comment $elfsharedlist; \
163         fi; } \
164 } }
165
166 %_source_payload        w9.gzdio
167 %_binary_payload        w9.bzdio
168
169 #-----------------------------------------------------------------
170 # post %install sequence:
171 # - autodeps exceptions
172 # - compress all man and info pages,
173 # - strip all ELF executables and ELF shared objects if not %debug.
174
175 ###################################################################
176 # Requires/Provides automation
177 # exceptions system by Jacek Konieczny <jajcus@pld.org.pl>
178 %__spec_prep_pre \
179 _autoreqprov=n \
180 %{?_noautoreqfiles:_autoreqprov=y}\
181 %{?_noautoreq:_autoreqprov=y}\
182 %{?_noautoreqdep:_autoreqprov=y}\
183 %{?_noautoprovfiles:_autoreqprov=y}\
184 %{?_noautoprov:_autoreqprov=y}\
185 if [ "$_autoreqprov" = "y" ] ; then \
186     if [ -f %{_builddir}/__rpm_lock ] ; then \
187         echo "Some package using \%_noauto*  macros is already being built" >&2 \
188         echo "If it is not true delete %{_builddir}/__rpm_lock" >&2 \
189         exit 1 \
190     else \
191         rm -f %{_builddir}/__rpm_*\
192         touch %{_builddir}/__rpm_lock \
193     fi \
194 fi \
195 %{nil}
196
197 %__os_install_post \
198 %{?_noautoreqfiles:for f in %{_noautoreqfiles} ; do echo %{?buildroot:%{buildroot}}$f >> %{_builddir}/__rpm_noautoreqfiles ; done }\
199 %{?_noautoreq:for f in %{_noautoreq} ; do echo "$f" >> %{_builddir}/__rpm_noautoreq ; done }\
200 %{?_noautoreqdep:for f in %{_noautoreqdep} ; do echo "$f" >> %{_builddir}/__rpm_noautoreqdep ; done }\
201 %{?_noautoprovfiles:for f in %{_noautoprovfiles} ; do echo %{?buildroot:%{buildroot}}$f >> %{_builddir}/__rpm_noautoprovfiles ; done }\
202 %{?_noautoprov:for f in %{_noautoprov} ; do echo "$f" >> %{_builddir}/__rpm_noautoprov ; done }\
203 %{__spec_install_post_strip}\
204 %{__spec_install_post_compress_docs}\
205 %{__arch_install_post}\
206 %{nil}
207
208 %__spec_clean_pre       %{___build_pre}\
209 _autoreqprov=n \
210 %{?_noautoreqfiles:_autoreqprov=y}\
211 %{?_noautoreq:_autoreqprov=y}\
212 %{?_noautoreqdep:_autoreqprov=y}\
213 %{?_noautoprovfiles:_autoreqprov=y}\
214 %{?_noautoprov:_autoreqprov=y}\
215 %{?_noautoreqfiles:_autoreqprov=y}\
216 if [ "$_autoreqprov" = "y" ] ; then \
217         rm -f %{_builddir}/__rpm_* \
218 fi \
219 %{nil}
220
221
222 #%_noautoreqfiles       "%{_defaultdocdir}.*" "%{_examplesdir}.*"
223 #%_noautoreq            %{nil}
224 #%_noautoreqdep         %{nil}
225 #%_noautoprovfiles      %{nil}
226 #%_noautoprov           %{nil}
This page took 0.038578 seconds and 3 git commands to generate.