]> git.pld-linux.org Git - packages/rpm-build-macros.git/blame - rpm.macros
- avoid compressing very small (manual) pages
[packages/rpm-build-macros.git] / rpm.macros
CommitLineData
397b586d 1# $Revision$, $Date$
d54662bf
AF
2# PLD rpm macros
3
e05017c1 4%epoch 0
3241033b 5%x8664 x86_64 amd64 ia32e
9c404149 6
ba1fdedc 7# kernel compiler
345d14e5 8%kgcc %{__cc}
d2e1bc22 9%kgcc_package gcc
ba1fdedc 10
33040789 11# Build system path macros.
12#
bddadece
JB
13%__autoconf autoconf %{?debug:-Wall}
14%__automake automake -a -c -f --foreign
f93109a0 15%__autopoint autopoint --force
16
83094b62 17%__gettextize { \
3241033b 18if ! gettextize --version | grep -q '0\.10\.' ; then \
8a995cff 19 if grep -qs 'AM_GNU_GETTEXT.*external' configure.{ac,in} ; then \
3241033b 20 gettextize --copy --force --no-changelog; \
97589b6e 21 else \
3241033b 22 gettextize --copy --force --no-changelog --intl; \
8a995cff
JB
23 fi; \
24 if [ ! -f po/Makevars ]; then \
3241033b 25 cp -f po/Makevars{.template,}; \
8a995cff 26 fi; \
3241033b 27else \
8a995cff 28 gettextize --copy --force; \
3241033b 29fi; \
8a995cff 30}
f93109a0 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
33040789 37
81e450f7
ER
38# The number of cvs changelog entries kept when building package.
39%_buildchangelogtruncate 20
40
6a5eda77 41%dependencytracking %{nil}
3241033b 42
e5da9169
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
9c404149 53#-----------------------------------------------------------------
9f4ce098 54%configure2_13 { \
9c404149
AM
55 if [ -n "$LINGUAS" ]; then unset LINGUAS; fi; \
56 LDFLAGS="${LDFLAGS:-%rpmldflags}" ; export LDFLAGS ; \
57 CFLAGS="${CFLAGS:-%rpmcflags}" ; export CFLAGS ; \
f4cc8832 58 CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" ; export CXXFLAGS ; \
9c404149 59 FFLAGS="${FFLAGS:-%rpmcflags}" ; export FFLAGS ; \
8ec1a12b 60 CPPFLAGS="${CPPFLAGS:-}" ; export CPPFLAGS ; \
8983c4c4
AM
61 %{?__cc:CC="%{__cc}" ; export CC ; } \
62 %{?__cxx:CXX="%{__cxx}" ; export CXX ; } \
8f74418b 63 %{?configuredir:%{configuredir}}%{!?configuredir:.}/configure \
2a7cfd3f 64 --host=%{_target_platform} \
9c404149
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} \
b6c5da52 78 --x-libraries=%{?_x_libraries}%{!?_x_libraries:%{_libdir}} \
93059874 79 %{dependencytracking} \
9c404149
AM
80}
81
39b9534b
ER
82%cmake { \
83CC="%{__cc}" \
84CXX="%{__cxx}" \
85CFLAGS="%{rpmcflags}" \
86CXXFLAGS="%{rpmcxxflags}" \
87cmake \
88}
89
4a6b0d54 90#----------------------------------------------------------------
73f832b3 91%global configure_cache 0
fe6c4bdd 92%configure_cache_file %{buildroot}.configure.cache
73f832b3 93
57f4166d 94%configure {./configure \
4a6b0d54
AF
95 LDFLAGS="${LDFLAGS:-%rpmldflags}" \
96 CFLAGS="${CFLAGS:-%rpmcflags}" \
f4cc8832 97 CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" \
4a6b0d54 98 FFLAGS="${FFLAGS:-%rpmcflags}" \
a2bd5992 99 CPPFLAGS="${CPPFLAGS:-}" \
8983c4c4
AM
100 %{?__cc:CC="%{__cc}"} \
101 %{?__cxx:CXX="%{__cxx}"} \
8e4cb85a 102 --host=%{_target_platform} \
4a6b0d54
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} \
b6c5da52 117 --x-libraries=%{?_x_libraries}%{!?_x_libraries:%{_libdir}} \
93059874 118 %{dependencytracking} \
73f832b3 119 %{?configure_cache:--cache-file=%{configure_cache_file:-%{buildroot}.configure.cache}} \
4a6b0d54
AF
120}
121
7dbab518 122# ------------------------------------------------------------------------
c80506a3
AM
123# Overloading of some basic macros
124%prep \
125%%prep\
126LANG=C\
127export LANG\
14e77e64 128unset DISPLAY ||:\
6db5639d 129unset LINGUAS ||:\
c80506a3
AM
130%{nil}
131
132%build %%build\
133LANG=C\
134export LANG\
14e77e64 135unset DISPLAY ||:\
6db5639d 136unset LINGUAS ||:\
c80506a3
AM
137%{nil}
138
b4e3d367
ER
139%install \
140%if 0%{?_enable_debug_packages}\
141%{?buildsubdir:%{debug_package}}\
142%endif\
c80506a3
AM
143%%install\
144LANG=C\
145export LANG\
14e77e64 146unset DISPLAY ||:\
6db5639d 147unset LINGUAS ||:\
c80506a3
AM
148%{nil}
149
9c404149
AM
150# Location of autoconf macros
151%_aclocaldir %(aclocal --print-ac-dir)
152
e2804f99
AM
153# Location of omf files
154%_omf_dest_dir %(scrollkeeper-config --omfdir)
155
e987a186 156# Location of pkgconfig files
9a4e877a 157%_pkgconfigdir /usr/%{_lib}/pkgconfig
e987a186 158
486b0b5f 159# Location of desktop files
160%_desktopdir /usr/share/applications
86dff2d0 161%_applnkdir ERROR:_applnkdir_is_obsolete_use_desktopdir_instead
486b0b5f 162
481463e9 163# Location of pixmaps for applnk/desktop files
e1f0a822 164%_pixmapsdir /usr/share/pixmaps
9c404149 165
481463e9 166# Location of themable icons for applnk/desktop files
b36c8e2a 167%_iconsdir /usr/share/icons
168
e987a186
JB
169# Location of fonts directories
170%_fontsdir /usr/share/fonts
171
b3282f3f 172# Location of Gtk and associated libraries documentation
fe6c4bdd 173%_gtkdocdir %{_defaultdocdir}/gtk-doc/html
b3282f3f 174
fc4d7771 175# Location of KDE documentation
fe6c4bdd 176%_kdedocdir %{_defaultdocdir}/kde/HTML
fc4d7771 177
5869828c 178# unsermake script
179%__unsermake /usr/share/unsermake/unsermake
180
9c404149
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
c8f7e820 190# Alternative kernel type/version
191%alt_kernel %{nil}%{?_alt_kernel:-%{?_alt_kernel}}
192
8377d27d 193# The directory holding Linux kernel sources
c8f7e820 194%_kernelsrcdir /usr/src/linux%{alt_kernel}
8377d27d 195
9c404149 196# If non-empty "debug" macro defined, add "dbg" suffix to release number
8f74418b 197%_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}%{?debug:dbg}.%%{ARCH}.rpm
9c404149 198
8f74418b 199# Requires name = version-release
ec4e8b11 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")
8bf3719d 201
fe6c4bdd
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
a0bbe604 205%requires_releq_kernel_smp(s:) Requires%{-s:(%{-s*})}: %releq_kernel_smp
8bf3719d 206
47935449 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")
16cb1d91 208%requires_eq_to() %(LC_ALL="C" rpm -q --qf 'Requires: %1 = %%{epoch}:%%{version}\\n' %2 | sed -e 's/ (none):/ /' | grep -v "is not")
01a9f990 209
c0b2771b 210%apache_modules_api %(awk '/#define MODULE_MAGIC_NUMBER_MAJOR/ {print $3}' /usr/include/apache/ap_mmn.h 2>/dev/null || echo ERROR)
b9d5d440 211
212# kernel version-release handling
3241033b
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")
fe6c4bdd 215%__kernel_rpmvr %(LC_ALL="C" rpm -qf %{_kernelsrcdir}/include/linux/fs.h 2>/dev/null --qf "%{VERSION}-%{RELEASE}" | grep -v "is not")
3241033b 216%_kernel_ver %{__kernel_ver}%{?with_dist_kernel:%(echo %{__kernel_ver} | grep -q -e - || echo -%{__kernel_rel})}
f62e856d 217%_kernel_ver_str %(echo %{!?_without_dist_kernel:%{__kernel_rpmvr}}%{?_without_dist_kernel:%{__kernel_ver}} | sed -e 's/-/_/g')
87be1cf0 218
e00dd7f6 219# sgml macros
3241033b
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 ;
e00dd7f6 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
4f044018
ER
237# minimum file size needed for compressed documents.
238# just smaller files than this get larger when compressed.
239# current number is based from experiment that 0 byte file compressed was 25 bytes .gz
240%_min_compress_bytes 25
241
9c404149
AM
242#-----------------------------------------------------------------
243# find and gzip all files in %{_mandir} and %{infodir}
244#
245# Requires: xargs, find
246#
247#%no_install_post_compress_docs 1
248%__spec_install_post_compress_docs { \
53d5af13 249%{!?no_install_post_compress_docs:__spec_install_post_compress_docs() { \
822d4d81 250 echo "Compress man and info pages."; \
9c404149
AM
251 for i in /usr/share/man /usr/X11R6/man /usr/share/info; do \
252 if [ -d "$RPM_BUILD_ROOT$i" ]; then \
4f044018
ER
253 find "$RPM_BUILD_ROOT$i" -name '*.bz2' -print | xargs -r %{__bzip2} -df; \
254 find "$RPM_BUILD_ROOT$i" -name '*.gz' -print | xargs -r %{__gzip} -dnf; \
255 find "$RPM_BUILD_ROOT$i" -type f -size +%{_min_compress_bytes}c -print | xargs -r %{__gzip} -9nf; \
9c404149
AM
256 fi; \
257 done; \
53d5af13 258}; __spec_install_post_compress_docs } }
9c404149
AM
259
260#-----------------------------------------------------------------
261# Strip executable binaries and shared object files
262#
263# Requires: find, awk, strip, cut, xargs
264#
265#%no_install_post_strip 1
266%__spec_install_post_strip {%{!?debug: \
53d5af13 267%{!?no_install_post_strip:__spec_install_post_strip() { \
3241033b 268 if [ -d "$RPM_BUILD_ROOT" ]; then \
8f74418b 269 echo "Strip executable binaries, archives and shared object files."; \
b4e3d367 270 filelist=`find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*" ! -regex ".*/usr/lib[0-9]*/debug/.*\.debug" %{?_noautostrip:! -regex "%{_noautostrip}"}`; \
9c404149
AM
271 elfexelist=`echo $filelist | xargs -r file | \
272 awk '/ELF.*executable/ {print $1}' | cut -d: -f1`; \
273 elfsharedlist=`echo $filelist | xargs -r file | \
274 awk '/LF.*shared object/ {print $1}' | cut -d: -f1`; \
8f74418b
MM
275 elfarchiveslist=`echo $filelist | xargs -r file | \
276 awk '/current ar archive/ {print $1}' | cut -d: -f1`; \
9c404149 277 if [ -n "$elfexelist" ]; then \
fe6c4bdd 278 %{__strip} --remove-section=.note --remove-section=.comment $elfexelist; \
9c404149
AM
279 fi; \
280 if [ -n "$elfsharedlist" ]; then \
fe6c4bdd 281 %{__strip} --strip-unneeded --remove-section=.note --remove-section=.comment $elfsharedlist; \
8f74418b
MM
282 fi; \
283 if [ -n "$elfarchiveslist" ]; then \
fe6c4bdd 284 %{__strip} --strip-debug --remove-section=.note --remove-section=.comment $elfarchiveslist; \
9f0d4f36 285 fi; \
53d5af13 286fi; }; __spec_install_post_strip } } }
3241033b 287
fc5d7e20 288#-----------------------------------------------------------------
289# remove all RPATH from executable binaries and shared object files
290#
291# Requires: find, awk, cut, xargs, chrpath, uname
292#
293#%no_install_post_chrpath 1
294%__spec_install_post_chrpath {%{!?debug: \
53d5af13 295%{!?no_install_post_chrpath: __spec_install_post_chrpath() { \
9f0d4f36 296if [ -d "$RPM_BUILD_ROOT" ]; then \
fc5d7e20 297echo "Remove RPATH from executable binaries and shared object files."; \
adb39da4 298find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*" ! -regex ".*/usr/lib[0-9]*/debug/.*" %{?_noautochrpath:! -regex "%{_noautochrpath}"} | xargs -r file | \
5bed2bb7 299 awk '/ELF.*(executable.*dynamically linked|shared object)/ {print $1}' | cut -d: -f1 | \
fc5d7e20 300while read file ; do \
301 rpath= ; \
302 chmod u+w "$file"; \
303 for dir in `chrpath -l "$file" | \
3241033b 304 awk '/RPATH=/ { gsub(/.*RPATH=/,""); gsub(/:/," "); print $0 }'` ; do \
fc5d7e20 305 case $dir in \
494e368c 306 /home/* | /tmp/* | /usr/lib | /usr/lib64 | /lib | /lib64 | /usr/local/lib | /usr/local/lib64 | /usr/X11R6/lib | /usr/X11R6/lib64 ) \
fc5d7e20 307 echo "remove-rpath: $dir in $file"; \
308 ;; \
309 * ) \
310 if [ "$rpath" = "" ] ; then rpath="$dir" ; \
311 else rpath="$rpath:$dir" ; fi ; \
312 ;; \
313 esac ; \
314 done ; \
315 if [ "$rpath" = "" ] ; then chrpath -d "$file" > /dev/null ; \
316 else chrpath -r "$rpath" "$file" > /dev/null ; fi ; \
9f0d4f36 317done; \
53d5af13 318fi; }; __spec_install_post_chrpath } } }
3241033b 319
d72c185f 320#-----------------------------------------------------------------
ccb8ae8d 321# Find and gzip all kernel modules
322#
323# Requires: find
324#
fe6c4bdd 325#%no_install_post_compress_modules 1
ccb8ae8d 326%__spec_install_post_compress_modules { \
53d5af13 327%{!?no_install_post_compress_modules: __spec_install_post_compress_modules() { \
3241033b
ER
328 if [ -d "$RPM_BUILD_ROOT" ]; then \
329 echo "Compress kernel modules if any."; \
330 if test -d $RPM_BUILD_ROOT/lib/modules ; then \
331 find $RPM_BUILD_ROOT/lib/modules -name \*o -type f -print | \
332 xargs -r %{__gzip} -9nf; \
fe6c4bdd
ER
333 find $RPM_BUILD_ROOT/lib/modules -name \*o -type l -printf "%p %l\n" | \
334 while read a b; do ln -sf $b.gz $a.gz; rm -f $a; done; \
3241033b
ER
335 fi; \
336 fi; \
53d5af13 337}; __spec_install_post_compress_modules } }
9c404149 338
ef64802f
ER
339# Remove common Perl files we don't package
340%__spec_install_post_perl_clean {\
341%{!?no_install_post_perl_clean: \
342%{?pdir:rm -f $RPM_BUILD_ROOT{%{perl_archlib}/perllocal.pod,%{perl_vendorarch}/auto/%{pdir}%{?pnam:/%(echo %{pnam} | tr - /)}/.packlist}} \
343} }
344
83094b62 345#-----------------------------------------------------------------
0e4cb4dd 346# Update GConf2 schemas
83094b62 347#
348# Requires: GConf2
349#
46885239 350%gconf_schema_install() \
3241033b
ER
351 umask 022; \
352 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 \
353 %{nil}
46885239 354
355%gconf_schema_uninstall() \
f93109a0 356if [ $1 = 0 ]; then \
3241033b
ER
357 umask 022; \
358 GCONF_CONFIG_SOURCE="xml:readwrite:/etc/gconf/gconf.xml.defaults" /usr/bin/gconftool-2 --makefile-uninstall-rule /etc/gconf/schemas/%{?1} > /dev/null \
f93109a0 359fi \
360%{nil}
361
362#-----------------------------------------------------------------
363# Update desktop MIME database
c0a4caa0 364# requires: desktop-file-utils
f93109a0 365#
820792a9 366%update_desktop_database_post() {{ \
f93109a0 367 umask 022; \
368 /usr/bin/update-desktop-database; \
4565b525 369}}
f93109a0 370
09e3522b 371%update_desktop_database_postun() {{ \
f93109a0 372if [ $1 = 0 ]; then \
373 umask 022; \
374 /usr/bin/update-desktop-database; \
375fi \
4565b525 376}}
f93109a0 377
378#-----------------------------------------------------------------
379# Update scrollkeeper database
380# requires: scrollkeeper
381#
382%scrollkeeper_update_post() \
f93109a0 383 /usr/bin/scrollkeeper-update -q; \
384 %{nil}
385
386%scrollkeeper_update_postun() \
387if [ $1 = 0 ]; then \
f93109a0 388 /usr/bin/scrollkeeper-update -q; \
389fi \
390%{nil}
391
9c404149
AM
392#-----------------------------------------------------------------
393# post %install sequence:
394# - autodeps exceptions
395# - compress all man and info pages,
396# - strip all ELF executables and ELF shared objects if not %debug.
8f74418b 397# - compress kernel modules if any
9c404149
AM
398
399###################################################################
400# Requires/Provides automation
401# exceptions system by Jacek Konieczny <jajcus@pld.org.pl>
338726a6 402#
2892b5df
JB
403%__noautoreqfiles %(sed -e s'/#.*//' /etc/rpm/noautoreqfiles)%{?_noautoreqfiles: %{_noautoreqfiles}}
404%__noautoprovfiles %(sed -e s'/#.*//' /etc/rpm/noautoprovfiles)%{?_noautoprovfiles: %{_noautoprovfiles}}
405%__noautoreq %(sed -e s'/#.*//' /etc/rpm/noautoreq)%{?_noautoreq: %{_noautoreq}}
406%__noautoreqdep %(sed -e s'/#.*//' /etc/rpm/noautoreqdep)%{?_noautoreqdep: %{_noautoreqdep}}
407%__noautoprov %(sed -e s'/#.*//' /etc/rpm/noautoprov)%{?_noautoprov: %{_noautoprov}}
338726a6
JB
408#%_noautocompressdoc %{nil}
409#
8f74418b
MM
410%_missing_doc_files_terminate_build 1%{nil}
411%_unpackaged_files_terminate_build %{nil}
8781dc74 412# (X)emacs support
d77dcb61 413%___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;}'
8781dc74
AF
414%_emacs_lispdir %(emacs %___emacs_lispdir_helper)
415%_xemacs_lispdir %(xemacs %___emacs_lispdir_helper)
25043cd4 416
02b58f60
JK
417%__php_provides %{nil}
418%__php_requires %{nil}
419%__perl_provides %{nil}
420%__perl_requires %{nil}
fa3497cd 421%__mono_provides %{nil}
422%__mono_requires %{nil}
25043cd4
AF
423
424# Perl specific macro definitions.
34f59add
ER
425%perl_privlib %(eval "`%{__perl} -V:installprivlib`"; echo $installprivlib)
426%perl_archlib %(eval "`%{__perl} -V:installarchlib`"; echo $installarchlib)
427%perl_vendorlib %(eval "`%{__perl} -V:installvendorlib`"; echo $installvendorlib)
c853f847 428%perl_vendorarch %(eval "`%{__perl} -V:installvendorarch`"; echo $installvendorarch)
34f59add
ER
429%perl_sitelib %(eval "`%{__perl} -V:installsitelib`"; echo $installsitelib)
430%perl_sitearch %(eval "`%{__perl} -V:installsitearch`"; echo $installsitearch)
25043cd4 431
45c00b39 432# Ruby
c5472d67
ER
433%ruby_archdir %(ruby -r rbconfig -e 'print Config::CONFIG["archdir"]' 2>/dev/null || echo ERROR)
434%ruby_ridir %(ruby -r rbconfig -e 'include Config; print File.join(CONFIG["datadir"], "ri", CONFIG["ruby_version"], "system")' 2>/dev/null || echo ERROR)
435%ruby_rubylibdir %(ruby -r rbconfig -e 'print Config::CONFIG["rubylibdir"]' 2>/dev/null || echo ERROR)
436%ruby_sitearchdir %(ruby -r rbconfig -e 'print Config::CONFIG["sitearchdir"]' 2>/dev/null || echo ERROR)
437%ruby_sitelibdir %(ruby -r rbconfig -e 'print Config::CONFIG["sitelibdir"]' 2>/dev/null || echo ERROR)
438%ruby_version %(ruby -r rbconfig -e 'print Config::CONFIG["ruby_version"]' 2>/dev/null || echo ERROR)
669604db
ER
439%ruby_ver_requires_eq Requires: ruby(ver) = %ruby_version
440%ruby_mod_ver_requires_eq Requires: ruby-modules(ver) = %ruby_version
45c00b39 441
c853f847 442%php_pear_dir %{_datadir}/pear
25043cd4 443
c1b2705c
ER
444# directory where php includes are installed on system.
445%__php_includedir /usr/include/php
0c5d1b9b 446# extract php/zend api versions
e9b6395a 447%php_major_version %(awk '/#define PHP_MAJOR_VERSION/{print $3}' %{__php_includedir}/main/php_version.h 2>/dev/null || echo ERROR)
c1b2705c 448%php_api_version %(awk '/#define PHP_API_VERSION/{print $3}' %{__php_includedir}/main/php.h 2>/dev/null || echo ERROR)
934c685f 449%php_pdo_api_version %(awk '/#define PDO_DRIVER_API/{print $3}' %{__php_includedir}/ext/pdo/php_pdo_driver.h 2>/dev/null || echo ERROR)
68b68193 450%php_debug %(awk '/#define ZEND_DEBUG/{print $3}' %{__php_includedir}/main/php_config.h 2>/dev/null || echo ERROR)
c1b2705c
ER
451%zend_module_api %(awk '/#define ZEND_MODULE_API_NO/{print $3}' %{__php_includedir}/Zend/zend_modules.h 2>/dev/null || echo ERROR)
452%zend_extension_api %(awk '/#define ZEND_EXTENSION_API_NO/{print $3}' %{__php_includedir}/Zend/zend_extensions.h 2>/dev/null || echo ERROR)
c0ac7203 453%zend_zts %(Z=$(grep -sc '^#define ZTS 1' %{__php_includedir}/main/php_config.h); echo ${Z:-ERROR})
c1b2705c
ER
454
455# helper macro
f952c0f3 456%__php_api_requires(v:) Requires: php%{-v*}(%{expand:%1}) = %{expand:%{%{!?2:%{1}}%{?2}}}
c1b2705c
ER
457
458# macros for public use
459# for php extensions (php-pecl)
68b68193 460%requires_php_extension %{__php_api_requires modules_api php_api_version} \
f952c0f3
ER
461%{__php_api_requires -v %php_major_version debug php_debug} \
462%{__php_api_requires -v %php_major_version thread-safety zend_zts}
68b68193 463
c1b2705c
ER
464# for zend extensions
465%requires_zend_extension %{__php_api_requires zend_module_api} \
68b68193 466%{__php_api_requires zend_extension_api} \
f952c0f3
ER
467%{__php_api_requires -v %php_major_version debug php_debug} \
468%{__php_api_requires -v %php_major_version thread-safety zend_zts}
c1b2705c 469
934c685f
ER
470# for php pdo modules (php-pecl-PDO_*)
471%requires_php_pdo_module %{__php_api_requires PDO_API php_pdo_api_version}
472
25043cd4
AF
473# Python specific macro definitions.
474# python main version
3241033b 475%py_ver %(python -c "import sys; print sys.version[:3]")
25043cd4
AF
476
477# directories
3241033b
ER
478%py_prefix %(python -c "import sys; print sys.prefix")
479%py_libdir %{py_prefix}/%{_lib}/python%{py_ver}
ef7ec0a8 480%py_scriptdir %{py_prefix}/share/python%{py_ver}
3241033b 481%py_incdir /usr/include/python%{py_ver}
ef7ec0a8
JK
482%py_sitedir %{py_libdir}/site-packages
483%py_sitescriptdir %{py_scriptdir}/site-packages
3241033b 484%py_dyndir %{py_libdir}/lib-dynload
25043cd4
AF
485
486# pure python modules compilation
3241033b 487%py_comp python -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
25043cd4 488
3241033b 489%py_ocomp python -O -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
25043cd4
AF
490
491# Software written in Python language require Python with main version
e63cd81d 492%pyrequires_eq() Requires: %1
25043cd4 493
f12c2314
AF
494# Hardlink binary identical .pyc and .pyo files
495# (idea by glen <at> pld-linux <dot> org)
496%__spec_install_post_py_hardlink {\
53d5af13 497%{!?no_install_post_py_hardlink: __spec_install_post_py_hardlink() { \
f12c2314
AF
498[ ! -d "$RPM_BUILD_ROOT" ] || find "$RPM_BUILD_ROOT" -name '*.pyc' | while read a; do \
499 b="$(echo $a|sed -e 's/.pyc$/.pyo/')"; \
500 if cmp -s "$a" "$b"; then \
501 ln -f "$a" "$b"; \
502 fi; \
503done \
53d5af13 504}; __spec_install_post_py_hardlink } }
f12c2314 505
9227b3f9 506# remove python sources, so that check-files won't complain
f12c2314
AF
507# (idea by glen <at> pld-linux <dot> org)
508%py_postclean() \
0f82e280 509for d in %{py_sitescriptdir} %{py_sitedir} %*; do \
820792a9 510 [ ! -d "$RPM_BUILD_ROOT$d" ] || find "$RPM_BUILD_ROOT$d" -name '*.py' -print0 | xargs -0r -l512 rm;\
f12c2314
AF
511done \
512%{nil}
513
0fc5cff8 514# depmod macro
515%depmod() { \
f6148427 516umask 022; \
0fc5cff8 517if [ -e /boot/System.map-%1 ]; then \
3241033b 518 /sbin/depmod -a -F /boot/System.map-%1 %1; \
0fc5cff8 519else \
3241033b
ER
520 if [ -e /boot/System.map ]; then \
521 /sbin/depmod -a -F /boot/System.map %1; \
522 else \
523 /sbin/depmod -a %1; \
524 fi \
0fc5cff8 525fi; \
526}
527
2afc6e64 528# XMMS specific macros
3241033b
ER
529%xmms_prefix %(xmms-config --prefix 2>/dev/null)
530%xmms_exec_prefix %(xmms-config --exec-prefix 2>/dev/null)
531%xmms_version %(xmms-config --version 2>/dev/null)
532%xmms_datadir %(xmms-config --data-dir 2>/dev/null)
533%xmms_plugindir %(xmms-config --plugin-dir 2>/dev/null)
534%xmms_visualization_plugindir %(xmms-config --visualization-plugin-dir 2>/dev/null)
535%xmms_input_plugindir %(xmms-config --input-plugin-dir 2>/dev/null)
536%xmms_output_plugindir %(xmms-config --output-plugin-dir 2>/dev/null)
537%xmms_effect_plugindir %(xmms-config --effect-plugin-dir 2>/dev/null)
538%xmms_general_plugindir %(xmms-config --general-plugin-dir 2>/dev/null)
2afc6e64 539
d1537778
PS
540%_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/')
541
848c0d68 542# user/group checking macros
543#
544# Usage:
545# %userremove myuser
546#
547%userremove /usr/lib/rpm/user_group.sh user del
548%groupremove /usr/lib/rpm/user_group.sh group del
549#
550# Usage:
551# if %usertestrm myuser; then
552# /usr/sbin/userdel -r myuser
553# Note:
554# use these macros only if you need to call userdel/groupdel with
555# a non-standard option or take an extra action; otherwise use the
556# %userremove/%groupremove macros
557#
558%usertestrm /usr/lib/rpm/user_group.sh user testrm
559%grouptestrm /usr/lib/rpm/user_group.sh group testrm
08d9b1f6
JK
560# user group membership management macros
561#
562# Usage:
563# %addusertogroup myuser agroup
564#
565%addusertogroup /usr/lib/rpm/user_group.sh user addtogroup
72fcfcb3 566
567# banner support (useful in {pre,post}{,un} and triggers)
568#
569# Usage:
aa41c920 570# %banner name [-a] [-e] [-n] [-tn] <<EOF
72fcfcb3 571# the banner text, the banner text
aa41c920
ER
572# the banner text, and following line
573#EOF
574# You can use any form of here-document, <<'EOF' <<-EOT will do.
575# NOTE: if your use "<<-EOF", then You can actually indent inside here-document.
576#
72fcfcb3 577# -a - append to the banner
a8b9562a 578# -e - send to stderr instead of stdout
628754cb 579# -n - no show banner (overrides -t)
580# -t - show only, if RPM_SCRIPTVERBOSITY >= n; default n=5
aa41c920 581%banner(aent:) \
1b334fe4 582RPM_SCRIPTVERBOSITY=5 \
583[ -r /etc/sysconfig/rpm ] && . /etc/sysconfig/rpm \
584if [ -x /usr/bin/banner.sh ]; then \
aa41c920 585 CMD="/usr/bin/banner.sh %{-e:--stderr} %{!-n:$([ $RPM_SCRIPTVERBOSITY -ge %{-t:%{-t*}}%{!-t:5} ] && echo -s)} %{!-a:-m}%{-a:-M} %1" \
1b334fe4 586else \
a8b9562a 587 CMD="cat%{-e: >&2}" \
1b334fe4 588fi \
c2e886e1 589eval $CMD %2%{?3: %3} \
72fcfcb3 590%nil
628754cb 591
90627280
ER
592# useradd/groupadd macros written by glen@pld-linux.org.
593# All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
594#
595# Usage:
596# %useradd [-P package] [-u uid] [-d home_dir] [-s shell] [-c comment]
597# [-g initial_group] [-G group[,...]] login
598#
599# -u uid. REQUIRED
600# -g gid/group. REQUIRED
601# -s defaults to /bin/false
602# -d defaults to /usr/share/empty
603# -c No default
604# -r is accepted but ignored (it's always set)
6bd4c218 605# -k skeleton dir. defaults to /usr/share/empty
90627280
ER
606# rpm specific flags
607# -P package name. defaults to %{name}
608#
90627280 609%useradd(c:d:e:f:g:G:Mmk:op:s:u:rP:) \
9ba02ba9
ER
610%{!-u:%{error:useradd: Required argument -u missing}} \
611%{!-g:%{error:useradd: Required argument -g missing}} \
612%{!?1:%{error:useradd: Required parameter login missing}} \
90627280
ER
613if [ -n "`/bin/id -u %{expand:%{%{#}}} 2>/dev/null`" ]; then \
614 if [ "`/bin/id -u %{expand:%{%{#}}}`" != "%{-u*}" ]; then \
615 echo "Error: user %{expand:%{%{#}}} doesn't have uid=%{-u*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
616 exit 1 \
617 fi \
618else \
619 echo "Adding user %{expand:%{%{#}}} UID=%{-u*}." \
620 /usr/sbin/useradd \\\
b5a7d552 621 %{-m:-m -k %{-k*}%{!-k:/usr/share/empty}} \\\
90627280
ER
622 -u %{-u*} \\\
623 -r \\\
624 -d %{-d*}%{!-d:/usr/share/empty} \\\
625 -s %{-s*}%{!-s:/bin/false} \\\
840e7b00 626 %{-c:-c "%(set -- %{-c*} %{*}; echo $1)"}\\\
90627280
ER
627 -g %{-g*} \\\
628 %{-M} \\\
629 %{-G:-G %{-G*}} \\\
1aac682a
ER
630 %{expand:%{%{#}}} 1>&2 || exit $? \
631 [ ! -x /usr/sbin/nscd ] || /usr/sbin/nscd -i passwd \
90627280
ER
632fi;
633
90627280
ER
634# Usage:
635# %groupadd [-P package] [-g gid] group
636#
637# -g gid. REQUIRED
638#
639# Sample:
640# %groupadd -P %{name}-base -g %{gid} %{name}
641
642%groupadd(g:P:rfo) \
9ba02ba9
ER
643%{!-g:%{error:groupadd: Required argument -g missing}} \
644%{!?1:%{error:groupadd: Required parameter group missing}} \
90627280
ER
645if [ -n "`/usr/bin/getgid %{1}`" ]; then \
646 if [ "`/usr/bin/getgid %{1}`" != "%{-g*}" ]; then \
647 echo "Error: group %{1} doesn't have gid=%{-g*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
648 exit 1 \
649 fi \
650else \
651 echo "Adding group %{1} GID=%{-g*}." \
1aac682a
ER
652 /usr/sbin/groupadd -g %{-g*} -r %{1} 1>&2 || exit $? \
653 [ ! -x /usr/sbin/nscd ] || /usr/sbin/nscd -i group \
90627280 654fi;
7cb77741
ER
655
656# apache_config_{install/uninstall} macros written by glen@pld-linux.org.
657# All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
658#
a0bbe604
ER
659# You should use webapp macros instead. these are here until single piece of them is gone from specs ;)
660#
7cb77741
ER
661# The config is installed/removed inside trigger, this means that you can any
662# time install apache1 or apache package and the configuration file is updated.
663# if you don't need the config for various reason for specific apache, just
664# remove the symlink from apache config directory. the trigger will not put the
665# config again to that version of apache. In other words the config is linked
666# to apache config directory on first install of PACKAGE or apache.
667#
668# should be called in trigger body:
669# %triggerin -- apache1 >= 1.3.33-2
670# %apache_config_install -v 1
671#
672# Add package's apache config to apache config.
673#
674# Usage:
675# %apache_config_install -v {1|2} -c %{_sysconfdir}/apache-%{name}.conf -n 99
676#
677# -v REQUIRED: specify apache version. can be 1 or 2.
678# -c OPTIONAL: specify full path to PACKAGE's config. Defaults to %{_sysconfdir}/apache-%{name}.conf.
679# -n OPTIONAL: specify config "slot". defaults to 99
13ee223c 680# -f OPTIONAL: force symlink creation regardless if package was upraded. useful in triggers
7cb77741
ER
681#
682# Internal macros. don't use ;).
683# expands apache config dir by apache version at build time.
684%__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)
685# expands apache service name by apache version at build time.
686%__apache_svcname() %(if [ %{1} = 1 ]; then echo apache; elif [ %{1} = 2 ]; then echo httpd; else echo >&2 Unknown apache version specified; fi)
687
13ee223c 688%apache_config_install(fv:c:n:) \
7cb77741
ER
689%{!-v:%{error:apache_config_install: Required argument -v missing}} \
690%{?debug:set -x; echo "apache_config_install:%{-v*} %{name}-%{version}-%{release} 1:[$1]; 2:[$2]"} \
13ee223c 691if [ -n "%{-f:1}" ] || ([ "$1" = "1" ] && [ "$2" = "1" ]) && [ -d %{__apache_confdir %{-v*}} ]; then\
7cb77741
ER
692 ln -sf %{-c*}%{!-c:%{_sysconfdir}/apache-%{name}.conf} %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf\
693fi\
e5a1a393 694# reload apache if the config symlink is there\
de11f042 695if [ -L %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf ]; then\
ab251261
ER
696 # additionally don't reload if target package (the webserver) is upgraded, as webserver is restarted anyway in %post \
697 if [ "$2" != "2" ] && [ -f /var/lock/subsys/%{__apache_svcname %{-v*}} ]; then\
e5a1a393 698 /etc/rc.d/init.d/%{__apache_svcname %{-v*}} reload 1>&2\
7cb77741
ER
699 fi\
700fi\
701%{nil}
702
703# Remove package's apache config from apache config.
704#
705# Usage:
706# %apache_config_uninstall -v {1|2} -n 99
707#
708# -v REQUIRED: specify apache version. can be 1 or 2.
709# -n OPTIONAL: specify config "slot". defaults to 99
710%apache_config_uninstall(v:n:) \
711%{!-v:%{error:apache_config_uninstall: Required argument -v missing}} \
712%{?debug:set -x; echo "apache_config_uninstall:%{-v*} %{name}-%{version}-%{release}: 1:[$1]; 2:[$2]"} \
feb15ceb 713# remove link if either of the packages are gone \
7cb77741
ER
714if [ "$1" = "0" ] || [ "$2" = "0" ]; then \
715 if [ -L %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf ]; then \
716 rm -f %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf \
717 if [ -f /var/lock/subsys/%{__apache_svcname %{-v*}} ]; then \
e5a1a393 718 /etc/rc.d/init.d/%{__apache_svcname %{-v*}} reload 1>&2 \
7cb77741
ER
719 fi \
720 fi \
721fi \
722%{nil}
723
7c50f037 724# webapp macros
35663282
ER
725#
726# The config is installed/removed inside trigger, this means that you can any
727# time install apache1/apache/lighttpd package and the configuration file is
fe6c4bdd 728# updated. if you don't need the config for various reason for specific
35663282
ER
729# webserver, just remove the symlink from config directory using webapp
730# program. the trigger will not recreate the symlink on upgrades. In other
731# words the config is linked to webserver config directory on first install of
732# PACKAGE or WEBSERVER.
733#
7c50f037
ER
734# Add package's webserver config to webserver webapps dir.
735# Usage:
df979130 736# %webapp_register WEBSERVER WEBAPP
35663282
ER
737#
738%webapp_register() \
739%{?debug:set -x; echo "webapp_register: %{name}-%{version}-%{release} 1:[$1]; 2:[$2]"} \
740if [ "$1" = "1" ] && [ "$2" = "1" ]; then\
741 /usr/sbin/webapp register %1 %2\
742fi\
694a8f2e 743# reload webserver if the config symlink is there and skip reload if webserver is upgraded\
6ec4309e 744if [ -L /etc/%1/webapps.d/%2.conf ] && [ "$2" -lt "2" ]; then\
16897aea 745 %{expand:%service -q %%1 reload}\
35663282
ER
746fi\
747%{nil}
748
749# Remove package's config from webserver webapps dir.
35663282 750# Usage:
531c0efc
ER
751# %webapp_register [-f] WEBSERVER WEBAPP
752%webapp_unregister(f) \
35663282
ER
753%{?debug:set -x; echo "webapp_unregister: %{name}-%{version}-%{release}: 1:[$1]; 2:[$2]"} \
754# remove link if either of the packages are gone \
531c0efc 755if [ -n "%{-f:1}" ] || [ "$1" = "0" ] || [ "$2" = "0" ] && [ -L /etc/%1/webapps.d/%2.conf ]; then \
df979130 756 /usr/sbin/webapp unregister %1 %2\
16897aea 757 %{expand:%service -q %%1 reload}\
35663282
ER
758fi \
759%{nil}
760
d87a3f0b
ER
761# see browser-plugins.spec / template-browser-plugin.spec
762# written by glen@pld-linux.org.
bba6d017 763%nsplugin_install(d:f) { \
d87a3f0b 764# create link if it's first install of either of the packages \
bba6d017 765if [ -n "%{-f:1}" ] || ([ "$1" = "1" ] && [ "$2" = "1" ] && [ -d %{-d*} ]); then \
d87a3f0b
ER
766( \
767%( \
768 for file in %{*}; do \
769 echo echo Installing $file to %{-d*}; \
770 echo "ln -sf %{_libdir}/browser-plugins/$file %{-d*};"; \
771 done ) \
772) | ( %banner -t 5 -e %{name}-in ); fi; \
773}
774
933139a5 775%nsplugin_uninstall(d:) { \
d87a3f0b
ER
776# remove link if either of the packages are gone \
777if [ "$1" = "0" ] || [ "$2" = "0" ]; then \
778( \
779%( \
780 for file in %{*}; do \
781 echo echo Removing $file from %{-d*}; \
782 echo "rm -f %{-d*}/$file;"; \
783 done ) \
784) | ( %banner -t 5 -e %{name}-un ); fi; \
785}
462b26fa
ER
786
787# service macro.
788#
789# calls usual service restart on package %post, but skips the restart if
790# administrator has disabled automatic service restarts in either global
791# /etc/sysconfig/rpm or per service /etc/sysconfig/SERVICE file.
792#
793# written by glen@pld-linux.org.
794# All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
795#
796# Usage:
3e913a30 797# %service [-q] SERVICE ACTION ["SERVICE NICE DESCRIPTION"]
462b26fa 798#
a0bbe604 799# -q be silent when service isn't started (for scriplets restaring other package's services)
462b26fa 800#
8b781cff 801%service(q) {{%(export quiet=%{-q:1}; /usr/lib/rpm/service_generator.sh %{*}) };}
6aedae62
ER
802
803
804# java macros. based on jpackage macros.java
2d4659a1
ER
805%_jvmdir %{_libdir}/jvm
806%_jvmjardir %{_libdir}/jvm-exports
807%_jvmprivdir %{_libdir}/jvm-private
808%_jvmlibdir %{_libdir}/jvm
fe6c4bdd
ER
809%_jvmdatadir %{_datadir}/jvm
810%_jvmsysconfdir %{_sysconfdir}/jvm
f5ed4276
ER
811# FIXME: are these used?
812%_jvmcommonlibdir %{_libdir}/jvm-common
813%_jvmcommondatadir %{_datadir}/jvm-common
814%_jvmcommonsysconfdir %{_sysconfdir}/jvm-common
2d4659a1 815%_jnidir %{_libdir}/java
fe6c4bdd 816%java_home %(unset JAVA_HOME; . %{_javadir}-utils/java-functions; set_jvm; echo $JAVA_HOME)
6aedae62 817
fe6c4bdd
ER
818%ant JAVA_HOME=%{java_home} ant
819%jar %{java_home}/bin/jar
820%java %(unset JAVACMD; . %{_javadir}-utils/java-functions; set_javacmd; echo $JAVACMD)
821%javac %{java_home}/bin/javac
822%javadoc %{java_home}/bin/javadoc
6aedae62 823
fe6c4bdd 824%add_jvm_extension JAVA_LIBDIR=%{buildroot}/%{_javadir} %{_bindir}/jvmjar -l
6aedae62
ER
825
826%jpackage_script() \
3ca65b87
ER
827install -d $RPM_BUILD_ROOT%{_bindir}\
828cat > $RPM_BUILD_ROOT%{_bindir}/%5 << 'EOF' \
6aedae62
ER
829#!/bin/sh\
830#\
831# %{name} script\
832# JPackage Project <http://www.jpackage.org/>\
833\
834# Source functions library\
835. %{_javadir}-utils/java-functions\
836\
837# Source system prefs\
3ca65b87 838if [ -f %{_sysconfdir}/java/%{name}.conf ]; then\
fe6c4bdd 839 . %{_sysconfdir}/java/%{name}.conf\
6aedae62
ER
840fi\
841\
842# Source user prefs\
3ca65b87
ER
843if [ -f $HOME/.%{name}rc ]; then\
844 . $HOME/.%{name}rc\
6aedae62
ER
845fi\
846\
847# Configuration\
848MAIN_CLASS=%1\
849BASE_FLAGS=%2\
850BASE_OPTIONS=%3\
3ca65b87 851BASE_JARS="%(echo %4 | tr ':' ' ')"\
6aedae62
ER
852\
853# Set parameters\
854set_jvm\
3ca65b87
ER
855set_classpath $BASE_JARS\
856set_flags $BASE_FLAGS\
857set_options $BASE_OPTIONS\
6aedae62
ER
858\
859# Let's start\
3ca65b87 860run "$@"\
6aedae62
ER
861EOF
862
dfce8b19
ER
863# pear install macros written by glen@pld-linux.org.
864# All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
865#
866# Usage:
867# %%pear_package_setup [-a #] [-n FMT]
868#
869# -a # - unpack SOURCE# instead of SOURCE0
870# -n FMT - create builddir with FMT, instead of default %%{_pearname}-%%{version}
871# -z - unpack pear package and let pear use package.xml (not tarball) for install. use this for buggy packages.
872# -f - force pear install. use with care.
873#
874# unpack PEAR package to %%{_builddir}/FMT. package is extracted with already
875# destination hierarchy. you should copy the tree to buildroot after
876# patching/reorganizing with %%pear_package_install.
877#
878# additionally BUILDROOT is stripped from files and files are converted to UNIX
879# line endings.
880#
881# the pear install process output is recorded to install.log, you should put it
882# to %%doc for latter debug or just information.
883#
884# additionally additional-packages.txt is produced if it was detected that the
885# package has optional dependencies. the file format is suitable of displaying
886# in %%post of a package. you should put this file to %%doc. noautocompressdoc is
887# automatically added for this file.
888#
889%pear_package_setup(a:n:zf) \
890%setup -q -c -T -n %{-n*}%{!-n:%{_pearname}-%{version}}\
891D=%{_builddir}/%{-n*}%{!-n:%{_pearname}-%{version}} \
892%{-z:tar zxf %{S:%{-a*}%{!-a:0}}; P=%{_pearname}-%{version}/package.xml; [ -f $P ] || P=package.xml} \
893pear \\\
894 -d doc_dir=/docs \\\
895 -d php_dir=%{php_pear_dir} \\\
896 -d bin_dir=%{_bindir} \\\
897 -d data_dir=%{php_pear_dir}/data \\\
898 -d test_dir=%{php_pear_dir}/tests \\\
899 install \\\
900 --installroot=${D} \\\
901 --offline \\\
902 --nodeps \\\
903 %{-f:--force} \\\
904 %{!-z:%{S:%{-a*}%{!-a:0}}}%{-z:$P} | tee install.log \
905# make post message of optional packages \
906grep 'can optionally use' install.log | sed -e 's,package "pear/,package "php-pear-,g;s,^pear/,php-pear-,' > optional-packages.txt \
907if [ -s optional-packages.txt ]; then \
908 awk -F'"' '/use package/{print $2}' optional-packages.txt | sed -e "s,_,/,g;s,php-pear-, 'pear(,;s,$,.*)'," | tr -d '\\\n' > _noautoreq \
909else \
910 rm -f optional-packages.txt \
911fi \
912rm ./%{php_pear_dir}/.{lock,filemap} \
913# undos sources \
914find . -type f -print0 | xargs -0 sed -i -e 's,\\r$,,' \
915# bug in PEAR --installroot. \
916# http://pear.php.net/bugs/bug.php?id=5448 \
917grep -rl "${D}" ./{%{_bindir},%{php_pear_dir}}/* | xargs -r sed -i -e "s,${D},," \
918%{!?_noautocompressdoc:%global _noautocompressdoc %{nil}}%{expand:%%global _noautocompressdoc %{_noautocompressdoc} optional-packages.txt} \
919%{!?_noautoprov:%global _noautoprov %{nil}}%{expand:%%global _noautoprov %{_noautoprov} 'pear(tests/.*)'} \
920%{nil}
921
922# copies exctracted PEAR package structure to buildroot.
923# also copies PEAR registry file.
924# please use this macro, for future extensions being possible.
925%pear_package_install() \
926cp -a ./%{php_pear_dir}/{.registry,*} $RPM_BUILD_ROOT%{php_pear_dir} \
927find $RPM_BUILD_ROOT%{php_pear_dir} '(' -name '*~' -o -name '*.orig' ')' | xargs -r rm -v \
928# help the developer out a little: \
929if [ -f _noautoreq ]; then \
930 echo "AutoReqdep detected:" \
931 echo "_noautoreq $(cat _noautoreq)" \
932fi \
933%{nil}
934
0d5dd00c
ER
935
936# Register OpenLDAP schema.
937