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