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