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