5 %x8664 x86_64 amd64 ia32e
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
15 %__rm /bin/rm --interactive=never
17 # Build system path macros.
19 %__autoconf autoconf %{?debug:-Wall}
20 %__automake automake -a -c -f --foreign
21 %__autopoint autopoint --force
24 if grep -qs 'AM_GNU_GETTEXT.*external' configure.{ac,in} ; then \
25 gettextize --copy --force --no-changelog; \
27 gettextize --copy --force --no-changelog --intl; \
29 if [ ! -f po/Makevars ]; then \
30 cp -f po/Makevars{.template,}; \
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
41 # Path to top of build area.
42 %_topdir %{expand:%%global _topdir %(test -d ../SPECS -a -d ../SOURCES && (cd ..; pwd) || echo $HOME/rpm)}%_topdir
44 # The number of cvs changelog entries kept when building package.
45 %_buildchangelogtruncate 20
47 %dependencytracking %{nil}
49 # Relations between package names that cause dependency loops
50 # with legacy packages that cannot be fixed. Relations are
53 # where package p has a Requires: on something that package q Provides:
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}
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")
63 #-----------------------------------------------------------------
65 # (re)definition of %{rpm*flags} with %filterout_* support
67 # BuildRequires: rpmbuild(macros) >= 1.315
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
74 # Regular expressions are supported, but to avoid some character be treated
75 # as regular expression it must be escaped twice.
78 for (i = 1; i in I; i++) { A=0; \
80 if (I[i] ~ "^" F[f] "$") A=1; \
82 if (!A) printf(I[i] FS); \
85 %rpmcflags %(awk 'BEGIN {
86 split("%{?debug:%debugcflags}%{!?debug:%optflags}%{?debuginfocflags}",I);
87 split("%{?filterout} %{?filterout_c} %{?filterout_ld}",F);
91 %rpmcxxflags %(awk 'BEGIN {
92 split("%{?debug:%debugcflags}%{!?debug:%optflags}%{?debuginfocflags}",I);
93 split("%{?filterout} %{?filterout_cxx} %{?filterout_ld}",F);
97 %rpmldflags %(awk 'BEGIN {
98 split("%{?optldflags}",I);
99 split("%{?filterout_ld}",F)
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);
117 #-----------------------------------------------------------------
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} \
147 # override __cmake to add -j4 in your ~/.rpmmacros for parallel make
148 %__cmake /usr/bin/cmake
152 CFLAGS="%{rpmcflags}" \
153 CXXFLAGS="%{rpmcxxflags}" \
157 # override __scons to add -j4 in your ~/.rpmmacros for parallel make
158 %__scons /usr/bin/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}"} \
173 # override __waf to add -j4 in your ~/.rpmmacros for parallel make
179 CFLAGS="%{rpmcflags}" \
180 CXXFLAGS="%{rpmcxxflags}" \
184 #----------------------------------------------------------------
186 %configure_cache_file %{buildroot}.configure.cache
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}} \
217 # overload to insert debuginfo package
219 %if 0%{?_enable_debug_packages}\
225 # Location of autoconf macros
226 %_aclocaldir %{expand:%%global _aclocaldir %(aclocal --print-ac-dir || echo ERROR)}%_aclocaldir
228 # Location of omf files
229 %_omf_dest_dir %{expand:%%global _omf_dest_dir %(scrollkeeper-config --omfdir || echo ERROR)}%_omf_dest_dir
231 # Location of pkgconfig files
232 %_pkgconfigdir /usr/%{_lib}/pkgconfig
233 # noarch pkgconfig files
234 %_npkgconfigdir /usr/share/pkgconfig
236 # Location of desktop files
237 %_desktopdir /usr/share/applications
238 %_applnkdir ERROR:_applnkdir_is_obsolete_use_desktopdir_instead
240 # Location of pixmaps for applnk/desktop files
241 %_pixmapsdir /usr/share/pixmaps
243 # Location of themable icons for applnk/desktop files
244 %_iconsdir /usr/share/icons
246 # Location of fonts directories
247 %_fontsdir /usr/share/fonts
249 # Location of Gtk and associated libraries documentation
250 %_gtkdocdir %{_defaultdocdir}/gtk-doc/html
252 # Location of KDE documentation
253 %_kdedocdir %{_defaultdocdir}/kde/HTML
256 %__unsermake /usr/share/unsermake/unsermake
259 %date %(LC_ALL="C" date +"%a %b %d %Y")
261 # Example files, programs, scripts...
262 %_examplesdir /usr/src/examples
264 # Alternative kernel type/version
265 %_alt_kernel %{nil}%{?alt_kernel:-%{?alt_kernel}}
267 # The directory holding Linux kernel sources
268 %_kernelsrcdir /usr/src/linux%{_alt_kernel}
270 # If non-empty "debug" macro defined, add "dbg" suffix to release number
271 %_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}%{?debug:dbg}.%%{ARCH}.rpm
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')
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
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")
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
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)}; \\
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
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
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 \
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"' \
319 ; do echo $l; done >> %1 \
324 # minimum file size needed for compressed documents.
325 # just smaller files than this get larger when compressed.
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
332 #-----------------------------------------------------------------
333 # find and gzip all files in %{_mandir} and %{infodir}
335 # Requires: xargs, find
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 \
348 echo .so ${m##*/} > $a; \
349 echo >&2 "Converted ${a#$RPM_BUILD_ROOT} from symlink to man link: ${m##*/}"; \
351 find "$RPM_BUILD_ROOT$i" -type f -size +%{_min_compress_bytes}c -print | xargs -r %{__gzip} -9nf; \
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; \
360 }; __spec_install_post_compress_docs } }
362 #-----------------------------------------------------------------
363 # Strip executable binaries and shared object files
365 # Requires: find, awk, strip, cut, xargs
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
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; \
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; \
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; \
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; \
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; \
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; \
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; \
433 fi; }; __spec_install_post_strip } } }
435 #-----------------------------------------------------------------
436 # remove all RPATH from executable binaries and shared object files
438 # Requires: find, awk, cut, xargs, chrpath, uname
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
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}'`; \
451 if [ -n "$objs" ]; then \
452 printf "Remove RPATH from %d executable binaries and shared object files.\n" $(echo "$objs" | wc -l); \
454 while read file; do \
457 for dir in $(chrpath -l "$file" | awk '/RPATH=/ { gsub(/.*RPATH=/,""); gsub(/:/," "); print $0 }'); do \
458 # translate $ORIGIN to real path, so that normalize path \
459 # would work with readlink and secondly we don't need to \
460 # relocate the binaries in rpm based distro \
461 local f=${file#$RPM_BUILD_ROOT}; \
462 local origin=${f%/*}; \
463 dir=$(echo $dir | sed -e "s,\$ORIGIN,$origin,g"); \
464 dir=$(readlink -m "$dir"); \
466 /home/* | /tmp/* | /usr/lib | /usr/lib64 | /lib | /lib64 | /usr/local/lib | /usr/local/lib64 | /usr/X11R6/lib | /usr/X11R6/lib64 ) \
467 echo "remove-rpath: $dir in $file"; \
470 if [ "$rpath" = "" ] ; then rpath="$dir" ; \
471 else rpath="$rpath:$dir" ; fi ; \
475 if [ "$rpath" = "" ] ; then chrpath -d "$file" > /dev/null ; \
476 else chrpath -r "$rpath" "$file" > /dev/null ; fi ; \
479 fi; }; __spec_install_post_chrpath } } }
481 #-----------------------------------------------------------------
482 # Find and gzip all kernel modules
486 #%no_install_post_compress_modules 1
487 %__spec_install_post_compress_modules { \
488 %{!?no_install_post_compress_modules: __spec_install_post_compress_modules() { \
489 if [ -d $RPM_BUILD_ROOT/lib/modules ]; then \
490 q=$(find $RPM_BUILD_ROOT/lib/modules -name '*o' -type f -print); \
492 printf "Compress %d kernel modules..." $(echo "$q" | wc -l); \
493 echo "$q" | xargs -r %{__gzip} -9nf; \
495 find $RPM_BUILD_ROOT/lib/modules -name '*o' -type l -printf "%p %l\n" | \
496 while read a b; do ln -sf $b.gz $a.gz; rm -f $a; done; \
499 }; __spec_install_post_compress_modules } }
501 # Remove common Perl files we don't package
502 %__spec_install_post_perl_clean {\
503 %{!?no_install_post_perl_clean: \
504 %{?pdir:rm -f $RPM_BUILD_ROOT{%{perl_archlib}/perllocal.pod,%{perl_vendorarch}/auto/%{pdir}%{?pnam:/%(echo %{pnam} | tr - /)}/.packlist}} \
507 #-----------------------------------------------------------------
508 # Update GConf2 schemas
512 %gconf_schema_install() \
514 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; \
517 %gconf_schema_uninstall() \
518 if [ $1 = 0 ]; then \
520 GCONF_CONFIG_SOURCE="xml:readwrite:/etc/gconf/gconf.xml.defaults" /usr/bin/gconftool-2 --makefile-uninstall-rule /etc/gconf/schemas/%{?1} > /dev/null \
524 #-----------------------------------------------------------------
525 # Update desktop MIME database
526 # requires: desktop-file-utils
527 %update_desktop_database() {{ \
529 /usr/bin/update-desktop-database -q; \
532 %update_desktop_database_post %update_desktop_database
534 %update_desktop_database_postun() {{ \
535 if [ "$1" = "0" ]; then \
536 %update_desktop_database; \
540 #-----------------------------------------------------------------
541 # Update shared MIME info database
542 # requires: shared-mime-info
544 %update_mime_database() {{ \
546 /usr/bin/update-mime-database %{_datadir}/mime; \
549 #-----------------------------------------------------------------
553 %update_icon_cache() {{ \
555 /usr/bin/gtk-update-icon-cache -qf %{_datadir}/icons/%1; \
558 #-----------------------------------------------------------------
559 # Update scrollkeeper database
560 # requires: scrollkeeper
562 %scrollkeeper_update_post() \
563 /usr/bin/scrollkeeper-update -q; \
566 %scrollkeeper_update_postun() \
567 if [ "$1" = "0" ]; then \
568 /usr/bin/scrollkeeper-update -q; \
572 #-----------------------------------------------------------------
573 # post %install sequence:
574 # - autodeps exceptions
575 # - compress all man and info pages,
576 # - strip all ELF executables and ELF shared objects if not %debug.
577 # - compress kernel modules if any
579 ###################################################################
580 # Requires/Provides automation
581 # exceptions system by Jacek Konieczny <jajcus@pld-linux.org>
583 %__noautoreqfiles %(sed -e s'/#.*//' /etc/rpm/noautoreqfiles)%{?_noautoreqfiles: %{_noautoreqfiles}}
584 %__noautoprovfiles %(sed -e s'/#.*//' /etc/rpm/noautoprovfiles)%{?_noautoprovfiles: %{_noautoprovfiles}}
585 %__noautoreq %(sed -e s'/#.*//' /etc/rpm/noautoreq)%{?_noautoreq: %{_noautoreq}}
586 %__noautoreqdep %(sed -e s'/#.*//' /etc/rpm/noautoreqdep)%{?_noautoreqdep: %{_noautoreqdep}}
587 %__noautoprov %(sed -e s'/#.*//' /etc/rpm/noautoprov)%{?_noautoprov: %{_noautoprov}}
589 #%_noautocompressdoc %{nil}
591 %_missing_doc_files_terminate_build 1%{nil}
592 %_unpackaged_files_terminate_build %{nil}
594 %___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;}'
595 %_emacs_lispdir %{expand:%%global _emacs_lispdir %(Z=$(emacs %___emacs_lispdir_helper); echo ${Z:-ERROR})}%_emacs_lispdir
596 %_xemacs_lispdir %{expand:%%global _xemacs_lispdir %(Z=$(xemacs %___emacs_lispdir_helper); echo ${Z:-ERROR})}%_xemacs_lispdir
598 %__php_provides %{nil}
599 %__php_requires %{nil}
600 %__perl_provides %{nil}
601 %__perl_requires %{nil}
602 %__mono_provides %{nil}
603 %__mono_requires %{nil}
605 # Perl specific macro definitions.
606 %perl_privlib %{expand:%%global perl_privlib %(eval $(%{__perl} -V:installprivlib 2>/dev/null); echo ${installprivlib:-ERROR})}%perl_privlib
607 %perl_archlib %{expand:%%global perl_archlib %(eval $(%{__perl} -V:installarchlib 2>/dev/null); echo ${installarchlib:-ERROR})}%perl_archlib
608 %perl_vendorlib %{expand:%%global perl_vendorlib %(eval $(%{__perl} -V:installvendorlib 2>/dev/null); echo ${installvendorlib:-ERROR})}%perl_vendorlib
609 %perl_vendorarch %{expand:%%global perl_vendorarch %(eval $(%{__perl} -V:installvendorarch 2>/dev/null); echo ${installvendorarch:-ERROR})}%perl_vendorarch
610 %perl_sitelib %{expand:%%global perl_sitelib %(eval $(%{__perl} -V:installsitelib 2>/dev/null); echo ${installsitelib:-ERROR})}%perl_sitelib
611 %perl_sitearch %{expand:%%global perl_sitearch %(eval $(%{__perl} -V:installsitearch 2>/dev/null); echo ${installsitearch:-ERROR})}%perl_sitearch
614 %__ruby /usr/bin/ruby
615 %ruby_archdir %{expand:%%global ruby_archdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["archdir"]' 2>/dev/null || echo ERROR)}%ruby_archdir
616 %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
617 %ruby_rubylibdir %{expand:%%global ruby_rubylibdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["rubylibdir"]' 2>/dev/null || echo ERROR)}%ruby_rubylibdir
618 %ruby_vendorarchdir %{expand:%%global ruby_vendorarchdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["vendorarchdir"]' 2>/dev/null || echo ERROR)}%ruby_vendorarchdir
619 %ruby_vendorlibdir %{expand:%%global ruby_vendorlibdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["vendorlibdir"]' 2>/dev/null || echo ERROR)}%ruby_vendorlibdir
620 %ruby_sitearchdir %{expand:%%global ruby_sitearchdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["sitearchdir"]' 2>/dev/null || echo ERROR)}%ruby_sitearchdir
621 %ruby_sitelibdir %{expand:%%global ruby_sitelibdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["sitelibdir"]' 2>/dev/null || echo ERROR)}%ruby_sitelibdir
622 %ruby_version %{expand:%%global ruby_version %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["ruby_version"]' 2>/dev/null || echo ERROR)}%ruby_version
623 %ruby_ver_requires_eq Requires: ruby(ver) = %ruby_version
624 %ruby_mod_ver_requires_eq Requires: ruby-modules(ver) = %ruby_version
626 %php_pear_dir /usr/share/pear
627 %php_data_dir /usr/share/php
628 %php_extensiondir %{expand:%%global php_extensiondir %(php-config --extension-dir 2>/dev/null || echo ERROR)}%php_extensiondir
629 %php_sysconfdir %{expand:%%global php_sysconfdir %(php-config --sysconfdir 2>/dev/null || echo ERROR)}%php_sysconfdir
630 %php_includedir %{expand:%%global php_includedir %(php-config --include-dir 2>/dev/null || echo ERROR)}%php_includedir
632 # extract php/zend api versions
633 %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
634 %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
635 %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
636 %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
637 %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
638 %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
639 %zend_zts %{expand:%%global zend_zts %(Z=$(grep -sc '^#define ZTS 1' %{php_includedir}/main/php_config.h); echo ${Z:-ERROR})}%zend_zts
642 %__php_api_requires(v:) Requires: php%{-v*}(%{expand:%1}) = %{expand:%{%{!?2:%{1}}%{?2}}}
644 # macros for public use
645 # for php extensions (php-pecl)
646 %requires_php_extension %{__php_api_requires modules_api php_api_version} \
647 %{__php_api_requires zend_module_api} \
648 %{__php_api_requires -v %php_major_version debug php_debug} \
649 %{__php_api_requires -v %php_major_version thread-safety zend_zts}
651 # for zend extensions
652 %requires_zend_extension %{__php_api_requires zend_module_api} \
653 %{__php_api_requires zend_extension_api} \
654 %{__php_api_requires -v %php_major_version debug php_debug} \
655 %{__php_api_requires -v %php_major_version thread-safety zend_zts}
657 # for php pdo modules (php-pecl-PDO_*)
658 %requires_php_pdo_module %{__php_api_requires PDO_API php_pdo_api_version}
660 # for using PHP post scripts. for PHP >= 5.0
661 %php_webserver_restart \
662 [ ! -f /etc/apache/conf.d/??_mod_php.conf ] || %service -q apache restart \
663 [ ! -f /etc/httpd/conf.d/??_mod_php.conf ] || %service -q httpd restart \
664 if [ -f /etc/rc.d/init.d/php-fcgi ]; then \
665 PHP_FCGI_BINARY=; . /etc/sysconfig/php-fcgi 2>/dev/null \
666 if [[ ${PHP_FCGI_BINARY:-php.fcgi} = *php.fcgi* ]]; then \
667 %service -q php-fcgi restart \
672 # for using php post scripts. for PHP >= 4.0 && PHP < 5.0
673 %php4_webserver_restart \
674 [ ! -f /etc/apache/conf.d/??_mod_php4.conf ] || %service -q apache restart \
675 [ ! -f /etc/httpd/conf.d/??_mod_php4.conf ] || %service -q httpd restart \
676 if [ -f /etc/rc.d/init.d/php-fcgi ]; then \
677 PHP_FCGI_BINARY=; . /etc/sysconfig/php-fcgi 2>/dev/null \
678 if [[ ${PHP_FCGI_BINARY:-php.fcgi} = *php4.fcgi* ]]; then \
679 %service -q php-fcgi restart \
685 # X.org helper macros
686 %__xorg_abi_requires() Requires: xorg-xserver-server(%{expand:%1}-abi) = %{expand:%{%{!?2:%{1}}%{?2}}}
688 %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
689 %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
690 %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
691 %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
692 %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 %requires_xorg_xserver_extension %{__xorg_abi_requires ansic xorg_xserver_ansic_abi} \
695 %{__xorg_abi_requires extension xorg_xserver_extension_abi}
696 %requires_xorg_xserver_xinput %{__xorg_abi_requires ansic xorg_xserver_ansic_abi} \
697 %{__xorg_abi_requires xinput xorg_xserver_xinput_abi}
698 %requires_xorg_xserver_font %{__xorg_abi_requires ansic xorg_xserver_ansic_abi} \
699 %{__xorg_abi_requires font xorg_xserver_font_abi}
700 %requires_xorg_xserver_videodrv %{__xorg_abi_requires ansic xorg_xserver_ansic_abi} \
701 %{__xorg_abi_requires videodrv xorg_xserver_videodrv_abi}
703 # Python specific macro definitions.
704 # python main version
705 %py_ver %{expand:%%global py_ver %(%{__python} -c "import sys; print sys.version[:3]" || echo ERROR)}%py_ver
708 %py_prefix %{expand:%%global py_prefix %(%{__python} -c "import sys; print sys.prefix" || echo ERROR)}%py_prefix
709 %py_libdir %{py_prefix}/%{_lib}/python%{py_ver}
710 %py_scriptdir %{py_prefix}/share/python%{py_ver}
711 %py_incdir /usr/include/python%{py_ver}
712 %py_sitedir %{py_libdir}/site-packages
713 %py_sitescriptdir %{py_scriptdir}/site-packages
714 %py_dyndir %{py_libdir}/lib-dynload
716 # pure python modules compilation
717 %py_comp python -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
719 %py_ocomp python -O -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
721 # Software written in Python language require Python with main version
722 %pyrequires_eq() Requires: %1
724 # Hardlink binary identical .pyc and .pyo files
725 # (idea by glen <at> pld-linux <dot> org)
726 %__spec_install_post_py_hardlink {\
727 %{!?no_install_post_py_hardlink: __spec_install_post_py_hardlink() { \
728 [ ! -d "$RPM_BUILD_ROOT" ] || find "$RPM_BUILD_ROOT" -name '*.pyc' | while read a; do \
730 if cmp -s "$a" "$b"; then \
734 }; __spec_install_post_py_hardlink } }
736 # remove python sources, so that check-files won't complain
737 # (idea by glen <at> pld-linux <dot> org)
739 for d in %{py_sitescriptdir} %{py_sitedir} %*; do \
740 [ ! -d "$RPM_BUILD_ROOT$d" ] || find "$RPM_BUILD_ROOT$d" -name '*.py' -print0 | xargs -0r -l512 rm;\
747 if [ -e /boot/System.map-%1 ]; then \
748 /sbin/depmod -a -F /boot/System.map-%1 %1; \
750 if [ -e /boot/System.map ]; then \
751 /sbin/depmod -a -F /boot/System.map %1; \
753 /sbin/depmod -a %1; \
758 # XMMS specific macros
759 %xmms_prefix %{expand:%%global xmms_prefix %(xmms-config --prefix 2>/dev/null || echo ERROR)}%xmms_prefix
760 %xmms_exec_prefix %{expand:%%global xmms_exec_prefix %(xmms-config --exec-prefix 2>/dev/null || echo ERROR)}%xmms_exec_prefix
761 %xmms_version %{expand:%%global xmms_version %(xmms-config --version 2>/dev/null || echo ERROR)}%xmms_version
762 %xmms_datadir %{expand:%%global xmms_datadir %(xmms-config --data-dir 2>/dev/null || echo ERROR)}%xmms_datadir
763 %xmms_plugindir %{expand:%%global xmms_plugindir %(xmms-config --plugin-dir 2>/dev/null || echo ERROR)}%xmms_plugindir
764 %xmms_visualization_plugindir %{expand:%%global xmms_visualization_plugindir %(xmms-config --visualization-plugin-dir 2>/dev/null || echo ERROR)}%xmms_visualization_plugindir
765 %xmms_input_plugindir %{expand:%%global xmms_input_plugindir %(xmms-config --input-plugin-dir 2>/dev/null || echo ERROR)}%xmms_input_plugindir
766 %xmms_output_plugindir %{expand:%%global xmms_output_plugindir %(xmms-config --output-plugin-dir 2>/dev/null || echo ERROR)}%xmms_output_plugindir
767 %xmms_effect_plugindir %{expand:%%global xmms_effect_plugindir %(xmms-config --effect-plugin-dir 2>/dev/null || echo ERROR)}%xmms_effect_plugindir
768 %xmms_general_plugindir %{expand:%%global xmms_general_plugindir %(xmms-config --general-plugin-dir 2>/dev/null || echo ERROR)}%xmms_general_plugindir
770 %_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 # user/group checking macros
777 %userremove /usr/lib/rpm/user_group.sh user del
778 %groupremove /usr/lib/rpm/user_group.sh group del
781 # if %usertestrm myuser; then
782 # /usr/sbin/userdel -r myuser
784 # use these macros only if you need to call userdel/groupdel with
785 # a non-standard option or take an extra action; otherwise use the
786 # %userremove/%groupremove macros
788 %usertestrm /usr/lib/rpm/user_group.sh user testrm
789 %grouptestrm /usr/lib/rpm/user_group.sh group testrm
790 # user group membership management macros
793 # %addusertogroup myuser agroup
795 %addusertogroup /usr/lib/rpm/user_group.sh user addtogroup
797 # banner support (useful in {pre,post}{,un} and triggers)
800 # %banner name [-a] [-e] [-n] [-tn] <<EOF
801 # the banner text, the banner text
802 # the banner text, and following line
804 # You can use any form of here-document, <<'EOF' <<-EOT will do.
805 # NOTE: if your use "<<-EOF", then You can actually indent inside here-document.
807 # -a - append to the banner
808 # -e - send to stderr instead of stdout
809 # -n - no show banner (overrides -t)
810 # -t - show only, if RPM_SCRIPTVERBOSITY >= n; default n=5
813 # (rpm -E '%banner -e banner <<EOF'; echo -e 'hi\nEOF') > m; sh -x m
814 # rpm -E 'date | %banner -e banner' > m; sh -x m
817 RPM_SCRIPTVERBOSITY=5 \
818 [ -r /etc/sysconfig/rpm ] && . /etc/sysconfig/rpm \
819 if [ -x /usr/bin/banner.sh ]; then \
820 CMD="/usr/bin/banner.sh %{-e:--stderr} %{!-n:$([ $RPM_SCRIPTVERBOSITY -ge %{-t:%{-t*}}%{!-t:5} ] && echo -s)} %{!-a:-m}%{-a:-M} %1" \
822 CMD="cat%{-e: >&2}" \
824 eval $CMD %{?2:%2}%{?3: %3}) \
827 # useradd/groupadd macros
828 # Author: Elan Ruusamäe <glen@pld-linux.org>
831 # %useradd [-P package] [-u uid] [-d home_dir] [-s shell] [-c comment]
832 # [-g initial_group] [-G group[,...]] login
835 # -g gid/group. REQUIRED
836 # -s defaults to /bin/false
837 # -d defaults to /usr/share/empty
839 # -r is accepted but ignored (it's always set)
840 # -k skeleton dir. defaults to /usr/share/empty
842 # -P package name. defaults to %{name}
844 %useradd(c:d:e:f:g:G:Mmk:op:s:u:rP:) \
845 %{!-u:%{error:useradd: Required argument -u missing}} \
846 %{!-g:%{error:useradd: Required argument -g missing}} \
847 %{!?1:%{error:useradd: Required parameter login missing}} \
848 if [ -n "`/bin/id -u %{expand:%{%{#}}} 2>/dev/null`" ]; then \
849 if [ "`/bin/id -u %{expand:%{%{#}}}`" != "%{-u*}" ]; then \
850 echo "Error: user %{expand:%{%{#}}} doesn't have uid=%{-u*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
854 echo "Adding user %{expand:%{%{#}}} UID=%{-u*}." \
855 /usr/sbin/useradd \\\
856 %{-m:-m -k %{-k*}%{!-k:/usr/share/empty}} \\\
859 -d %{-d*}%{!-d:/usr/share/empty} \\\
860 -s %{-s*}%{!-s:/bin/false} \\\
861 %{-c:-c "%(set -- %{-c*} %{*}; echo $1)"}\\\
865 %{expand:%{%{#}}} 1>&2 || exit $? \
866 [ ! -x /usr/sbin/nscd ] || /usr/sbin/nscd -i passwd || : \
870 # %groupadd [-P package] [-g gid] group
875 # %groupadd -P %{name}-base -g %{gid} %{name}
878 %{!-g:%{error:groupadd: Required argument -g missing}} \
879 %{!?1:%{error:groupadd: Required parameter group missing}} \
880 if [ -n "`/usr/bin/getgid %{1}`" ]; then \
881 if [ "`/usr/bin/getgid %{1}`" != "%{-g*}" ]; then \
882 echo "Error: group %{1} doesn't have gid=%{-g*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
886 echo "Adding group %{1} GID=%{-g*}." \
887 /usr/sbin/groupadd -g %{-g*} -r %{1} 1>&2 || exit $? \
888 [ ! -x /usr/sbin/nscd ] || /usr/sbin/nscd -i group || : \
892 # Author: Elan Ruusamäe <glen@pld-linux.org>
894 # The config is installed/removed inside trigger, this means that you can any
895 # time install apache1/apache/lighttpd package and the configuration file is
896 # updated. if you don't need the config for various reason for specific
897 # webserver, just remove the symlink from config directory using webapp
898 # program. the trigger will not recreate the symlink on upgrades. In other
899 # words the config is linked to webserver config directory on first install of
900 # PACKAGE or WEBSERVER.
902 # Add package's webserver config to webserver webapps dir.
904 # %webapp_register WEBSERVER WEBAPP
907 %{?debug:set -x; echo "webapp_register: %{name}-%{version}-%{release} 1:[$1]; 2:[$2]"} \
908 if [ "$1" = "1" ] && [ "$2" = "1" ]; then\
909 /usr/sbin/webapp register %1 %2\
911 # reload webserver if the config symlink is there and skip reload if webserver is upgraded\
912 if [ -L /etc/%1/webapps.d/%(echo "%2" | tr '/' '-').conf ] && [ "$2" -lt "2" ]; then\
913 %{expand:%service -q %%1 reload}\
917 # Remove package's config from webserver webapps dir.
919 # %webapp_register [-f] WEBSERVER WEBAPP
920 %webapp_unregister(f) \
921 %{?debug:set -x; echo "webapp_unregister: %{name}-%{version}-%{release}: 1:[$1]; 2:[$2]"} \
922 # remove link if either of the packages are gone \
923 if [ -n "%{-f:1}" ] || [ "$1" = "0" ] || [ "$2" = "0" ] && [ -L /etc/%1/webapps.d/%(echo "%2" | tr '/' '-').conf ]; then \
924 /usr/sbin/webapp unregister %1 %2\
925 %{expand:%service -q %%1 reload}\
930 # Author: Elan Ruusamäe <glen@pld-linux.org>
932 # calls usual service restart on package %post, but skips the restart if
933 # administrator has disabled automatic service restarts in either global
934 # /etc/sysconfig/rpm or per service /etc/sysconfig/SERVICE file.
937 # %service [-q] [-n] SERVICE ACTION ["SERVICE NICE DESCRIPTION"]
939 # -q be silent when service isn't started (for scriplets restaring other package's services)
940 # -n NOOP mode, do not actually restart service
943 # BuildRequires: rpmbuild(macros) >= 1.268
944 # Requires: rc-scripts
946 # BuildRequires: rpmbuild(macros) >= 1.450
947 %service(qn) {{%(export noop=%{-n:1} quiet=%{-q:1}; /usr/lib/rpm/service_generator.sh %{*}) };}
950 # Java macros. based on jpackage macros.java
952 # Root directory where all Java VMs/SDK/JREs are installed.
953 %_jvmdir %{_libdir}/jvm
955 # Root directory where all Java VMs/SDK/JREs expose their jars
956 %_jvmjardir %{_libdir}/jvm-exports
958 # Root directory for all Java VM/SDK/JRE's private things.
959 %_jvmprivdir %{_libdir}/jvm-private
961 # Root directory for all architecture dependent parts of Java VM/SDK/JRE's
962 %_jvmlibdir %{_libdir}/jvm
964 # Root directory for all architecture independent parts of Java VM/SDK/JRE's
965 %_jvmdatadir %{_datadir}/jvm
967 # Root directory for all configurations parts of Java VM/SDK/JRE's
968 %_jvmsysconfdir %{_sysconfdir}/jvm
970 # Root directory for all common architecture dependent parts of Java VM/SDK/JRE's
971 %_jvmcommonlibdir %{_libdir}/jvm-common
973 # Root directory for all common architecture independent parts of Java VM/SDK/JRE's
974 %_jvmcommondatadir %{_datadir}/jvm-common
976 # Root directory for all common configurations parts of Java VM/SDK/JRE's
977 %_jvmcommonsysconfdir %{_sysconfdir}/jvm-common
979 # Directory where arch-specific (JNI) version-independent jars are installed.
980 %_jnidir %{_libdir}/java
982 %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 %ant JAVA_HOME=%{java_home} ant
985 %jar %{java_home}/bin/jar
986 %java %{expand:%%global java %([ -f %{_javadir}-utils/java-functions ] || { echo ERROR; exit 0; }; unset JAVACMD; . %{_javadir}-utils/java-functions; set_javacmd; echo $JAVACMD)}%java
987 %javac %{java_home}/bin/javac
988 %javadoc %{java_home}/bin/javadoc
990 %add_jvm_extension JAVA_LIBDIR=%{buildroot}/%{_javadir} %{_bindir}/jvmjar -l
993 install -d $RPM_BUILD_ROOT%{_bindir}\
994 cat > $RPM_BUILD_ROOT%{_bindir}/%5 << 'EOF' \
998 # JPackage Project <http://www.jpackage.org/>\
1000 # Source functions library\
1001 . %{_javadir}-utils/java-functions\
1003 # Source system prefs\
1004 if [ -f %{_sysconfdir}/java/%{name}.conf ]; then\
1005 . %{_sysconfdir}/java/%{name}.conf\
1008 # Source user prefs\
1009 if [ -f $HOME/.%{name}rc ]; then\
1017 BASE_JARS="%(echo %4 | tr ':' ' ')"\
1021 set_classpath $BASE_JARS\
1022 set_flags $BASE_FLAGS\
1023 set_options $BASE_OPTIONS\
1030 # Directory for maven depmaps
1032 %_mavendepmapdir /etc/maven
1033 %_mavendepmapfragdir /etc/maven/fragments
1036 # add_to_depmap adds an entry to the depmap. The arguments are:
1038 # %1 the original groupid
1039 # %2 the original artifact id
1041 # %4 the new groupid
1042 # %5 the new artifactid
1045 %add_to_maven_depmap() \
1046 install -dm 755 $RPM_BUILD_ROOT/%{_mavendepmapfragdir}\
1047 cat >>$RPM_BUILD_ROOT/%{_mavendepmapfragdir}/%{name}<< EOF\
1050 <groupId>%1</groupId>\
1051 <artifactId>%2</artifactId>\
1052 <version>%3</version>\
1055 <groupId>%4</groupId>\
1056 <artifactId>%5</artifactId>\
1057 <version>%3</version>\
1064 #==============================================================================
1066 # update_maven_depmap updates the main maven depmap
1068 %update_maven_depmap() \
1069 echo -e "<dependencies>\\n" > %{_mavendepmapdir}/maven2-depmap.xml\
1070 if [ -d %{_mavendepmapfragdir} ] && [ -n "`find %{_mavendepmapfragdir} -type f`" ]; then\
1071 cat %{_mavendepmapfragdir}/* >> %{_mavendepmapdir}/maven2-depmap.xml\
1073 echo -e "</dependencies>\\n" >> %{_mavendepmapdir}/maven2-depmap.xml
1076 # PEAR install macros
1077 # Author: Elan Ruusamäe <glen@pld-linux.org>
1080 # %%pear_package_setup [-a #] [-n FMT]
1082 # -a # - also unpack SOURCE#. for PEAR bootstrapping
1083 # -n FMT - create builddir with FMT, instead of default %%{_pearname}-%%{version}
1084 # -z - unpack pear package and let pear use package.xml (not tarball) for install. for PEAR bootstrapping
1086 # unpack PEAR package to %%{_builddir}/FMT. package is extracted with already
1087 # destination hierarchy. you should copy the tree to buildroot after
1088 # patching/reorganizing with %%pear_package_install.
1090 # additionally BUILDROOT is stripped from files and files are converted to UNIX
1093 # the pear install process output is recorded to install.log, you should put it
1094 # to %%doc for later debug or just for information.
1096 # additionally additional-packages.txt is produced if it was detected that the
1097 # package has optional dependencies. the file format is suitable of displaying
1098 # in %%post of a package. you should put this file to %%doc. noautocompressdoc is
1099 # automatically added for this file.
1102 # records install.log and transforms PEAR names to PLD Linux rpm package names.
1103 %__pear_install_log \
1105 # make post message of optional packages \
1106 grep 'can optionally use' install.log | sed -e 's,package "pear/,package "php-pear-,g;s,^pear/,php-pear-,' > optional-packages.txt \
1107 if [ -s optional-packages.txt ]; then \
1108 awk -F'"' '/use package/{print $2}' optional-packages.txt | sed -e "s,_,/,g;s,php-pear-, 'pear(,;s,$,.*)'," | tr -d '\\\n' > _noautoreq \
1110 rm -f optional-packages.txt \
1114 # command invoking pear cli
1115 %__pear /usr/bin/pear
1117 %pear_install(a:n:zD) \
1120 -d doc_dir=/docs \\\
1121 -d php_dir=%{php_pear_dir} \\\
1122 -d bin_dir=%{_bindir} \\\
1123 -d data_dir=%{php_pear_dir}/data \\\
1124 -d test_dir=%{php_pear_dir}/tests \\\
1126 --packagingroot=%{builddir} \\\
1130 %{!-z:%{S:%{-a*}%{!-a:0}}}%{-z:$_P} > .install.log || { c=$?; cat .install.log; exit $c; }; \
1134 # using this macro will append optional-packages.txt to the nocompressdoc list
1135 # as it's displayed to user after package install. and adding additional gzip
1136 # dep is just waste ;)
1137 %pear_package_setup(a:n:zD) \
1138 %define srcdir %{-n*}%{!-n:%{_pearname}-%{version}} \
1139 %define builddir %{_builddir}/%{srcdir} \
1140 %setup -q -c -T %{-D:-D} -n %{srcdir} \
1141 %{-z:tar zxf %{S:0}; %{-a:tar zxf %{S:%{-a*}}}} \
1142 %{-z:_P=package2.xml; [ -f $_P ] || _P=package.xml; _N=%{srcdir}; mv $_P $_N; cd $_N} \
1145 cat %{-z:$_N/}.install.log | %__pear_install_log \
1148 find -type f -print0 | xargs -0 sed -i -e 's,\\r$,,' \
1149 %{!?_noautocompressdoc:%global _noautocompressdoc %{nil}}%{expand:%%global _noautocompressdoc %{_noautocompressdoc} optional-packages.txt} \
1150 %{!?_noautoprov:%global _noautoprov %{nil}}%{expand:%%global _noautoprov %{_noautoprov} 'pear(tests/.*)'} \
1153 # Copies exctracted PEAR package structure and PEAR registry to buildroot.
1154 # Author: Elan Ruusamäe <glen@pld-linux.org>
1155 %pear_package_install() \
1156 cp -a ./%{php_pear_dir}/{.registry,*} $RPM_BUILD_ROOT%{php_pear_dir} \
1157 find $RPM_BUILD_ROOT%{php_pear_dir} '(' -name '*~' -o -name '*.orig' ')' | xargs -r rm -v \
1158 # help the developer out a little: \
1159 if [ -f _noautoreq ]; then \
1160 echo "AutoReqdep detected:" \
1161 echo "_noautoreq $(cat _noautoreq)" \
1166 # Register OpenLDAP schema.
1167 # Author: Elan Ruusamäe <glen@pld-linux.org>
1170 # %%openldap_schema_register [-d core,nis] %{schemadir}/horde.schema
1172 # -d specify dependant schemas, separated by comma
1174 %openldap_schema_register(d:) \
1175 for schema in %*; do \
1176 if ! grep -q "$schema" /etc/openldap/slapd.conf; then \
1178 /^include.*local.schema/{ \
1179 iinclude\\t $schema\
1181 " /etc/openldap/slapd.conf \
1184 # enable dependant schemas \
1185 if [ "%{-d*}" ]; then \
1187 /^#include.*\\(%(echo '%{-d*}' | %{__sed} -e 's/,/\\\\|/g')\\)\\.schema/{ \
1189 }' /etc/openldap/slapd.conf \
1193 # Unregister OpenLDAP schema.
1194 # Author: Elan Ruusamäe <glen@pld-linux.org>
1197 # %%openldap_schema_unregister %{schemadir}/horde.schema
1199 %openldap_schema_unregister() \
1200 for schema in %*; do \
1201 if grep -q "$schema" /etc/openldap/slapd.conf; then \
1203 /^include.*$(echo "$schema" | %{__sed} -e 's,/,\\\\/,g')/d \
1204 # for symmetry it would be nice if we disable enabled schemas in post, \
1205 # but we really can not do that, it would break something else. \
1206 " /etc/openldap/slapd.conf \
1211 %env_update [ ! -x /sbin/env-update ] || /sbin/env-update -u || :
1214 # Build modules for kernels 2.6
1215 # Author: Przemyslaw Iskra <sparky@pld-linux.org>
1218 # %build_kernel_modules -m <modules> -C <directory>
1220 # remember that proper Makefile is still required
1222 # -m <modules> (required) -- comma-separated list of modules to save,
1223 # without .ko extension, may be placed in subdirectory
1224 # -C <directory> -- change to <directory> before doing anything
1225 # -p <arg>, -P <arg> -- arguments passeed to make scripts
1226 # -c -- do not execute make clean
1227 # <additional arguments> -- all additional arguments will be passed to
1230 # Additional patching supported via here document. Try:
1231 # %build_kernel_modules -m module <<'EOF'
1232 # your patch script here
1234 # Don't use it unless patching depends on config options.
1236 # Developer note: don't touch it unless you know how to handle '\'.
1237 # - \ in script expands to nothing
1238 # - \\\ in script expands to \
1239 # - \\\ inside definition expands to nothing
1240 # - \\\\\\\ inside definition expands to \
1241 # - in last line \ has to touch arguments so arguments passing
1242 # in new lines (using \) will be supported
1244 %build_kernel_modules(p:P:m:C:c) \
1245 %{!?-m:%{error:%{0}: Required module name/list missing} exit 1} \
1247 %define Opts \\\\\\\
1248 %if "%{_target_base_arch}" != "%{_arch}" \\\
1249 %if "%{_arch}" == "x86_64" && "%{_target_base_arch}" == "i386" \\\
1250 CC="%{kgcc}" ARCH=%{_target_base_arch} \\\
1252 ARCH=%{_target_base_arch} CROSS_COMPILE=%{_target_cpu}-pld-linux- \\\
1257 %define MakeOpts HOSTCC="%{kgcc}" SYSSRC=%{_kernelsrcdir} SYSOUT=$PWD/o \\\\\\\
1258 O=$PWD/o %{?with_verbose:V=1} %{Opts} \
1262 local L="<" PATCH_SH; \
1263 [[ '%{*}' != *$L$L* ]] || PATCH_SH="set -x -e;$(cat)" \
1265 local cfgs='%{?with_dist_kernel:%{?with_smp: smp}%{?with_up: up}}%{!?with_dist_kernel: nondist}' \
1267 for cfg in ${cfgs:-dist}; do \
1268 [ -r "%{_kernelsrcdir}/config-$cfg" ] || exit 1 \
1271 install -d o/include/linux \
1272 ln -sf %{_kernelsrcdir}/config-$cfg o/.config \
1273 ln -sf %{_kernelsrcdir}/Module.symvers-$cfg o/Module.symvers \
1274 ln -sf %{_kernelsrcdir}/include/linux/autoconf-$cfg.h o/include/linux/autoconf.h \
1277 [ -z "$PATCH_SH" ] || echo "$PATCH_SH" | %__spec_build_shell \
1280 %if %{with dist_kernel} \
1281 %{__make} -j1 -C %{_kernelsrcdir} prepare scripts \\\
1285 install -d o/include/config \
1286 touch o/include/config/MARKER \
1287 ln -sf %{_kernelsrcdir}/scripts o/scripts \
1290 %{!?-c:%{__make} -C %{_kernelsrcdir} clean \\\
1291 RCS_FIND_IGNORE="-name '*.ko' -o" \\\
1293 M=$PWD %{MakeOpts}} \
1295 %{__make} -C %{_kernelsrcdir} modules \\\
1297 M=$PWD %{MakeOpts} \
1299 for MODULE in {%{-m*},}; do \
1300 [ -z "${MODULE}" ] || mv ${MODULE}{,-$cfg}.ko \
1309 # Install kernel modules built by %build_kernel_modules
1310 # Author: Przemyslaw Iskra <sparky@pld-linux.org>
1313 # %install_kernel_modules -m <modules> -d <directory>
1316 # -m <modules> (required) -- comma-separated list of modules to install,
1317 # without .ko extension, may be placed in subdirectory
1318 # -d <directory> (required) -- in what subdirectory modules should be
1319 # installed (eg. misc, kernel/drivers/net)
1320 # -s <suffix> -- suffix to use when installing modules, useful when module
1321 # with same name exists in kernel already
1322 # -n <file> -- name of modprobe config file to use (without .conf extension)
1323 # for defining aliases, only useful with -s
1325 %install_kernel_modules(m:d:s:n:) \
1326 %{!?-m:%{error:%{0}: Required module name (-m) missing}exit 1} \
1327 %{!?-d:%{error:%{0}: Required module directory missing}exit 1} \
1328 %{?-n:%{!?-s:%{error:%{0}: Modprobe .conf file requires module suffix}exit 1}} \
1330 %define KernelD $RPM_BUILD_ROOT/lib/modules/%{_kernel_ver} \
1331 %define ModprobeD $RPM_BUILD_ROOT%{_sysconfdir}/modprobe.d/%{_kernel_ver} \
1333 local cfgs='%{?with_dist_kernel:%{?with_smp: smp}%{?with_up: up}}%{!?with_dist_kernel: nondist}' \
1335 for MODULE in {%{-m*},}; do \
1336 [ -n "${MODULE}" ] || continue \
1337 for cfg in ${cfgs:-dist}; do \
1338 [ "$cfg" = smp ] && suf=smp || suf= \
1339 MNAME=${MODULE##*/} \
1340 install -D ${MODULE}-$cfg.ko \\\
1341 %{KernelD}$suf/%{-d*}/${MNAME}%{-s:-%{-s*}}.ko \
1342 %{?-s:install -d %{ModprobeD}$suf \
1343 echo "alias ${MNAME} ${MNAME}-%{-s*}" \\\
1344 >> %{ModprobeD}$suf/%{-n*}.conf} \
1350 # Author: Elan Ruusamäe <glen@pld-linux.org>
1353 # %patchset_source -f <seq(1) format> <start> [<end>]
1354 # %patchset_patch <start> [<end>]
1356 # If <end> is omited, it is assumed to be <start>.
1358 # For example in preamble:
1359 # %patchset_source -f ftp://ftp.vim.org/pub/editors/vim/patches/7.0/7.0.%03g 33 44
1361 # %patchset_patch 33 44
1363 # generate SourceX urls from range START STOP
1364 # Format can be SINGLE format char of %e, %f, %g, see seq(1)
1365 # The sources start from 10000
1366 %patchset_source(f:b:) %(
1367 base=%{-b*}%{!-b*:10000};
1368 start=$(expr $base + %1);
1369 end=$(expr $base + %{?2}%{!?2:%{1}});
1370 # we need to call seq twice as it doesn't allow two formats
1371 seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
1372 seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
1373 paste %{tmpdir}/__ps{1,2};
1374 rm -f %{tmpdir}/__ps{1,2};
1378 # apply sources from %patchset_source
1379 # -p specify -pX for %patch line
1380 # -b base offset: defaults to 10000
1381 %patchset_patch(f:p:b:) %(
1382 base=%{-b*}%{!-b*:10000};
1383 start=$(expr $base + %1);
1384 end=$(expr $base + %{?2}%{!?2:%{1}});
1385 echo ": patchset_patch %1%{?2: to %2}";
1386 seq -f 'patch%g %{-p*:-p%{-p*}}' $start $end | sed -e s,^,%%,;
1390 # browser plugins v2
1391 # Author: Elan Ruusamäe <glen@pld-linux.org>
1394 # %browser_plugins_add_browser <name> -p <plugindir>
1396 # <name> (required) -- name of the browser. usually %{name}.
1397 # -p <plugindir> (required) -- in what directory browser searches for its plugins.
1398 # -b -- default blacklists
1399 # -a <arch> override arch
1402 # %browser_plugins_add_browser %{name} -p %{_firefoxdir}/plugins
1404 %_browserpluginsconfdir /etc/browser-plugins
1405 %_browserpluginsdir %{_libdir}/browser-plugins
1406 %update_browser_plugins /usr/sbin/update-browser-plugins || :
1408 %browser_plugins_add_browser(p:b:a:) \
1409 browser=%1.%{!-a:%{_target_base_arch}}%{-a*} \
1410 install -d $RPM_BUILD_ROOT%{_browserpluginsconfdir}/{blacklist,browsers}.d \
1411 ln -s %{-p*} $RPM_BUILD_ROOT%{_browserpluginsconfdir}/browsers.d/$browser \
1412 blacklist_file=$RPM_BUILD_ROOT%{_browserpluginsconfdir}/blacklist.d/$browser.blacklist \
1413 echo '# This file format is shell globs at base dir of plugindir' > $blacklist_file \
1414 %{-b:cat >> $blacklist_file %{-b*}} \
1418 # split string separated by space into quoted list
1420 # Author: Elan Ruusamäe <glen@pld-linux.org>
1422 # %__lua_split /bin/sh /bin/pdksh -> "/bin/sh", "/bin/pdksh"
1423 %__lua_split() %(echo "%*" | awk '{for (i=1;i<=NF;i++) printf("\\"%%s\\"%%s", $i, i == NF ? "" : ", ")}')
1425 # adjust /etc/shells by adding and removing shells from there
1426 # Author: Elan Ruusamäe <glen@pld-linux.org>
1429 # %post -p %add_etc_shells -p /bin/sh /bin/pdksh
1430 # %preun -p %remove_etc_shells -p /bin/sh /bin/pdksh
1432 # -p (optional) -- specifies that result is embeded %post script (prepends <lua> as first line)
1435 # BuildRequires: rpmbuild(macros) >= 1.429
1437 %add_etc_shells(p) %{-p:<lua>}\
1439 f = io.open("/etc/shells", "r")\
1441 for l in f:lines() do t[l]=l; end\
1444 for _, s in ipairs({%{expand:%%__lua_split %*}}) do\
1446 print("Adding "..s.." to /etc/shells")\
1447 f = io.open("/etc/shells", "a"); f:write(s.."\\n"); f:close()\
1452 %remove_etc_shells(p) %{-p:<lua>}\
1453 %{-p:if arg[2] == 0 then}\
1455 f = io.open("/etc/shells", "r")\
1457 for l in f:lines() do t[l]=l; end\
1460 for _, l in pairs({%{expand:%%__lua_split %*}}) do\
1461 print("Removing "..l.." from /etc/shells")\
1465 for _, l in pairs(t) do\
1468 io.open("/etc/shells", "w"):write(s)\
1472 # vim:ts=4 sw=4 noet syn=spec