]> git.pld-linux.org Git - packages/rpm-build-macros.git/blame - rpm.macros
- removed bcond macros; applied upstream
[packages/rpm-build-macros.git] / rpm.macros
CommitLineData
d54662bf
AF
1# PLD rpm macros
2
f633038a 3# other macros
e05017c1 4%epoch 0
9c404149 5
ba1fdedc 6# kernel compiler
d2e1bc22 7%kgcc gcc
8%kgcc_package gcc
ba1fdedc 9
33040789 10# Build system path macros.
11#
bddadece
JB
12%__autoconf autoconf %{?debug:-Wall}
13%__automake automake -a -c -f --foreign
f93109a0 14%__autopoint autopoint --force
15
83094b62 16%__gettextize { \
afff6d37 17 if ! gettextize --version | grep -q '0\.10\.' ; then \
8a995cff
JB
18 if grep -qs 'AM_GNU_GETTEXT.*external' configure.{ac,in} ; then \
19 gettextize --copy --force --no-changelog; \
97589b6e 20 else \
8a995cff
JB
21 gettextize --copy --force --no-changelog --intl; \
22 fi; \
23 if [ ! -f po/Makevars ]; then \
24 cp -f po/Makevars{.template,}; \
25 fi; \
26 else \
27 gettextize --copy --force; \
83094b62 28 fi; \
8a995cff 29}
f93109a0 30
31%__glib_gettextize glib-gettextize --copy --force
32%__gnome_doc_common gnome-doc-common --copy
33%__gtkdocize gtkdocize --copy
34%__intltoolize intltoolize --copy --force
35%__libtoolize libtoolize --copy --force
33040789 36
6a5eda77 37%dependencytracking %{nil}
9c404149 38#-----------------------------------------------------------------
9f4ce098 39%configure2_13 { \
9c404149
AM
40 if [ -n "$LINGUAS" ]; then unset LINGUAS; fi; \
41 LDFLAGS="${LDFLAGS:-%rpmldflags}" ; export LDFLAGS ; \
42 CFLAGS="${CFLAGS:-%rpmcflags}" ; export CFLAGS ; \
f4cc8832 43 CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" ; export CXXFLAGS ; \
9c404149 44 FFLAGS="${FFLAGS:-%rpmcflags}" ; export FFLAGS ; \
8ec1a12b 45 CPPFLAGS="${CPPFLAGS:-}" ; export CPPFLAGS ; \
8983c4c4
AM
46 %{?__cc:CC="%{__cc}" ; export CC ; } \
47 %{?__cxx:CXX="%{__cxx}" ; export CXX ; } \
8f74418b 48 %{?configuredir:%{configuredir}}%{!?configuredir:.}/configure \
2a7cfd3f 49 --host=%{_target_platform} \
9c404149
AM
50 --prefix=%{_prefix} \
51 --exec-prefix=%{_exec_prefix} \
52 --bindir=%{_bindir} \
53 --sbindir=%{_sbindir} \
54 --sysconfdir=%{_sysconfdir} \
55 --datadir=%{_datadir} \
56 --includedir=%{_includedir} \
57 --libdir=%{_libdir} \
58 --libexecdir=%{_libexecdir} \
59 --localstatedir=%{_localstatedir} \
60 --sharedstatedir=%{_sharedstatedir} \
61 --mandir=%{_mandir} \
62 --infodir=%{_infodir} \
c0d1b3ad 63 --x-libraries=/usr/X11R6/%{_lib} \
93059874 64 %{dependencytracking} \
9c404149
AM
65}
66
4a6b0d54 67#----------------------------------------------------------------
73f832b3 68%global configure_cache 0
69%configure_cache_file %{buildroot}.configure.cache
70
57f4166d 71%configure {./configure \
4a6b0d54
AF
72 LDFLAGS="${LDFLAGS:-%rpmldflags}" \
73 CFLAGS="${CFLAGS:-%rpmcflags}" \
f4cc8832 74 CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" \
4a6b0d54 75 FFLAGS="${FFLAGS:-%rpmcflags}" \
a2bd5992 76 CPPFLAGS="${CPPFLAGS:-}" \
8983c4c4
AM
77 %{?__cc:CC="%{__cc}"} \
78 %{?__cxx:CXX="%{__cxx}"} \
8e4cb85a 79 --host=%{_target_platform} \
4a6b0d54
AF
80 --build=%{_target_platform} \
81 --prefix=%{_prefix} \
82 --exec-prefix=%{_exec_prefix} \
83 --bindir=%{_bindir} \
84 --sbindir=%{_sbindir} \
85 --sysconfdir=%{_sysconfdir} \
86 --datadir=%{_datadir} \
87 --includedir=%{_includedir} \
88 --libdir=%{_libdir} \
89 --libexecdir=%{_libexecdir} \
90 --localstatedir=%{_localstatedir} \
91 --sharedstatedir=%{_sharedstatedir} \
92 --mandir=%{_mandir} \
93 --infodir=%{_infodir} \
c0d1b3ad 94 --x-libraries=/usr/X11R6/%{_lib} \
93059874 95 %{dependencytracking} \
73f832b3 96 %{?configure_cache:--cache-file=%{configure_cache_file:-%{buildroot}.configure.cache}} \
4a6b0d54
AF
97}
98
7dbab518 99# ------------------------------------------------------------------------
c80506a3
AM
100# Overloading of some basic macros
101%prep \
102%%prep\
103LANG=C\
104export LANG\
14e77e64 105unset DISPLAY ||:\
6db5639d 106unset LINGUAS ||:\
c80506a3
AM
107%{nil}
108
109%build %%build\
110LANG=C\
111export LANG\
14e77e64 112unset DISPLAY ||:\
6db5639d 113unset LINGUAS ||:\
c80506a3
AM
114%{nil}
115
b4e3d367
ER
116%install \
117%if 0%{?_enable_debug_packages}\
118%{?buildsubdir:%{debug_package}}\
119%endif\
c80506a3
AM
120%%install\
121LANG=C\
122export LANG\
14e77e64 123unset DISPLAY ||:\
6db5639d 124unset LINGUAS ||:\
c80506a3
AM
125%{nil}
126
9c404149
AM
127# Location of autoconf macros
128%_aclocaldir %(aclocal --print-ac-dir)
129
e2804f99
AM
130# Location of omf files
131%_omf_dest_dir %(scrollkeeper-config --omfdir)
132
e987a186 133# Location of pkgconfig files
9a4e877a 134%_pkgconfigdir /usr/%{_lib}/pkgconfig
e987a186 135
486b0b5f 136# Location of desktop files
137%_desktopdir /usr/share/applications
86dff2d0 138%_applnkdir ERROR:_applnkdir_is_obsolete_use_desktopdir_instead
486b0b5f 139
481463e9 140# Location of pixmaps for applnk/desktop files
e1f0a822 141%_pixmapsdir /usr/share/pixmaps
9c404149 142
481463e9 143# Location of themable icons for applnk/desktop files
b36c8e2a 144%_iconsdir /usr/share/icons
145
e987a186
JB
146# Location of fonts directories
147%_fontsdir /usr/share/fonts
148
b3282f3f 149# Location of Gtk and associated libraries documentation
6eed6d84 150%_gtkdocdir %{_defaultdocdir}/gtk-doc/html
b3282f3f 151
fc4d7771 152# Location of KDE documentation
153%_kdedocdir %{_defaultdocdir}/kde/HTML
154
5869828c 155# unsermake script
156%__unsermake /usr/share/unsermake/unsermake
157
9c404149
AM
158# Current date
159%date %(LC_ALL="C" date +"%a %b %d %Y")
160
161# tmp directory
162%tmpdir %(echo "${TMPDIR:-/tmp}")
163
164# Example files, programs, scripts...
165%_examplesdir /usr/src/examples
166
8377d27d 167# The directory holding Linux kernel sources
168%_kernelsrcdir /usr/src/linux
169
9c404149 170# If non-empty "debug" macro defined, add "dbg" suffix to release number
8f74418b 171%_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}%{?debug:dbg}.%%{ARCH}.rpm
9c404149 172
8f74418b 173# Requires name = version-release
ec4e8b11 174%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 175
c12095e9
PS
176%releq_kernel_up() %(LC_ALL="C" rpm -qf --qf '%%{name}-up = %%{epoch}:%%{version}-%%{release}\\n' %{_kernelsrcdir}/include/linux/version.h | sed -e 's/ (none):/ /' | sed -e 's:-headers::' | grep -vE "(is not|no such)")
177%releq_kernel_smp() %(LC_ALL="C" rpm -qf --qf '%%{name}-smp = %%{epoch}:%%{version}-%%{release}\\n' %{_kernelsrcdir}/include/linux/version.h | sed -e 's/ (none):/ /' | sed -e 's:-headers::' | grep -vE "(is not|no such)")
178%requires_releq_kernel_up() %(LC_ALL="C" rpm -qf --qf 'PreReq: %%{name}-up = %%{epoch}:%%{version}-%%{release}\\n' %{_kernelsrcdir}/include/linux/version.h | sed -e 's/ (none):/ /' | sed -e 's:-headers::' | grep -vE "(is not|no such)")
179%requires_releq_kernel_smp() %(LC_ALL="C" rpm -qf --qf 'PreReq: %%{name}-smp = %%{epoch}:%%{version}-%%{release}\\n' %{_kernelsrcdir}/include/linux/version.h | sed -e 's/ (none):/ /' | sed -e 's:-headers::' | grep -vE "(is not|no such)")
8bf3719d 180
16cb1d91 181%requires_eq_to() %(LC_ALL="C" rpm -q --qf 'Requires: %1 = %%{epoch}:%%{version}\\n' %2 | sed -e 's/ (none):/ /' | grep -v "is not")
01a9f990 182
179fcc7f 183%apache_modules_api %(awk '/#define MODULE_MAGIC_NUMBER_MAJOR/ {print $3}' /usr/include/apache/ap_mmn.h 2>/dev/null || echo ERROR)
b9d5d440 184
185# kernel version-release handling
541d11fe 186%__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))
f004e915
PS
187%__kernel_rel %(LC_ALL="C" rpm -qf %{_kernelsrcdir}/include/linux/fs.h 2>/dev/null --qf "%{RELEASE}" | grep -v "is not")
188%__kernel_rpmvr %(LC_ALL="C" rpm -qf %{_kernelsrcdir}/include/linux/fs.h 2>/dev/null --qf "%{VERSION}-%{RELEASE}" | grep -v "is not")
16cb1d91 189%_kernel_ver %{__kernel_ver}%{?with_dist_kernel:%(echo %{__kernel_ver} | grep -q -e - || echo -%{__kernel_rel})}
f62e856d 190%_kernel_ver_str %(echo %{!?_without_dist_kernel:%{__kernel_rpmvr}}%{?_without_dist_kernel:%{__kernel_ver}} | sed -e 's/-/_/g')
87be1cf0 191
e00dd7f6 192# sgml macros
741b471b 193%xmlcat_add() /usr/bin/xmlcatalog --noout --add nextCatalog \"\" %1 /etc/xml/catalog ;
194%xmlcat_del() /usr/bin/xmlcatalog --noout --del %1 /etc/xml/catalog ;
847db862 195%xmlcat_add_rewrite /usr/bin/xmlcatalog --noout --add rewriteSystem
741b471b 196%xmlcat_create() /usr/bin/xmlcatalog --noout --create %1 ;
197%sgmlcat_add() /usr/bin/install-catalog --add %1 %2 > /dev/null ;
198%sgmlcat_del() /usr/bin/install-catalog --remove %1 %2 > /dev/null ;
e00dd7f6 199%docbook_sgmlcat_fix() { for l in \
200'' \
201' -- default decl --' \
202'DTDDECL "-//OASIS//DTD DocBook XML V%2//EN" "../../xml.dcl"' \
203' -- hacks for opensp --' \
204'SYSTEM "file://%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
205'SYSTEM "http://www.oasis-open.org/docbook/xml/%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
206'' \
207; do echo $l; done >> %1 \
208}
209
9c404149
AM
210#-----------------------------------------------------------------
211# find and gzip all files in %{_mandir} and %{infodir}
212#
213# Requires: xargs, find
214#
215#%no_install_post_compress_docs 1
216%__spec_install_post_compress_docs { \
9c404149 217%{!?no_install_post_compress_docs: \
822d4d81 218 echo "Compress man and info pages."; \
9c404149
AM
219 %{?verbose:set -x;} \
220 for i in /usr/share/man /usr/X11R6/man /usr/share/info; do \
221 if [ -d "$RPM_BUILD_ROOT$i" ]; then \
222 find "$RPM_BUILD_ROOT$i" -name \*.bz2 -print | xargs -r %{__bzip2} -df; \
223 find "$RPM_BUILD_ROOT$i" -name \*.gz -print | xargs -r %{__gzip} -dnf; \
224 find "$RPM_BUILD_ROOT$i" -type f -print | xargs -r %{__gzip} -9nf; \
225 fi; \
226 done; \
227} }
228
229#-----------------------------------------------------------------
230# Strip executable binaries and shared object files
231#
232# Requires: find, awk, strip, cut, xargs
233#
234#%no_install_post_strip 1
235%__spec_install_post_strip {%{!?debug: \
236%{!?no_install_post_strip: \
9f0d4f36
JB
237 %{?verbose:set -x;} \
238 if [ -d "$RPM_BUILD_ROOT" ]; then \
8f74418b 239 echo "Strip executable binaries, archives and shared object files."; \
b4e3d367 240 filelist=`find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*" ! -regex ".*/usr/lib[0-9]*/debug/.*\.debug" %{?_noautostrip:! -regex "%{_noautostrip}"}`; \
9c404149
AM
241 elfexelist=`echo $filelist | xargs -r file | \
242 awk '/ELF.*executable/ {print $1}' | cut -d: -f1`; \
243 elfsharedlist=`echo $filelist | xargs -r file | \
244 awk '/LF.*shared object/ {print $1}' | cut -d: -f1`; \
8f74418b
MM
245 elfarchiveslist=`echo $filelist | xargs -r file | \
246 awk '/current ar archive/ {print $1}' | cut -d: -f1`; \
9c404149 247 if [ -n "$elfexelist" ]; then \
60ad88f2 248 %{__strip} --remove-section=.note --remove-section=.comment $elfexelist; \
9c404149
AM
249 fi; \
250 if [ -n "$elfsharedlist" ]; then \
60ad88f2 251 %{__strip} --strip-unneeded --remove-section=.note --remove-section=.comment $elfsharedlist; \
8f74418b
MM
252 fi; \
253 if [ -n "$elfarchiveslist" ]; then \
60ad88f2 254 %{__strip} --strip-debug --remove-section=.note --remove-section=.comment $elfarchiveslist; \
9f0d4f36
JB
255 fi; \
256 fi; } \
9c404149 257} }
fc5d7e20 258#-----------------------------------------------------------------
259# remove all RPATH from executable binaries and shared object files
260#
261# Requires: find, awk, cut, xargs, chrpath, uname
262#
263#%no_install_post_chrpath 1
264%__spec_install_post_chrpath {%{!?debug: \
265%{!?no_install_post_chrpath: \
266 %{?verbose:set -x;} \
9f0d4f36 267if [ -d "$RPM_BUILD_ROOT" ]; then \
fc5d7e20 268echo "Remove RPATH from executable binaries and shared object files."; \
adb39da4 269find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*" ! -regex ".*/usr/lib[0-9]*/debug/.*" %{?_noautochrpath:! -regex "%{_noautochrpath}"} | xargs -r file | \
5bed2bb7 270 awk '/ELF.*(executable.*dynamically linked|shared object)/ {print $1}' | cut -d: -f1 | \
fc5d7e20 271while read file ; do \
272 rpath= ; \
273 chmod u+w "$file"; \
274 for dir in `chrpath -l "$file" | \
275 awk '/RPATH=/ { gsub(/.*RPATH=/,""); gsub(/:/," "); print $0 }'` ; do \
276 case $dir in \
494e368c 277 /home/* | /tmp/* | /usr/lib | /usr/lib64 | /lib | /lib64 | /usr/local/lib | /usr/local/lib64 | /usr/X11R6/lib | /usr/X11R6/lib64 ) \
fc5d7e20 278 echo "remove-rpath: $dir in $file"; \
279 ;; \
280 * ) \
281 if [ "$rpath" = "" ] ; then rpath="$dir" ; \
282 else rpath="$rpath:$dir" ; fi ; \
283 ;; \
284 esac ; \
285 done ; \
286 if [ "$rpath" = "" ] ; then chrpath -d "$file" > /dev/null ; \
287 else chrpath -r "$rpath" "$file" > /dev/null ; fi ; \
9f0d4f36
JB
288done; \
289fi; } \
fc5d7e20 290} }
d72c185f 291#-----------------------------------------------------------------
ccb8ae8d 292# Find and gzip all kernel modules
293#
294# Requires: find
295#
296#%no_install_post_compress_modules 1
297%__spec_install_post_compress_modules { \
ccb8ae8d 298%{!?no_install_post_compress_modules: \
299 %{?verbose:set -x;} \
9f0d4f36
JB
300 if [ -d "$RPM_BUILD_ROOT" ]; then \
301echo "Compress kernel modules if any."; \
d618340e 302 if test -d $RPM_BUILD_ROOT/lib/modules ; then \
16cb1d91
JB
303 find $RPM_BUILD_ROOT/lib/modules -name \*o -type f -print | \
304 xargs -r %{__gzip} -9nf; \
a33b1418 305 find $RPM_BUILD_ROOT/lib/modules -name \*o -type l -printf "%p %l\n" | \
03b234a5 306 while read a b; do ln -sf $b.gz $a.gz; rm -f $a; done; \
d618340e 307 fi; \
9f0d4f36 308 fi; \
ccb8ae8d 309} }
9c404149
AM
310
311%_source_payload w9.gzdio
312%_binary_payload w9.bzdio
313
83094b62 314#-----------------------------------------------------------------
0e4cb4dd 315# Update GConf2 schemas
83094b62 316#
317# Requires: GConf2
318#
46885239 319%gconf_schema_install() \
320 umask 022; \
f93109a0 321 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 \
46885239 322 %{nil}
323
324%gconf_schema_uninstall() \
f93109a0 325if [ $1 = 0 ]; then \
46885239 326 umask 022; \
f93109a0 327 GCONF_CONFIG_SOURCE="xml:readwrite:/etc/gconf/gconf.xml.defaults" /usr/bin/gconftool-2 --makefile-uninstall-rule /etc/gconf/schemas/%{?1} > /dev/null \
328fi \
329%{nil}
330
331#-----------------------------------------------------------------
332# Update desktop MIME database
c0a4caa0 333# requires: desktop-file-utils
f93109a0 334#
820792a9 335%update_desktop_database_post() {{ \
f93109a0 336 umask 022; \
337 /usr/bin/update-desktop-database; \
4565b525 338}}
f93109a0 339
09e3522b 340%update_desktop_database_postun() {{ \
f93109a0 341if [ $1 = 0 ]; then \
342 umask 022; \
343 /usr/bin/update-desktop-database; \
344fi \
4565b525 345}}
f93109a0 346
347#-----------------------------------------------------------------
348# Update scrollkeeper database
349# requires: scrollkeeper
350#
351%scrollkeeper_update_post() \
f93109a0 352 /usr/bin/scrollkeeper-update -q; \
353 %{nil}
354
355%scrollkeeper_update_postun() \
356if [ $1 = 0 ]; then \
f93109a0 357 /usr/bin/scrollkeeper-update -q; \
358fi \
359%{nil}
360
361#-----------------------------------------------------------------
362# Run ldconfig after installing/deinstalling libraries
363#
364%ldconfig_post() \
365 /sbin/ldconfig; \
366 %{nil}
367
368%ldconfig_postun() \
f93109a0 369 /sbin/ldconfig; \
b430f866 370 %{nil}
83094b62 371
9c404149
AM
372#-----------------------------------------------------------------
373# post %install sequence:
374# - autodeps exceptions
375# - compress all man and info pages,
376# - strip all ELF executables and ELF shared objects if not %debug.
8f74418b 377# - compress kernel modules if any
9c404149
AM
378
379###################################################################
380# Requires/Provides automation
381# exceptions system by Jacek Konieczny <jajcus@pld.org.pl>
338726a6 382#
2892b5df
JB
383%__noautoreqfiles %(sed -e s'/#.*//' /etc/rpm/noautoreqfiles)%{?_noautoreqfiles: %{_noautoreqfiles}}
384%__noautoprovfiles %(sed -e s'/#.*//' /etc/rpm/noautoprovfiles)%{?_noautoprovfiles: %{_noautoprovfiles}}
385%__noautoreq %(sed -e s'/#.*//' /etc/rpm/noautoreq)%{?_noautoreq: %{_noautoreq}}
386%__noautoreqdep %(sed -e s'/#.*//' /etc/rpm/noautoreqdep)%{?_noautoreqdep: %{_noautoreqdep}}
387%__noautoprov %(sed -e s'/#.*//' /etc/rpm/noautoprov)%{?_noautoprov: %{_noautoprov}}
338726a6
JB
388#%_noautocompressdoc %{nil}
389#
8f74418b
MM
390%_missing_doc_files_terminate_build 1%{nil}
391%_unpackaged_files_terminate_build %{nil}
8781dc74 392# (X)emacs support
d77dcb61 393%___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
394%_emacs_lispdir %(emacs %___emacs_lispdir_helper)
395%_xemacs_lispdir %(xemacs %___emacs_lispdir_helper)
25043cd4 396
02b58f60
JK
397%__php_provides %{nil}
398%__php_requires %{nil}
399%__perl_provides %{nil}
400%__perl_requires %{nil}
fa3497cd 401%__mono_provides %{nil}
402%__mono_requires %{nil}
25043cd4
AF
403
404# Perl specific macro definitions.
c853f847
AF
405%perl_privlib %(eval "`%{__perl} -V:installprivlib`"; echo $installprivlib)
406%perl_archlib %(eval "`%{__perl} -V:installarchlib`"; echo $installarchlib)
407%perl_vendorlib %(eval "`%{__perl} -V:installvendorlib`"; echo $installvendorlib)
408%perl_vendorarch %(eval "`%{__perl} -V:installvendorarch`"; echo $installvendorarch)
409%perl_sitelib %(eval "`%{__perl} -V:installsitelib`"; echo $installsitelib)
410%perl_sitearch %(eval "`%{__perl} -V:installsitearch`"; echo $installsitearch)
25043cd4 411
c853f847 412%php_pear_dir %{_datadir}/pear
25043cd4 413
c1b2705c
ER
414# extract php/zend api versions
415%php_api_version %(awk '/#define PHP_API_VERSION/{print $3}' /usr/include/php/main/php.h)
416%zend_module_api %(awk '/#define ZEND_MODULE_API_NO/{print $3}' /usr/include/php/Zend/zend_modules.h)
417%zend_extension_api %(awk '/#define ZEND_EXTENSION_API_NO/{print $3}' /usr/include/php/Zend/zend_extensions.h)
418
419# directory where php includes are installed on system.
420%__php_includedir /usr/include/php
e9b6395a 421%php_major_version %(awk '/#define PHP_MAJOR_VERSION/{print $3}' %{__php_includedir}/main/php_version.h 2>/dev/null || echo ERROR)
c1b2705c 422%php_api_version %(awk '/#define PHP_API_VERSION/{print $3}' %{__php_includedir}/main/php.h 2>/dev/null || echo ERROR)
68b68193 423%php_debug %(awk '/#define ZEND_DEBUG/{print $3}' %{__php_includedir}/main/php_config.h 2>/dev/null || echo ERROR)
c1b2705c
ER
424%zend_module_api %(awk '/#define ZEND_MODULE_API_NO/{print $3}' %{__php_includedir}/Zend/zend_modules.h 2>/dev/null || echo ERROR)
425%zend_extension_api %(awk '/#define ZEND_EXTENSION_API_NO/{print $3}' %{__php_includedir}/Zend/zend_extensions.h 2>/dev/null || echo ERROR)
c0ac7203 426%zend_zts %(Z=$(grep -sc '^#define ZTS 1' %{__php_includedir}/main/php_config.h); echo ${Z:-ERROR})
c1b2705c
ER
427
428# helper macro
f952c0f3 429%__php_api_requires(v:) Requires: php%{-v*}(%{expand:%1}) = %{expand:%{%{!?2:%{1}}%{?2}}}
c1b2705c
ER
430
431# macros for public use
432# for php extensions (php-pecl)
68b68193 433%requires_php_extension %{__php_api_requires modules_api php_api_version} \
f952c0f3
ER
434%{__php_api_requires -v %php_major_version debug php_debug} \
435%{__php_api_requires -v %php_major_version thread-safety zend_zts}
68b68193 436
c1b2705c
ER
437# for zend extensions
438%requires_zend_extension %{__php_api_requires zend_module_api} \
68b68193 439%{__php_api_requires zend_extension_api} \
f952c0f3
ER
440%{__php_api_requires -v %php_major_version debug php_debug} \
441%{__php_api_requires -v %php_major_version thread-safety zend_zts}
c1b2705c 442
25043cd4
AF
443# Python specific macro definitions.
444# python main version
c853f847 445%py_ver %(echo `python -c "import sys; print sys.version[:3]"`)
25043cd4
AF
446
447# directories
c853f847 448%py_prefix %(echo `python -c "import sys; print sys.prefix"`)
aadb0079 449%py_libdir %{py_prefix}/%{_lib}/python%{py_ver}
ef7ec0a8 450%py_scriptdir %{py_prefix}/share/python%{py_ver}
c853f847 451%py_incdir /usr/include/python%{py_ver}
ef7ec0a8
JK
452%py_sitedir %{py_libdir}/site-packages
453%py_sitescriptdir %{py_scriptdir}/site-packages
c853f847 454%py_dyndir %{py_libdir}/lib-dynload
25043cd4
AF
455
456# pure python modules compilation
c853f847 457%py_comp python -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
25043cd4 458
c853f847 459%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
460
461# Software written in Python language require Python with main version
e63cd81d 462%pyrequires_eq() Requires: %1
25043cd4 463
f12c2314
AF
464
465# Hardlink binary identical .pyc and .pyo files
466# (idea by glen <at> pld-linux <dot> org)
467%__spec_install_post_py_hardlink {\
d56b7e24 468%{!?no_install_post_py_hardlink: \
f12c2314
AF
469[ ! -d "$RPM_BUILD_ROOT" ] || find "$RPM_BUILD_ROOT" -name '*.pyc' | while read a; do \
470 b="$(echo $a|sed -e 's/.pyc$/.pyo/')"; \
471 if cmp -s "$a" "$b"; then \
472 ln -f "$a" "$b"; \
473 fi; \
474done \
475} }
476
9227b3f9 477# remove python sources, so that check-files won't complain
f12c2314
AF
478# (idea by glen <at> pld-linux <dot> org)
479%py_postclean() \
0f82e280 480for d in %{py_sitescriptdir} %{py_sitedir} %*; do \
820792a9 481 [ ! -d "$RPM_BUILD_ROOT$d" ] || find "$RPM_BUILD_ROOT$d" -name '*.py' -print0 | xargs -0r -l512 rm;\
f12c2314
AF
482done \
483%{nil}
484
0fc5cff8 485# depmod macro
486%depmod() { \
f6148427 487umask 022; \
0fc5cff8 488if [ -e /boot/System.map-%1 ]; then \
489 /sbin/depmod -a -F /boot/System.map-%1 %1; \
490else \
491 if [ -e /boot/System.map ]; then \
492 /sbin/depmod -a -F /boot/System.map %1; \
493 else \
494 /sbin/depmod -a %1; \
495 fi \
496fi; \
497}
498
2afc6e64 499# XMMS specific macros
2ea9b0e8
ER
500%xmms_prefix %(xmms-config --prefix 2>/dev/null)
501%xmms_exec_prefix %(xmms-config --exec-prefix 2>/dev/null)
502%xmms_version %(xmms-config --version 2>/dev/null)
503%xmms_datadir %(xmms-config --data-dir 2>/dev/null)
504%xmms_plugindir %(xmms-config --plugin-dir 2>/dev/null)
505%xmms_visualization_plugindir %(xmms-config --visualization-plugin-dir 2>/dev/null)
506%xmms_input_plugindir %(xmms-config --input-plugin-dir 2>/dev/null)
507%xmms_output_plugindir %(xmms-config --output-plugin-dir 2>/dev/null)
508%xmms_effect_plugindir %(xmms-config --effect-plugin-dir 2>/dev/null)
509%xmms_general_plugindir %(xmms-config --general-plugin-dir 2>/dev/null)
2afc6e64 510
d1537778
PS
511%_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/')
512
f031b1b0 513%x8664 x86_64 amd64 ia32e
848c0d68 514
515# user/group checking macros
516#
517# Usage:
518# %userremove myuser
519#
520%userremove /usr/lib/rpm/user_group.sh user del
521%groupremove /usr/lib/rpm/user_group.sh group del
522#
523# Usage:
524# if %usertestrm myuser; then
525# /usr/sbin/userdel -r myuser
526# Note:
527# use these macros only if you need to call userdel/groupdel with
528# a non-standard option or take an extra action; otherwise use the
529# %userremove/%groupremove macros
530#
531%usertestrm /usr/lib/rpm/user_group.sh user testrm
532%grouptestrm /usr/lib/rpm/user_group.sh group testrm
08d9b1f6
JK
533# user group membership management macros
534#
535# Usage:
536# %addusertogroup myuser agroup
537#
538%addusertogroup /usr/lib/rpm/user_group.sh user addtogroup
72fcfcb3 539
540# banner support (useful in {pre,post}{,un} and triggers)
541#
542# Usage:
aa41c920 543# %banner name [-a] [-e] [-n] [-tn] <<EOF
72fcfcb3 544# the banner text, the banner text
aa41c920
ER
545# the banner text, and following line
546#EOF
547# You can use any form of here-document, <<'EOF' <<-EOT will do.
548# NOTE: if your use "<<-EOF", then You can actually indent inside here-document.
549#
72fcfcb3 550# -a - append to the banner
a8b9562a 551# -e - send to stderr instead of stdout
628754cb 552# -n - no show banner (overrides -t)
553# -t - show only, if RPM_SCRIPTVERBOSITY >= n; default n=5
aa41c920 554%banner(aent:) \
1b334fe4 555RPM_SCRIPTVERBOSITY=5 \
556[ -r /etc/sysconfig/rpm ] && . /etc/sysconfig/rpm \
557if [ -x /usr/bin/banner.sh ]; then \
aa41c920 558 CMD="/usr/bin/banner.sh %{-e:--stderr} %{!-n:$([ $RPM_SCRIPTVERBOSITY -ge %{-t:%{-t*}}%{!-t:5} ] && echo -s)} %{!-a:-m}%{-a:-M} %1" \
1b334fe4 559else \
a8b9562a 560 CMD="cat%{-e: >&2}" \
1b334fe4 561fi \
c2e886e1 562eval $CMD %2%{?3: %3} \
72fcfcb3 563%nil
628754cb 564
90627280
ER
565# useradd/groupadd macros written by glen@pld-linux.org.
566# All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
567#
568# Usage:
569# %useradd [-P package] [-u uid] [-d home_dir] [-s shell] [-c comment]
570# [-g initial_group] [-G group[,...]] login
571#
572# -u uid. REQUIRED
573# -g gid/group. REQUIRED
574# -s defaults to /bin/false
575# -d defaults to /usr/share/empty
576# -c No default
577# -r is accepted but ignored (it's always set)
6bd4c218 578# -k skeleton dir. defaults to /usr/share/empty
90627280
ER
579# rpm specific flags
580# -P package name. defaults to %{name}
581#
90627280 582%useradd(c:d:e:f:g:G:Mmk:op:s:u:rP:) \
9ba02ba9
ER
583%{!-u:%{error:useradd: Required argument -u missing}} \
584%{!-g:%{error:useradd: Required argument -g missing}} \
585%{!?1:%{error:useradd: Required parameter login missing}} \
90627280
ER
586if [ -n "`/bin/id -u %{expand:%{%{#}}} 2>/dev/null`" ]; then \
587 if [ "`/bin/id -u %{expand:%{%{#}}}`" != "%{-u*}" ]; then \
588 echo "Error: user %{expand:%{%{#}}} doesn't have uid=%{-u*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
589 exit 1 \
590 fi \
591else \
592 echo "Adding user %{expand:%{%{#}}} UID=%{-u*}." \
593 /usr/sbin/useradd \\\
b5a7d552 594 %{-m:-m -k %{-k*}%{!-k:/usr/share/empty}} \\\
90627280
ER
595 -u %{-u*} \\\
596 -r \\\
597 -d %{-d*}%{!-d:/usr/share/empty} \\\
598 -s %{-s*}%{!-s:/bin/false} \\\
840e7b00 599 %{-c:-c "%(set -- %{-c*} %{*}; echo $1)"}\\\
90627280
ER
600 -g %{-g*} \\\
601 %{-M} \\\
602 %{-G:-G %{-G*}} \\\
840e7b00 603 %{expand:%{%{#}}} 1>&2 \
90627280
ER
604fi;
605
90627280
ER
606# Usage:
607# %groupadd [-P package] [-g gid] group
608#
609# -g gid. REQUIRED
610#
611# Sample:
612# %groupadd -P %{name}-base -g %{gid} %{name}
613
614%groupadd(g:P:rfo) \
9ba02ba9
ER
615%{!-g:%{error:groupadd: Required argument -g missing}} \
616%{!?1:%{error:groupadd: Required parameter group missing}} \
90627280
ER
617if [ -n "`/usr/bin/getgid %{1}`" ]; then \
618 if [ "`/usr/bin/getgid %{1}`" != "%{-g*}" ]; then \
619 echo "Error: group %{1} doesn't have gid=%{-g*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
620 exit 1 \
621 fi \
622else \
623 echo "Adding group %{1} GID=%{-g*}." \
840e7b00 624 /usr/sbin/groupadd -g %{-g*} -r %{1} 1>&2 \
90627280 625fi;
7cb77741
ER
626
627# apache_config_{install/uninstall} macros written by glen@pld-linux.org.
628# All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
629#
630# The config is installed/removed inside trigger, this means that you can any
631# time install apache1 or apache package and the configuration file is updated.
632# if you don't need the config for various reason for specific apache, just
633# remove the symlink from apache config directory. the trigger will not put the
634# config again to that version of apache. In other words the config is linked
635# to apache config directory on first install of PACKAGE or apache.
636#
637# should be called in trigger body:
638# %triggerin -- apache1 >= 1.3.33-2
639# %apache_config_install -v 1
640#
641# Add package's apache config to apache config.
642#
643# Usage:
644# %apache_config_install -v {1|2} -c %{_sysconfdir}/apache-%{name}.conf -n 99
645#
646# -v REQUIRED: specify apache version. can be 1 or 2.
647# -c OPTIONAL: specify full path to PACKAGE's config. Defaults to %{_sysconfdir}/apache-%{name}.conf.
648# -n OPTIONAL: specify config "slot". defaults to 99
649#
650# Internal macros. don't use ;).
651# expands apache config dir by apache version at build time.
652%__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)
653# expands apache service name by apache version at build time.
654%__apache_svcname() %(if [ %{1} = 1 ]; then echo apache; elif [ %{1} = 2 ]; then echo httpd; else echo >&2 Unknown apache version specified; fi)
655
656%apache_config_install(v:c:n:) \
657%{!-v:%{error:apache_config_install: Required argument -v missing}} \
658%{?debug:set -x; echo "apache_config_install:%{-v*} %{name}-%{version}-%{release} 1:[$1]; 2:[$2]"} \
659if [ "$1" = "1" ] && [ "$2" = "1" ] && [ -d %{__apache_confdir %{-v*}} ]; then\
660 ln -sf %{-c*}%{!-c:%{_sysconfdir}/apache-%{name}.conf} %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf\
661fi\
e5a1a393 662# reload apache if the config symlink is there\
de11f042 663if [ -L %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf ]; then\
ab251261
ER
664 # additionally don't reload if target package (the webserver) is upgraded, as webserver is restarted anyway in %post \
665 if [ "$2" != "2" ] && [ -f /var/lock/subsys/%{__apache_svcname %{-v*}} ]; then\
e5a1a393 666 /etc/rc.d/init.d/%{__apache_svcname %{-v*}} reload 1>&2\
7cb77741
ER
667 fi\
668fi\
669%{nil}
670
671# Remove package's apache config from apache config.
672#
673# Usage:
674# %apache_config_uninstall -v {1|2} -n 99
675#
676# -v REQUIRED: specify apache version. can be 1 or 2.
677# -n OPTIONAL: specify config "slot". defaults to 99
678%apache_config_uninstall(v:n:) \
679%{!-v:%{error:apache_config_uninstall: Required argument -v missing}} \
680%{?debug:set -x; echo "apache_config_uninstall:%{-v*} %{name}-%{version}-%{release}: 1:[$1]; 2:[$2]"} \
feb15ceb 681# remove link if either of the packages are gone \
7cb77741
ER
682if [ "$1" = "0" ] || [ "$2" = "0" ]; then \
683 if [ -L %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf ]; then \
684 rm -f %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf \
685 if [ -f /var/lock/subsys/%{__apache_svcname %{-v*}} ]; then \
e5a1a393 686 /etc/rc.d/init.d/%{__apache_svcname %{-v*}} reload 1>&2 \
7cb77741
ER
687 fi \
688 fi \
689fi \
690%{nil}
691
d87a3f0b
ER
692# see browser-plugins.spec / template-browser-plugin.spec
693# written by glen@pld-linux.org.
bba6d017 694%nsplugin_install(d:f) { \
d87a3f0b 695# create link if it's first install of either of the packages \
bba6d017 696if [ -n "%{-f:1}" ] || ([ "$1" = "1" ] && [ "$2" = "1" ] && [ -d %{-d*} ]); then \
d87a3f0b
ER
697( \
698%( \
699 for file in %{*}; do \
700 echo echo Installing $file to %{-d*}; \
701 echo "ln -sf %{_libdir}/browser-plugins/$file %{-d*};"; \
702 done ) \
703) | ( %banner -t 5 -e %{name}-in ); fi; \
704}
705
933139a5 706%nsplugin_uninstall(d:) { \
d87a3f0b
ER
707# remove link if either of the packages are gone \
708if [ "$1" = "0" ] || [ "$2" = "0" ]; then \
709( \
710%( \
711 for file in %{*}; do \
712 echo echo Removing $file from %{-d*}; \
713 echo "rm -f %{-d*}/$file;"; \
714 done ) \
715) | ( %banner -t 5 -e %{name}-un ); fi; \
716}
462b26fa
ER
717
718# service macro.
719#
720# calls usual service restart on package %post, but skips the restart if
721# administrator has disabled automatic service restarts in either global
722# /etc/sysconfig/rpm or per service /etc/sysconfig/SERVICE file.
723#
724# written by glen@pld-linux.org.
725# All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
726#
727# Usage:
3e913a30 728# %service [-q] SERVICE ACTION ["SERVICE NICE DESCRIPTION"]
462b26fa
ER
729#
730# -q be silent when service isn't started (for postun scriplets)
731#
e2070050 732%service(q) {{ \
462b26fa
ER
733# we use function, not to globber namespace with useless variables \
734skip_auto_restart() { \
e2070050
ER
735 . /etc/sysconfig/rpm; # global setting \
736 [ -f /etc/sysconfig/%1 ] && . /etc/sysconfig/%1; # per service setting \
737 echo ${RPM_SKIP_AUTO_RESTART:-no}; \
738}; \
462b26fa
ER
739if [ -f /var/lock/subsys/%1 ]; then \
740 if [ $(skip_auto_restart) = no ]; then \
e2070050 741 /etc/rc.d/init.d/%1 %2 1>&2; \
462b26fa 742 else \
3e913a30 743 echo 'Run "/etc/rc.d/init.d/%1 %2" to %2 %{!?3:%1 service}%{?3:%(set -- %{*}; echo "$3")}.'; \
462b26fa 744 fi \
3dabcf32 745%{!-q:else} \
3e913a30 746 %{!-q:echo 'Run "/etc/rc.d/init.d/%1 start" to start %{!?3:%1 service}%{?3:%(set -- %{*}; echo "$3")}.';} \
28d8c4be 747fi }; }
462b26fa 748
This page took 0.188646 seconds and 4 git commands to generate.