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