]> git.pld-linux.org Git - packages/rpm.git/blame - rpm.macros
- revert to python solution in %__spec_install_post_chrpath, readlink causes
[packages/rpm.git] / rpm.macros
CommitLineData
b52fc1f1 1# $Revision$, $Date$
cc2b296f 2# PLD Linux rpm macros
a8bf9720 3
90c0eaed 4%epoch 0
31b569b6 5%x8664 x86_64 amd64 ia32e
cd33aab7 6
a544555d 7# kernel compiler
6f86c45e 8%kgcc %{__cc}
cabacfeb 9%kgcc_package gcc
a544555d 10
7104afbf
ER
11# compiler version
12%cc_version %{expand:%%global cc_version %(%{__cc} -dumpversion || echo ERROR)}%cc_version
48a39d1d 13%cxx_version %{expand:%%global cxx_version %(%{__cxx} -dumpversion || echo ERROR)}%cxx_version
7104afbf 14
4343a1f7
ER
15%__rm /bin/rm --interactive=never
16
5f9f9bd7 17# Build system path macros.
18#
8af1c6f5
JB
19%__autoconf autoconf %{?debug:-Wall}
20%__automake automake -a -c -f --foreign
429d047e 21%__autopoint autopoint --force
22
aad1c8e4 23%__gettextize { \
4cd84746 24 if grep -qs 'AM_GNU_GETTEXT.*external' configure.{ac,in} ; then \
31b569b6 25 gettextize --copy --force --no-changelog; \
93bce43f 26 else \
31b569b6 27 gettextize --copy --force --no-changelog --intl; \
4cd84746
JB
28 fi; \
29 if [ ! -f po/Makevars ]; then \
31b569b6 30 cp -f po/Makevars{.template,}; \
4cd84746 31 fi; \
4cd84746 32}
429d047e 33
34%__glib_gettextize glib-gettextize --copy --force
35%__gnome_doc_common gnome-doc-common --copy
db1adf13 36%__gnome_doc_prepare gnome-doc-prepare --copy --force
429d047e 37%__gtkdocize gtkdocize --copy
38%__intltoolize intltoolize --copy --force
39%__libtoolize libtoolize --copy --force
5f9f9bd7 40
702e8027 41# Path to top of build area.
135188cb 42%_topdir %{expand:%%global _topdir %(test -d ../SPECS -a -d ../SOURCES && (cd ..; pwd) || echo $HOME/rpm)}%_topdir
702e8027 43
38e780ca
ER
44# The number of cvs changelog entries kept when building package.
45%_buildchangelogtruncate 20
46
bd1cd543 47%dependencytracking %{nil}
31b569b6 48
073ae3ba
ER
49# Relations between package names that cause dependency loops
50# with legacy packages that cannot be fixed. Relations are
51# specified as
52# p>q
53# where package p has a Requires: on something that package q Provides:
54#
55# XXX Note: that there cannot be any whitespace within the string "p>q",
56# and that both p and q are package names (i.e. no version/release).
57%_dependency_whiteout %{nil}
58
9ba56d1b
AM
59%_smp_mflags %([ -z "$RPM_BUILD_NCPUS" ] \\\
60 && RPM_BUILD_NCPUS="`/usr/bin/getconf _NPROCESSORS_ONLN`"; \\\
61 [ "$RPM_BUILD_NCPUS" -gt 1 ] && echo "-j$RPM_BUILD_NCPUS")
cece03f9 62
63#-----------------------------------------------------------------
64#
65# (re)definition of %{rpm*flags} with %filterout_* support
7c9f98ce
ER
66# BuildRequires: awk
67# BuildRequires: rpmbuild(macros) >= 1.315
cece03f9 68#
69# Flags specified in %filterout_* are removed from %rpm*flags, exactly:
a0bf497e 70# %rpmcflags = %optflags - %filterout - %filterout_c - %filterout_ld
71# %rpmcxxflags = %optflags - %filterout - %filterout_cxx - %filterout_ld
72# %rpmldflags = %optldflags - %filterout_ld
cece03f9 73#
74# Regular expressions are supported, but to avoid some character be treated
75# as regular expression it must be escaped twice.
76
77%filter_out \
bf66145e 78 for (i = 1; i in I; i++) { A=0; \
cece03f9 79 for (f in F) { \
80 if (I[i] ~ "^" F[f] "$") A=1; \
81 }; \
82 if (!A) printf(I[i] FS); \
83 }
84
85%rpmcflags %(awk 'BEGIN {
86 split("%{?debug:%debugcflags}%{!?debug:%optflags}%{?debuginfocflags}",I);
a0bf497e 87 split("%{?filterout} %{?filterout_c} %{?filterout_ld}",F);
cece03f9 88 %{filter_out}
89}')
90
91%rpmcxxflags %(awk 'BEGIN {
a0bf497e 92 split("%{?debug:%debugcflags}%{!?debug:%optflags}%{?debuginfocflags}",I);
93 split("%{?filterout} %{?filterout_cxx} %{?filterout_ld}",F);
cece03f9 94 %{filter_out}
95}')
96
97%rpmldflags %(awk 'BEGIN {
b699ccff 98 split("%{?optldflags}",I);
cece03f9 99 split("%{?filterout_ld}",F)
100 %{filter_out}
101}')
102
111942c6 103# rpmldflags with stripped -Wl, -- in the form flags have to be passed to 'ld'
104# but, don't use it, better use gcc as linker
105%ld_rpmldflags %(awk 'BEGIN {
106 split("%{rpmldflags}",F);
107 for (f in F) {
108 s = F[f];
109 if (s ~ /^-Wl,/) {
110 s = substr(s,5);
111 gsub(/,/," ",s);
112 };
113 printf(s FS);
114 };
115}')
116
cd33aab7 117#-----------------------------------------------------------------
9f0287b5 118%configure2_13 { \
cd33aab7
AM
119 if [ -n "$LINGUAS" ]; then unset LINGUAS; fi; \
120 LDFLAGS="${LDFLAGS:-%rpmldflags}" ; export LDFLAGS ; \
121 CFLAGS="${CFLAGS:-%rpmcflags}" ; export CFLAGS ; \
af18d245 122 CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" ; export CXXFLAGS ; \
cd33aab7 123 FFLAGS="${FFLAGS:-%rpmcflags}" ; export FFLAGS ; \
d4392e78 124 FCFLAGS="${FCFLAGS:-%rpmcflags}" ; export FCFLAGS ; \
c55f2219 125 CPPFLAGS="${CPPFLAGS:-}" ; export CPPFLAGS ; \
4eac2e49
AM
126 %{?__cc:CC="%{__cc}" ; export CC ; } \
127 %{?__cxx:CXX="%{__cxx}" ; export CXX ; } \
5b0f0ac9 128 %{?configuredir:%{configuredir}}%{!?configuredir:.}/configure \
fa74a11c 129 --host=%{_target_platform} \
cd33aab7
AM
130 --prefix=%{_prefix} \
131 --exec-prefix=%{_exec_prefix} \
132 --bindir=%{_bindir} \
133 --sbindir=%{_sbindir} \
134 --sysconfdir=%{_sysconfdir} \
135 --datadir=%{_datadir} \
136 --includedir=%{_includedir} \
137 --libdir=%{_libdir} \
138 --libexecdir=%{_libexecdir} \
139 --localstatedir=%{_localstatedir} \
140 --sharedstatedir=%{_sharedstatedir} \
141 --mandir=%{_mandir} \
142 --infodir=%{_infodir} \
c3420100 143 --x-libraries=%{?_x_libraries}%{!?_x_libraries:%{_libdir}} \
8b4be1e1 144 %{dependencytracking} \
cd33aab7
AM
145}
146
53c34296
ER
147# override __cmake to add -j4 in your ~/.rpmmacros for parallel make
148%__cmake /usr/bin/cmake
29771119
ER
149%cmake { \
150CC="%{__cc}" \
151CXX="%{__cxx}" \
152CFLAGS="%{rpmcflags}" \
153CXXFLAGS="%{rpmcxxflags}" \
53c34296
ER
154%{__cmake} \
155}
156
157# override __scons to add -j4 in your ~/.rpmmacros for parallel make
158%__scons /usr/bin/scons
159%scons { \
160%{__scons} \
13eb0f84
ER
161 LDFLAGS="${LDFLAGS:-%rpmldflags}" \
162 CFLAGS="${CFLAGS:-%rpmcflags}" \
163 CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" \
164 FFLAGS="${FFLAGS:-%rpmcflags}" \
165 CPPFLAGS="${CPPFLAGS:-}" \
166 %{?__cc:CC="%{__cc}"} \
167 %{?__cxx:CXX="%{__cxx}"} \
168 libsuffix=%{_lib} \
169 prefix=%{_prefix} \
29771119
ER
170}
171
ac093701 172# waf. see waf.spec
53c34296 173# override __waf to add -j4 in your ~/.rpmmacros for parallel make
ac093701
ER
174%__waf /usr/bin/waf
175%waf { \
ac093701
ER
176CC="%{__cc}" \
177CXX="%{__cxx}" \
1624498d 178CPP="%{__cpp}" \
ac093701
ER
179CFLAGS="%{rpmcflags}" \
180CXXFLAGS="%{rpmcxxflags}" \
181%{__waf} \
ac093701
ER
182}
183
85f82bec 184#----------------------------------------------------------------
b7626f51 185#%configure_cache 0
43f81f06 186%configure_cache_file %{buildroot}.configure.cache
7e4e3f2b 187
b8cf6778 188%configure {./configure \
85f82bec
AF
189 LDFLAGS="${LDFLAGS:-%rpmldflags}" \
190 CFLAGS="${CFLAGS:-%rpmcflags}" \
af18d245 191 CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" \
85f82bec 192 FFLAGS="${FFLAGS:-%rpmcflags}" \
d4392e78 193 FCFLAGS="${FCFLAGS:-%rpmcflags}" \
418d9760 194 CPPFLAGS="${CPPFLAGS:-}" \
4eac2e49
AM
195 %{?__cc:CC="%{__cc}"} \
196 %{?__cxx:CXX="%{__cxx}"} \
a9bea0f7 197 --host=%{_target_platform} \
85f82bec
AF
198 --build=%{_target_platform} \
199 --prefix=%{_prefix} \
200 --exec-prefix=%{_exec_prefix} \
201 --bindir=%{_bindir} \
202 --sbindir=%{_sbindir} \
203 --sysconfdir=%{_sysconfdir} \
204 --datadir=%{_datadir} \
205 --includedir=%{_includedir} \
206 --libdir=%{_libdir} \
207 --libexecdir=%{_libexecdir} \
208 --localstatedir=%{_localstatedir} \
209 --sharedstatedir=%{_sharedstatedir} \
210 --mandir=%{_mandir} \
211 --infodir=%{_infodir} \
c3420100 212 --x-libraries=%{?_x_libraries}%{!?_x_libraries:%{_libdir}} \
8b4be1e1 213 %{dependencytracking} \
b7626f51 214 %{?configure_cache:--cache-file=%{configure_cache_file}} \
85f82bec
AF
215}
216
9cd5fb46
ER
217# overload to insert debuginfo package
218%prep \
219%if 0%{?_enable_debug_packages}\
220%{debug_package}\
221%endif\
222%%prep\
223%{nil}
224
cd33aab7 225# Location of autoconf macros
742f3bc4 226%_aclocaldir %{expand:%%global _aclocaldir %(aclocal --print-ac-dir || echo ERROR)}%_aclocaldir
cd33aab7 227
32720a50 228# Location of omf files
742f3bc4 229%_omf_dest_dir %{expand:%%global _omf_dest_dir %(scrollkeeper-config --omfdir || echo ERROR)}%_omf_dest_dir
32720a50 230
c5eece2c 231# Location of pkgconfig files
a46897a7 232%_pkgconfigdir /usr/%{_lib}/pkgconfig
e2023017
JB
233# noarch pkgconfig files
234%_npkgconfigdir /usr/share/pkgconfig
c5eece2c 235
c917274d 236# Location of desktop files
237%_desktopdir /usr/share/applications
510f694c 238%_applnkdir ERROR:_applnkdir_is_obsolete_use_desktopdir_instead
c917274d 239
fb08fb4a 240# Location of pixmaps for applnk/desktop files
3a9bb008 241%_pixmapsdir /usr/share/pixmaps
cd33aab7 242
fb08fb4a 243# Location of themable icons for applnk/desktop files
986c3bcd 244%_iconsdir /usr/share/icons
245
c5eece2c
JB
246# Location of fonts directories
247%_fontsdir /usr/share/fonts
248
5cfcbc9e 249# Location of Gtk and associated libraries documentation
43f81f06 250%_gtkdocdir %{_defaultdocdir}/gtk-doc/html
5cfcbc9e 251
eee08b2d 252# Location of KDE documentation
43f81f06 253%_kdedocdir %{_defaultdocdir}/kde/HTML
eee08b2d 254
a7cad6ae 255# unsermake script
256%__unsermake /usr/share/unsermake/unsermake
257
cd33aab7
AM
258# Current date
259%date %(LC_ALL="C" date +"%a %b %d %Y")
260
cd33aab7
AM
261# Example files, programs, scripts...
262%_examplesdir /usr/src/examples
263
7127e0fc 264# Alternative kernel type/version
c604d0a9 265%_alt_kernel %{nil}%{?alt_kernel:-%{?alt_kernel}}
7127e0fc 266
bd63739a 267# The directory holding Linux kernel sources
c604d0a9 268%_kernelsrcdir /usr/src/linux%{_alt_kernel}
bd63739a 269
cd33aab7 270# If non-empty "debug" macro defined, add "dbg" suffix to release number
5b0f0ac9 271%_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}%{?debug:dbg}.%%{ARCH}.rpm
cd33aab7 272
5b0f0ac9 273# Requires name = version-release
48c1bf9f 274%requires_releq() %(echo '%*' | LC_ALL="C" xargs -r rpm -q --qf 'Requires: %{N} = %|E?{%{E}:}|%{V}-%{R}\\n' | grep -v 'is not')
511ee4c6 275
135188cb
ER
276%releq_kernel %{expand:%%global releq_kernel %(R=$(LC_ALL=C rpm -q --qf '%{N} = %|E?{%{E}:}|%{V}-%{R}' -f %{_kernelsrcdir}/include/linux/version.h 2>/dev/null | grep -v 'is not' | sed -e 's:-headers::;s:-config::'); echo ${R:-ERROR})}%releq_kernel
277%releq_kernel_up %{expand:%%global releq_kernel_up %(R=$(LC_ALL=C rpm -q --qf '%{N}-up = %|E?{%{E}:}|%{V}-%{R}' -f %{_kernelsrcdir}/include/linux/version.h 2>/dev/null | grep -v 'is not' | sed -e 's:-headers::;s:-config::'); echo ${R:-ERROR})}%releq_kernel_up
278%releq_kernel_smp() %{expand:%%global releq_kernel_smp %(R=$(LC_ALL=C rpm -q --qf '%{N}-smp = %|E?{%{E}:}|%{V}-%{R}' -f %{_kernelsrcdir}/include/linux/version.h 2>/dev/null | grep -v 'is not' | sed -e 's:-headers::;s:-config::'); echo ${R:-ERROR})}%releq_kernel_smp
d606f9ca
ER
279%requires_releq_kernel(s:) Requires%{-s:(%{-s*})}: %releq_kernel
280%requires_releq_kernel_up(s:) Requires%{-s:(%{-s*})}: %releq_kernel_up
281%requires_releq_kernel_smp(s:) Requires%{-s:(%{-s*})}: %releq_kernel_smp
511ee4c6 282
48c1bf9f
ER
283# XXX: why epoch 0 is stripped?
284%requires_eq() %(echo '%*' | LC_ALL="C" xargs -r rpm -q --qf 'Requires: %{N} = %|E?{%{E}:}|%{V}\\n' | sed -e 's/ 0:/ /' | grep -v 'is not')
285%requires_eq_to() %(LC_ALL="C" rpm -q --qf 'Requires: %1 = %|E?{%{E}:}|%{V}' %2 | grep -v "is not")
e478b9e7 286
a1551c98 287%apache_modules_api %{expand:%%global apache_modules_api %(awk '/#define MODULE_MAGIC_NUMBER_MAJOR/ {print $3}' /usr/include/apache/ap_mmn.h 2>/dev/null || echo ERROR)}%apache_modules_api
8dea1306 288
289# kernel version-release handling
1c1268c5
ER
290%__kernel_ver %{expand:%%global __kernel_ver %( \\
291 Z=$(awk -F'"' '/UTS_RELEASE/{print $2}' %{_kernelsrcdir}/include/linux/{version,utsrelease}.h 2>/dev/null); \\
292 Z=${Z:-$(awk -F' = ' '/^VERSION/{v=$2} /^PATCHLEVEL/{p=$2} /^SUBLEVEL/{s=$2} /^EXTRAVERSION/{e=$2} END {printf("%d.%d.%d%s", v, p, s, e)}' %{_kernelsrcdir}/Makefile 2>/dev/null)}; \\
293 echo ${Z:-ERROR}; \\
91897f8e 294)}%__kernel_ver
1c1268c5 295
a1551c98
ER
296%__kernel_rel %{expand:%%global __kernel_rel %(Z=$(LC_ALL=C rpm -qf %{_kernelsrcdir}/include/linux/fs.h 2>/dev/null --qf "%{R}" | grep -v "is not"); echo ${Z:-ERROR})}%__kernel_rel
297%__kernel_rpmvr %{expand:%%global __kernel_rpmvr %(Z=$(LC_ALL=C rpm -qf %{_kernelsrcdir}/include/linux/fs.h 2>/dev/null --qf "%{V}-%{R}" | grep -v "is not"); echo ${Z:-ERROR})}%__kernel_rpmvr
298%_kernel_ver %{expand:%%global _kernel_ver %{__kernel_ver}%{?with_dist_kernel:%(echo %{__kernel_ver} | grep -q -e - || echo -%{__kernel_rel})}}%_kernel_ver
299%_kernel_ver_str %{expand:%%global _kernel_ver_str %(echo %{!?_without_dist_kernel:%{__kernel_rpmvr}}%{?_without_dist_kernel:%{__kernel_ver}} | sed -e 's/-/_/g')}%_kernel_ver_str
fd4d8ee0 300
63fcfda0
ER
301# `uname -r` to be used in @release field
302%_kernel_vermagic %{expand:%%global _kernel_vermagic %(echo %{_kernel_ver} | sed -e 's/-/_/g')}%_kernel_vermagic
303
c2c27a5a 304# sgml macros
31b569b6
ER
305%xmlcat_add() /usr/bin/xmlcatalog --noout --add nextCatalog \"\" %1 /etc/xml/catalog ;
306%xmlcat_del() /usr/bin/xmlcatalog --noout --del %1 /etc/xml/catalog ;
307%xmlcat_add_rewrite /usr/bin/xmlcatalog --noout --add rewriteSystem
308%xmlcat_create() /usr/bin/xmlcatalog --noout --create %1 ;
309%sgmlcat_add() /usr/bin/install-catalog --add %1 %2 > /dev/null ;
310%sgmlcat_del() /usr/bin/install-catalog --remove %1 %2 > /dev/null ;
c2c27a5a 311%docbook_sgmlcat_fix() { for l in \
312'' \
313' -- default decl --' \
314'DTDDECL "-//OASIS//DTD DocBook XML V%2//EN" "../../xml.dcl"' \
315' -- hacks for opensp --' \
316'SYSTEM "file://%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
317'SYSTEM "http://www.oasis-open.org/docbook/xml/%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
318'' \
319; do echo $l; done >> %1 \
320}
321
31bd34a8
ER
322# vim - "
323
f3f40db8
ER
324# minimum file size needed for compressed documents.
325# just smaller files than this get larger when compressed.
cdbfc157
ER
326# some stats:
327# - 0 byte file compressed was 25 bytes .gz
328# - 39 byte file was compressed as 57
329# - with test/test.spec@man 158 byte file was compressed also 158
330%_min_compress_bytes 159
f3f40db8 331
cd33aab7
AM
332#-----------------------------------------------------------------
333# find and gzip all files in %{_mandir} and %{infodir}
334#
335# Requires: xargs, find
336#
337#%no_install_post_compress_docs 1
338%__spec_install_post_compress_docs { \
f67bd19e 339%{!?no_install_post_compress_docs:__spec_install_post_compress_docs() { \
026ed59b 340 for i in /usr/share/man /usr/X11R6/man; do \
cd33aab7 341 if [ -d "$RPM_BUILD_ROOT$i" ]; then \
026ed59b 342 echo "Compress man pages: $i"; \
f3f40db8
ER
343 find "$RPM_BUILD_ROOT$i" -name '*.bz2' -print | xargs -r %{__bzip2} -df; \
344 find "$RPM_BUILD_ROOT$i" -name '*.gz' -print | xargs -r %{__gzip} -dnf; \
38e531f0
ER
345 find $RPM_BUILD_ROOT$i -type l | while read a; do \
346 m=$(readlink $a); \
347 rm -f $a; \
348 echo .so ${m##*/} > $a; \
349 echo >&2 "Converted ${a#$RPM_BUILD_ROOT} from symlink to man link: ${m##*/}"; \
350 done; \
f3f40db8 351 find "$RPM_BUILD_ROOT$i" -type f -size +%{_min_compress_bytes}c -print | xargs -r %{__gzip} -9nf; \
cd33aab7
AM
352 fi; \
353 done; \
91bfff1c
JB
354 if [ -d "$RPM_BUILD_ROOT%{_infodir}" ]; then \
355 echo "Compress info pages: %{_infodir}"; \
356 find "$RPM_BUILD_ROOT%{_infodir}" -name '*.bz2' -print | xargs -r %{__bzip2} -df; \
357 find "$RPM_BUILD_ROOT%{_infodir}" -name '*.gz' -print | xargs -r %{__gzip} -dnf; \
358 find "$RPM_BUILD_ROOT%{_infodir}" -name '*.info*' -type f -size +%{_min_compress_bytes}c -print | xargs -r %{__gzip} -9nf; \
026ed59b 359 fi; \
f67bd19e 360}; __spec_install_post_compress_docs } }
cd33aab7
AM
361
362#-----------------------------------------------------------------
363# Strip executable binaries and shared object files
364#
365# Requires: find, awk, strip, cut, xargs
366#
ee170415
JB
367# Special macros which affect this process:
368#%no_install_post_strip 1 # disable stripping at all
369#%_noautostrip regexp # exclude files matching (anchored!) regex from stripping
370#%_autostripall regexp # strip files matching (anchored!) regex using plain strip
371#%_autostripunneeded regexp # strip files matching (anchored!) regex using strip --strip-unneeded
372#%_autostripdebug regexp # strip files matching (anchored!) regex using strip --strip-debug
373#
cd33aab7 374%__spec_install_post_strip {%{!?debug: \
f67bd19e 375%{!?no_install_post_strip:__spec_install_post_strip() { \
65e03cc0 376if [ -d "$RPM_BUILD_ROOT" ]; then \
31bd34a8
ER
377 if [ -d $RPM_BUILD_ROOT/lib/modules ]; then \
378 modulelist=$(find $RPM_BUILD_ROOT/lib/modules -name '*o' -type f -print); \
fefadad0
ER
379 if [ "$modulelist" ]; then \
380 modulecount=$(echo "$modulelist" | wc -l); \
7f1d3873 381 printf "Stripping %d kernel modules..." $modulecount; \
6cf69412
ER
382 echo "$modulelist" | xargs -l512 chmod u+w; \
383 echo "$modulelist" | xargs -l512 %{__strip} --strip-unneeded --remove-section=.comment --remove-section=.note.GNU-stack; \
384 echo "DONE"; \
385 fi; \
31bd34a8 386 fi; \
559c4907 387 filelist=$(find $RPM_BUILD_ROOT -type f ! -regex ".*/usr/lib[0-9]*/debug/.*\.debug" ! -regex ".*/lib/modules/.*" ! -regex ".*%{_docdir}/.*" ! -regex ".*%{_includedir}/.*" %{?_noautostrip:! -regex "%{_noautostrip}"} %{?_autostripall:! -regex "%{_autostripall}"} %{?_autostripunneeded:! -regex "%{_autostripunneeded}"} %{?_autostripdebug:! -regex "%{_autostripdebug}"}); \
d65f5d0e
JB
388 if [ -n "$filelist" ]; then \
389 filetypes=`echo "$filelist" | xargs -r -d'\\n' file`; \
390 elfexelist=`echo "$filetypes" | awk -F: '/ELF.*executable/ {print $1}'`; \
391 elfsharedlist=`echo "$filetypes" | awk -F: '/LF.*shared object/ {print $1}'`; \
ee170415 392 archiveslist=`echo "$filetypes" | awk -F: '/current ar archive/ {print $1}'`; \
d65f5d0e 393 if [ -n "$elfexelist" ]; then \
fefadad0 394 printf "Stripping %d ELF executables..." $(echo "$elfexelist" | wc -l); \
d65f5d0e
JB
395 chmod u+w $elfexelist; \
396 %{__strip} --remove-section=.note --remove-section=.comment $elfexelist; \
397 echo "DONE"; \
398 fi; \
399 if [ -n "$elfsharedlist" ]; then \
fefadad0 400 printf "Stripping %d ELF shared libraries..." $(echo "$elfsharedlist" | wc -l); \
d65f5d0e
JB
401 chmod u+w $elfsharedlist; \
402 %{__strip} --strip-unneeded --remove-section=.note --remove-section=.comment $elfsharedlist; \
403 echo "DONE"; \
404 fi; \
405 if [ -n "$archiveslist" ]; then \
fefadad0 406 printf "Stripping %d ar archives..." $(echo "$archiveslist" | wc -l); \
d65f5d0e
JB
407 chmod u+w $archiveslist; \
408 %{__strip} --strip-debug --remove-section=.note --remove-section=.comment $archiveslist; \
409 echo "DONE"; \
410 fi; \
65e03cc0 411 fi; \
559c4907
ER
412 filelist_all=%{?_autostripall:$(find $RPM_BUILD_ROOT -type f -regex "%{_autostripall}")}; \
413 filelist_unneeded=%{?_autostripunneeded:$(find $RPM_BUILD_ROOT -type f -regex "%{_autostripunneeded}")}; \
414 filelist_debug=%{?_autostripdebug:$(find $RPM_BUILD_ROOT -type f -regex "%{_autostripdebug}")}; \
d65f5d0e 415 if [ -n "$filelist_all" ]; then \
fefadad0 416 printf "Stripping everything from %d additional files..." $(echo "$filelist_all" | wc -l); \
ee170415 417 chmod u+w $filelist_all; \
d65f5d0e 418 %{__strip} --remove-section=.note --remove-section=.comment $filelist_all; \
fc87add2 419 echo "DONE"; \
cd33aab7 420 fi; \
d65f5d0e 421 if [ -n "$filelist_unneeded" ]; then \
fefadad0 422 printf "Stripping unneeded from %d additional files..." $(echo "$filelist_unneeded" | wc -l); \
ee170415 423 chmod u+w $filelist_unneeded; \
d65f5d0e 424 %{__strip} --strip-unneeded --remove-section=.note --remove-section=.comment $filelist_unneeded; \
fc87add2 425 echo "DONE"; \
5b0f0ac9 426 fi; \
d65f5d0e 427 if [ -n "$filelist_debug" ]; then \
fefadad0 428 printf "Stripping debuginfo from %d additional files..." $(echo "$filelist_debug" | wc -l); \
ee170415 429 chmod u+w $filelist_debug; \
d65f5d0e 430 %{__strip} --strip-debug --remove-section=.note --remove-section=.comment $filelist_debug; \
fc87add2 431 echo "DONE"; \
f80cefa3 432 fi; \
f67bd19e 433fi; }; __spec_install_post_strip } } }
31b569b6 434
cc545e1a 435#-----------------------------------------------------------------
436# remove all RPATH from executable binaries and shared object files
437#
438# Requires: find, awk, cut, xargs, chrpath, uname
439#
ee170415
JB
440# Special macros which affect this process
441#%no_install_post_chrpath 1 # disable chrpath at all
442#%_noautochrpath regex # exclude files matching (anchored!) regex from chrpath
443#
cc545e1a 444%__spec_install_post_chrpath {%{!?debug: \
f67bd19e 445%{!?no_install_post_chrpath: __spec_install_post_chrpath() { \
f80cefa3 446if [ -d "$RPM_BUILD_ROOT" ]; then \
559c4907 447 files=`find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*" ! -regex ".*/usr/lib[0-9]*/debug/.*" ! -regex ".*/lib/modules/.*" ! -regex ".*%{_docdir}/.*" ! -regex ".*%{_includedir}/.*" %{?_noautochrpath:! -regex "%{_noautochrpath}"}`; \
65e03cc0 448 if [ -n "$files" ]; then \
0faed11b 449 objs=`echo "$files" | xargs -r -d'\\n' file | awk -F: '/ELF.*(executable.*dynamically linked|shared object)/ {print $1}'`; \
fd3a42b0 450 fi; \
65e03cc0 451 if [ -n "$objs" ]; then \
fefadad0 452 printf "Remove RPATH from %d executable binaries and shared object files.\n" $(echo "$objs" | wc -l); \
65e03cc0
ER
453 echo "$objs" | \
454 while read file; do \
455 rpath= ; \
456 chmod u+w "$file"; \
ebc04679 457 for dir in $(chrpath -l "$file" | awk '/RPATH=/ { gsub(/.*RPATH=/,""); gsub(/:/," "); print $0 }'); do \
73f65316 458 dir=$(%{__python} -c 'import sys, os; print os.path.normpath(sys.argv[1]);' "$dir"); \
65e03cc0
ER
459 case $dir in \
460 /home/* | /tmp/* | /usr/lib | /usr/lib64 | /lib | /lib64 | /usr/local/lib | /usr/local/lib64 | /usr/X11R6/lib | /usr/X11R6/lib64 ) \
461 echo "remove-rpath: $dir in $file"; \
462 ;; \
463 * ) \
464 if [ "$rpath" = "" ] ; then rpath="$dir" ; \
465 else rpath="$rpath:$dir" ; fi ; \
466 ;; \
467 esac ; \
468 done ; \
469 if [ "$rpath" = "" ] ; then chrpath -d "$file" > /dev/null ; \
470 else chrpath -r "$rpath" "$file" > /dev/null ; fi ; \
471 done; \
472 fi; \
f67bd19e 473fi; }; __spec_install_post_chrpath } } }
31b569b6 474
22a54b3e 475#-----------------------------------------------------------------
93b46c00 476# Find and gzip all kernel modules
477#
478# Requires: find
479#
43f81f06 480#%no_install_post_compress_modules 1
93b46c00 481%__spec_install_post_compress_modules { \
f67bd19e 482%{!?no_install_post_compress_modules: __spec_install_post_compress_modules() { \
9cf7c1b9 483 if [ -d $RPM_BUILD_ROOT/lib/modules ]; then \
9cf7c1b9 484 q=$(find $RPM_BUILD_ROOT/lib/modules -name '*o' -type f -print); \
fefadad0
ER
485 if [ "$q" ]; then \
486 printf "Compress %d kernel modules..." $(echo "$q" | wc -l); \
487 echo "$q" | xargs -r %{__gzip} -9nf; \
488 echo "DONE"; \
489 find $RPM_BUILD_ROOT/lib/modules -name '*o' -type l -printf "%p %l\n" | \
490 while read a b; do ln -sf $b.gz $a.gz; rm -f $a; done; \
491 fi; \
31b569b6 492 fi; \
f67bd19e 493}; __spec_install_post_compress_modules } }
cd33aab7 494
e4d71427
ER
495# Remove common Perl files we don't package
496%__spec_install_post_perl_clean {\
497%{!?no_install_post_perl_clean: \
498%{?pdir:rm -f $RPM_BUILD_ROOT{%{perl_archlib}/perllocal.pod,%{perl_vendorarch}/auto/%{pdir}%{?pnam:/%(echo %{pnam} | tr - /)}/.packlist}} \
499} }
500
aad1c8e4 501#-----------------------------------------------------------------
cc6c554c 502# Update GConf2 schemas
aad1c8e4 503#
504# Requires: GConf2
505#
5b8ed3c0 506%gconf_schema_install() \
31b569b6 507 umask 022; \
2b633092
ER
508 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; \
509%{nil}
5b8ed3c0 510
511%gconf_schema_uninstall() \
429d047e 512if [ $1 = 0 ]; then \
31b569b6
ER
513 umask 022; \
514 GCONF_CONFIG_SOURCE="xml:readwrite:/etc/gconf/gconf.xml.defaults" /usr/bin/gconftool-2 --makefile-uninstall-rule /etc/gconf/schemas/%{?1} > /dev/null \
2b633092 515fi; \
429d047e 516%{nil}
517
518#-----------------------------------------------------------------
519# Update desktop MIME database
96999189 520# requires: desktop-file-utils
7ec40643 521%update_desktop_database() {{ \
429d047e 522 umask 022; \
db1adf13 523 /usr/bin/update-desktop-database -q; \
c6f21aa8 524}}%{nil}
429d047e 525
7ec40643
ER
526%update_desktop_database_post %update_desktop_database
527
528%update_desktop_database_postun() {{ \
2b633092 529if [ "$1" = "0" ]; then \
7ec40643 530 %update_desktop_database; \
2b633092 531fi; \
c6f21aa8 532}}%{nil}
429d047e 533
db1adf13 534#-----------------------------------------------------------------
535# Update shared MIME info database
536# requires: shared-mime-info
537#
7ec40643 538%update_mime_database() {{ \
db1adf13 539 umask 022; \
540 /usr/bin/update-mime-database %{_datadir}/mime; \
c6f21aa8 541}}%{nil}
db1adf13 542
543#-----------------------------------------------------------------
544# Update icon cache
545# requires: gtk+
546#
7ec40643 547%update_icon_cache() {{ \
db1adf13 548 umask 022; \
8ffd1cc2 549 /usr/bin/gtk-update-icon-cache -qf %{_datadir}/icons/%1; \
c6f21aa8 550}}%{nil}
db1adf13 551
429d047e 552#-----------------------------------------------------------------
553# Update scrollkeeper database
554# requires: scrollkeeper
555#
556%scrollkeeper_update_post() \
429d047e 557 /usr/bin/scrollkeeper-update -q; \
2b633092 558%{nil}
429d047e 559
560%scrollkeeper_update_postun() \
2b633092 561if [ "$1" = "0" ]; then \
429d047e 562 /usr/bin/scrollkeeper-update -q; \
2b633092 563fi; \
429d047e 564%{nil}
565
cd33aab7
AM
566#-----------------------------------------------------------------
567# post %install sequence:
568# - autodeps exceptions
569# - compress all man and info pages,
570# - strip all ELF executables and ELF shared objects if not %debug.
5b0f0ac9 571# - compress kernel modules if any
cd33aab7
AM
572
573###################################################################
574# Requires/Provides automation
575# exceptions system by Jacek Konieczny <jajcus@pld.org.pl>
a4852742 576#
fbbdca08
JB
577%__noautoreqfiles %(sed -e s'/#.*//' /etc/rpm/noautoreqfiles)%{?_noautoreqfiles: %{_noautoreqfiles}}
578%__noautoprovfiles %(sed -e s'/#.*//' /etc/rpm/noautoprovfiles)%{?_noautoprovfiles: %{_noautoprovfiles}}
579%__noautoreq %(sed -e s'/#.*//' /etc/rpm/noautoreq)%{?_noautoreq: %{_noautoreq}}
580%__noautoreqdep %(sed -e s'/#.*//' /etc/rpm/noautoreqdep)%{?_noautoreqdep: %{_noautoreqdep}}
581%__noautoprov %(sed -e s'/#.*//' /etc/rpm/noautoprov)%{?_noautoprov: %{_noautoprov}}
a1551c98 582
a4852742
JB
583#%_noautocompressdoc %{nil}
584#
5b0f0ac9
MM
585%_missing_doc_files_terminate_build 1%{nil}
586%_unpackaged_files_terminate_build %{nil}
4c7d3ba4 587# (X)emacs support
42b7e5ac 588%___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;}'
a1551c98
ER
589%_emacs_lispdir %{expand:%%global _emacs_lispdir %(Z=$(emacs %___emacs_lispdir_helper); echo ${Z:-ERROR})}%_emacs_lispdir
590%_xemacs_lispdir %{expand:%%global _xemacs_lispdir %(Z=$(xemacs %___emacs_lispdir_helper); echo ${Z:-ERROR})}%_xemacs_lispdir
41a62699 591
984f6de6
JK
592%__php_provides %{nil}
593%__php_requires %{nil}
594%__perl_provides %{nil}
595%__perl_requires %{nil}
63b0a9d7 596%__mono_provides %{nil}
597%__mono_requires %{nil}
41a62699
AF
598
599# Perl specific macro definitions.
a1551c98
ER
600%perl_privlib %{expand:%%global perl_privlib %(eval $(%{__perl} -V:installprivlib 2>/dev/null); echo ${installprivlib:-ERROR})}%perl_privlib
601%perl_archlib %{expand:%%global perl_archlib %(eval $(%{__perl} -V:installarchlib 2>/dev/null); echo ${installarchlib:-ERROR})}%perl_archlib
602%perl_vendorlib %{expand:%%global perl_vendorlib %(eval $(%{__perl} -V:installvendorlib 2>/dev/null); echo ${installvendorlib:-ERROR})}%perl_vendorlib
603%perl_vendorarch %{expand:%%global perl_vendorarch %(eval $(%{__perl} -V:installvendorarch 2>/dev/null); echo ${installvendorarch:-ERROR})}%perl_vendorarch
604%perl_sitelib %{expand:%%global perl_sitelib %(eval $(%{__perl} -V:installsitelib 2>/dev/null); echo ${installsitelib:-ERROR})}%perl_sitelib
605%perl_sitearch %{expand:%%global perl_sitearch %(eval $(%{__perl} -V:installsitearch 2>/dev/null); echo ${installsitearch:-ERROR})}%perl_sitearch
41a62699 606
cb84f517 607# Ruby
a1551c98
ER
608%__ruby /usr/bin/ruby
609%ruby_archdir %{expand:%%global ruby_archdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["archdir"]' 2>/dev/null || echo ERROR)}%ruby_archdir
610%ruby_ridir %{expand:%%global ruby_ridir %(%{__ruby} -r rbconfig -e 'include Config; print File.join(CONFIG["datadir"], "ri", CONFIG["ruby_version"], "system")' 2>/dev/null || echo ERROR)}%ruby_ridir
611%ruby_rubylibdir %{expand:%%global ruby_rubylibdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["rubylibdir"]' 2>/dev/null || echo ERROR)}%ruby_rubylibdir
612%ruby_vendorarchdir %{expand:%%global ruby_vendorarchdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["vendorarchdir"]' 2>/dev/null || echo ERROR)}%ruby_vendorarchdir
613%ruby_vendorlibdir %{expand:%%global ruby_vendorlibdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["vendorlibdir"]' 2>/dev/null || echo ERROR)}%ruby_vendorlibdir
614%ruby_sitearchdir %{expand:%%global ruby_sitearchdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["sitearchdir"]' 2>/dev/null || echo ERROR)}%ruby_sitearchdir
615%ruby_sitelibdir %{expand:%%global ruby_sitelibdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["sitelibdir"]' 2>/dev/null || echo ERROR)}%ruby_sitelibdir
616%ruby_version %{expand:%%global ruby_version %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["ruby_version"]' 2>/dev/null || echo ERROR)}%ruby_version
5483bb35
ER
617%ruby_ver_requires_eq Requires: ruby(ver) = %ruby_version
618%ruby_mod_ver_requires_eq Requires: ruby-modules(ver) = %ruby_version
cb84f517 619
3da52f86 620%php_pear_dir /usr/share/pear
a1551c98
ER
621%php_extensiondir %{expand:%%global php_extensiondir %(php-config --extension-dir 2>/dev/null || echo ERROR)}%php_extensiondir
622%php_sysconfdir %{expand:%%global php_sysconfdir %(php-config --sysconfdir 2>/dev/null || echo ERROR)}%php_sysconfdir
623%php_includedir %{expand:%%global php_includedir %(php-config --include-dir 2>/dev/null || echo ERROR)}%php_includedir
41a62699 624
f73da51b 625# extract php/zend api versions
a1551c98
ER
626%php_major_version %{expand:%%global php_major_version %(awk '/#define PHP_MAJOR_VERSION/{print $3}' %{php_includedir}/main/php_version.h 2>/dev/null || echo ERROR)}%php_major_version
627%php_api_version %{expand:%%global php_api_version %(awk '/#define PHP_API_VERSION/{print $3}' %{php_includedir}/main/php.h 2>/dev/null || echo ERROR)}%php_api_version
628%php_pdo_api_version %{expand:%%global php_pdo_api_version %(awk '/#define PDO_DRIVER_API/{print $3}' %{php_includedir}/ext/pdo/php_pdo_driver.h 2>/dev/null || echo ERROR)}%php_pdo_api_version
629%php_debug %{expand:%%global php_debug %(awk '/#define ZEND_DEBUG/{print $3}' %{php_includedir}/main/php_config.h 2>/dev/null || echo ERROR)}%php_debug
630%zend_module_api %{expand:%%global zend_module_api %(awk '/#define ZEND_MODULE_API_NO/{print $3}' %{php_includedir}/Zend/zend_modules.h 2>/dev/null || echo ERROR)}%zend_module_api
631%zend_extension_api %{expand:%%global zend_extension_api %(awk '/#define ZEND_EXTENSION_API_NO/{print $3}' %{php_includedir}/Zend/zend_extensions.h 2>/dev/null || echo ERROR)}%zend_extension_api
632%zend_zts %{expand:%%global zend_zts %(Z=$(grep -sc '^#define ZTS 1' %{php_includedir}/main/php_config.h); echo ${Z:-ERROR})}%zend_zts
6b2157a6
ER
633
634# helper macro
e255dfdc 635%__php_api_requires(v:) Requires: php%{-v*}(%{expand:%1}) = %{expand:%{%{!?2:%{1}}%{?2}}}
6b2157a6
ER
636
637# macros for public use
638# for php extensions (php-pecl)
ab8d73ee 639%requires_php_extension %{__php_api_requires modules_api php_api_version} \
cc2b296f 640%{__php_api_requires zend_module_api} \
e255dfdc
ER
641%{__php_api_requires -v %php_major_version debug php_debug} \
642%{__php_api_requires -v %php_major_version thread-safety zend_zts}
ab8d73ee 643
6b2157a6
ER
644# for zend extensions
645%requires_zend_extension %{__php_api_requires zend_module_api} \
ab8d73ee 646%{__php_api_requires zend_extension_api} \
e255dfdc
ER
647%{__php_api_requires -v %php_major_version debug php_debug} \
648%{__php_api_requires -v %php_major_version thread-safety zend_zts}
6b2157a6 649
1c107a2d
ER
650# for php pdo modules (php-pecl-PDO_*)
651%requires_php_pdo_module %{__php_api_requires PDO_API php_pdo_api_version}
652
e6ca24e8
ER
653# for using PHP post scripts. for PHP >= 5.0
654%php_webserver_restart \
655[ ! -f /etc/apache/conf.d/??_mod_php.conf ] || %service -q apache restart \
febce2c9 656[ ! -f /etc/httpd/conf.d/??_mod_php.conf ] || %service -q httpd restart \
b4080c85
ER
657if [ -f /etc/rc.d/init.d/php-fcgi ]; then \
658 PHP_FCGI_BINARY=; . /etc/sysconfig/php-fcgi 2>/dev/null \
659 if [[ ${PHP_FCGI_BINARY:-php.fcgi} = *php.fcgi* ]]; then \
660 %service -q php-fcgi restart \
661 fi \
662fi \
e6ca24e8
ER
663%{nil}
664
665# for using php post scripts. for PHP >= 4.0 && PHP < 5.0
666%php4_webserver_restart \
667[ ! -f /etc/apache/conf.d/??_mod_php4.conf ] || %service -q apache restart \
febce2c9 668[ ! -f /etc/httpd/conf.d/??_mod_php4.conf ] || %service -q httpd restart \
b4080c85
ER
669if [ -f /etc/rc.d/init.d/php-fcgi ]; then \
670 PHP_FCGI_BINARY=; . /etc/sysconfig/php-fcgi 2>/dev/null \
671 if [[ ${PHP_FCGI_BINARY:-php.fcgi} = *php4.fcgi* ]]; then \
672 %service -q php-fcgi restart \
673 fi \
674fi \
e6ca24e8
ER
675%{nil}
676
b89f672e
AM
677
678# X.org helper macros
04336b74 679%__xorg_abi_requires() Requires: xorg-xserver-server(%{expand:%1}-abi) = %{expand:%{%{!?2:%{1}}%{?2}}}
b89f672e 680#
a1551c98
ER
681%xorg_xserver_ansic_abi %{expand:%%global xorg_xserver_ansic_abi %(awk '/#define ABI_ANSIC_VERSION/ { split($0,A,/[(,)]/); printf("%d.%d",A[2], A[3]); }' /usr/include/xorg/xf86Module.h 2> /dev/null || echo ERROR)}%xorg_xserver_ansic_abi
682%xorg_xserver_extension_abi %{expand:%%global xorg_xserver_extension_abi %(awk '/#define ABI_EXTENSION_VERSION/ { split($0,A,/[(,)]/); printf("%d.%d",A[2], A[3]); }' /usr/include/xorg/xf86Module.h 2> /dev/null || echo ERROR)}%xorg_xserver_extension_abi
683%xorg_xserver_font_abi %{expand:%%global xorg_xserver_font_abi %(awk '/#define ABI_FONT_VERSION/ { split($0,A,/[(,)]/); printf("%d.%d",A[2], A[3]); }' /usr/include/xorg/xf86Module.h 2> /dev/null | echo ERROR)}%xorg_xserver_font_abi
684%xorg_xserver_videodrv_abi %{expand:%%global xorg_xserver_videodrv_abi %(awk '/#define ABI_VIDEODRV_VERSION/ { split($0,A,/[(,)]/); printf("%d.%d",A[2], A[3]); }' /usr/include/xorg/xf86Module.h 2> /dev/null || echo ERROR)}%xorg_xserver_videodrv_abi
685%xorg_xserver_xinput_abi %{expand:%%global xorg_xserver_xinput_abi %(awk '/#define ABI_XINPUT_VERSION/ { split($0,A,/[(,)]/); printf("%d.%d",A[2], A[3]); }' /usr/include/xorg/xf86Module.h 2> /dev/null || echo ERROR)}%xorg_xserver_xinput_abi
b89f672e
AM
686
687%requires_xorg_xserver_extension %{__xorg_abi_requires ansic xorg_xserver_ansic_abi} \
688%{__xorg_abi_requires extension xorg_xserver_extension_abi}
689%requires_xorg_xserver_xinput %{__xorg_abi_requires ansic xorg_xserver_ansic_abi} \
690%{__xorg_abi_requires xinput xorg_xserver_xinput_abi}
691%requires_xorg_xserver_font %{__xorg_abi_requires ansic xorg_xserver_ansic_abi} \
692%{__xorg_abi_requires font xorg_xserver_font_abi}
693%requires_xorg_xserver_videodrv %{__xorg_abi_requires ansic xorg_xserver_ansic_abi} \
694%{__xorg_abi_requires videodrv xorg_xserver_videodrv_abi}
695
41a62699
AF
696# Python specific macro definitions.
697# python main version
a1551c98 698%py_ver %{expand:%%global py_ver %(%{__python} -c "import sys; print sys.version[:3]" || echo ERROR)}%py_ver
41a62699
AF
699
700# directories
a1551c98 701%py_prefix %{expand:%%global py_prefix %(%{__python} -c "import sys; print sys.prefix" || echo ERROR)}%py_prefix
31b569b6 702%py_libdir %{py_prefix}/%{_lib}/python%{py_ver}
a4f0b5e0 703%py_scriptdir %{py_prefix}/share/python%{py_ver}
31b569b6 704%py_incdir /usr/include/python%{py_ver}
3da52f86 705%py_sitedir %{py_libdir}/site-packages
a4f0b5e0 706%py_sitescriptdir %{py_scriptdir}/site-packages
31b569b6 707%py_dyndir %{py_libdir}/lib-dynload
41a62699
AF
708
709# pure python modules compilation
31b569b6 710%py_comp python -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
41a62699 711
31b569b6 712%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
713
714# Software written in Python language require Python with main version
5177c7b1 715%pyrequires_eq() Requires: %1
41a62699 716
ea4b2900
AF
717# Hardlink binary identical .pyc and .pyo files
718# (idea by glen <at> pld-linux <dot> org)
719%__spec_install_post_py_hardlink {\
f67bd19e 720%{!?no_install_post_py_hardlink: __spec_install_post_py_hardlink() { \
ea4b2900 721[ ! -d "$RPM_BUILD_ROOT" ] || find "$RPM_BUILD_ROOT" -name '*.pyc' | while read a; do \
455bd3f1 722 b="${a%.pyc}.pyo"; \
ea4b2900
AF
723 if cmp -s "$a" "$b"; then \
724 ln -f "$a" "$b"; \
725 fi; \
726done \
f67bd19e 727}; __spec_install_post_py_hardlink } }
ea4b2900 728
16f6f416 729# remove python sources, so that check-files won't complain
ea4b2900
AF
730# (idea by glen <at> pld-linux <dot> org)
731%py_postclean() \
e4e8948b 732for d in %{py_sitescriptdir} %{py_sitedir} %*; do \
9ba5542a 733 [ ! -d "$RPM_BUILD_ROOT$d" ] || find "$RPM_BUILD_ROOT$d" -name '*.py' -print0 | xargs -0r -l512 rm;\
ea4b2900
AF
734done \
735%{nil}
736
67ed5b97 737# depmod macro
738%depmod() { \
fe30b3ea 739umask 022; \
67ed5b97 740if [ -e /boot/System.map-%1 ]; then \
31b569b6 741 /sbin/depmod -a -F /boot/System.map-%1 %1; \
67ed5b97 742else \
31b569b6
ER
743 if [ -e /boot/System.map ]; then \
744 /sbin/depmod -a -F /boot/System.map %1; \
745 else \
746 /sbin/depmod -a %1; \
747 fi \
67ed5b97 748fi; \
749}
750
495892af 751# XMMS specific macros
a1551c98
ER
752%xmms_prefix %{expand:%%global xmms_prefix %(xmms-config --prefix 2>/dev/null || echo ERROR)}%xmms_prefix
753%xmms_exec_prefix %{expand:%%global xmms_exec_prefix %(xmms-config --exec-prefix 2>/dev/null || echo ERROR)}%xmms_exec_prefix
754%xmms_version %{expand:%%global xmms_version %(xmms-config --version 2>/dev/null || echo ERROR)}%xmms_version
755%xmms_datadir %{expand:%%global xmms_datadir %(xmms-config --data-dir 2>/dev/null || echo ERROR)}%xmms_datadir
756%xmms_plugindir %{expand:%%global xmms_plugindir %(xmms-config --plugin-dir 2>/dev/null || echo ERROR)}%xmms_plugindir
757%xmms_visualization_plugindir %{expand:%%global xmms_visualization_plugindir %(xmms-config --visualization-plugin-dir 2>/dev/null || echo ERROR)}%xmms_visualization_plugindir
758%xmms_input_plugindir %{expand:%%global xmms_input_plugindir %(xmms-config --input-plugin-dir 2>/dev/null || echo ERROR)}%xmms_input_plugindir
759%xmms_output_plugindir %{expand:%%global xmms_output_plugindir %(xmms-config --output-plugin-dir 2>/dev/null || echo ERROR)}%xmms_output_plugindir
760%xmms_effect_plugindir %{expand:%%global xmms_effect_plugindir %(xmms-config --effect-plugin-dir 2>/dev/null || echo ERROR)}%xmms_effect_plugindir
761%xmms_general_plugindir %{expand:%%global xmms_general_plugindir %(xmms-config --general-plugin-dir 2>/dev/null || echo ERROR)}%xmms_general_plugindir
762
763%_target_base_arch %{expand:%%global _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/')}%_target_base_arch
bb128216 764
e3618ee9 765# user/group checking macros
766#
767# Usage:
768# %userremove myuser
769#
770%userremove /usr/lib/rpm/user_group.sh user del
771%groupremove /usr/lib/rpm/user_group.sh group del
772#
773# Usage:
774# if %usertestrm myuser; then
775# /usr/sbin/userdel -r myuser
776# Note:
777# use these macros only if you need to call userdel/groupdel with
778# a non-standard option or take an extra action; otherwise use the
779# %userremove/%groupremove macros
780#
781%usertestrm /usr/lib/rpm/user_group.sh user testrm
782%grouptestrm /usr/lib/rpm/user_group.sh group testrm
13f70a2c
JK
783# user group membership management macros
784#
785# Usage:
786# %addusertogroup myuser agroup
787#
788%addusertogroup /usr/lib/rpm/user_group.sh user addtogroup
bfd9689c 789
790# banner support (useful in {pre,post}{,un} and triggers)
791#
792# Usage:
a980efc1 793# %banner name [-a] [-e] [-n] [-tn] <<EOF
bfd9689c 794# the banner text, the banner text
a980efc1
ER
795# the banner text, and following line
796#EOF
797# You can use any form of here-document, <<'EOF' <<-EOT will do.
798# NOTE: if your use "<<-EOF", then You can actually indent inside here-document.
799#
bfd9689c 800# -a - append to the banner
fb033326 801# -e - send to stderr instead of stdout
1257c400 802# -n - no show banner (overrides -t)
803# -t - show only, if RPM_SCRIPTVERBOSITY >= n; default n=5
4055114a
ER
804#
805# Tests:
806# (rpm -E '%banner -e banner <<EOF'; echo -e 'hi\nEOF') > m; sh -x m
807# rpm -E 'date | %banner -e banner' > m; sh -x m
808#
8bea2501 809%banner(aent:) ( \
f1bbc6ff 810RPM_SCRIPTVERBOSITY=5 \
811[ -r /etc/sysconfig/rpm ] && . /etc/sysconfig/rpm \
812if [ -x /usr/bin/banner.sh ]; then \
a980efc1 813 CMD="/usr/bin/banner.sh %{-e:--stderr} %{!-n:$([ $RPM_SCRIPTVERBOSITY -ge %{-t:%{-t*}}%{!-t:5} ] && echo -s)} %{!-a:-m}%{-a:-M} %1" \
f1bbc6ff 814else \
fb033326 815 CMD="cat%{-e: >&2}" \
f1bbc6ff 816fi \
4055114a
ER
817eval $CMD %{?2:%2}%{?3: %3}) \
818%{nil}
1257c400 819
3c972982 820# useradd/groupadd macros
1ebc460a 821# Author: Elan Ruusamäe <glen@pld-linux.org>
29c5556c
ER
822#
823# Usage:
824# %useradd [-P package] [-u uid] [-d home_dir] [-s shell] [-c comment]
825# [-g initial_group] [-G group[,...]] login
826#
827# -u uid. REQUIRED
828# -g gid/group. REQUIRED
829# -s defaults to /bin/false
830# -d defaults to /usr/share/empty
831# -c No default
832# -r is accepted but ignored (it's always set)
6eb25d5d 833# -k skeleton dir. defaults to /usr/share/empty
29c5556c
ER
834# rpm specific flags
835# -P package name. defaults to %{name}
836#
29c5556c 837%useradd(c:d:e:f:g:G:Mmk:op:s:u:rP:) \
0044d46f
ER
838%{!-u:%{error:useradd: Required argument -u missing}} \
839%{!-g:%{error:useradd: Required argument -g missing}} \
840%{!?1:%{error:useradd: Required parameter login missing}} \
29c5556c
ER
841if [ -n "`/bin/id -u %{expand:%{%{#}}} 2>/dev/null`" ]; then \
842 if [ "`/bin/id -u %{expand:%{%{#}}}`" != "%{-u*}" ]; then \
843 echo "Error: user %{expand:%{%{#}}} doesn't have uid=%{-u*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
844 exit 1 \
845 fi \
846else \
847 echo "Adding user %{expand:%{%{#}}} UID=%{-u*}." \
848 /usr/sbin/useradd \\\
cc333c8b 849 %{-m:-m -k %{-k*}%{!-k:/usr/share/empty}} \\\
29c5556c
ER
850 -u %{-u*} \\\
851 -r \\\
852 -d %{-d*}%{!-d:/usr/share/empty} \\\
853 -s %{-s*}%{!-s:/bin/false} \\\
85e3e9a1 854 %{-c:-c "%(set -- %{-c*} %{*}; echo $1)"}\\\
29c5556c
ER
855 -g %{-g*} \\\
856 %{-M} \\\
857 %{-G:-G %{-G*}} \\\
6750d9f5 858 %{expand:%{%{#}}} 1>&2 || exit $? \
52e30914 859 [ ! -x /usr/sbin/nscd ] || /usr/sbin/nscd -i passwd || : \
29c5556c
ER
860fi;
861
29c5556c
ER
862# Usage:
863# %groupadd [-P package] [-g gid] group
864#
865# -g gid. REQUIRED
866#
867# Sample:
868# %groupadd -P %{name}-base -g %{gid} %{name}
869
870%groupadd(g:P:rfo) \
0044d46f
ER
871%{!-g:%{error:groupadd: Required argument -g missing}} \
872%{!?1:%{error:groupadd: Required parameter group missing}} \
29c5556c
ER
873if [ -n "`/usr/bin/getgid %{1}`" ]; then \
874 if [ "`/usr/bin/getgid %{1}`" != "%{-g*}" ]; then \
875 echo "Error: group %{1} doesn't have gid=%{-g*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
876 exit 1 \
877 fi \
878else \
879 echo "Adding group %{1} GID=%{-g*}." \
6750d9f5 880 /usr/sbin/groupadd -g %{-g*} -r %{1} 1>&2 || exit $? \
52e30914 881 [ ! -x /usr/sbin/nscd ] || /usr/sbin/nscd -i group || : \
29c5556c 882fi;
053b8de1 883
55a50f1a 884# webapp macros
1ebc460a 885# Author: Elan Ruusamäe <glen@pld-linux.org>
ba42a822
ER
886#
887# The config is installed/removed inside trigger, this means that you can any
888# time install apache1/apache/lighttpd package and the configuration file is
43f81f06 889# updated. if you don't need the config for various reason for specific
ba42a822
ER
890# webserver, just remove the symlink from config directory using webapp
891# program. the trigger will not recreate the symlink on upgrades. In other
892# words the config is linked to webserver config directory on first install of
893# PACKAGE or WEBSERVER.
894#
55a50f1a
ER
895# Add package's webserver config to webserver webapps dir.
896# Usage:
217f2cb2 897# %webapp_register WEBSERVER WEBAPP
ba42a822
ER
898#
899%webapp_register() \
900%{?debug:set -x; echo "webapp_register: %{name}-%{version}-%{release} 1:[$1]; 2:[$2]"} \
901if [ "$1" = "1" ] && [ "$2" = "1" ]; then\
902 /usr/sbin/webapp register %1 %2\
903fi\
973c1dc7 904# reload webserver if the config symlink is there and skip reload if webserver is upgraded\
afe4f5f0 905if [ -L /etc/%1/webapps.d/%(echo "%2" | tr '/' '-').conf ] && [ "$2" -lt "2" ]; then\
5f0b2e29 906 %{expand:%service -q %%1 reload}\
ba42a822
ER
907fi\
908%{nil}
909
910# Remove package's config from webserver webapps dir.
ba42a822 911# Usage:
b9588fe6
ER
912# %webapp_register [-f] WEBSERVER WEBAPP
913%webapp_unregister(f) \
ba42a822
ER
914%{?debug:set -x; echo "webapp_unregister: %{name}-%{version}-%{release}: 1:[$1]; 2:[$2]"} \
915# remove link if either of the packages are gone \
afe4f5f0 916if [ -n "%{-f:1}" ] || [ "$1" = "0" ] || [ "$2" = "0" ] && [ -L /etc/%1/webapps.d/%(echo "%2" | tr '/' '-').conf ]; then \
217f2cb2 917 /usr/sbin/webapp unregister %1 %2\
5f0b2e29 918 %{expand:%service -q %%1 reload}\
ba42a822
ER
919fi \
920%{nil}
921
8edf8498 922# service macro.
1ebc460a 923# Author: Elan Ruusamäe <glen@pld-linux.org>
8edf8498
ER
924#
925# calls usual service restart on package %post, but skips the restart if
926# administrator has disabled automatic service restarts in either global
927# /etc/sysconfig/rpm or per service /etc/sysconfig/SERVICE file.
928#
8edf8498 929# Usage:
378ae5eb 930# %service [-q] [-n] SERVICE ACTION ["SERVICE NICE DESCRIPTION"]
8edf8498 931#
dd4e969a 932# -q be silent when service isn't started (for scriplets restaring other package's services)
378ae5eb 933# -n NOOP mode, do not actually restart service
8edf8498 934#
378ae5eb
ER
935# Requirements:
936# BuildRequires: rpmbuild(macros) >= 1.268
937# Requires: rc-scripts
938# -n option:
939# BuildRequires: rpmbuild(macros) >= 1.450
940%service(qn) {{%(export noop=%{-n:1} quiet=%{-q:1}; /usr/lib/rpm/service_generator.sh %{*}) };}
cec3a041
ER
941
942
91bd3172
ER
943# Java macros. based on jpackage macros.java
944#
945# Root directory where all Java VMs/SDK/JREs are installed.
93406dd9 946%_jvmdir %{_libdir}/jvm
91bd3172
ER
947
948# Root directory where all Java VMs/SDK/JREs expose their jars
93406dd9 949%_jvmjardir %{_libdir}/jvm-exports
91bd3172
ER
950
951# Root directory for all Java VM/SDK/JRE's private things.
952%_jvmprivdir %{_libdir}/jvm-private
953
954# Root directory for all architecture dependent parts of Java VM/SDK/JRE's
93406dd9 955%_jvmlibdir %{_libdir}/jvm
91bd3172
ER
956
957# Root directory for all architecture independent parts of Java VM/SDK/JRE's
958%_jvmdatadir %{_datadir}/jvm
959
960# Root directory for all configurations parts of Java VM/SDK/JRE's
961%_jvmsysconfdir %{_sysconfdir}/jvm
962
963# Root directory for all common architecture dependent parts of Java VM/SDK/JRE's
29959405 964%_jvmcommonlibdir %{_libdir}/jvm-common
91bd3172
ER
965
966# Root directory for all common architecture independent parts of Java VM/SDK/JRE's
29959405 967%_jvmcommondatadir %{_datadir}/jvm-common
91bd3172
ER
968
969# Root directory for all common configurations parts of Java VM/SDK/JRE's
29959405 970%_jvmcommonsysconfdir %{_sysconfdir}/jvm-common
91bd3172
ER
971
972# Directory where arch-specific (JNI) version-independent jars are installed.
93406dd9 973%_jnidir %{_libdir}/java
91bd3172 974
a1551c98 975%java_home %{expand:%%global java_home %([ -f %{_javadir}-utils/java-functions ] || { echo ERROR; exit 0; }; unset JAVA_HOME; . %{_javadir}-utils/java-functions; set_jvm; echo ${JAVA_HOME:-ERROR})}%java_home
cec3a041 976
43f81f06
ER
977%ant JAVA_HOME=%{java_home} ant
978%jar %{java_home}/bin/jar
a1551c98 979%java %{expand:%%global java %([ -f %{_javadir}-utils/java-functions ] || { echo ERROR; exit 0; }; unset JAVACMD; . %{_javadir}-utils/java-functions; set_javacmd; echo $JAVACMD)}%java
43f81f06
ER
980%javac %{java_home}/bin/javac
981%javadoc %{java_home}/bin/javadoc
cec3a041 982
43f81f06 983%add_jvm_extension JAVA_LIBDIR=%{buildroot}/%{_javadir} %{_bindir}/jvmjar -l
cec3a041
ER
984
985%jpackage_script() \
a2047fce
ER
986install -d $RPM_BUILD_ROOT%{_bindir}\
987cat > $RPM_BUILD_ROOT%{_bindir}/%5 << 'EOF' \
cec3a041
ER
988#!/bin/sh\
989#\
990# %{name} script\
991# JPackage Project <http://www.jpackage.org/>\
992\
993# Source functions library\
994. %{_javadir}-utils/java-functions\
995\
996# Source system prefs\
a2047fce 997if [ -f %{_sysconfdir}/java/%{name}.conf ]; then\
43f81f06 998 . %{_sysconfdir}/java/%{name}.conf\
cec3a041
ER
999fi\
1000\
1001# Source user prefs\
a2047fce
ER
1002if [ -f $HOME/.%{name}rc ]; then\
1003 . $HOME/.%{name}rc\
cec3a041
ER
1004fi\
1005\
1006# Configuration\
1007MAIN_CLASS=%1\
1008BASE_FLAGS=%2\
1009BASE_OPTIONS=%3\
a2047fce 1010BASE_JARS="%(echo %4 | tr ':' ' ')"\
cec3a041
ER
1011\
1012# Set parameters\
1013set_jvm\
a2047fce
ER
1014set_classpath $BASE_JARS\
1015set_flags $BASE_FLAGS\
1016set_options $BASE_OPTIONS\
cec3a041
ER
1017\
1018# Let's start\
a2047fce 1019run "$@"\
cec3a041
ER
1020EOF
1021
d449d2c8
ER
1022# jpackage 1.7
1023# Directory for maven depmaps
1024#
1025%_mavendepmapdir /etc/maven
1026%_mavendepmapfragdir /etc/maven/fragments
1027
1028#
1029# add_to_depmap adds an entry to the depmap. The arguments are:
1030#
1031# %1 the original groupid
1032# %2 the original artifact id
1033# %3 the version
1034# %4 the new groupid
1035# %5 the new artifactid
1036#
1037
1038%add_to_maven_depmap() \
1039install -dm 755 $RPM_BUILD_ROOT/%{_mavendepmapfragdir}\
1040cat >>$RPM_BUILD_ROOT/%{_mavendepmapfragdir}/%{name}<< EOF\
1041<dependency>\
1042 <maven>\
1043 <groupId>%1</groupId>\
1044 <artifactId>%2</artifactId>\
1045 <version>%3</version>\
1046 </maven>\
1047 <jpp>\
1048 <groupId>%4</groupId>\
1049 <artifactId>%5</artifactId>\
1050 <version>%3</version>\
1051 </jpp>\
1052</dependency>\
1053\
1054EOF\
1055%{nil}
1056
1057#==============================================================================
1058#
1059# update_maven_depmap updates the main maven depmap
1060#
1061%update_maven_depmap() \
1062echo -e "<dependencies>\\n" > %{_mavendepmapdir}/maven2-depmap.xml\
1063if [ -d %{_mavendepmapfragdir} ] && [ -n "`find %{_mavendepmapfragdir} -type f`" ]; then\
1064cat %{_mavendepmapfragdir}/* >> %{_mavendepmapdir}/maven2-depmap.xml\
1065fi\
1066echo -e "</dependencies>\\n" >> %{_mavendepmapdir}/maven2-depmap.xml
1067
1068
e22fc3d1 1069# PEAR install macros
1ebc460a 1070# Author: Elan Ruusamäe <glen@pld-linux.org>
d2a29d34
ER
1071#
1072# Usage:
1073# %%pear_package_setup [-a #] [-n FMT]
1074#
e22fc3d1 1075# -a # - also unpack SOURCE#. for PEAR bootstrapping
d2a29d34 1076# -n FMT - create builddir with FMT, instead of default %%{_pearname}-%%{version}
e22fc3d1 1077# -z - unpack pear package and let pear use package.xml (not tarball) for install. for PEAR bootstrapping
d2a29d34
ER
1078#
1079# unpack PEAR package to %%{_builddir}/FMT. package is extracted with already
1080# destination hierarchy. you should copy the tree to buildroot after
1081# patching/reorganizing with %%pear_package_install.
1082#
1083# additionally BUILDROOT is stripped from files and files are converted to UNIX
1084# line endings.
1085#
1086# the pear install process output is recorded to install.log, you should put it
a4f06f46 1087# to %%doc for later debug or just for information.
d2a29d34
ER
1088#
1089# additionally additional-packages.txt is produced if it was detected that the
1090# package has optional dependencies. the file format is suitable of displaying
1091# in %%post of a package. you should put this file to %%doc. noautocompressdoc is
1092# automatically added for this file.
e22fc3d1
ER
1093
1094
1095# records install.log and transforms PEAR names to PLD Linux rpm package names.
1096%__pear_install_log \
1097tee install.log \
1098# make post message of optional packages \
1099grep 'can optionally use' install.log | sed -e 's,package "pear/,package "php-pear-,g;s,^pear/,php-pear-,' > optional-packages.txt \
1100if [ -s optional-packages.txt ]; then \
1101 awk -F'"' '/use package/{print $2}' optional-packages.txt | sed -e "s,_,/,g;s,php-pear-, 'pear(,;s,$,.*)'," | tr -d '\\\n' > _noautoreq \
1102else \
1103 rm -f optional-packages.txt \
1104fi \
1105%{nil}
1106
1107# command invoking pear cli
1108%__pear /usr/bin/pear
1109
856feeea 1110%pear_install(a:n:zD) \
e22fc3d1
ER
1111%__pear \\\
1112 -c pearrc \\\
d2a29d34
ER
1113 -d doc_dir=/docs \\\
1114 -d php_dir=%{php_pear_dir} \\\
1115 -d bin_dir=%{_bindir} \\\
1116 -d data_dir=%{php_pear_dir}/data \\\
1117 -d test_dir=%{php_pear_dir}/tests \\\
1118 install \\\
e22fc3d1 1119 --packagingroot=%{builddir} \\\
d2a29d34
ER
1120 --offline \\\
1121 --nodeps \\\
1122 %{-f:--force} \\\
856feeea
ER
1123 %{!-z:%{S:%{-a*}%{!-a:0}}}%{-z:$_P} > .install.log || { c=$?; cat .install.log; exit $c; }; \
1124%{nil}
1125
1126# The main macro.
1127# using this macro will append optional-packages.txt to the nocompressdoc list
1128# as it's displayed to user after package install. and adding additional gzip
1129# dep is just waste ;)
1130%pear_package_setup(a:n:zD) \
1131%define srcdir %{-n*}%{!-n:%{_pearname}-%{version}} \
1132%define builddir %{_builddir}/%{srcdir} \
1133%setup -q -c -T %{-D:-D} -n %{srcdir} \
1134%{-z:tar zxf %{S:0}; %{-a:tar zxf %{S:%{-a*}}}} \
1135%{-z:_P=package2.xml; [ -f $_P ] || _P=package.xml; _N=%{srcdir}; mv $_P $_N; cd $_N} \
1136%pear_install \
e22fc3d1
ER
1137%{-z:cd ..} \
1138cat %{-z:$_N/}.install.log | %__pear_install_log \
1139\
d2a29d34 1140# undos sources \
07fa2259 1141find -type f -print0 | xargs -0 sed -i -e 's,\\r$,,' \
d2a29d34
ER
1142%{!?_noautocompressdoc:%global _noautocompressdoc %{nil}}%{expand:%%global _noautocompressdoc %{_noautocompressdoc} optional-packages.txt} \
1143%{!?_noautoprov:%global _noautoprov %{nil}}%{expand:%%global _noautoprov %{_noautoprov} 'pear(tests/.*)'} \
1144%{nil}
1145
0aced28c 1146# Copies exctracted PEAR package structure and PEAR registry to buildroot.
1ebc460a 1147# Author: Elan Ruusamäe <glen@pld-linux.org>
d2a29d34
ER
1148%pear_package_install() \
1149cp -a ./%{php_pear_dir}/{.registry,*} $RPM_BUILD_ROOT%{php_pear_dir} \
1150find $RPM_BUILD_ROOT%{php_pear_dir} '(' -name '*~' -o -name '*.orig' ')' | xargs -r rm -v \
1151# help the developer out a little: \
1152if [ -f _noautoreq ]; then \
1153 echo "AutoReqdep detected:" \
1154 echo "_noautoreq $(cat _noautoreq)" \
1155fi \
1156%{nil}
1157
54294c49
ER
1158
1159# Register OpenLDAP schema.
1ebc460a 1160# Author: Elan Ruusamäe <glen@pld-linux.org>
54294c49
ER
1161#
1162# Usage:
1163# %%openldap_schema_register [-d core,nis] %{schemadir}/horde.schema
1164#
1165# -d specify dependant schemas, separated by comma
1166#
1167%openldap_schema_register(d:) \
1168for schema in %*; do \
1169 if ! grep -q "$schema" /etc/openldap/slapd.conf; then \
1170 %{__sed} -i -e " \
1171 /^include.*local.schema/{ \
1172 iinclude\\t $schema\
1173 } \
1174 " /etc/openldap/slapd.conf \
1175 fi \
1176done \
1177# enable dependant schemas \
1178if [ "%{-d*}" ]; then \
1179 %{__sed} -i -e ' \
1180 /^#include.*\\(%(echo '%{-d*}' | %{__sed} -e 's/,/\\\\|/g')\\)\\.schema/{ \
1181 s/^#// \
1182 }' /etc/openldap/slapd.conf \
1183fi \
1184%{nil}
1185
1186# Unregister OpenLDAP schema.
1ebc460a 1187# Author: Elan Ruusamäe <glen@pld-linux.org>
54294c49
ER
1188#
1189# Usage:
1190# %%openldap_schema_unregister %{schemadir}/horde.schema
1191#
1192%openldap_schema_unregister() \
1193for schema in %*; do \
1194 if grep -q "$schema" /etc/openldap/slapd.conf; then \
1195 %{__sed} -i -e " \
1196 /^include.*$(echo "$schema" | %{__sed} -e 's,/,\\\\/,g')/d \
1197 # for symmetry it would be nice if we disable enabled schemas in post, \
1198 # but we really can not do that, it would break something else. \
1199 " /etc/openldap/slapd.conf \
1200 fi \
1201done \
1202%{nil}
1203
feb61fae 1204%env_update [ ! -x /sbin/env-update ] || /sbin/env-update -u || :
6ee06092 1205
a4623211 1206
1207# Build modules for kernels 2.6
1208# Author: Przemyslaw Iskra <sparky@pld-linux.org>
1209#
1210# Usage:
650cc681 1211# %build_kernel_modules -m <modules> -C <directory>
a4623211 1212#
1213# remember that proper Makefile is still required
1214# Options:
3c972982 1215# -m <modules> (required) -- comma-separated list of modules to save,
a4623211 1216# without .ko extension, may be placed in subdirectory
650cc681 1217# -C <directory> -- change to <directory> before doing anything
a4623211 1218# -p <arg>, -P <arg> -- arguments passeed to make scripts
bf97e3a6 1219# -c -- do not execute make clean
a4623211 1220# <additional arguments> -- all additional arguments will be passed to
1221# make modules
1222#
1223# Additional patching supported via here document. Try:
1224# %build_kernel_modules -m module <<'EOF'
1225# your patch script here
1226# EOF
1227# Don't use it unless patching depends on config options.
1228
1229# Developer note: don't touch it unless you know how to handle '\'.
1230# - \ in script expands to nothing
1231# - \\\ in script expands to \
8ad8b353 1232# - \\\ inside definition expands to nothing
a4623211 1233# - \\\\\\\ inside definition expands to \
1234# - in last line \ has to touch arguments so arguments passing
1235# in new lines (using \) will be supported
1236
bf97e3a6 1237%build_kernel_modules(p:P:m:C:c) \
a4623211 1238%{!?-m:%{error:%{0}: Required module name/list missing} exit 1} \
1239 \
1240%define Opts \\\\\\\
1241%if "%{_target_base_arch}" != "%{_arch}" \\\
1242 %if "%{_arch}" == "x86_64" && "%{_target_base_arch}" == "i386" \\\
4d45063a 1243 CC="%{kgcc}" ARCH=%{_target_base_arch} \\\
a4623211 1244 %else \\\
1245 ARCH=%{_target_base_arch} CROSS_COMPILE=%{_target_cpu}-pld-linux- \\\
1246 %endif \\\
1247%else \\\
4d45063a 1248 CC="%{kgcc}" \\\
a4623211 1249%endif \
4d45063a 1250%define MakeOpts HOSTCC="%{kgcc}" SYSSRC=%{_kernelsrcdir} SYSOUT=$PWD/o \\\\\\\
a4623211 1251 O=$PWD/o %{?with_verbose:V=1} %{Opts} \
1252 \
8b51c37f 1253%{?-C:cd %{-C*}} \
a4623211 1254compile() { \
7ab1c0b6
ER
1255 local L="<" PATCH_SH; \
1256 [[ '%{*}' != *$L$L* ]] || PATCH_SH="set -x -e;$(cat)" \
a4623211 1257 set -e -x \
d606f9ca 1258 local cfgs='%{?with_dist_kernel:%{?with_smp: smp}%{?with_up: up}}%{!?with_dist_kernel: nondist}' \
a4623211 1259 \
d606f9ca 1260for cfg in ${cfgs:-dist}; do \
a4623211 1261 [ -r "%{_kernelsrcdir}/config-$cfg" ] || exit 1 \
1262 \
8e042a98 1263 rm -rf o \
a4623211 1264 install -d o/include/linux \
1265 ln -sf %{_kernelsrcdir}/config-$cfg o/.config \
1266 ln -sf %{_kernelsrcdir}/Module.symvers-$cfg o/Module.symvers \
1267 ln -sf %{_kernelsrcdir}/include/linux/autoconf-$cfg.h o/include/linux/autoconf.h \
1268 \
1269 set +x \
1270 [ -z "$PATCH_SH" ] || echo "$PATCH_SH" | %__spec_build_shell \
1271 set -x \
1272 \
1273 %if %{with dist_kernel} \
1274 %{__make} -j1 -C %{_kernelsrcdir} prepare scripts \\\
1275 %{-p*} %{-P*} \\\
1276 %{MakeOpts} \
1277 %else \
1278 install -d o/include/config \
1279 touch o/include/config/MARKER \
1280 ln -sf %{_kernelsrcdir}/scripts o/scripts \
1281 %endif \
1282 \
bf97e3a6 1283 %{!?-c:%{__make} -C %{_kernelsrcdir} clean \\\
a4623211 1284 RCS_FIND_IGNORE="-name '*.ko' -o" \\\
220948bb 1285 ${1+"$@"} \\\
bf97e3a6 1286 M=$PWD %{MakeOpts}} \
220948bb 1287 \
a4623211 1288 %{__make} -C %{_kernelsrcdir} modules \\\
1289 ${1+"$@"} \\\
1290 M=$PWD %{MakeOpts} \
1291 \
1292 for MODULE in {%{-m*},}; do \
1293 [ -z "${MODULE}" ] || mv ${MODULE}{,-$cfg}.ko \
1294 done \
1295done \
650cc681 1296%{?-C:cd -} \
a4623211 1297} \
1298compile %{*}\
1299%{nil}
1300
1301
1302# Install kernel modules built by %build_kernel_modules
1303# Author: Przemyslaw Iskra <sparky@pld-linux.org>
1304#
1305# Usage:
1306# %install_kernel_modules -m <modules> -d <directory>
1307#
1308# Options:
3c972982 1309# -m <modules> (required) -- comma-separated list of modules to install,
a4623211 1310# without .ko extension, may be placed in subdirectory
1311# -d <directory> (required) -- in what subdirectory modules should be
1312# installed (eg. misc, kernel/drivers/net)
1313# -s <suffix> -- suffix to use when installing modules, useful when module
1314# with same name exists in kernel already
1315# -n <file> -- name of modprobe config file to use (without .conf extension)
c4bd6177 1316# for defining aliases, only useful with -s
a4623211 1317
1318%install_kernel_modules(m:d:s:n:) \
1319%{!?-m:%{error:%{0}: Required module name (-m) missing}exit 1} \
1320%{!?-d:%{error:%{0}: Required module directory missing}exit 1} \
1321%{?-n:%{!?-s:%{error:%{0}: Modprobe .conf file requires module suffix}exit 1}} \
1322 \
1323%define KernelD $RPM_BUILD_ROOT/lib/modules/%{_kernel_ver} \
1324%define ModprobeD $RPM_BUILD_ROOT%{_sysconfdir}/modprobe.d/%{_kernel_ver} \
c6bb8dfe 1325 \
d606f9ca 1326local cfgs='%{?with_dist_kernel:%{?with_smp: smp}%{?with_up: up}}%{!?with_dist_kernel: nondist}' \
a4623211 1327 \
1328for MODULE in {%{-m*},}; do \
1329 [ -n "${MODULE}" ] || continue \
d606f9ca
ER
1330 for cfg in ${cfgs:-dist}; do \
1331 [ "$cfg" = smp ] && suf=smp || suf= \
1332 MNAME=${MODULE##*/} \
1333 install -D ${MODULE}-$cfg.ko \\\
1334 %{KernelD}$suf/%{-d*}/${MNAME}%{-s:-%{-s*}}.ko \
b37738c0 1335 %{?-s:install -d %{ModprobeD}$suf \
d606f9ca
ER
1336 echo "alias ${MNAME} ${MNAME}-%{-s*}" \\\
1337 >> %{ModprobeD}$suf/%{-n*}.conf} \
1338 done \
a4623211 1339done \
1340%{nil}
1341
16516cbd 1342# patchset macros
1ebc460a 1343# Author: Elan Ruusamäe <glen@pld-linux.org>
16516cbd
ER
1344#
1345# Usage:
1346# %patchset_source -f <seq(1) format> <start> [<end>]
1347# %patchset_patch <start> [<end>]
1348#
1349# If <end> is omited, it is assumed to be <start>.
1350#
1351# For example in preamble:
1352# %patchset_source -f ftp://ftp.vim.org/pub/editors/vim/patches/7.0/7.0.%03g 33 44
1353# and in %prep:
1354# %patchset_patch 33 44
1355
1356# generate SourceX urls from range START STOP
1357# Format can be SINGLE format char of %e, %f, %g, see seq(1)
1358# The sources start from 10000
cc2d394a 1359%patchset_source(f:b:) %(
8c40a202 1360 base=%{-b*}%{!-b*:10000};
3b7f1777
ER
1361 start=$(expr $base + %1);
1362 end=$(expr $base + %{?2}%{!?2:%{1}});
cc2d394a
ER
1363 # we need to call seq twice as it doesn't allow two formats
1364 seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
1365 seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
1366 paste %{tmpdir}/__ps{1,2};
1367 rm -f %{tmpdir}/__ps{1,2};
3b7f1777
ER
1368) \
1369%{nil}
16516cbd
ER
1370
1371# apply sources from %patchset_source
1372# -p specify -pX for %patch line
1373# -b base offset: defaults to 10000
1374%patchset_patch(f:p:b:) %(
8c40a202 1375 base=%{-b*}%{!-b*:10000};
3b7f1777
ER
1376 start=$(expr $base + %1);
1377 end=$(expr $base + %{?2}%{!?2:%{1}});
cc2d394a
ER
1378 echo ": patchset_patch %1%{?2: to %2}";
1379 seq -f 'patch%g %{-p*:-p%{-p*}}' $start $end | sed -e s,^,%%,;
3b7f1777
ER
1380) \
1381%{nil}
16516cbd 1382
c7cb683a 1383# browser plugins v2
1ebc460a 1384# Author: Elan Ruusamäe <glen@pld-linux.org>
c7cb683a
ER
1385#
1386# Usage:
1387# %browser_plugins_add_browser <name> -p <plugindir>
1388#
1389# <name> (required) -- name of the browser. usually %{name}.
1390# -p <plugindir> (required) -- in what directory browser searches for its plugins.
825d0960
ER
1391# -b -- default blacklists
1392# -a <arch> override arch
c7cb683a
ER
1393#
1394# Example:
1395# %browser_plugins_add_browser %{name} -p %{_firefoxdir}/plugins
1396
1397%_browserpluginsconfdir /etc/browser-plugins
292d3658 1398%_browserpluginsdir %{_libdir}/browser-plugins
c7cb683a
ER
1399%update_browser_plugins /usr/sbin/update-browser-plugins || :
1400
825d0960 1401%browser_plugins_add_browser(p:b:a:) \
2ac4652b 1402 browser=%1.%{!-a:%{_target_base_arch}}%{-a*} \
c7cb683a 1403 install -d $RPM_BUILD_ROOT%{_browserpluginsconfdir}/{blacklist,browsers}.d \
825d0960
ER
1404 ln -s %{-p*} $RPM_BUILD_ROOT%{_browserpluginsconfdir}/browsers.d/$browser \
1405 blacklist_file=$RPM_BUILD_ROOT%{_browserpluginsconfdir}/blacklist.d/$browser.blacklist \
c7cb683a
ER
1406 echo '# This file format is shell globs at base dir of plugindir' > $blacklist_file \
1407 %{-b:cat >> $blacklist_file %{-b*}} \
1408%{nil}
1409
c879189d
ER
1410# Helper for LUA.
1411# split string separated by space into quoted list
1412#
1ebc460a 1413# Author: Elan Ruusamäe <glen@pld-linux.org>
c879189d
ER
1414#
1415# %__lua_split /bin/sh /bin/pdksh -> "/bin/sh", "/bin/pdksh"
1416%__lua_split() %(echo "%*" | awk '{for (i=1;i<=NF;i++) printf("\\"%%s\\"%%s", $i, i == NF ? "" : ", ")}')
1417
1418# adjust /etc/shells by adding and removing shells from there
1ebc460a 1419# Author: Elan Ruusamäe <glen@pld-linux.org>
c879189d
ER
1420#
1421# Usage:
1422# %post -p %add_etc_shells -p /bin/sh /bin/pdksh
1423# %preun -p %remove_etc_shells -p /bin/sh /bin/pdksh
1424#
1425# -p (optional) -- specifies that result is embeded %post script (prepends <lua> as first line)
378ae5eb
ER
1426#
1427# Requirements:
1428# BuildRequires: rpmbuild(macros) >= 1.429
c879189d
ER
1429
1430%add_etc_shells(p) %{-p:<lua>}\
1431t = {}\
1432f = io.open("/etc/shells", "r")\
1433if f then\
1434 for l in f:lines() do t[l]=l; end\
1435 f:close()\
1436end\
1437for _, s in ipairs({%{expand:%%__lua_split %*}}) do\
1438 if not t[s] then\
b566b93e 1439 print("Adding "..s.." to /etc/shells")\
c879189d
ER
1440 f = io.open("/etc/shells", "a"); f:write(s.."\\n"); f:close()\
1441 end\
1442end\
1443%{nil}
1444
1445%remove_etc_shells(p) %{-p:<lua>}\
b566b93e 1446%{-p:if arg[2] == 0 then}\
39e5924d
ER
1447 t = {}\
1448 f = io.open("/etc/shells", "r")\
1449 if f then\
1450 for l in f:lines() do t[l]=l; end\
1451 f:close()\
1452 end\
1453 for _, l in pairs({%{expand:%%__lua_split %*}}) do\
b566b93e 1454 print("Removing "..l.." from /etc/shells")\
39e5924d
ER
1455 t[l] = nil\
1456 end\
1457 s=""\
1458 for _, l in pairs(t) do\
1459 s=s..l.."\\n"\
1460 end\
1461 io.open("/etc/shells", "w"):write(s)\
1462%{-p:end} \
c879189d
ER
1463%{nil}
1464
e22fc3d1 1465# vim:ts=4 sw=4 noet syn=spec
This page took 0.361497 seconds and 4 git commands to generate.