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