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