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