]> git.pld-linux.org Git - packages/rpm.git/blame - rpm.macros
- partial merge from HEAD
[packages/rpm.git] / rpm.macros
CommitLineData
b52fc1f1 1# $Revision$, $Date$
a8bf9720
AF
2# PLD rpm macros
3
90c0eaed 4%epoch 0
31b569b6 5%x8664 x86_64 amd64 ia32e
cd33aab7 6
a544555d 7# kernel compiler
6f86c45e 8%kgcc %{__cc}
cabacfeb 9%kgcc_package gcc
a544555d 10
31b569b6
ER
11%_source_payload w9.gzdio
12%_binary_payload w9.bzdio
13
5f9f9bd7 14# Build system path macros.
15#
8af1c6f5
JB
16%__autoconf autoconf %{?debug:-Wall}
17%__automake automake -a -c -f --foreign
429d047e 18%__autopoint autopoint --force
19
aad1c8e4 20%__gettextize { \
31b569b6 21if ! gettextize --version | grep -q '0\.10\.' ; then \
4cd84746 22 if grep -qs 'AM_GNU_GETTEXT.*external' configure.{ac,in} ; then \
31b569b6 23 gettextize --copy --force --no-changelog; \
93bce43f 24 else \
31b569b6 25 gettextize --copy --force --no-changelog --intl; \
4cd84746
JB
26 fi; \
27 if [ ! -f po/Makevars ]; then \
31b569b6 28 cp -f po/Makevars{.template,}; \
4cd84746 29 fi; \
31b569b6 30else \
4cd84746 31 gettextize --copy --force; \
31b569b6 32fi; \
4cd84746 33}
429d047e 34
35%__glib_gettextize glib-gettextize --copy --force
36%__gnome_doc_common gnome-doc-common --copy
37%__gtkdocize gtkdocize --copy
38%__intltoolize intltoolize --copy --force
39%__libtoolize libtoolize --copy --force
5f9f9bd7 40
38e780ca
ER
41# The number of cvs changelog entries kept when building package.
42%_buildchangelogtruncate 20
43
bd1cd543 44%dependencytracking %{nil}
31b569b6 45
073ae3ba
ER
46# Relations between package names that cause dependency loops
47# with legacy packages that cannot be fixed. Relations are
48# specified as
49# p>q
50# where package p has a Requires: on something that package q Provides:
51#
52# XXX Note: that there cannot be any whitespace within the string "p>q",
53# and that both p and q are package names (i.e. no version/release).
54%_dependency_whiteout %{nil}
55
cd33aab7 56#-----------------------------------------------------------------
9f0287b5 57%configure2_13 { \
cd33aab7
AM
58 if [ -n "$LINGUAS" ]; then unset LINGUAS; fi; \
59 LDFLAGS="${LDFLAGS:-%rpmldflags}" ; export LDFLAGS ; \
60 CFLAGS="${CFLAGS:-%rpmcflags}" ; export CFLAGS ; \
af18d245 61 CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" ; export CXXFLAGS ; \
cd33aab7 62 FFLAGS="${FFLAGS:-%rpmcflags}" ; export FFLAGS ; \
c55f2219 63 CPPFLAGS="${CPPFLAGS:-}" ; export CPPFLAGS ; \
4eac2e49
AM
64 %{?__cc:CC="%{__cc}" ; export CC ; } \
65 %{?__cxx:CXX="%{__cxx}" ; export CXX ; } \
5b0f0ac9 66 %{?configuredir:%{configuredir}}%{!?configuredir:.}/configure \
fa74a11c 67 --host=%{_target_platform} \
cd33aab7
AM
68 --prefix=%{_prefix} \
69 --exec-prefix=%{_exec_prefix} \
70 --bindir=%{_bindir} \
71 --sbindir=%{_sbindir} \
72 --sysconfdir=%{_sysconfdir} \
73 --datadir=%{_datadir} \
74 --includedir=%{_includedir} \
75 --libdir=%{_libdir} \
76 --libexecdir=%{_libexecdir} \
77 --localstatedir=%{_localstatedir} \
78 --sharedstatedir=%{_sharedstatedir} \
79 --mandir=%{_mandir} \
80 --infodir=%{_infodir} \
c3420100 81 --x-libraries=%{?_x_libraries}%{!?_x_libraries:%{_libdir}} \
8b4be1e1 82 %{dependencytracking} \
cd33aab7
AM
83}
84
85f82bec 85#----------------------------------------------------------------
7e4e3f2b 86%global configure_cache 0
87%configure_cache_file %{buildroot}.configure.cache
88
b8cf6778 89%configure {./configure \
85f82bec
AF
90 LDFLAGS="${LDFLAGS:-%rpmldflags}" \
91 CFLAGS="${CFLAGS:-%rpmcflags}" \
af18d245 92 CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" \
85f82bec 93 FFLAGS="${FFLAGS:-%rpmcflags}" \
418d9760 94 CPPFLAGS="${CPPFLAGS:-}" \
4eac2e49
AM
95 %{?__cc:CC="%{__cc}"} \
96 %{?__cxx:CXX="%{__cxx}"} \
a9bea0f7 97 --host=%{_target_platform} \
85f82bec
AF
98 --build=%{_target_platform} \
99 --prefix=%{_prefix} \
100 --exec-prefix=%{_exec_prefix} \
101 --bindir=%{_bindir} \
102 --sbindir=%{_sbindir} \
103 --sysconfdir=%{_sysconfdir} \
104 --datadir=%{_datadir} \
105 --includedir=%{_includedir} \
106 --libdir=%{_libdir} \
107 --libexecdir=%{_libexecdir} \
108 --localstatedir=%{_localstatedir} \
109 --sharedstatedir=%{_sharedstatedir} \
110 --mandir=%{_mandir} \
111 --infodir=%{_infodir} \
c3420100 112 --x-libraries=%{?_x_libraries}%{!?_x_libraries:%{_libdir}} \
8b4be1e1 113 %{dependencytracking} \
7e4e3f2b 114 %{?configure_cache:--cache-file=%{configure_cache_file:-%{buildroot}.configure.cache}} \
85f82bec
AF
115}
116
617b7266 117# ------------------------------------------------------------------------
a0bade1c
AM
118# Overloading of some basic macros
119%prep \
120%%prep\
121LANG=C\
122export LANG\
7febf367 123unset DISPLAY ||:\
7507b4fa 124unset LINGUAS ||:\
a0bade1c
AM
125%{nil}
126
127%build %%build\
128LANG=C\
129export LANG\
7febf367 130unset DISPLAY ||:\
7507b4fa 131unset LINGUAS ||:\
a0bade1c
AM
132%{nil}
133
1fcb29e9
ER
134%install \
135%if 0%{?_enable_debug_packages}\
136%{?buildsubdir:%{debug_package}}\
137%endif\
a0bade1c
AM
138%%install\
139LANG=C\
140export LANG\
7febf367 141unset DISPLAY ||:\
7507b4fa 142unset LINGUAS ||:\
a0bade1c
AM
143%{nil}
144
cd33aab7
AM
145# Location of autoconf macros
146%_aclocaldir %(aclocal --print-ac-dir)
147
32720a50
AM
148# Location of omf files
149%_omf_dest_dir %(scrollkeeper-config --omfdir)
150
c5eece2c 151# Location of pkgconfig files
a46897a7 152%_pkgconfigdir /usr/%{_lib}/pkgconfig
c5eece2c 153
c917274d 154# Location of desktop files
155%_desktopdir /usr/share/applications
510f694c 156%_applnkdir ERROR:_applnkdir_is_obsolete_use_desktopdir_instead
c917274d 157
fb08fb4a 158# Location of pixmaps for applnk/desktop files
3a9bb008 159%_pixmapsdir /usr/share/pixmaps
cd33aab7 160
fb08fb4a 161# Location of themable icons for applnk/desktop files
986c3bcd 162%_iconsdir /usr/share/icons
163
c5eece2c
JB
164# Location of fonts directories
165%_fontsdir /usr/share/fonts
166
5cfcbc9e 167# Location of Gtk and associated libraries documentation
e9f33a26 168%_gtkdocdir %{_defaultdocdir}/gtk-doc/html
5cfcbc9e 169
eee08b2d 170# Location of KDE documentation
171%_kdedocdir %{_defaultdocdir}/kde/HTML
172
a7cad6ae 173# unsermake script
174%__unsermake /usr/share/unsermake/unsermake
175
cd33aab7
AM
176# Current date
177%date %(LC_ALL="C" date +"%a %b %d %Y")
178
179# tmp directory
180%tmpdir %(echo "${TMPDIR:-/tmp}")
181
182# Example files, programs, scripts...
183%_examplesdir /usr/src/examples
184
bd63739a 185# The directory holding Linux kernel sources
186%_kernelsrcdir /usr/src/linux
187
cd33aab7 188# If non-empty "debug" macro defined, add "dbg" suffix to release number
5b0f0ac9 189%_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}%{?debug:dbg}.%%{ARCH}.rpm
cd33aab7 190
5b0f0ac9 191# Requires name = version-release
5237e419 192%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")
511ee4c6 193
7348a2f8
ER
194%releq_kernel_up() %((LC_ALL="C" rpm -qf --qf '%%{name}-up = %%{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)")
195%releq_kernel_smp() %((LC_ALL="C" rpm -qf --qf '%%{name}-smp = %%{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)")
dd4e969a
ER
196%requires_releq_kernel_up(s:) Requires%{-s:(%{-s*})}: %releq_kernel_up
197%requires_releq_kernel_smp(s:) Requires%{-s:(%{-s*})}: %releq_kernel_smp
511ee4c6 198
c7359865 199%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")
d0bdd45a 200%requires_eq_to() %(LC_ALL="C" rpm -q --qf 'Requires: %1 = %%{epoch}:%%{version}\\n' %2 | sed -e 's/ (none):/ /' | grep -v "is not")
e478b9e7 201
4ca2266c 202%apache_modules_api %(awk '/#define MODULE_MAGIC_NUMBER_MAJOR/ {print $3}' /usr/include/apache/ap_mmn.h 2>/dev/null || echo ERROR)
8dea1306 203
204# kernel version-release handling
31b569b6
ER
205%__kernel_ver %([ -f %{_kernelsrcdir}/include/linux/version.h ] && (grep UTS_RELEASE %{_kernelsrcdir}/include/linux/version.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))
206%__kernel_rel %(LC_ALL="C" rpm -qf %{_kernelsrcdir}/include/linux/fs.h 2>/dev/null --qf "%{RELEASE}" | grep -v "is not")
ed0057d9 207%__kernel_rpmvr %(LC_ALL="C" rpm -qf %{_kernelsrcdir}/include/linux/fs.h 2>/dev/null --qf "%{VERSION}-%{RELEASE}" | grep -v "is not")
31b569b6 208%_kernel_ver %{__kernel_ver}%{?with_dist_kernel:%(echo %{__kernel_ver} | grep -q -e - || echo -%{__kernel_rel})}
066309eb 209%_kernel_ver_str %(echo %{!?_without_dist_kernel:%{__kernel_rpmvr}}%{?_without_dist_kernel:%{__kernel_ver}} | sed -e 's/-/_/g')
fd4d8ee0 210
c2c27a5a 211# sgml macros
31b569b6
ER
212%xmlcat_add() /usr/bin/xmlcatalog --noout --add nextCatalog \"\" %1 /etc/xml/catalog ;
213%xmlcat_del() /usr/bin/xmlcatalog --noout --del %1 /etc/xml/catalog ;
214%xmlcat_add_rewrite /usr/bin/xmlcatalog --noout --add rewriteSystem
215%xmlcat_create() /usr/bin/xmlcatalog --noout --create %1 ;
216%sgmlcat_add() /usr/bin/install-catalog --add %1 %2 > /dev/null ;
217%sgmlcat_del() /usr/bin/install-catalog --remove %1 %2 > /dev/null ;
c2c27a5a 218%docbook_sgmlcat_fix() { for l in \
219'' \
220' -- default decl --' \
221'DTDDECL "-//OASIS//DTD DocBook XML V%2//EN" "../../xml.dcl"' \
222' -- hacks for opensp --' \
223'SYSTEM "file://%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
224'SYSTEM "http://www.oasis-open.org/docbook/xml/%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
225'' \
226; do echo $l; done >> %1 \
227}
228
cd33aab7
AM
229#-----------------------------------------------------------------
230# find and gzip all files in %{_mandir} and %{infodir}
231#
232# Requires: xargs, find
233#
234#%no_install_post_compress_docs 1
235%__spec_install_post_compress_docs { \
f67bd19e 236%{!?no_install_post_compress_docs:__spec_install_post_compress_docs() { \
89f18684 237 echo "Compress man and info pages."; \
cd33aab7
AM
238 for i in /usr/share/man /usr/X11R6/man /usr/share/info; do \
239 if [ -d "$RPM_BUILD_ROOT$i" ]; then \
240 find "$RPM_BUILD_ROOT$i" -name \*.bz2 -print | xargs -r %{__bzip2} -df; \
241 find "$RPM_BUILD_ROOT$i" -name \*.gz -print | xargs -r %{__gzip} -dnf; \
242 find "$RPM_BUILD_ROOT$i" -type f -print | xargs -r %{__gzip} -9nf; \
243 fi; \
244 done; \
f67bd19e 245}; __spec_install_post_compress_docs } }
cd33aab7
AM
246
247#-----------------------------------------------------------------
248# Strip executable binaries and shared object files
249#
250# Requires: find, awk, strip, cut, xargs
251#
252#%no_install_post_strip 1
253%__spec_install_post_strip {%{!?debug: \
f67bd19e 254%{!?no_install_post_strip:__spec_install_post_strip() { \
31b569b6 255 if [ -d "$RPM_BUILD_ROOT" ]; then \
5b0f0ac9 256 echo "Strip executable binaries, archives and shared object files."; \
1fcb29e9 257 filelist=`find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*" ! -regex ".*/usr/lib[0-9]*/debug/.*\.debug" %{?_noautostrip:! -regex "%{_noautostrip}"}`; \
cd33aab7
AM
258 elfexelist=`echo $filelist | xargs -r file | \
259 awk '/ELF.*executable/ {print $1}' | cut -d: -f1`; \
260 elfsharedlist=`echo $filelist | xargs -r file | \
261 awk '/LF.*shared object/ {print $1}' | cut -d: -f1`; \
5b0f0ac9
MM
262 elfarchiveslist=`echo $filelist | xargs -r file | \
263 awk '/current ar archive/ {print $1}' | cut -d: -f1`; \
cd33aab7 264 if [ -n "$elfexelist" ]; then \
aaa1486f 265 %{__strip} --remove-section=.note --remove-section=.comment $elfexelist; \
cd33aab7
AM
266 fi; \
267 if [ -n "$elfsharedlist" ]; then \
aaa1486f 268 %{__strip} --strip-unneeded --remove-section=.note --remove-section=.comment $elfsharedlist; \
5b0f0ac9
MM
269 fi; \
270 if [ -n "$elfarchiveslist" ]; then \
aaa1486f 271 %{__strip} --strip-debug --remove-section=.note --remove-section=.comment $elfarchiveslist; \
f80cefa3 272 fi; \
f67bd19e 273fi; }; __spec_install_post_strip } } }
31b569b6 274
cc545e1a 275#-----------------------------------------------------------------
276# remove all RPATH from executable binaries and shared object files
277#
278# Requires: find, awk, cut, xargs, chrpath, uname
279#
280#%no_install_post_chrpath 1
281%__spec_install_post_chrpath {%{!?debug: \
f67bd19e 282%{!?no_install_post_chrpath: __spec_install_post_chrpath() { \
f80cefa3 283if [ -d "$RPM_BUILD_ROOT" ]; then \
cc545e1a 284echo "Remove RPATH from executable binaries and shared object files."; \
d274a19d 285find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*" ! -regex ".*/usr/lib[0-9]*/debug/.*" %{?_noautochrpath:! -regex "%{_noautochrpath}"} | xargs -r file | \
3d66db15 286 awk '/ELF.*(executable.*dynamically linked|shared object)/ {print $1}' | cut -d: -f1 | \
cc545e1a 287while read file ; do \
288 rpath= ; \
289 chmod u+w "$file"; \
290 for dir in `chrpath -l "$file" | \
31b569b6 291 awk '/RPATH=/ { gsub(/.*RPATH=/,""); gsub(/:/," "); print $0 }'` ; do \
cc545e1a 292 case $dir in \
570a0c29 293 /home/* | /tmp/* | /usr/lib | /usr/lib64 | /lib | /lib64 | /usr/local/lib | /usr/local/lib64 | /usr/X11R6/lib | /usr/X11R6/lib64 ) \
cc545e1a 294 echo "remove-rpath: $dir in $file"; \
295 ;; \
296 * ) \
297 if [ "$rpath" = "" ] ; then rpath="$dir" ; \
298 else rpath="$rpath:$dir" ; fi ; \
299 ;; \
300 esac ; \
301 done ; \
302 if [ "$rpath" = "" ] ; then chrpath -d "$file" > /dev/null ; \
303 else chrpath -r "$rpath" "$file" > /dev/null ; fi ; \
f80cefa3 304done; \
f67bd19e 305fi; }; __spec_install_post_chrpath } } }
31b569b6 306
22a54b3e 307#-----------------------------------------------------------------
93b46c00 308# Find and gzip all kernel modules
309#
310# Requires: find
311#
312#%no_install_post_compress_modules 1
313%__spec_install_post_compress_modules { \
f67bd19e 314%{!?no_install_post_compress_modules: __spec_install_post_compress_modules() { \
31b569b6
ER
315 if [ -d "$RPM_BUILD_ROOT" ]; then \
316 echo "Compress kernel modules if any."; \
317 if test -d $RPM_BUILD_ROOT/lib/modules ; then \
318 find $RPM_BUILD_ROOT/lib/modules -name \*o -type f -print | \
319 xargs -r %{__gzip} -9nf; \
320 find $RPM_BUILD_ROOT/lib/modules -name \*o -type l -printf "%p %l\n" | \
321 while read a b; do ln -sf $b.gz $a.gz; rm -f $a; done; \
322 fi; \
323 fi; \
f67bd19e 324}; __spec_install_post_compress_modules } }
cd33aab7 325
e4d71427
ER
326# Remove common Perl files we don't package
327%__spec_install_post_perl_clean {\
328%{!?no_install_post_perl_clean: \
329%{?pdir:rm -f $RPM_BUILD_ROOT{%{perl_archlib}/perllocal.pod,%{perl_vendorarch}/auto/%{pdir}%{?pnam:/%(echo %{pnam} | tr - /)}/.packlist}} \
330} }
331
aad1c8e4 332#-----------------------------------------------------------------
cc6c554c 333# Update GConf2 schemas
aad1c8e4 334#
335# Requires: GConf2
336#
5b8ed3c0 337%gconf_schema_install() \
31b569b6
ER
338 umask 022; \
339 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 \
340 %{nil}
5b8ed3c0 341
342%gconf_schema_uninstall() \
429d047e 343if [ $1 = 0 ]; then \
31b569b6
ER
344 umask 022; \
345 GCONF_CONFIG_SOURCE="xml:readwrite:/etc/gconf/gconf.xml.defaults" /usr/bin/gconftool-2 --makefile-uninstall-rule /etc/gconf/schemas/%{?1} > /dev/null \
429d047e 346fi \
347%{nil}
348
349#-----------------------------------------------------------------
350# Update desktop MIME database
96999189 351# requires: desktop-file-utils
429d047e 352#
9ba5542a 353%update_desktop_database_post() {{ \
429d047e 354 umask 022; \
355 /usr/bin/update-desktop-database; \
17c49976 356}}
429d047e 357
38267983 358%update_desktop_database_postun() {{ \
429d047e 359if [ $1 = 0 ]; then \
360 umask 022; \
361 /usr/bin/update-desktop-database; \
362fi \
17c49976 363}}
429d047e 364
365#-----------------------------------------------------------------
366# Update scrollkeeper database
367# requires: scrollkeeper
368#
369%scrollkeeper_update_post() \
429d047e 370 /usr/bin/scrollkeeper-update -q; \
371 %{nil}
372
373%scrollkeeper_update_postun() \
374if [ $1 = 0 ]; then \
429d047e 375 /usr/bin/scrollkeeper-update -q; \
376fi \
377%{nil}
378
379#-----------------------------------------------------------------
380# Run ldconfig after installing/deinstalling libraries
381#
382%ldconfig_post() \
383 /sbin/ldconfig; \
384 %{nil}
385
386%ldconfig_postun() \
429d047e 387 /sbin/ldconfig; \
bbc02b2d 388 %{nil}
aad1c8e4 389
cd33aab7
AM
390#-----------------------------------------------------------------
391# post %install sequence:
392# - autodeps exceptions
393# - compress all man and info pages,
394# - strip all ELF executables and ELF shared objects if not %debug.
5b0f0ac9 395# - compress kernel modules if any
cd33aab7
AM
396
397###################################################################
398# Requires/Provides automation
399# exceptions system by Jacek Konieczny <jajcus@pld.org.pl>
a4852742 400#
fbbdca08
JB
401%__noautoreqfiles %(sed -e s'/#.*//' /etc/rpm/noautoreqfiles)%{?_noautoreqfiles: %{_noautoreqfiles}}
402%__noautoprovfiles %(sed -e s'/#.*//' /etc/rpm/noautoprovfiles)%{?_noautoprovfiles: %{_noautoprovfiles}}
403%__noautoreq %(sed -e s'/#.*//' /etc/rpm/noautoreq)%{?_noautoreq: %{_noautoreq}}
404%__noautoreqdep %(sed -e s'/#.*//' /etc/rpm/noautoreqdep)%{?_noautoreqdep: %{_noautoreqdep}}
405%__noautoprov %(sed -e s'/#.*//' /etc/rpm/noautoprov)%{?_noautoprov: %{_noautoprov}}
a4852742
JB
406#%_noautocompressdoc %{nil}
407#
5b0f0ac9
MM
408%_missing_doc_files_terminate_build 1%{nil}
409%_unpackaged_files_terminate_build %{nil}
4c7d3ba4 410# (X)emacs support
42b7e5ac 411%___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;}'
4c7d3ba4
AF
412%_emacs_lispdir %(emacs %___emacs_lispdir_helper)
413%_xemacs_lispdir %(xemacs %___emacs_lispdir_helper)
41a62699 414
984f6de6
JK
415%__php_provides %{nil}
416%__php_requires %{nil}
417%__perl_provides %{nil}
418%__perl_requires %{nil}
63b0a9d7 419%__mono_provides %{nil}
420%__mono_requires %{nil}
41a62699
AF
421
422# Perl specific macro definitions.
23c8318b
ER
423%perl_privlib %(eval "`%{__perl} -V:installprivlib`"; echo $installprivlib)
424%perl_archlib %(eval "`%{__perl} -V:installarchlib`"; echo $installarchlib)
425%perl_vendorlib %(eval "`%{__perl} -V:installvendorlib`"; echo $installvendorlib)
942c693c 426%perl_vendorarch %(eval "`%{__perl} -V:installvendorarch`"; echo $installvendorarch)
23c8318b
ER
427%perl_sitelib %(eval "`%{__perl} -V:installsitelib`"; echo $installsitelib)
428%perl_sitearch %(eval "`%{__perl} -V:installsitearch`"; echo $installsitearch)
41a62699 429
cb84f517 430# Ruby
75368847
ER
431%ruby_archdir %(ruby -r rbconfig -e 'print Config::CONFIG["archdir"]' 2>/dev/null || echo ERROR)
432%ruby_ridir %(ruby -r rbconfig -e 'include Config; print File.join(CONFIG["datadir"], "ri", CONFIG["ruby_version"], "system")' 2>/dev/null || echo ERROR)
433%ruby_rubylibdir %(ruby -r rbconfig -e 'print Config::CONFIG["rubylibdir"]' 2>/dev/null || echo ERROR)
434%ruby_sitearchdir %(ruby -r rbconfig -e 'print Config::CONFIG["sitearchdir"]' 2>/dev/null || echo ERROR)
435%ruby_sitelibdir %(ruby -r rbconfig -e 'print Config::CONFIG["sitelibdir"]' 2>/dev/null || echo ERROR)
436%ruby_version %(ruby -r rbconfig -e 'print Config::CONFIG["ruby_version"]' 2>/dev/null || echo ERROR)
5483bb35
ER
437%ruby_ver_requires_eq Requires: ruby(ver) = %ruby_version
438%ruby_mod_ver_requires_eq Requires: ruby-modules(ver) = %ruby_version
cb84f517 439
942c693c 440%php_pear_dir %{_datadir}/pear
41a62699 441
6b2157a6
ER
442# directory where php includes are installed on system.
443%__php_includedir /usr/include/php
f73da51b 444# extract php/zend api versions
09fac83f 445%php_major_version %(awk '/#define PHP_MAJOR_VERSION/{print $3}' %{__php_includedir}/main/php_version.h 2>/dev/null || echo ERROR)
6b2157a6 446%php_api_version %(awk '/#define PHP_API_VERSION/{print $3}' %{__php_includedir}/main/php.h 2>/dev/null || echo ERROR)
ab8d73ee 447%php_debug %(awk '/#define ZEND_DEBUG/{print $3}' %{__php_includedir}/main/php_config.h 2>/dev/null || echo ERROR)
6b2157a6
ER
448%zend_module_api %(awk '/#define ZEND_MODULE_API_NO/{print $3}' %{__php_includedir}/Zend/zend_modules.h 2>/dev/null || echo ERROR)
449%zend_extension_api %(awk '/#define ZEND_EXTENSION_API_NO/{print $3}' %{__php_includedir}/Zend/zend_extensions.h 2>/dev/null || echo ERROR)
ea702d15 450%zend_zts %(Z=$(grep -sc '^#define ZTS 1' %{__php_includedir}/main/php_config.h); echo ${Z:-ERROR})
6b2157a6
ER
451
452# helper macro
e255dfdc 453%__php_api_requires(v:) Requires: php%{-v*}(%{expand:%1}) = %{expand:%{%{!?2:%{1}}%{?2}}}
6b2157a6
ER
454
455# macros for public use
456# for php extensions (php-pecl)
ab8d73ee 457%requires_php_extension %{__php_api_requires modules_api php_api_version} \
e255dfdc
ER
458%{__php_api_requires -v %php_major_version debug php_debug} \
459%{__php_api_requires -v %php_major_version thread-safety zend_zts}
ab8d73ee 460
6b2157a6
ER
461# for zend extensions
462%requires_zend_extension %{__php_api_requires zend_module_api} \
ab8d73ee 463%{__php_api_requires zend_extension_api} \
e255dfdc
ER
464%{__php_api_requires -v %php_major_version debug php_debug} \
465%{__php_api_requires -v %php_major_version thread-safety zend_zts}
6b2157a6 466
41a62699
AF
467# Python specific macro definitions.
468# python main version
31b569b6 469%py_ver %(python -c "import sys; print sys.version[:3]")
41a62699
AF
470
471# directories
31b569b6
ER
472%py_prefix %(python -c "import sys; print sys.prefix")
473%py_libdir %{py_prefix}/%{_lib}/python%{py_ver}
a4f0b5e0 474%py_scriptdir %{py_prefix}/share/python%{py_ver}
31b569b6 475%py_incdir /usr/include/python%{py_ver}
a4f0b5e0
JK
476%py_sitedir %{py_libdir}/site-packages
477%py_sitescriptdir %{py_scriptdir}/site-packages
31b569b6 478%py_dyndir %{py_libdir}/lib-dynload
41a62699
AF
479
480# pure python modules compilation
31b569b6 481%py_comp python -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
41a62699 482
31b569b6 483%py_ocomp python -O -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
41a62699
AF
484
485# Software written in Python language require Python with main version
5177c7b1 486%pyrequires_eq() Requires: %1
41a62699 487
ea4b2900
AF
488# Hardlink binary identical .pyc and .pyo files
489# (idea by glen <at> pld-linux <dot> org)
490%__spec_install_post_py_hardlink {\
f67bd19e 491%{!?no_install_post_py_hardlink: __spec_install_post_py_hardlink() { \
ea4b2900
AF
492[ ! -d "$RPM_BUILD_ROOT" ] || find "$RPM_BUILD_ROOT" -name '*.pyc' | while read a; do \
493 b="$(echo $a|sed -e 's/.pyc$/.pyo/')"; \
494 if cmp -s "$a" "$b"; then \
495 ln -f "$a" "$b"; \
496 fi; \
497done \
f67bd19e 498}; __spec_install_post_py_hardlink } }
ea4b2900 499
16f6f416 500# remove python sources, so that check-files won't complain
ea4b2900
AF
501# (idea by glen <at> pld-linux <dot> org)
502%py_postclean() \
e4e8948b 503for d in %{py_sitescriptdir} %{py_sitedir} %*; do \
9ba5542a 504 [ ! -d "$RPM_BUILD_ROOT$d" ] || find "$RPM_BUILD_ROOT$d" -name '*.py' -print0 | xargs -0r -l512 rm;\
ea4b2900
AF
505done \
506%{nil}
507
67ed5b97 508# depmod macro
509%depmod() { \
fe30b3ea 510umask 022; \
67ed5b97 511if [ -e /boot/System.map-%1 ]; then \
31b569b6 512 /sbin/depmod -a -F /boot/System.map-%1 %1; \
67ed5b97 513else \
31b569b6
ER
514 if [ -e /boot/System.map ]; then \
515 /sbin/depmod -a -F /boot/System.map %1; \
516 else \
517 /sbin/depmod -a %1; \
518 fi \
67ed5b97 519fi; \
520}
521
495892af 522# XMMS specific macros
31b569b6
ER
523%xmms_prefix %(xmms-config --prefix 2>/dev/null)
524%xmms_exec_prefix %(xmms-config --exec-prefix 2>/dev/null)
525%xmms_version %(xmms-config --version 2>/dev/null)
526%xmms_datadir %(xmms-config --data-dir 2>/dev/null)
527%xmms_plugindir %(xmms-config --plugin-dir 2>/dev/null)
528%xmms_visualization_plugindir %(xmms-config --visualization-plugin-dir 2>/dev/null)
529%xmms_input_plugindir %(xmms-config --input-plugin-dir 2>/dev/null)
530%xmms_output_plugindir %(xmms-config --output-plugin-dir 2>/dev/null)
531%xmms_effect_plugindir %(xmms-config --effect-plugin-dir 2>/dev/null)
532%xmms_general_plugindir %(xmms-config --general-plugin-dir 2>/dev/null)
495892af 533
bb128216
PS
534%_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/')
535
e3618ee9 536# user/group checking macros
537#
538# Usage:
539# %userremove myuser
540#
541%userremove /usr/lib/rpm/user_group.sh user del
542%groupremove /usr/lib/rpm/user_group.sh group del
543#
544# Usage:
545# if %usertestrm myuser; then
546# /usr/sbin/userdel -r myuser
547# Note:
548# use these macros only if you need to call userdel/groupdel with
549# a non-standard option or take an extra action; otherwise use the
550# %userremove/%groupremove macros
551#
552%usertestrm /usr/lib/rpm/user_group.sh user testrm
553%grouptestrm /usr/lib/rpm/user_group.sh group testrm
13f70a2c
JK
554# user group membership management macros
555#
556# Usage:
557# %addusertogroup myuser agroup
558#
559%addusertogroup /usr/lib/rpm/user_group.sh user addtogroup
bfd9689c 560
561# banner support (useful in {pre,post}{,un} and triggers)
562#
563# Usage:
a980efc1 564# %banner name [-a] [-e] [-n] [-tn] <<EOF
bfd9689c 565# the banner text, the banner text
a980efc1
ER
566# the banner text, and following line
567#EOF
568# You can use any form of here-document, <<'EOF' <<-EOT will do.
569# NOTE: if your use "<<-EOF", then You can actually indent inside here-document.
570#
bfd9689c 571# -a - append to the banner
fb033326 572# -e - send to stderr instead of stdout
1257c400 573# -n - no show banner (overrides -t)
574# -t - show only, if RPM_SCRIPTVERBOSITY >= n; default n=5
a980efc1 575%banner(aent:) \
f1bbc6ff 576RPM_SCRIPTVERBOSITY=5 \
577[ -r /etc/sysconfig/rpm ] && . /etc/sysconfig/rpm \
578if [ -x /usr/bin/banner.sh ]; then \
a980efc1 579 CMD="/usr/bin/banner.sh %{-e:--stderr} %{!-n:$([ $RPM_SCRIPTVERBOSITY -ge %{-t:%{-t*}}%{!-t:5} ] && echo -s)} %{!-a:-m}%{-a:-M} %1" \
f1bbc6ff 580else \
fb033326 581 CMD="cat%{-e: >&2}" \
f1bbc6ff 582fi \
f9cf2bf7 583eval $CMD %2%{?3: %3} \
bfd9689c 584%nil
1257c400 585
29c5556c
ER
586# useradd/groupadd macros written by glen@pld-linux.org.
587# All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
588#
589# Usage:
590# %useradd [-P package] [-u uid] [-d home_dir] [-s shell] [-c comment]
591# [-g initial_group] [-G group[,...]] login
592#
593# -u uid. REQUIRED
594# -g gid/group. REQUIRED
595# -s defaults to /bin/false
596# -d defaults to /usr/share/empty
597# -c No default
598# -r is accepted but ignored (it's always set)
6eb25d5d 599# -k skeleton dir. defaults to /usr/share/empty
29c5556c
ER
600# rpm specific flags
601# -P package name. defaults to %{name}
602#
29c5556c 603%useradd(c:d:e:f:g:G:Mmk:op:s:u:rP:) \
0044d46f
ER
604%{!-u:%{error:useradd: Required argument -u missing}} \
605%{!-g:%{error:useradd: Required argument -g missing}} \
606%{!?1:%{error:useradd: Required parameter login missing}} \
29c5556c
ER
607if [ -n "`/bin/id -u %{expand:%{%{#}}} 2>/dev/null`" ]; then \
608 if [ "`/bin/id -u %{expand:%{%{#}}}`" != "%{-u*}" ]; then \
609 echo "Error: user %{expand:%{%{#}}} doesn't have uid=%{-u*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
610 exit 1 \
611 fi \
612else \
613 echo "Adding user %{expand:%{%{#}}} UID=%{-u*}." \
614 /usr/sbin/useradd \\\
cc333c8b 615 %{-m:-m -k %{-k*}%{!-k:/usr/share/empty}} \\\
29c5556c
ER
616 -u %{-u*} \\\
617 -r \\\
618 -d %{-d*}%{!-d:/usr/share/empty} \\\
619 -s %{-s*}%{!-s:/bin/false} \\\
85e3e9a1 620 %{-c:-c "%(set -- %{-c*} %{*}; echo $1)"}\\\
29c5556c
ER
621 -g %{-g*} \\\
622 %{-M} \\\
623 %{-G:-G %{-G*}} \\\
6750d9f5
ER
624 %{expand:%{%{#}}} 1>&2 || exit $? \
625 [ ! -x /usr/sbin/nscd ] || /usr/sbin/nscd -i passwd \
29c5556c
ER
626fi;
627
29c5556c
ER
628# Usage:
629# %groupadd [-P package] [-g gid] group
630#
631# -g gid. REQUIRED
632#
633# Sample:
634# %groupadd -P %{name}-base -g %{gid} %{name}
635
636%groupadd(g:P:rfo) \
0044d46f
ER
637%{!-g:%{error:groupadd: Required argument -g missing}} \
638%{!?1:%{error:groupadd: Required parameter group missing}} \
29c5556c
ER
639if [ -n "`/usr/bin/getgid %{1}`" ]; then \
640 if [ "`/usr/bin/getgid %{1}`" != "%{-g*}" ]; then \
641 echo "Error: group %{1} doesn't have gid=%{-g*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
642 exit 1 \
643 fi \
644else \
645 echo "Adding group %{1} GID=%{-g*}." \
6750d9f5
ER
646 /usr/sbin/groupadd -g %{-g*} -r %{1} 1>&2 || exit $? \
647 [ ! -x /usr/sbin/nscd ] || /usr/sbin/nscd -i group \
29c5556c 648fi;
053b8de1
ER
649
650# apache_config_{install/uninstall} macros written by glen@pld-linux.org.
651# All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
652#
dd4e969a
ER
653# You should use webapp macros instead. these are here until single piece of them is gone from specs ;)
654#
053b8de1
ER
655# The config is installed/removed inside trigger, this means that you can any
656# time install apache1 or apache package and the configuration file is updated.
657# if you don't need the config for various reason for specific apache, just
658# remove the symlink from apache config directory. the trigger will not put the
659# config again to that version of apache. In other words the config is linked
660# to apache config directory on first install of PACKAGE or apache.
661#
662# should be called in trigger body:
663# %triggerin -- apache1 >= 1.3.33-2
664# %apache_config_install -v 1
665#
666# Add package's apache config to apache config.
667#
668# Usage:
669# %apache_config_install -v {1|2} -c %{_sysconfdir}/apache-%{name}.conf -n 99
670#
671# -v REQUIRED: specify apache version. can be 1 or 2.
672# -c OPTIONAL: specify full path to PACKAGE's config. Defaults to %{_sysconfdir}/apache-%{name}.conf.
673# -n OPTIONAL: specify config "slot". defaults to 99
22d9c327 674# -f OPTIONAL: force symlink creation regardless if package was upraded. useful in triggers
053b8de1
ER
675#
676# Internal macros. don't use ;).
677# expands apache config dir by apache version at build time.
678%__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)
679# expands apache service name by apache version at build time.
680%__apache_svcname() %(if [ %{1} = 1 ]; then echo apache; elif [ %{1} = 2 ]; then echo httpd; else echo >&2 Unknown apache version specified; fi)
681
22d9c327 682%apache_config_install(fv:c:n:) \
053b8de1
ER
683%{!-v:%{error:apache_config_install: Required argument -v missing}} \
684%{?debug:set -x; echo "apache_config_install:%{-v*} %{name}-%{version}-%{release} 1:[$1]; 2:[$2]"} \
22d9c327 685if [ -n "%{-f:1}" ] || ([ "$1" = "1" ] && [ "$2" = "1" ]) && [ -d %{__apache_confdir %{-v*}} ]; then\
053b8de1
ER
686 ln -sf %{-c*}%{!-c:%{_sysconfdir}/apache-%{name}.conf} %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf\
687fi\
7e4c6837 688# reload apache if the config symlink is there\
1d90410b 689if [ -L %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf ]; then\
71d37358
ER
690 # additionally don't reload if target package (the webserver) is upgraded, as webserver is restarted anyway in %post \
691 if [ "$2" != "2" ] && [ -f /var/lock/subsys/%{__apache_svcname %{-v*}} ]; then\
7e4c6837 692 /etc/rc.d/init.d/%{__apache_svcname %{-v*}} reload 1>&2\
053b8de1
ER
693 fi\
694fi\
695%{nil}
696
697# Remove package's apache config from apache config.
698#
699# Usage:
700# %apache_config_uninstall -v {1|2} -n 99
701#
702# -v REQUIRED: specify apache version. can be 1 or 2.
703# -n OPTIONAL: specify config "slot". defaults to 99
704%apache_config_uninstall(v:n:) \
705%{!-v:%{error:apache_config_uninstall: Required argument -v missing}} \
706%{?debug:set -x; echo "apache_config_uninstall:%{-v*} %{name}-%{version}-%{release}: 1:[$1]; 2:[$2]"} \
9e0d77bc 707# remove link if either of the packages are gone \
053b8de1
ER
708if [ "$1" = "0" ] || [ "$2" = "0" ]; then \
709 if [ -L %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf ]; then \
710 rm -f %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf \
711 if [ -f /var/lock/subsys/%{__apache_svcname %{-v*}} ]; then \
7e4c6837 712 /etc/rc.d/init.d/%{__apache_svcname %{-v*}} reload 1>&2 \
053b8de1
ER
713 fi \
714 fi \
715fi \
716%{nil}
717
55a50f1a 718# webapp macros
ba42a822
ER
719#
720# The config is installed/removed inside trigger, this means that you can any
721# time install apache1/apache/lighttpd package and the configuration file is
722# updated. if you don't need the config for various reason for specific
723# webserver, just remove the symlink from config directory using webapp
724# program. the trigger will not recreate the symlink on upgrades. In other
725# words the config is linked to webserver config directory on first install of
726# PACKAGE or WEBSERVER.
727#
55a50f1a
ER
728# Add package's webserver config to webserver webapps dir.
729# Usage:
217f2cb2 730# %webapp_register WEBSERVER WEBAPP
ba42a822
ER
731#
732%webapp_register() \
733%{?debug:set -x; echo "webapp_register: %{name}-%{version}-%{release} 1:[$1]; 2:[$2]"} \
734if [ "$1" = "1" ] && [ "$2" = "1" ]; then\
735 /usr/sbin/webapp register %1 %2\
736fi\
973c1dc7 737# reload webserver if the config symlink is there and skip reload if webserver is upgraded\
57ff17b4 738if [ -L /etc/%1/webapps.d/%2.conf ] && [ "$2" -lt "2" ]; then\
5f0b2e29 739 %{expand:%service -q %%1 reload}\
ba42a822
ER
740fi\
741%{nil}
742
743# Remove package's config from webserver webapps dir.
ba42a822 744# Usage:
b9588fe6
ER
745# %webapp_register [-f] WEBSERVER WEBAPP
746%webapp_unregister(f) \
ba42a822
ER
747%{?debug:set -x; echo "webapp_unregister: %{name}-%{version}-%{release}: 1:[$1]; 2:[$2]"} \
748# remove link if either of the packages are gone \
b9588fe6 749if [ -n "%{-f:1}" ] || [ "$1" = "0" ] || [ "$2" = "0" ] && [ -L /etc/%1/webapps.d/%2.conf ]; then \
217f2cb2 750 /usr/sbin/webapp unregister %1 %2\
5f0b2e29 751 %{expand:%service -q %%1 reload}\
ba42a822
ER
752fi \
753%{nil}
754
745c4676
ER
755# see browser-plugins.spec / template-browser-plugin.spec
756# written by glen@pld-linux.org.
f6565dd0 757%nsplugin_install(d:f) { \
745c4676 758# create link if it's first install of either of the packages \
f6565dd0 759if [ -n "%{-f:1}" ] || ([ "$1" = "1" ] && [ "$2" = "1" ] && [ -d %{-d*} ]); then \
745c4676
ER
760( \
761%( \
762 for file in %{*}; do \
763 echo echo Installing $file to %{-d*}; \
764 echo "ln -sf %{_libdir}/browser-plugins/$file %{-d*};"; \
765 done ) \
766) | ( %banner -t 5 -e %{name}-in ); fi; \
767}
768
3e680cb6 769%nsplugin_uninstall(d:) { \
745c4676
ER
770# remove link if either of the packages are gone \
771if [ "$1" = "0" ] || [ "$2" = "0" ]; then \
772( \
773%( \
774 for file in %{*}; do \
775 echo echo Removing $file from %{-d*}; \
776 echo "rm -f %{-d*}/$file;"; \
777 done ) \
778) | ( %banner -t 5 -e %{name}-un ); fi; \
779}
8edf8498
ER
780
781# service macro.
782#
783# calls usual service restart on package %post, but skips the restart if
784# administrator has disabled automatic service restarts in either global
785# /etc/sysconfig/rpm or per service /etc/sysconfig/SERVICE file.
786#
787# written by glen@pld-linux.org.
788# All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
789#
790# Usage:
524e081b 791# %service [-q] SERVICE ACTION ["SERVICE NICE DESCRIPTION"]
8edf8498 792#
dd4e969a 793# -q be silent when service isn't started (for scriplets restaring other package's services)
8edf8498 794#
e42cbd35 795%service(q) {{%(export quiet=%{-q:1}; /usr/lib/rpm/service_generator.sh %{*}) };}
This page took 0.244105 seconds and 4 git commands to generate.