]> git.pld-linux.org Git - packages/rpm.git/blob - rpm.macros
- keep ORIGIN, we need it because some absolute paths are too long to be in rpath...
[packages/rpm.git] / rpm.macros
1 # $Revision$, $Date$
2 # PLD Linux rpm macros
3
4 %epoch          0
5 %x8664          x86_64 amd64 ia32e
6
7 # kernel compiler
8 %kgcc           %{__cc}
9 %kgcc_package   gcc
10
11 # compiler version
12 %cc_version             %{expand:%%global cc_version %(%{__cc} -dumpversion || echo ERROR)}%cc_version
13 %cxx_version    %{expand:%%global cxx_version %(%{__cxx} -dumpversion || echo ERROR)}%cxx_version
14
15 %__rm                   /bin/rm --interactive=never
16
17 # Build system path macros.
18 #
19 %__autoconf             autoconf %{?debug:-Wall}
20 %__automake             automake -a -c -f --foreign
21 %__autopoint            autopoint --force
22
23 %__gettextize { \
24         if grep -qs 'AM_GNU_GETTEXT.*external' configure.{ac,in} ; then \
25                 gettextize --copy --force --no-changelog; \
26         else \
27                 gettextize --copy --force --no-changelog --intl; \
28         fi; \
29         if [ ! -f po/Makevars ]; then \
30                 cp -f po/Makevars{.template,}; \
31         fi; \
32 }
33
34 %__glib_gettextize      glib-gettextize --copy --force
35 %__gnome_doc_common     gnome-doc-common --copy
36 %__gnome_doc_prepare    gnome-doc-prepare --copy --force
37 %__gtkdocize            gtkdocize --copy
38 %__intltoolize          intltoolize --copy --force
39 %__libtoolize           libtoolize --copy --force
40
41 #       Path to top of build area.
42 %_topdir                %{expand:%%global _topdir %(test -d ../SPECS -a -d ../SOURCES && (cd ..; pwd) || echo $HOME/rpm)}%_topdir
43
44 #       The number of cvs changelog entries kept when building package.
45 %_buildchangelogtruncate 20
46
47 %dependencytracking     %{nil}
48
49 #       Relations between package names that cause dependency loops
50 #       with legacy packages that cannot be fixed. Relations are
51 #       specified as
52 #               p>q
53 #       where package p has a Requires: on something that package q Provides:
54 #
55 # XXX   Note: that there cannot be any whitespace within the string "p>q",
56 #       and that both p and q are package names (i.e. no version/release).
57 %_dependency_whiteout   %{nil}
58
59 %_smp_mflags %([ -z "$RPM_BUILD_NCPUS" ] \\\
60         && RPM_BUILD_NCPUS="`/usr/bin/getconf _NPROCESSORS_ONLN`"; \\\
61         [ "$RPM_BUILD_NCPUS" -gt 1 ] && echo "-j$RPM_BUILD_NCPUS")
62
63 #-----------------------------------------------------------------
64 #
65 # (re)definition of %{rpm*flags} with %filterout_* support
66 # BuildRequires:        awk
67 # BuildRequires:        rpmbuild(macros) >= 1.315
68 #
69 # Flags specified in %filterout_* are removed from %rpm*flags, exactly:
70 # %rpmcflags    = %optflags - %filterout - %filterout_c   - %filterout_ld
71 # %rpmcxxflags  = %optflags - %filterout - %filterout_cxx - %filterout_ld
72 # %rpmldflags   = %optldflags - %filterout_ld
73 #
74 # Regular expressions are supported, but to avoid some character be treated
75 # as regular expression it must be escaped twice.
76
77 %filter_out                                             \
78         for (i = 1; i in I; i++) {      A=0;    \
79                 for (f in F) {                          \
80                         if (I[i] ~ "^" F[f] "$") A=1;   \
81                 };                                                      \
82                 if (!A) printf(I[i] FS);        \
83         }
84
85 %rpmcflags %(awk 'BEGIN {
86         split("%{?debug:%debugcflags}%{!?debug:%optflags}%{?debuginfocflags}",I);
87         split("%{?filterout} %{?filterout_c} %{?filterout_ld}",F);
88         %{filter_out}
89 }')
90
91 %rpmcxxflags %(awk 'BEGIN {
92         split("%{?debug:%debugcflags}%{!?debug:%optflags}%{?debuginfocflags}",I);
93         split("%{?filterout} %{?filterout_cxx} %{?filterout_ld}",F);
94         %{filter_out}
95 }')
96
97 %rpmldflags %(awk 'BEGIN {
98         split("%{?optldflags}",I);
99         split("%{?filterout_ld}",F)
100         %{filter_out}
101 }')
102
103 # rpmldflags with stripped -Wl, -- in the form flags have to be passed to 'ld'
104 # but, don't use it, better use gcc as linker
105 %ld_rpmldflags %(awk 'BEGIN {
106         split("%{rpmldflags}",F);
107         for (f in F) {
108                 s = F[f];
109                 if (s ~ /^-Wl,/) {
110                         s = substr(s,5);
111                         gsub(/,/," ",s);
112                 };
113                 printf(s FS);
114         };
115 }')
116
117 #-----------------------------------------------------------------
118 %configure2_13 { \
119  if [ -n "$LINGUAS" ]; then unset LINGUAS; fi; \
120  LDFLAGS="${LDFLAGS:-%rpmldflags}" ; export LDFLAGS ; \
121  CFLAGS="${CFLAGS:-%rpmcflags}" ; export CFLAGS ; \
122  CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" ; export CXXFLAGS ; \
123  FFLAGS="${FFLAGS:-%rpmcflags}" ; export FFLAGS ; \
124  FCFLAGS="${FCFLAGS:-%rpmcflags}" ; export FCFLAGS ; \
125  CPPFLAGS="${CPPFLAGS:-}" ; export CPPFLAGS ; \
126  %{?__cc:CC="%{__cc}" ; export CC ; } \
127  %{?__cxx:CXX="%{__cxx}" ; export CXX ; } \
128  %{?configuredir:%{configuredir}}%{!?configuredir:.}/configure \
129         --host=%{_target_platform} \
130         --prefix=%{_prefix} \
131         --exec-prefix=%{_exec_prefix} \
132         --bindir=%{_bindir} \
133         --sbindir=%{_sbindir} \
134         --sysconfdir=%{_sysconfdir} \
135         --datadir=%{_datadir} \
136         --includedir=%{_includedir} \
137         --libdir=%{_libdir} \
138         --libexecdir=%{_libexecdir} \
139         --localstatedir=%{_localstatedir} \
140         --sharedstatedir=%{_sharedstatedir} \
141         --mandir=%{_mandir} \
142         --infodir=%{_infodir} \
143         --x-libraries=%{?_x_libraries}%{!?_x_libraries:%{_libdir}} \
144         %{dependencytracking} \
145 }
146
147 # override __cmake to add -j4 in your ~/.rpmmacros for parallel make
148 %__cmake        /usr/bin/cmake
149 %cmake { \
150 CC="%{__cc}" \
151 CXX="%{__cxx}" \
152 CFLAGS="%{rpmcflags}" \
153 CXXFLAGS="%{rpmcxxflags}" \
154 %{__cmake} \
155 }
156
157 # override __scons to add -j4 in your ~/.rpmmacros for parallel make
158 %__scons        /usr/bin/scons
159 %scons { \
160 %{__scons} \
161         LDFLAGS="${LDFLAGS:-%rpmldflags}" \
162         CFLAGS="${CFLAGS:-%rpmcflags}" \
163         CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" \
164         FFLAGS="${FFLAGS:-%rpmcflags}" \
165         CPPFLAGS="${CPPFLAGS:-}" \
166         %{?__cc:CC="%{__cc}"} \
167         %{?__cxx:CXX="%{__cxx}"} \
168         libsuffix=%{_lib} \
169         prefix=%{_prefix} \
170 }
171
172 # waf. see waf.spec
173 # override __waf to add -j4 in your ~/.rpmmacros for parallel make
174 %__waf  /usr/bin/waf
175 %waf { \
176 CC="%{__cc}" \
177 CXX="%{__cxx}" \
178 CPP="%{__cpp}" \
179 CFLAGS="%{rpmcflags}" \
180 CXXFLAGS="%{rpmcxxflags}" \
181 %{__waf} \
182 }
183
184 #----------------------------------------------------------------
185 #%configure_cache 0
186 %configure_cache_file   %{buildroot}.configure.cache
187
188 %configure {./configure \
189         LDFLAGS="${LDFLAGS:-%rpmldflags}" \
190         CFLAGS="${CFLAGS:-%rpmcflags}" \
191         CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" \
192         FFLAGS="${FFLAGS:-%rpmcflags}" \
193         FCFLAGS="${FCFLAGS:-%rpmcflags}" \
194         CPPFLAGS="${CPPFLAGS:-}" \
195         %{?__cc:CC="%{__cc}"} \
196         %{?__cxx:CXX="%{__cxx}"} \
197         --host=%{_target_platform} \
198         --build=%{_target_platform} \
199         --prefix=%{_prefix} \
200         --exec-prefix=%{_exec_prefix} \
201         --bindir=%{_bindir} \
202         --sbindir=%{_sbindir} \
203         --sysconfdir=%{_sysconfdir} \
204         --datadir=%{_datadir} \
205         --includedir=%{_includedir} \
206         --libdir=%{_libdir} \
207         --libexecdir=%{_libexecdir} \
208         --localstatedir=%{_localstatedir} \
209         --sharedstatedir=%{_sharedstatedir} \
210         --mandir=%{_mandir} \
211         --infodir=%{_infodir} \
212         --x-libraries=%{?_x_libraries}%{!?_x_libraries:%{_libdir}} \
213         %{dependencytracking} \
214         %{?configure_cache:--cache-file=%{configure_cache_file}} \
215 }
216
217 # overload to insert debuginfo package
218 %prep \
219 %if 0%{?_enable_debug_packages}\
220 %{debug_package}\
221 %endif\
222 %%prep\
223 %{nil}
224
225 # Location of autoconf macros
226 %_aclocaldir    %{expand:%%global _aclocaldir %(aclocal --print-ac-dir || echo ERROR)}%_aclocaldir
227
228 # Location of omf files
229 %_omf_dest_dir  %{expand:%%global _omf_dest_dir %(scrollkeeper-config --omfdir || echo ERROR)}%_omf_dest_dir
230
231 # Location of pkgconfig files
232 %_pkgconfigdir  /usr/%{_lib}/pkgconfig
233 # noarch pkgconfig files
234 %_npkgconfigdir /usr/share/pkgconfig
235
236 # Location of desktop files
237 %_desktopdir    /usr/share/applications
238 %_applnkdir     ERROR:_applnkdir_is_obsolete_use_desktopdir_instead
239
240 # Location of pixmaps for applnk/desktop files
241 %_pixmapsdir    /usr/share/pixmaps
242
243 # Location of themable icons for applnk/desktop files
244 %_iconsdir      /usr/share/icons
245
246 # Location of fonts directories
247 %_fontsdir      /usr/share/fonts
248
249 # Location of Gtk and associated libraries documentation
250 %_gtkdocdir     %{_defaultdocdir}/gtk-doc/html
251
252 # Location of KDE documentation
253 %_kdedocdir     %{_defaultdocdir}/kde/HTML
254
255 # unsermake script
256 %__unsermake /usr/share/unsermake/unsermake
257
258 # Current date
259 %date           %(LC_ALL="C" date +"%a %b %d %Y")
260
261 # Example files, programs, scripts...
262 %_examplesdir   /usr/src/examples
263
264 # Alternative kernel type/version
265 %_alt_kernel    %{nil}%{?alt_kernel:-%{?alt_kernel}}
266
267 # The directory holding Linux kernel sources
268 %_kernelsrcdir  /usr/src/linux%{_alt_kernel}
269
270 # If non-empty "debug" macro defined, add "dbg" suffix to release number
271 %_rpmfilename           %%{NAME}-%%{VERSION}-%%{RELEASE}%{?debug:dbg}.%%{ARCH}.rpm
272
273 # Requires name = version-release
274 %requires_releq()               %(echo '%*' | LC_ALL="C" xargs -r rpm -q --qf 'Requires: %{N} = %|E?{%{E}:}|%{V}-%{R}\\n' | grep -v 'is not')
275
276 %releq_kernel                   %{expand:%%global releq_kernel %(R=$(LC_ALL=C rpm -q --qf '%{N} = %|E?{%{E}:}|%{V}-%{R}' -f %{_kernelsrcdir}/include/linux/version.h 2>/dev/null | grep -v 'is not' | sed -e 's:-headers::;s:-config::'); echo ${R:-ERROR})}%releq_kernel
277 %releq_kernel_up                %{expand:%%global releq_kernel_up %(R=$(LC_ALL=C rpm -q --qf '%{N}-up = %|E?{%{E}:}|%{V}-%{R}' -f %{_kernelsrcdir}/include/linux/version.h 2>/dev/null | grep -v 'is not' | sed -e 's:-headers::;s:-config::'); echo ${R:-ERROR})}%releq_kernel_up
278 %releq_kernel_smp()             %{expand:%%global releq_kernel_smp %(R=$(LC_ALL=C rpm -q --qf '%{N}-smp = %|E?{%{E}:}|%{V}-%{R}' -f %{_kernelsrcdir}/include/linux/version.h 2>/dev/null | grep -v 'is not' | sed -e 's:-headers::;s:-config::'); echo ${R:-ERROR})}%releq_kernel_smp
279 %requires_releq_kernel(s:)              Requires%{-s:(%{-s*})}: %releq_kernel
280 %requires_releq_kernel_up(s:)   Requires%{-s:(%{-s*})}: %releq_kernel_up
281 %requires_releq_kernel_smp(s:)  Requires%{-s:(%{-s*})}: %releq_kernel_smp
282
283 # XXX: why epoch 0 is stripped?
284 %requires_eq()          %(echo '%*' | LC_ALL="C" xargs -r rpm -q --qf 'Requires: %{N} = %|E?{%{E}:}|%{V}\\n' | sed -e 's/ 0:/ /' | grep -v 'is not')
285 %requires_eq_to() %(LC_ALL="C" rpm -q --qf 'Requires: %1 = %|E?{%{E}:}|%{V}' %2 | grep -v "is not")
286
287 %apache_modules_api %{expand:%%global apache_modules_api %(awk '/#define MODULE_MAGIC_NUMBER_MAJOR/ {print $3}' /usr/include/apache/ap_mmn.h 2>/dev/null || echo ERROR)}%apache_modules_api
288
289 # kernel version-release handling
290 %__kernel_ver    %{expand:%%global __kernel_ver %( \\
291         Z=$(awk -F'"' '/UTS_RELEASE/{print $2}' %{_kernelsrcdir}/include/linux/{version,utsrelease}.h 2>/dev/null); \\
292         Z=${Z:-$(awk -F' = ' '/^VERSION/{v=$2} /^PATCHLEVEL/{p=$2} /^SUBLEVEL/{s=$2} /^EXTRAVERSION/{e=$2} END {printf("%d.%d.%d%s", v, p, s, e)}' %{_kernelsrcdir}/Makefile 2>/dev/null)}; \\
293         echo ${Z:-ERROR}; \\
294 )}%__kernel_ver
295
296 %__kernel_rel   %{expand:%%global __kernel_rel %(Z=$(LC_ALL=C rpm -qf %{_kernelsrcdir}/include/linux/fs.h 2>/dev/null --qf "%{R}" | grep -v "is not"); echo ${Z:-ERROR})}%__kernel_rel
297 %__kernel_rpmvr %{expand:%%global __kernel_rpmvr %(Z=$(LC_ALL=C rpm -qf %{_kernelsrcdir}/include/linux/fs.h 2>/dev/null --qf "%{V}-%{R}" | grep -v "is not"); echo ${Z:-ERROR})}%__kernel_rpmvr
298 %_kernel_ver    %{expand:%%global _kernel_ver %{__kernel_ver}%{?with_dist_kernel:%(echo %{__kernel_ver} | grep -q -e - || echo -%{__kernel_rel})}}%_kernel_ver
299 %_kernel_ver_str %{expand:%%global _kernel_ver_str %(echo %{!?_without_dist_kernel:%{__kernel_rpmvr}}%{?_without_dist_kernel:%{__kernel_ver}} | sed -e 's/-/_/g')}%_kernel_ver_str
300
301 # `uname -r` to be used in @release field
302 %_kernel_vermagic       %{expand:%%global _kernel_vermagic %(echo %{_kernel_ver} | sed -e 's/-/_/g')}%_kernel_vermagic
303
304 # sgml macros
305 %xmlcat_add()           /usr/bin/xmlcatalog --noout --add nextCatalog \"\" %1 /etc/xml/catalog ;
306 %xmlcat_del()           /usr/bin/xmlcatalog --noout --del %1 /etc/xml/catalog ;
307 %xmlcat_add_rewrite     /usr/bin/xmlcatalog --noout --add rewriteSystem
308 %xmlcat_create()        /usr/bin/xmlcatalog --noout --create %1 ;
309 %sgmlcat_add()          /usr/bin/install-catalog --add %1 %2 > /dev/null ;
310 %sgmlcat_del()          /usr/bin/install-catalog --remove %1 %2 > /dev/null ;
311 %docbook_sgmlcat_fix() { for l in \
312 '' \
313 '  -- default decl --' \
314 'DTDDECL "-//OASIS//DTD DocBook XML V%2//EN" "../../xml.dcl"' \
315 '  -- hacks for opensp --' \
316 'SYSTEM "file://%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
317 'SYSTEM "http://www.oasis-open.org/docbook/xml/%2/docbookx.dtd"                  "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
318 '' \
319 ; do echo $l; done >> %1 \
320 }
321
322 # vim - "
323
324 # minimum file size needed for compressed documents.
325 # just smaller files than this get larger when compressed.
326 # some stats:
327 # - 0 byte file compressed was 25 bytes .gz
328 # - 39 byte file was compressed as 57
329 # - with test/test.spec@man 158 byte file was compressed also 158
330 %_min_compress_bytes    159
331
332 #-----------------------------------------------------------------
333 # find and gzip all files in %{_mandir} and %{infodir}
334 #
335 # Requires: xargs, find
336 #
337 #%no_install_post_compress_docs 1
338 %__spec_install_post_compress_docs { \
339 %{!?no_install_post_compress_docs:__spec_install_post_compress_docs() { \
340         for i in /usr/share/man /usr/X11R6/man; do \
341                 if [ -d "$RPM_BUILD_ROOT$i" ]; then \
342                         echo "Compress man pages: $i"; \
343                         find "$RPM_BUILD_ROOT$i" -name '*.bz2' -print | xargs -r %{__bzip2} -df; \
344                         find "$RPM_BUILD_ROOT$i" -name '*.gz' -print | xargs -r %{__gzip} -dnf; \
345                         find $RPM_BUILD_ROOT$i -type l | while read a; do \
346                                 m=$(readlink $a); \
347                                 rm -f $a; \
348                                 echo .so ${m##*/} > $a; \
349                                 echo >&2 "Converted ${a#$RPM_BUILD_ROOT} from symlink to man link: ${m##*/}"; \
350                         done; \
351                         find "$RPM_BUILD_ROOT$i" -type f -size +%{_min_compress_bytes}c -print | xargs -r %{__gzip} -9nf; \
352                 fi; \
353         done; \
354         if [ -d "$RPM_BUILD_ROOT%{_infodir}" ]; then \
355                 echo "Compress info pages: %{_infodir}"; \
356                 find "$RPM_BUILD_ROOT%{_infodir}" -name '*.bz2' -print | xargs -r %{__bzip2} -df; \
357                 find "$RPM_BUILD_ROOT%{_infodir}" -name '*.gz' -print | xargs -r %{__gzip} -dnf; \
358                 find "$RPM_BUILD_ROOT%{_infodir}" -name '*.info*' -type f -size +%{_min_compress_bytes}c -print | xargs -r %{__gzip} -9nf; \
359         fi; \
360 }; __spec_install_post_compress_docs } }
361
362 #-----------------------------------------------------------------
363 # Strip executable binaries and shared object files
364 #
365 # Requires: find, awk, strip, cut, xargs
366 #
367 # Special macros which affect this process:
368 #%no_install_post_strip 1               # disable stripping at all
369 #%_noautostrip                  regexp  # exclude files matching (anchored!) regex from stripping
370 #%_autostripall                 regexp  # strip files matching (anchored!) regex using plain strip
371 #%_autostripunneeded    regexp  # strip files matching (anchored!) regex using strip --strip-unneeded
372 #%_autostripdebug               regexp  # strip files matching (anchored!) regex using strip --strip-debug
373 #
374 %__spec_install_post_strip {%{!?debug: \
375 %{!?no_install_post_strip:__spec_install_post_strip() { \
376 if [ -d "$RPM_BUILD_ROOT" ]; then \
377         if [ -d $RPM_BUILD_ROOT/lib/modules ]; then \
378                 modulelist=$(find $RPM_BUILD_ROOT/lib/modules -name '*o' -type f -print); \
379                 if [ "$modulelist" ]; then \
380                         modulecount=$(echo "$modulelist" | wc -l); \
381                         printf "Stripping %d kernel modules..." $modulecount; \
382                         echo "$modulelist" | xargs -l512 chmod u+w; \
383                         echo "$modulelist" | xargs -l512 %{__strip} --strip-unneeded --remove-section=.comment --remove-section=.note.GNU-stack; \
384                         echo "DONE"; \
385                 fi; \
386         fi; \
387         filelist=$(find $RPM_BUILD_ROOT -type f ! -regex ".*/usr/lib[0-9]*/debug/.*\.debug" ! -regex ".*/lib/modules/.*" ! -regex ".*%{_docdir}/.*" ! -regex ".*%{_includedir}/.*" %{?_noautostrip:! -regex "%{_noautostrip}"} %{?_autostripall:! -regex "%{_autostripall}"} %{?_autostripunneeded:! -regex "%{_autostripunneeded}"} %{?_autostripdebug:! -regex "%{_autostripdebug}"}); \
388         if [ -n "$filelist" ]; then \
389                 filetypes=`echo "$filelist" | xargs -r -d'\\n' file`; \
390                 elfexelist=`echo "$filetypes" | awk -F: '/ELF.*executable/ {print $1}'`; \
391                 elfsharedlist=`echo "$filetypes" | awk -F: '/LF.*shared object/ {print $1}'`; \
392                 archiveslist=`echo "$filetypes" | awk -F: '/current ar archive/ {print $1}'`; \
393                 if [ -n "$elfexelist" ]; then \
394                         printf "Stripping %d ELF executables..." $(echo "$elfexelist" | wc -l); \
395                         chmod u+w $elfexelist; \
396                         %{__strip} --remove-section=.note --remove-section=.comment $elfexelist; \
397                         echo "DONE"; \
398                 fi; \
399                 if [ -n "$elfsharedlist" ]; then \
400                         printf "Stripping %d ELF shared libraries..." $(echo "$elfsharedlist" | wc -l); \
401                         chmod u+w $elfsharedlist; \
402                         %{__strip} --strip-unneeded --remove-section=.note --remove-section=.comment $elfsharedlist; \
403                         echo "DONE"; \
404                 fi; \
405                 if [ -n "$archiveslist" ]; then \
406                         printf "Stripping %d ar archives..." $(echo "$archiveslist" | wc -l); \
407                         chmod u+w $archiveslist; \
408                         %{__strip} --strip-debug --remove-section=.note --remove-section=.comment $archiveslist; \
409                         echo "DONE"; \
410                 fi; \
411         fi; \
412     filelist_all=%{?_autostripall:$(find $RPM_BUILD_ROOT -type f -regex "%{_autostripall}")}; \
413     filelist_unneeded=%{?_autostripunneeded:$(find $RPM_BUILD_ROOT -type f -regex "%{_autostripunneeded}")}; \
414     filelist_debug=%{?_autostripdebug:$(find $RPM_BUILD_ROOT -type f -regex "%{_autostripdebug}")}; \
415         if [ -n "$filelist_all" ]; then \
416                 printf "Stripping everything from %d additional files..." $(echo "$filelist_all" | wc -l); \
417                 chmod u+w $filelist_all; \
418                 %{__strip} --remove-section=.note --remove-section=.comment $filelist_all; \
419                 echo "DONE"; \
420         fi; \
421         if [ -n "$filelist_unneeded" ]; then \
422                 printf "Stripping unneeded from %d additional files..." $(echo "$filelist_unneeded" | wc -l); \
423                 chmod u+w $filelist_unneeded; \
424                 %{__strip} --strip-unneeded --remove-section=.note --remove-section=.comment $filelist_unneeded; \
425                 echo "DONE"; \
426         fi; \
427         if [ -n "$filelist_debug" ]; then \
428                 printf "Stripping debuginfo from %d additional files..." $(echo "$filelist_debug" | wc -l); \
429                 chmod u+w $filelist_debug; \
430                 %{__strip} --strip-debug --remove-section=.note --remove-section=.comment $filelist_debug; \
431                 echo "DONE"; \
432         fi; \
433 fi; }; __spec_install_post_strip } } }
434
435 #-----------------------------------------------------------------
436 # remove all RPATH from executable binaries and shared object files
437 #
438 # Requires: find, awk, cut, xargs, chrpath, uname
439 #
440 # Special macros which affect this process
441 #%no_install_post_chrpath       1       # disable chrpath at all
442 #%_noautochrpath        regex           # exclude files matching (anchored!) regex from chrpath
443 #
444 %__spec_install_post_chrpath {%{!?debug: \
445 %{!?no_install_post_chrpath: __spec_install_post_chrpath() { \
446 if [ -d "$RPM_BUILD_ROOT" ]; then \
447         files=`find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*" ! -regex ".*/usr/lib[0-9]*/debug/.*" ! -regex ".*/lib/modules/.*" ! -regex ".*%{_docdir}/.*" ! -regex ".*%{_includedir}/.*" %{?_noautochrpath:! -regex "%{_noautochrpath}"}`; \
448         if [ -n "$files" ]; then \
449                 objs=`echo "$files" | xargs -r -d'\\n' file | awk -F: '/ELF.*(executable.*dynamically linked|shared object)/ {print $1}'`; \
450         fi; \
451         if [ -n "$objs" ]; then \
452                 printf "Remove RPATH from %d executable binaries and shared object files.\n" $(echo "$objs" | wc -l); \
453                 echo "$objs" | \
454                 while read file; do \
455                         rpath= ; \
456                         chmod u+w "$file"; \
457                         for dir in $(chrpath -l "$file" | awk '/RPATH=/ { gsub(/.*RPATH=/,""); gsub(/:/," "); print $0 }'); do \
458                                         case $dir in \
459                                         '$ORIGIN' ) \
460                                                 if [ "$rpath" = "" ] ; then rpath="$dir" ; \
461                                                 else rpath="$rpath:$dir" ; fi ; \
462                                                 continue ; \
463                                                 ;; \
464                                         esac ; \
465                                         dir=$(readlink -m "$dir"); \
466                                         case $dir in \
467                                         /home/* | /tmp/* | /usr/lib | /usr/lib64 | /lib | /lib64 | /usr/local/lib | /usr/local/lib64 | /usr/X11R6/lib | /usr/X11R6/lib64 ) \
468                                                 echo "remove-rpath: $dir in $file"; \
469                                                 ;; \
470                                         * ) \
471                                                 if [ "$rpath" = "" ] ; then rpath="$dir" ; \
472                                                 else rpath="$rpath:$dir" ; fi ; \
473                                                 ;; \
474                                         esac ; \
475                         done ; \
476                         if [ "$rpath" = "" ] ; then chrpath -d "$file" > /dev/null ; \
477                         else chrpath -r "$rpath" "$file" > /dev/null ; fi ; \
478                 done; \
479         fi; \
480 fi; }; __spec_install_post_chrpath } } }
481
482 #-----------------------------------------------------------------
483 # Find and gzip all kernel modules
484 #
485 # Requires: find
486 #
487 #%no_install_post_compress_modules      1
488 %__spec_install_post_compress_modules { \
489 %{!?no_install_post_compress_modules: __spec_install_post_compress_modules() { \
490         if [ -d $RPM_BUILD_ROOT/lib/modules ]; then \
491                 q=$(find $RPM_BUILD_ROOT/lib/modules -name '*o' -type f -print); \
492                 if [ "$q" ]; then \
493                         printf "Compress %d kernel modules..." $(echo "$q" | wc -l); \
494                         echo "$q" | xargs -r %{__gzip} -9nf; \
495                         echo "DONE"; \
496                         find $RPM_BUILD_ROOT/lib/modules -name '*o' -type l -printf "%p %l\n" | \
497                         while read a b; do ln -sf $b.gz $a.gz; rm -f $a; done; \
498                 fi; \
499         fi; \
500 }; __spec_install_post_compress_modules } }
501
502 # Remove common Perl files we don't package
503 %__spec_install_post_perl_clean {\
504 %{!?no_install_post_perl_clean: \
505 %{?pdir:rm -f $RPM_BUILD_ROOT{%{perl_archlib}/perllocal.pod,%{perl_vendorarch}/auto/%{pdir}%{?pnam:/%(echo %{pnam} | tr - /)}/.packlist}} \
506 } }
507
508 #-----------------------------------------------------------------
509 # Update GConf2 schemas
510 #
511 # Requires: GConf2
512 #
513 %gconf_schema_install() \
514         umask 022; \
515         GCONF_CONFIG_SOURCE="xml:readwrite:/etc/gconf/gconf.xml.defaults" /usr/bin/gconftool-2 --makefile-install-rule /etc/gconf/schemas/%{?1}%{!?1:*.schemas} > /dev/null; \
516 %{nil}
517
518 %gconf_schema_uninstall() \
519 if [ $1 = 0 ]; then \
520         umask 022; \
521         GCONF_CONFIG_SOURCE="xml:readwrite:/etc/gconf/gconf.xml.defaults" /usr/bin/gconftool-2 --makefile-uninstall-rule /etc/gconf/schemas/%{?1} > /dev/null \
522 fi; \
523 %{nil}
524
525 #-----------------------------------------------------------------
526 # Update desktop MIME database
527 # requires: desktop-file-utils
528 %update_desktop_database() {{ \
529         umask 022; \
530         /usr/bin/update-desktop-database -q; \
531 }}%{nil}
532
533 %update_desktop_database_post %update_desktop_database
534
535 %update_desktop_database_postun() {{ \
536 if [ "$1" = "0" ]; then \
537         %update_desktop_database; \
538 fi; \
539 }}%{nil}
540
541 #-----------------------------------------------------------------
542 # Update shared MIME info database
543 # requires: shared-mime-info
544 #
545 %update_mime_database() {{ \
546         umask 022; \
547         /usr/bin/update-mime-database %{_datadir}/mime; \
548 }}%{nil}
549
550 #-----------------------------------------------------------------
551 # Update icon cache
552 # requires: gtk+
553 #
554 %update_icon_cache() {{ \
555         umask 022; \
556         /usr/bin/gtk-update-icon-cache -qf %{_datadir}/icons/%1; \
557 }}%{nil}
558
559 #-----------------------------------------------------------------
560 # Update scrollkeeper database
561 # requires: scrollkeeper
562 #
563 %scrollkeeper_update_post() \
564         /usr/bin/scrollkeeper-update -q; \
565 %{nil}
566
567 %scrollkeeper_update_postun() \
568 if [ "$1" = "0" ]; then \
569         /usr/bin/scrollkeeper-update -q; \
570 fi; \
571 %{nil}
572
573 #-----------------------------------------------------------------
574 # post %install sequence:
575 # - autodeps exceptions
576 # - compress all man and info pages,
577 # - strip all ELF executables and ELF shared objects if not %debug.
578 # - compress kernel modules if any
579
580 ###################################################################
581 # Requires/Provides automation
582 # exceptions system by Jacek Konieczny <jajcus@pld-linux.org>
583 #
584 %__noautoreqfiles       %(sed -e s'/#.*//' /etc/rpm/noautoreqfiles)%{?_noautoreqfiles: %{_noautoreqfiles}}
585 %__noautoprovfiles      %(sed -e s'/#.*//' /etc/rpm/noautoprovfiles)%{?_noautoprovfiles: %{_noautoprovfiles}}
586 %__noautoreq            %(sed -e s'/#.*//' /etc/rpm/noautoreq)%{?_noautoreq: %{_noautoreq}}
587 %__noautoreqdep         %(sed -e s'/#.*//' /etc/rpm/noautoreqdep)%{?_noautoreqdep: %{_noautoreqdep}}
588 %__noautoprov           %(sed -e s'/#.*//' /etc/rpm/noautoprov)%{?_noautoprov: %{_noautoprov}}
589
590 #%_noautocompressdoc    %{nil}
591 #
592 %_missing_doc_files_terminate_build     1%{nil}
593 %_unpackaged_files_terminate_build      %{nil}
594 # (X)emacs support
595 %___emacs_lispdir_helper  -batch -q -eval '(while load-path (princ (concat (car load-path) "\\n")) (setq load-path (cdr load-path)))' 2> /dev/null|sed -n '/\\(.*\\/x\\?emacs\\/site-lisp\\)\\/\\?$/{s,,\\1,p;q;}'
596 %_emacs_lispdir %{expand:%%global _emacs_lispdir %(Z=$(emacs %___emacs_lispdir_helper); echo ${Z:-ERROR})}%_emacs_lispdir
597 %_xemacs_lispdir %{expand:%%global _xemacs_lispdir %(Z=$(xemacs %___emacs_lispdir_helper); echo ${Z:-ERROR})}%_xemacs_lispdir
598
599 %__php_provides %{nil}
600 %__php_requires %{nil}
601 %__perl_provides %{nil}
602 %__perl_requires %{nil}
603 %__mono_provides %{nil}
604 %__mono_requires %{nil}
605
606 # Perl specific macro definitions.
607 %perl_privlib           %{expand:%%global perl_privlib %(eval $(%{__perl} -V:installprivlib 2>/dev/null); echo ${installprivlib:-ERROR})}%perl_privlib
608 %perl_archlib           %{expand:%%global perl_archlib %(eval $(%{__perl} -V:installarchlib 2>/dev/null); echo ${installarchlib:-ERROR})}%perl_archlib
609 %perl_vendorlib         %{expand:%%global perl_vendorlib %(eval $(%{__perl} -V:installvendorlib 2>/dev/null); echo ${installvendorlib:-ERROR})}%perl_vendorlib
610 %perl_vendorarch        %{expand:%%global perl_vendorarch %(eval $(%{__perl} -V:installvendorarch 2>/dev/null); echo ${installvendorarch:-ERROR})}%perl_vendorarch
611 %perl_sitelib           %{expand:%%global perl_sitelib %(eval $(%{__perl} -V:installsitelib 2>/dev/null); echo ${installsitelib:-ERROR})}%perl_sitelib
612 %perl_sitearch          %{expand:%%global perl_sitearch %(eval $(%{__perl} -V:installsitearch 2>/dev/null); echo ${installsitearch:-ERROR})}%perl_sitearch
613
614 # Ruby
615 %__ruby                         /usr/bin/ruby
616 %ruby_archdir           %{expand:%%global ruby_archdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["archdir"]' 2>/dev/null || echo ERROR)}%ruby_archdir
617 %ruby_ridir                     %{expand:%%global ruby_ridir %(%{__ruby} -r rbconfig -e 'include Config; print File.join(CONFIG["datadir"], "ri", CONFIG["ruby_version"], "system")' 2>/dev/null || echo ERROR)}%ruby_ridir
618 %ruby_rubylibdir        %{expand:%%global ruby_rubylibdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["rubylibdir"]' 2>/dev/null || echo ERROR)}%ruby_rubylibdir
619 %ruby_vendorarchdir     %{expand:%%global ruby_vendorarchdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["vendorarchdir"]' 2>/dev/null || echo ERROR)}%ruby_vendorarchdir
620 %ruby_vendorlibdir      %{expand:%%global ruby_vendorlibdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["vendorlibdir"]' 2>/dev/null || echo ERROR)}%ruby_vendorlibdir
621 %ruby_sitearchdir       %{expand:%%global ruby_sitearchdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["sitearchdir"]' 2>/dev/null || echo ERROR)}%ruby_sitearchdir
622 %ruby_sitelibdir        %{expand:%%global ruby_sitelibdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["sitelibdir"]' 2>/dev/null || echo ERROR)}%ruby_sitelibdir
623 %ruby_version           %{expand:%%global ruby_version %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["ruby_version"]' 2>/dev/null || echo ERROR)}%ruby_version
624 %ruby_ver_requires_eq   Requires:       ruby(ver) = %ruby_version
625 %ruby_mod_ver_requires_eq       Requires:       ruby-modules(ver) = %ruby_version
626
627 %php_pear_dir           /usr/share/pear
628 %php_data_dir           /usr/share/php
629 %php_extensiondir       %{expand:%%global php_extensiondir %(php-config --extension-dir 2>/dev/null || echo ERROR)}%php_extensiondir
630 %php_sysconfdir         %{expand:%%global php_sysconfdir %(php-config --sysconfdir 2>/dev/null || echo ERROR)}%php_sysconfdir
631 %php_includedir         %{expand:%%global php_includedir %(php-config --include-dir 2>/dev/null || echo ERROR)}%php_includedir
632
633 # extract php/zend api versions
634 %php_major_version              %{expand:%%global php_major_version %(awk '/#define PHP_MAJOR_VERSION/{print $3}' %{php_includedir}/main/php_version.h 2>/dev/null || echo ERROR)}%php_major_version
635 %php_api_version                %{expand:%%global php_api_version %(awk '/#define PHP_API_VERSION/{print $3}' %{php_includedir}/main/php.h 2>/dev/null || echo ERROR)}%php_api_version
636 %php_pdo_api_version    %{expand:%%global php_pdo_api_version %(awk '/#define PDO_DRIVER_API/{print $3}' %{php_includedir}/ext/pdo/php_pdo_driver.h 2>/dev/null || echo ERROR)}%php_pdo_api_version
637 %php_debug                              %{expand:%%global php_debug %(awk '/#define ZEND_DEBUG/{print $3}' %{php_includedir}/main/php_config.h 2>/dev/null || echo ERROR)}%php_debug
638 %zend_module_api                %{expand:%%global zend_module_api %(awk '/#define ZEND_MODULE_API_NO/{print $3}' %{php_includedir}/Zend/zend_modules.h 2>/dev/null || echo ERROR)}%zend_module_api
639 %zend_extension_api             %{expand:%%global zend_extension_api %(awk '/#define ZEND_EXTENSION_API_NO/{print $3}' %{php_includedir}/Zend/zend_extensions.h 2>/dev/null || echo ERROR)}%zend_extension_api
640 %zend_zts                               %{expand:%%global zend_zts %(Z=$(grep -sc '^#define ZTS 1' %{php_includedir}/main/php_config.h); echo ${Z:-ERROR})}%zend_zts
641
642 # helper macro
643 %__php_api_requires(v:) Requires: php%{-v*}(%{expand:%1}) = %{expand:%{%{!?2:%{1}}%{?2}}}
644
645 # macros for public use
646 # for php extensions (php-pecl)
647 %requires_php_extension %{__php_api_requires modules_api php_api_version} \
648 %{__php_api_requires zend_module_api} \
649 %{__php_api_requires -v %php_major_version debug php_debug} \
650 %{__php_api_requires -v %php_major_version thread-safety zend_zts}
651
652 # for zend extensions
653 %requires_zend_extension %{__php_api_requires zend_module_api} \
654 %{__php_api_requires zend_extension_api} \
655 %{__php_api_requires -v %php_major_version debug php_debug} \
656 %{__php_api_requires -v %php_major_version thread-safety zend_zts}
657
658 # for php pdo modules (php-pecl-PDO_*)
659 %requires_php_pdo_module %{__php_api_requires PDO_API php_pdo_api_version}
660
661 # for using PHP post scripts. for PHP >= 5.0
662 %php_webserver_restart \
663 [ ! -f /etc/apache/conf.d/??_mod_php.conf ] || %service -q apache restart \
664 [ ! -f /etc/httpd/conf.d/??_mod_php.conf ] || %service -q httpd restart \
665 if [ -f /etc/rc.d/init.d/php-fcgi ]; then \
666         PHP_FCGI_BINARY=; . /etc/sysconfig/php-fcgi 2>/dev/null \
667         if [[ ${PHP_FCGI_BINARY:-php.fcgi} = *php.fcgi* ]]; then \
668                 %service -q php-fcgi restart \
669         fi \
670 fi \
671 %{nil}
672
673 # for using php post scripts. for PHP >= 4.0 && PHP < 5.0
674 %php4_webserver_restart \
675 [ ! -f /etc/apache/conf.d/??_mod_php4.conf ] || %service -q apache restart \
676 [ ! -f /etc/httpd/conf.d/??_mod_php4.conf ] || %service -q httpd restart \
677 if [ -f /etc/rc.d/init.d/php-fcgi ]; then \
678         PHP_FCGI_BINARY=; . /etc/sysconfig/php-fcgi 2>/dev/null \
679         if [[ ${PHP_FCGI_BINARY:-php.fcgi} = *php4.fcgi* ]]; then \
680                 %service -q php-fcgi restart \
681         fi \
682 fi \
683 %{nil}
684
685
686 # X.org helper macros
687 %__xorg_abi_requires() Requires: xorg-xserver-server(%{expand:%1}-abi) = %{expand:%{%{!?2:%{1}}%{?2}}}
688 #
689 %xorg_xserver_ansic_abi         %{expand:%%global xorg_xserver_ansic_abi %(awk '/#define ABI_ANSIC_VERSION/ { split($0,A,/[(,)]/); printf("%d.%d",A[2], A[3]); }' /usr/include/xorg/xf86Module.h 2> /dev/null || echo ERROR)}%xorg_xserver_ansic_abi
690 %xorg_xserver_extension_abi     %{expand:%%global xorg_xserver_extension_abi %(awk '/#define ABI_EXTENSION_VERSION/ { split($0,A,/[(,)]/); printf("%d.%d",A[2], A[3]); }' /usr/include/xorg/xf86Module.h 2> /dev/null || echo ERROR)}%xorg_xserver_extension_abi
691 %xorg_xserver_font_abi          %{expand:%%global xorg_xserver_font_abi %(awk '/#define ABI_FONT_VERSION/ { split($0,A,/[(,)]/); printf("%d.%d",A[2], A[3]); }' /usr/include/xorg/xf86Module.h 2> /dev/null | echo ERROR)}%xorg_xserver_font_abi
692 %xorg_xserver_videodrv_abi      %{expand:%%global xorg_xserver_videodrv_abi %(awk '/#define ABI_VIDEODRV_VERSION/ { split($0,A,/[(,)]/); printf("%d.%d",A[2], A[3]); }' /usr/include/xorg/xf86Module.h 2> /dev/null || echo ERROR)}%xorg_xserver_videodrv_abi
693 %xorg_xserver_xinput_abi        %{expand:%%global xorg_xserver_xinput_abi %(awk '/#define ABI_XINPUT_VERSION/ { split($0,A,/[(,)]/); printf("%d.%d",A[2], A[3]); }' /usr/include/xorg/xf86Module.h 2> /dev/null || echo ERROR)}%xorg_xserver_xinput_abi
694
695 %requires_xorg_xserver_extension %{__xorg_abi_requires ansic xorg_xserver_ansic_abi} \
696 %{__xorg_abi_requires extension xorg_xserver_extension_abi}
697 %requires_xorg_xserver_xinput %{__xorg_abi_requires ansic xorg_xserver_ansic_abi} \
698 %{__xorg_abi_requires xinput xorg_xserver_xinput_abi}
699 %requires_xorg_xserver_font %{__xorg_abi_requires ansic xorg_xserver_ansic_abi} \
700 %{__xorg_abi_requires font xorg_xserver_font_abi}
701 %requires_xorg_xserver_videodrv %{__xorg_abi_requires ansic xorg_xserver_ansic_abi} \
702 %{__xorg_abi_requires videodrv xorg_xserver_videodrv_abi}
703
704 # Python specific macro definitions.
705 # python main version
706 %py_ver                 %{expand:%%global py_ver %(%{__python} -c "import sys; print sys.version[:3]" || echo ERROR)}%py_ver
707
708 # directories
709 %py_prefix              %{expand:%%global py_prefix %(%{__python} -c "import sys; print sys.prefix" || echo ERROR)}%py_prefix
710 %py_libdir              %{py_prefix}/%{_lib}/python%{py_ver}
711 %py_scriptdir   %{py_prefix}/share/python%{py_ver}
712 %py_incdir              /usr/include/python%{py_ver}
713 %py_sitedir             %{py_libdir}/site-packages
714 %py_sitescriptdir %{py_scriptdir}/site-packages
715 %py_dyndir              %{py_libdir}/lib-dynload
716
717 # pure python modules compilation
718 %py_comp                python -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
719
720 %py_ocomp               python -O -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
721
722 # Software written in Python language require Python with main version
723 %pyrequires_eq() Requires:      %1
724
725 # Hardlink binary identical .pyc and .pyo files
726 # (idea by glen <at> pld-linux <dot> org)
727 %__spec_install_post_py_hardlink {\
728 %{!?no_install_post_py_hardlink: __spec_install_post_py_hardlink() { \
729 [ ! -d "$RPM_BUILD_ROOT" ] || find "$RPM_BUILD_ROOT" -name '*.pyc' | while read a; do \
730         b="${a%.pyc}.pyo"; \
731         if cmp -s "$a" "$b"; then \
732                 ln -f "$a" "$b"; \
733         fi; \
734 done \
735 }; __spec_install_post_py_hardlink } }
736
737 # remove python sources, so that check-files won't complain
738 # (idea by glen <at> pld-linux <dot> org)
739 %py_postclean() \
740 for d in %{py_sitescriptdir} %{py_sitedir} %*; do \
741  [ ! -d "$RPM_BUILD_ROOT$d" ] || find "$RPM_BUILD_ROOT$d" -name '*.py' -print0 | xargs -0r -l512 rm;\
742 done \
743 %{nil}
744
745 # depmod macro
746 %depmod() { \
747 umask 022; \
748 if [ -e /boot/System.map-%1 ]; then \
749         /sbin/depmod -a -F /boot/System.map-%1 %1; \
750 else \
751         if [ -e /boot/System.map ]; then \
752                 /sbin/depmod -a -F /boot/System.map %1; \
753         else \
754                 /sbin/depmod -a %1; \
755         fi \
756 fi; \
757 }
758
759 # XMMS specific macros
760 %xmms_prefix                    %{expand:%%global xmms_prefix %(xmms-config --prefix 2>/dev/null || echo ERROR)}%xmms_prefix
761 %xmms_exec_prefix               %{expand:%%global xmms_exec_prefix %(xmms-config --exec-prefix 2>/dev/null || echo ERROR)}%xmms_exec_prefix
762 %xmms_version                   %{expand:%%global xmms_version %(xmms-config --version 2>/dev/null || echo ERROR)}%xmms_version
763 %xmms_datadir                   %{expand:%%global xmms_datadir %(xmms-config --data-dir 2>/dev/null || echo ERROR)}%xmms_datadir
764 %xmms_plugindir                 %{expand:%%global xmms_plugindir %(xmms-config --plugin-dir 2>/dev/null || echo ERROR)}%xmms_plugindir
765 %xmms_visualization_plugindir   %{expand:%%global xmms_visualization_plugindir %(xmms-config --visualization-plugin-dir 2>/dev/null || echo ERROR)}%xmms_visualization_plugindir
766 %xmms_input_plugindir           %{expand:%%global xmms_input_plugindir %(xmms-config --input-plugin-dir 2>/dev/null || echo ERROR)}%xmms_input_plugindir
767 %xmms_output_plugindir          %{expand:%%global xmms_output_plugindir %(xmms-config --output-plugin-dir 2>/dev/null || echo ERROR)}%xmms_output_plugindir
768 %xmms_effect_plugindir          %{expand:%%global xmms_effect_plugindir %(xmms-config --effect-plugin-dir 2>/dev/null || echo ERROR)}%xmms_effect_plugindir
769 %xmms_general_plugindir         %{expand:%%global xmms_general_plugindir %(xmms-config --general-plugin-dir 2>/dev/null || echo ERROR)}%xmms_general_plugindir
770
771 %_target_base_arch      %{expand:%%global _target_base_arch %(echo %{_target_cpu} | sed 's/i.86/i386/;s/athlon/i386/;s/pentium./i386/;s/amd64/x86_64/;s/ia32e/x86_64/')}%_target_base_arch
772
773 # user/group checking macros
774 #
775 # Usage:
776 #       %userremove myuser
777 #
778 %userremove     /usr/lib/rpm/user_group.sh user del
779 %groupremove    /usr/lib/rpm/user_group.sh group del
780 #
781 # Usage:
782 #       if %usertestrm myuser; then
783 #               /usr/sbin/userdel -r myuser
784 # Note:
785 #       use these macros only if you need to call userdel/groupdel with
786 #       a non-standard option or take an extra action; otherwise use the
787 #       %userremove/%groupremove macros
788 #
789 %usertestrm     /usr/lib/rpm/user_group.sh user testrm
790 %grouptestrm    /usr/lib/rpm/user_group.sh group testrm
791 # user group membership management macros
792 #
793 # Usage:
794 #       %addusertogroup myuser agroup
795 #
796 %addusertogroup /usr/lib/rpm/user_group.sh user addtogroup
797
798 # banner support (useful in {pre,post}{,un} and triggers)
799 #
800 # Usage:
801 #       %banner name [-a] [-e] [-n] [-tn] <<EOF
802 # the banner text, the banner text
803 # the banner text, and following line
804 #EOF
805 # You can use any form of here-document, <<'EOF' <<-EOT will do.
806 # NOTE: if your use "<<-EOF", then You can actually indent inside here-document.
807 #
808 # -a   - append to the banner
809 # -e   - send to stderr instead of stdout
810 # -n   - no show banner (overrides -t)
811 # -t   - show only, if RPM_SCRIPTVERBOSITY >= n; default n=5
812 #
813 # Tests:
814 # (rpm -E '%banner -e banner <<EOF'; echo -e 'hi\nEOF') > m; sh -x m
815 # rpm -E 'date | %banner -e banner' > m; sh -x m
816 #
817 %banner(aent:) ( \
818 RPM_SCRIPTVERBOSITY=5 \
819 [ -r /etc/sysconfig/rpm ] && . /etc/sysconfig/rpm \
820 if [ -x /usr/bin/banner.sh ]; then \
821         CMD="/usr/bin/banner.sh %{-e:--stderr} %{!-n:$([ $RPM_SCRIPTVERBOSITY -ge %{-t:%{-t*}}%{!-t:5} ] && echo -s)} %{!-a:-m}%{-a:-M} %1" \
822 else \
823         CMD="cat%{-e: >&2}" \
824 fi \
825 eval $CMD %{?2:%2}%{?3: %3}) \
826 %{nil}
827
828 # useradd/groupadd macros
829 # Author: Elan Ruusamäe <glen@pld-linux.org>
830 #
831 # Usage:
832 #   %useradd [-P package] [-u uid] [-d home_dir] [-s shell] [-c comment]
833 #   [-g initial_group] [-G group[,...]] login
834 #
835 #  -u uid. REQUIRED
836 #  -g gid/group. REQUIRED
837 #  -s defaults to /bin/false
838 #  -d defaults to /usr/share/empty
839 #  -c No default
840 #  -r is accepted but ignored (it's always set)
841 #  -k skeleton dir. defaults to /usr/share/empty
842 # rpm specific flags
843 #  -P package name. defaults to %{name}
844 #
845 %useradd(c:d:e:f:g:G:Mmk:op:s:u:rP:) \
846 %{!-u:%{error:useradd: Required argument -u missing}} \
847 %{!-g:%{error:useradd: Required argument -g missing}} \
848 %{!?1:%{error:useradd: Required parameter login missing}} \
849 if [ -n "`/bin/id -u %{expand:%{%{#}}} 2>/dev/null`" ]; then \
850         if [ "`/bin/id -u %{expand:%{%{#}}}`" != "%{-u*}" ]; then \
851                 echo "Error: user %{expand:%{%{#}}} doesn't have uid=%{-u*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
852                 exit 1 \
853         fi \
854 else \
855         echo "Adding user %{expand:%{%{#}}} UID=%{-u*}." \
856         /usr/sbin/useradd \\\
857                 %{-m:-m -k %{-k*}%{!-k:/usr/share/empty}} \\\
858                 -u %{-u*} \\\
859                 -r \\\
860                 -d %{-d*}%{!-d:/usr/share/empty} \\\
861                 -s %{-s*}%{!-s:/bin/false} \\\
862                 %{-c:-c "%(set -- %{-c*} %{*}; echo $1)"}\\\
863                 -g %{-g*} \\\
864                 %{-M} \\\
865                 %{-G:-G %{-G*}} \\\
866                 %{expand:%{%{#}}} 1>&2 || exit $? \
867         [ ! -x /usr/sbin/nscd ] || /usr/sbin/nscd -i passwd || : \
868 fi;
869
870 # Usage:
871 #   %groupadd [-P package] [-g gid] group
872 #
873 # -g gid. REQUIRED
874 #
875 # Sample:
876 #   %groupadd -P %{name}-base -g %{gid} %{name}
877
878 %groupadd(g:P:rfo)      \
879 %{!-g:%{error:groupadd: Required argument -g missing}} \
880 %{!?1:%{error:groupadd: Required parameter group missing}} \
881 if [ -n "`/usr/bin/getgid %{1}`" ]; then \
882         if [ "`/usr/bin/getgid %{1}`" != "%{-g*}" ]; then \
883                 echo "Error: group %{1} doesn't have gid=%{-g*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
884                 exit 1 \
885         fi \
886 else \
887         echo "Adding group %{1} GID=%{-g*}." \
888         /usr/sbin/groupadd -g %{-g*} -r %{1} 1>&2 || exit $? \
889         [ ! -x /usr/sbin/nscd ] || /usr/sbin/nscd -i group || : \
890 fi;
891
892 # webapp macros
893 # Author: Elan Ruusamäe <glen@pld-linux.org>
894 #
895 # The config is installed/removed inside trigger, this means that you can any
896 # time install apache1/apache/lighttpd package and the configuration file is
897 # updated. if you don't need the config for various reason for specific
898 # webserver, just remove the symlink from config directory using webapp
899 # program. the trigger will not recreate the symlink on upgrades. In other
900 # words the config is linked to webserver config directory on first install of
901 # PACKAGE or WEBSERVER.
902 #
903 # Add package's webserver config to webserver webapps dir.
904 # Usage:
905 #   %webapp_register WEBSERVER WEBAPP
906 #
907 %webapp_register() \
908 %{?debug:set -x; echo "webapp_register: %{name}-%{version}-%{release} 1:[$1]; 2:[$2]"} \
909 if [ "$1" = "1" ] && [ "$2" = "1" ]; then\
910         /usr/sbin/webapp register %1 %2\
911 fi\
912 # reload webserver if the config symlink is there and skip reload if webserver is upgraded\
913 if [ -L /etc/%1/webapps.d/%(echo "%2" | tr '/' '-').conf ] && [ "$2" -lt "2" ]; then\
914         %{expand:%service -q %%1 reload}\
915 fi\
916 %{nil}
917
918 # Remove package's config from webserver webapps dir.
919 # Usage:
920 #   %webapp_register [-f] WEBSERVER WEBAPP
921 %webapp_unregister(f) \
922 %{?debug:set -x; echo "webapp_unregister: %{name}-%{version}-%{release}: 1:[$1]; 2:[$2]"} \
923 # remove link if either of the packages are gone \
924 if [ -n "%{-f:1}" ] || [ "$1" = "0" ] || [ "$2" = "0" ] && [ -L /etc/%1/webapps.d/%(echo "%2" | tr '/' '-').conf ]; then \
925         /usr/sbin/webapp unregister %1 %2\
926         %{expand:%service -q %%1 reload}\
927 fi \
928 %{nil}
929
930 # service macro.
931 # Author: Elan Ruusamäe <glen@pld-linux.org>
932 #
933 # calls usual service restart on package %post, but skips the restart if
934 # administrator has disabled automatic service restarts in either global
935 # /etc/sysconfig/rpm or per service /etc/sysconfig/SERVICE file.
936 #
937 # Usage:
938 #   %service [-q] [-n] SERVICE ACTION ["SERVICE NICE DESCRIPTION"]
939 #
940 #  -q be silent when service isn't started (for scriplets restaring other package's services)
941 #  -n NOOP mode, do not actually restart service
942 #
943 # Requirements:
944 # BuildRequires:        rpmbuild(macros) >= 1.268
945 # Requires:     rc-scripts
946 # -n option:
947 # BuildRequires:        rpmbuild(macros) >= 1.450
948 %service(qn) {{%(export noop=%{-n:1} quiet=%{-q:1}; /usr/lib/rpm/service_generator.sh %{*}) };}
949
950
951 # Java macros. based on jpackage macros.java
952 #
953 # Root directory where all Java VMs/SDK/JREs are installed.
954 %_jvmdir                %{_libdir}/jvm
955
956 # Root directory where all Java VMs/SDK/JREs expose their jars
957 %_jvmjardir             %{_libdir}/jvm-exports
958
959 # Root directory for all Java VM/SDK/JRE's private things.
960 %_jvmprivdir    %{_libdir}/jvm-private
961
962 # Root directory for all architecture dependent parts of Java VM/SDK/JRE's
963 %_jvmlibdir             %{_libdir}/jvm
964
965 # Root directory for all architecture independent parts of Java VM/SDK/JRE's
966 %_jvmdatadir    %{_datadir}/jvm
967
968 # Root directory for all configurations parts of Java VM/SDK/JRE's
969 %_jvmsysconfdir %{_sysconfdir}/jvm
970
971 # Root directory for all common architecture dependent parts of Java VM/SDK/JRE's
972 %_jvmcommonlibdir       %{_libdir}/jvm-common
973
974 # Root directory for all common architecture independent parts of Java VM/SDK/JRE's
975 %_jvmcommondatadir      %{_datadir}/jvm-common
976
977 # Root directory for all common configurations parts of Java VM/SDK/JRE's
978 %_jvmcommonsysconfdir   %{_sysconfdir}/jvm-common
979
980 # Directory where arch-specific (JNI) version-independent jars are installed.
981 %_jnidir                %{_libdir}/java
982
983 %java_home              %{expand:%%global java_home %([ -f %{_javadir}-utils/java-functions ] || { echo ERROR; exit 0; }; unset JAVA_HOME; . %{_javadir}-utils/java-functions; set_jvm; echo ${JAVA_HOME:-ERROR})}%java_home
984
985 %ant                    JAVA_HOME=%{java_home} ant
986 %jar                    %{java_home}/bin/jar
987 %java                   %{expand:%%global java %([ -f %{_javadir}-utils/java-functions ] || { echo ERROR; exit 0; }; unset JAVACMD; . %{_javadir}-utils/java-functions; set_javacmd; echo $JAVACMD)}%java
988 %javac                  %{java_home}/bin/javac
989 %javadoc                %{java_home}/bin/javadoc
990
991 %add_jvm_extension      JAVA_LIBDIR=%{buildroot}/%{_javadir}    %{_bindir}/jvmjar -l
992
993 %jpackage_script() \
994 install -d $RPM_BUILD_ROOT%{_bindir}\
995 cat > $RPM_BUILD_ROOT%{_bindir}/%5 << 'EOF' \
996 #!/bin/sh\
997 #\
998 # %{name} script\
999 # JPackage Project <http://www.jpackage.org/>\
1000 \
1001 # Source functions library\
1002 . %{_javadir}-utils/java-functions\
1003 \
1004 # Source system prefs\
1005 if [ -f %{_sysconfdir}/java/%{name}.conf ]; then\
1006     . %{_sysconfdir}/java/%{name}.conf\
1007 fi\
1008 \
1009 # Source user prefs\
1010 if [ -f $HOME/.%{name}rc ]; then\
1011     . $HOME/.%{name}rc\
1012 fi\
1013 \
1014 # Configuration\
1015 MAIN_CLASS=%1\
1016 BASE_FLAGS=%2\
1017 BASE_OPTIONS=%3\
1018 BASE_JARS="%(echo %4 | tr ':' ' ')"\
1019 \
1020 # Set parameters\
1021 set_jvm\
1022 set_classpath $BASE_JARS\
1023 set_flags $BASE_FLAGS\
1024 set_options $BASE_OPTIONS\
1025 \
1026 # Let's start\
1027 run "$@"\
1028 EOF
1029
1030 # jpackage 1.7
1031 # Directory for maven depmaps
1032 #
1033 %_mavendepmapdir /etc/maven
1034 %_mavendepmapfragdir /etc/maven/fragments
1035
1036 #
1037 # add_to_depmap adds an entry to the depmap. The arguments are:
1038 #
1039 # %1 the original groupid
1040 # %2 the original artifact id
1041 # %3 the version
1042 # %4 the new groupid
1043 # %5 the new artifactid
1044 #
1045
1046 %add_to_maven_depmap() \
1047 install -dm 755 $RPM_BUILD_ROOT/%{_mavendepmapfragdir}\
1048 cat >>$RPM_BUILD_ROOT/%{_mavendepmapfragdir}/%{name}<< EOF\
1049 <dependency>\
1050     <maven>\
1051         <groupId>%1</groupId>\
1052         <artifactId>%2</artifactId>\
1053         <version>%3</version>\
1054     </maven>\
1055     <jpp>\
1056         <groupId>%4</groupId>\
1057         <artifactId>%5</artifactId>\
1058         <version>%3</version>\
1059     </jpp>\
1060 </dependency>\
1061 \
1062 EOF\
1063 %{nil}
1064
1065 #==============================================================================
1066 #
1067 # update_maven_depmap updates the main maven depmap
1068 #
1069 %update_maven_depmap() \
1070 echo -e "<dependencies>\\n" > %{_mavendepmapdir}/maven2-depmap.xml\
1071 if [ -d %{_mavendepmapfragdir} ] && [ -n "`find %{_mavendepmapfragdir} -type f`" ]; then\
1072 cat %{_mavendepmapfragdir}/* >> %{_mavendepmapdir}/maven2-depmap.xml\
1073 fi\
1074 echo -e "</dependencies>\\n" >> %{_mavendepmapdir}/maven2-depmap.xml
1075
1076
1077 # PEAR install macros
1078 # Author: Elan Ruusamäe <glen@pld-linux.org>
1079 #
1080 # Usage:
1081 #       %%pear_package_setup [-a #] [-n FMT]
1082 #
1083 # -a #   - also unpack SOURCE#. for PEAR bootstrapping
1084 # -n FMT - create builddir with FMT, instead of default %%{_pearname}-%%{version}
1085 # -z     - unpack pear package and let pear use package.xml (not tarball) for install. for PEAR bootstrapping
1086 #
1087 # unpack PEAR package to %%{_builddir}/FMT. package is extracted with already
1088 # destination hierarchy. you should copy the tree to buildroot after
1089 # patching/reorganizing with %%pear_package_install.
1090 #
1091 # additionally BUILDROOT is stripped from files and files are converted to UNIX
1092 # line endings.
1093 #
1094 # the pear install process output is recorded to install.log, you should put it
1095 # to %%doc for later debug or just for information.
1096 #
1097 # additionally additional-packages.txt is produced if it was detected that the
1098 # package has optional dependencies. the file format is suitable of displaying
1099 # in %%post of a package. you should put this file to %%doc. noautocompressdoc is
1100 # automatically added for this file.
1101
1102
1103 # records install.log and transforms PEAR names to PLD Linux rpm package names.
1104 %__pear_install_log \
1105 tee install.log \
1106 # make post message of optional packages \
1107 grep 'can optionally use' install.log | sed -e 's,package "pear/,package "php-pear-,g;s,^pear/,php-pear-,' > optional-packages.txt \
1108 if [ -s optional-packages.txt ]; then \
1109         awk -F'"' '/use package/{print $2}' optional-packages.txt | sed -e "s,_,/,g;s,php-pear-, 'pear(,;s,$,.*)'," | tr -d '\\\n' > _noautoreq \
1110 else \
1111         rm -f optional-packages.txt \
1112 fi \
1113 %{nil}
1114
1115 # command invoking pear cli
1116 %__pear /usr/bin/pear
1117
1118 %pear_install(a:n:zD) \
1119 %__pear \\\
1120         -c pearrc \\\
1121         -d doc_dir=/docs \\\
1122         -d php_dir=%{php_pear_dir} \\\
1123         -d bin_dir=%{_bindir} \\\
1124         -d data_dir=%{php_pear_dir}/data \\\
1125         -d test_dir=%{php_pear_dir}/tests \\\
1126         install \\\
1127         --packagingroot=%{builddir} \\\
1128         --offline \\\
1129         --nodeps \\\
1130         %{-f:--force} \\\
1131         %{!-z:%{S:%{-a*}%{!-a:0}}}%{-z:$_P} > .install.log || { c=$?; cat .install.log; exit $c; }; \
1132 %{nil}
1133
1134 # The main macro.
1135 # using this macro will append optional-packages.txt to the nocompressdoc list
1136 # as it's displayed to user after package install. and adding additional gzip
1137 # dep is just waste ;)
1138 %pear_package_setup(a:n:zD) \
1139 %define srcdir %{-n*}%{!-n:%{_pearname}-%{version}} \
1140 %define builddir %{_builddir}/%{srcdir} \
1141 %setup -q -c -T %{-D:-D} -n %{srcdir} \
1142 %{-z:tar zxf %{S:0}; %{-a:tar zxf %{S:%{-a*}}}} \
1143 %{-z:_P=package2.xml; [ -f $_P ] || _P=package.xml; _N=%{srcdir}; mv $_P $_N; cd $_N} \
1144 %pear_install \
1145 %{-z:cd ..} \
1146 cat %{-z:$_N/}.install.log | %__pear_install_log \
1147 \
1148 # undos sources \
1149 find -type f -print0 | xargs -0 sed -i -e 's,\\r$,,' \
1150 %{!?_noautocompressdoc:%global _noautocompressdoc %{nil}}%{expand:%%global _noautocompressdoc %{_noautocompressdoc} optional-packages.txt} \
1151 %{!?_noautoprov:%global _noautoprov %{nil}}%{expand:%%global _noautoprov %{_noautoprov} 'pear(tests/.*)'} \
1152 %{nil}
1153
1154 # Copies exctracted PEAR package structure and PEAR registry to buildroot.
1155 # Author: Elan Ruusamäe <glen@pld-linux.org>
1156 %pear_package_install() \
1157 cp -a ./%{php_pear_dir}/{.registry,*} $RPM_BUILD_ROOT%{php_pear_dir} \
1158 find $RPM_BUILD_ROOT%{php_pear_dir} '(' -name '*~' -o -name '*.orig' ')' | xargs -r rm -v \
1159 # help the developer out a little: \
1160 if [ -f _noautoreq ]; then \
1161         echo "AutoReqdep detected:" \
1162         echo "_noautoreq $(cat _noautoreq)" \
1163 fi \
1164 %{nil}
1165
1166
1167 # Register OpenLDAP schema.
1168 # Author: Elan Ruusamäe <glen@pld-linux.org>
1169 #
1170 # Usage:
1171 #   %%openldap_schema_register [-d core,nis] %{schemadir}/horde.schema
1172 #
1173 #  -d specify dependant schemas, separated by comma
1174 #
1175 %openldap_schema_register(d:) \
1176 for schema in %*; do \
1177         if ! grep -q "$schema" /etc/openldap/slapd.conf; then \
1178                 %{__sed} -i -e " \
1179                         /^include.*local.schema/{ \
1180                                 iinclude\\t     $schema\
1181                         } \
1182                 " /etc/openldap/slapd.conf \
1183         fi \
1184 done \
1185 # enable dependant schemas \
1186 if [ "%{-d*}" ]; then \
1187         %{__sed} -i -e ' \
1188         /^#include.*\\(%(echo '%{-d*}' | %{__sed} -e 's/,/\\\\|/g')\\)\\.schema/{ \
1189                 s/^#// \
1190         }' /etc/openldap/slapd.conf \
1191 fi \
1192 %{nil}
1193
1194 # Unregister OpenLDAP schema.
1195 # Author: Elan Ruusamäe <glen@pld-linux.org>
1196 #
1197 # Usage:
1198 #   %%openldap_schema_unregister %{schemadir}/horde.schema
1199 #
1200 %openldap_schema_unregister() \
1201 for schema in %*; do \
1202         if grep -q "$schema" /etc/openldap/slapd.conf; then \
1203                 %{__sed} -i -e " \
1204                 /^include.*$(echo "$schema" | %{__sed} -e 's,/,\\\\/,g')/d \
1205                 # for symmetry it would be nice if we disable enabled schemas in post, \
1206                 # but we really can not do that, it would break something else. \
1207                 " /etc/openldap/slapd.conf \
1208         fi \
1209 done \
1210 %{nil}
1211
1212 %env_update [ ! -x /sbin/env-update ] || /sbin/env-update -u || :
1213
1214
1215 # Build modules for kernels 2.6
1216 # Author: Przemyslaw Iskra <sparky@pld-linux.org>
1217 #
1218 # Usage:
1219 #       %build_kernel_modules -m <modules> -C <directory>
1220 #
1221 #  remember that proper Makefile is still required
1222 # Options:
1223 #  -m <modules> (required) -- comma-separated list of modules to save,
1224 #               without .ko extension, may be placed in subdirectory
1225 #  -C <directory> -- change to <directory> before doing anything
1226 #  -p <arg>, -P <arg> -- arguments passeed to make scripts
1227 #  -c -- do not execute make clean
1228 #  <additional arguments> -- all additional arguments will be passed to
1229 #               make modules
1230 #
1231 # Additional patching supported via here document. Try:
1232 #       %build_kernel_modules -m module <<'EOF'
1233 #       your patch script here
1234 #       EOF
1235 # Don't use it unless patching depends on config options.
1236
1237 # Developer note: don't touch it unless you know how to handle '\'.
1238 # - \ in script expands to nothing
1239 # - \\\ in script expands to \
1240 # - \\\ inside definition expands to nothing
1241 # - \\\\\\\ inside definition expands to \
1242 # - in last line \ has to touch arguments so arguments passing
1243 #   in new lines (using \) will be supported
1244
1245 %build_kernel_modules(p:P:m:C:c)                                                                        \
1246 %{!?-m:%{error:%{0}: Required module name/list missing} exit 1}         \
1247                                                                                                                                         \
1248 %define Opts                                                                                                            \\\\\\\
1249 %if "%{_target_base_arch}" != "%{_arch}"                                                        \\\
1250         %if "%{_arch}" == "x86_64" && "%{_target_base_arch}" == "i386"  \\\
1251         CC="%{kgcc}" ARCH=%{_target_base_arch}                                                  \\\
1252         %else                                                                                                                   \\\
1253         ARCH=%{_target_base_arch} CROSS_COMPILE=%{_target_cpu}-pld-linux- \\\
1254         %endif                                                                                                                  \\\
1255 %else                                                                                                                           \\\
1256         CC="%{kgcc}"                                                                                                    \\\
1257 %endif                                                                                                                          \
1258 %define MakeOpts HOSTCC="%{kgcc}" SYSSRC=%{_kernelsrcdir} SYSOUT=$PWD/o \\\\\\\
1259                 O=$PWD/o %{?with_verbose:V=1} %{Opts}                                           \
1260                                                                                                                                         \
1261 %{?-C:cd %{-C*}}                                                                                                        \
1262 compile() {                                                                                                                     \
1263         local L="<" PATCH_SH;                                                                                   \
1264         [[ '%{*}' != *$L$L* ]] || PATCH_SH="set -x -e;$(cat)"                   \
1265         set -e -x                                                                                                               \
1266         local cfgs='%{?with_dist_kernel:%{?with_smp: smp}%{?with_up: up}}%{!?with_dist_kernel: nondist}' \
1267                                                                                                                                         \
1268 for cfg in ${cfgs:-dist}; do                                        \
1269         [ -r "%{_kernelsrcdir}/config-$cfg" ] || exit 1                                 \
1270                                                                                                                                         \
1271         rm -rf o                                                                                                                \
1272         install -d o/include/linux                                                                              \
1273         ln -sf %{_kernelsrcdir}/config-$cfg o/.config                                   \
1274         ln -sf %{_kernelsrcdir}/Module.symvers-$cfg o/Module.symvers    \
1275         ln -sf %{_kernelsrcdir}/include/linux/autoconf-$cfg.h o/include/linux/autoconf.h \
1276                                                                                                                                         \
1277         set +x                                                                                                                  \
1278         [ -z "$PATCH_SH" ] || echo "$PATCH_SH" | %__spec_build_shell    \
1279         set -x                                                                                                                  \
1280                                                                                                                                         \
1281         %if %{with dist_kernel}                                                                                 \
1282                 %{__make} -j1 -C %{_kernelsrcdir} prepare scripts                       \\\
1283                         %{-p*} %{-P*}                                                                                   \\\
1284                         %{MakeOpts}                                                                                             \
1285         %else                                                                                                                   \
1286                 install -d o/include/config                                                                     \
1287                 touch o/include/config/MARKER                                                           \
1288                 ln -sf %{_kernelsrcdir}/scripts o/scripts                                       \
1289         %endif                                                                                                                  \
1290                                                                                                                                         \
1291         %{!?-c:%{__make} -C %{_kernelsrcdir} clean                                              \\\
1292                 RCS_FIND_IGNORE="-name '*.ko' -o"                                                       \\\
1293                 ${1+"$@"}                                                                                                       \\\
1294                 M=$PWD %{MakeOpts}}                                                                                     \
1295                                                                                                                                         \
1296         %{__make} -C %{_kernelsrcdir} modules                                                   \\\
1297                 ${1+"$@"}                                                                                                       \\\
1298                 M=$PWD %{MakeOpts}                                                                                      \
1299                                                                                                                                         \
1300         for MODULE in {%{-m*},}; do                                                                             \
1301                 [ -z "${MODULE}" ] || mv ${MODULE}{,-$cfg}.ko                           \
1302         done                                                                                                                    \
1303 done                                                                                                                            \
1304 %{?-C:cd -}                                                                                                                     \
1305 }                                                                                                                                       \
1306 compile %{*}\
1307 %{nil}
1308
1309
1310 # Install kernel modules built by %build_kernel_modules
1311 # Author: Przemyslaw Iskra <sparky@pld-linux.org>
1312 #
1313 # Usage:
1314 #       %install_kernel_modules -m <modules> -d <directory>
1315 #
1316 # Options:
1317 #  -m <modules> (required) -- comma-separated list of modules to install,
1318 #               without .ko extension, may be placed in subdirectory
1319 #  -d <directory> (required) -- in what subdirectory modules should be
1320 #               installed (eg. misc, kernel/drivers/net)
1321 #  -s <suffix> -- suffix to use when installing modules, useful when module
1322 #               with same name exists in kernel already
1323 #  -n <file> -- name of modprobe config file to use (without .conf extension)
1324 #               for defining aliases, only useful with -s
1325
1326 %install_kernel_modules(m:d:s:n:)                                                                       \
1327 %{!?-m:%{error:%{0}: Required module name (-m) missing}exit 1}          \
1328 %{!?-d:%{error:%{0}: Required module directory missing}exit 1}          \
1329 %{?-n:%{!?-s:%{error:%{0}: Modprobe .conf file requires module suffix}exit 1}} \
1330                                                                                                                                         \
1331 %define KernelD $RPM_BUILD_ROOT/lib/modules/%{_kernel_ver}                      \
1332 %define ModprobeD $RPM_BUILD_ROOT%{_sysconfdir}/modprobe.d/%{_kernel_ver} \
1333                                                                                                                                         \
1334 local cfgs='%{?with_dist_kernel:%{?with_smp: smp}%{?with_up: up}}%{!?with_dist_kernel: nondist}' \
1335                                                                                                                                         \
1336 for MODULE in {%{-m*},}; do                                                                                     \
1337         [ -n "${MODULE}" ] || continue                                                                  \
1338         for cfg in ${cfgs:-dist}; do                                    \
1339                 [ "$cfg" = smp ] && suf=smp || suf=                                                     \
1340                 MNAME=${MODULE##*/}                                                                                     \
1341                 install -D ${MODULE}-$cfg.ko                                                            \\\
1342                         %{KernelD}$suf/%{-d*}/${MNAME}%{-s:-%{-s*}}.ko                  \
1343                 %{?-s:install -d %{ModprobeD}$suf                                                       \
1344                         echo "alias ${MNAME} ${MNAME}-%{-s*}"                                   \\\
1345                         >> %{ModprobeD}$suf/%{-n*}.conf}                                                \
1346         done                                                                                                                    \
1347 done                                                                                                                            \
1348 %{nil}
1349
1350 # patchset macros
1351 # Author: Elan Ruusamäe <glen@pld-linux.org>
1352 #
1353 # Usage:
1354 #   %patchset_source -f <seq(1) format> <start> [<end>]
1355 #   %patchset_patch <start> [<end>]
1356 #
1357 # If <end> is omited, it is assumed to be <start>.
1358 #
1359 # For example in preamble:
1360 #  %patchset_source -f ftp://ftp.vim.org/pub/editors/vim/patches/7.0/7.0.%03g 33 44
1361 # and in %prep:
1362 #  %patchset_patch 33 44
1363
1364 # generate SourceX urls from range START STOP
1365 # Format can be SINGLE format char of %e, %f, %g, see seq(1)
1366 # The sources start from 10000
1367 %patchset_source(f:b:) %(
1368         base=%{-b*}%{!-b*:10000};
1369         start=$(expr $base + %1);
1370         end=$(expr $base + %{?2}%{!?2:%{1}});
1371         # we need to call seq twice as it doesn't allow two formats
1372         seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
1373         seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
1374         paste %{tmpdir}/__ps{1,2};
1375         rm -f %{tmpdir}/__ps{1,2};
1376 ) \
1377 %{nil}
1378
1379 # apply sources from %patchset_source
1380 # -p specify -pX for %patch line
1381 # -b base offset: defaults to 10000
1382 %patchset_patch(f:p:b:) %(
1383         base=%{-b*}%{!-b*:10000};
1384         start=$(expr $base + %1);
1385         end=$(expr $base + %{?2}%{!?2:%{1}});
1386         echo ": patchset_patch %1%{?2: to %2}";
1387         seq -f 'patch%g %{-p*:-p%{-p*}}' $start $end | sed -e s,^,%%,;
1388 ) \
1389 %{nil}
1390
1391 # browser plugins v2
1392 # Author: Elan Ruusamäe <glen@pld-linux.org>
1393 #
1394 # Usage:
1395 #       %browser_plugins_add_browser <name> -p <plugindir>
1396 #
1397 #  <name> (required) -- name of the browser. usually %{name}.
1398 #  -p <plugindir> (required) -- in what directory browser searches for its plugins.
1399 #  -b -- default blacklists
1400 #  -a <arch> override arch
1401 #
1402 # Example:
1403 #   %browser_plugins_add_browser %{name} -p %{_firefoxdir}/plugins
1404
1405 %_browserpluginsconfdir         /etc/browser-plugins
1406 %_browserpluginsdir                     %{_libdir}/browser-plugins
1407 %update_browser_plugins         /usr/sbin/update-browser-plugins || :
1408
1409 %browser_plugins_add_browser(p:b:a:) \
1410         browser=%1.%{!-a:%{_target_base_arch}}%{-a*} \
1411         install -d $RPM_BUILD_ROOT%{_browserpluginsconfdir}/{blacklist,browsers}.d \
1412         ln -s %{-p*} $RPM_BUILD_ROOT%{_browserpluginsconfdir}/browsers.d/$browser \
1413         blacklist_file=$RPM_BUILD_ROOT%{_browserpluginsconfdir}/blacklist.d/$browser.blacklist \
1414         echo '# This file format is shell globs at base dir of plugindir' > $blacklist_file \
1415         %{-b:cat >> $blacklist_file %{-b*}} \
1416 %{nil}
1417
1418 # Helper for LUA.
1419 # split string separated by space into quoted list
1420 #
1421 # Author: Elan Ruusamäe <glen@pld-linux.org>
1422 #
1423 # %__lua_split /bin/sh /bin/pdksh -> "/bin/sh", "/bin/pdksh"
1424 %__lua_split() %(echo "%*" | awk '{for (i=1;i<=NF;i++) printf("\\"%%s\\"%%s", $i, i == NF ? "" : ", ")}')
1425
1426 # adjust /etc/shells by adding and removing shells from there
1427 # Author: Elan Ruusamäe <glen@pld-linux.org>
1428 #
1429 # Usage:
1430 #   %post       -p <lua>
1431 #   %lua_add_etc_shells /bin/sh /bin/pdksh
1432 #
1433 #   %preun      -p <lua>
1434 #   if arg[2] == 0 then
1435 #       %lua_remove_etc_shells /bin/bash /bin/rbash
1436 #   end
1437 #
1438 # Requirements:
1439 # BuildRequires:        rpmbuild(macros) >= 1.462
1440 #
1441
1442 %lua_add_etc_shells() \
1443 t = {}\
1444 f = io.open("/etc/shells", "r")\
1445 if f then\
1446         for l in f:lines() do t[l]=l; end\
1447         f:close()\
1448 end\
1449 for _, s in ipairs({%{expand:%%__lua_split %*}}) do\
1450         if not t[s] then\
1451                 print("Adding "..s.." to /etc/shells")\
1452                 f = io.open("/etc/shells", "a"); f:write(s.."\\n"); f:close()\
1453         end\
1454 end\
1455 %{nil}
1456
1457 %lua_remove_etc_shells() \
1458 t = {}\
1459 f = io.open("/etc/shells", "r")\
1460 if f then\
1461         for l in f:lines() do t[l]=l; end\
1462         f:close()\
1463 end\
1464 for _, l in pairs({%{expand:%%__lua_split %*}}) do\
1465         print("Removing "..l.." from /etc/shells")\
1466         t[l] = nil\
1467 end\
1468 s=""\
1469 for _, l in pairs(t) do\
1470         s=s..l.."\\n"\
1471 end\
1472 io.open("/etc/shells", "w"):write(s)\
1473 %{nil}
1474
1475 # Backwards compat. Use of %lua_ prefixed macros is preferred as these are cleaner to read.
1476 #
1477 # Author: Elan Ruusamäe <glen@pld-linux.org>
1478 #
1479 # Usage:
1480 #   %post       -p %add_etc_shells -p /bin/sh /bin/pdksh
1481 #   %preun      -p %remove_etc_shells -p /bin/sh /bin/pdksh
1482 #
1483 #  -p (optional) -- specifies that result is embeded %post script (prepends <lua> as first line)
1484 #
1485 # Requirements:
1486 # BuildRequires:        rpmbuild(macros) >= 1.429
1487 #
1488 %add_etc_shells(p) %{-p:<lua>}\
1489 %{expand:%%lua_add_etc_shells %*}\
1490 %{nil}
1491
1492 %remove_etc_shells(p) %{-p:<lua>}\
1493 %{-p:if arg[2] == 0 then}\
1494 %{expand:%%lua_remove_etc_shells %*}\
1495 %{-p:end} \
1496 %{nil}
1497
1498 # vim:ts=4 sw=4 noet syn=spec
This page took 0.340747 seconds and 3 git commands to generate.