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