]> git.pld-linux.org Git - packages/rpm-pld-macros.git/blob - rpm.macros
- define %undos macro, ver 1.533
[packages/rpm-pld-macros.git] / rpm.macros
1 # $Revision$, $Date$
2 # PLD Linux rpm macros.
3 # <http://www.pld-linux.org/>
4
5 %epoch          0
6 %x8664          x86_64 amd64 ia32e
7
8 # kernel compiler
9 %kgcc           %{__cc}
10 %kgcc_package   gcc
11
12 # compiler version
13 %cc_version     %{expand:%%global cc_version %(%{__cc} -dumpversion || echo ERROR)}%cc_version
14 %cxx_version    %{expand:%%global cxx_version %(%{__cxx} -dumpversion || echo ERROR)}%cxx_version
15
16 %__rm           /bin/rm --interactive=never
17
18 # Build system path macros.
19 %__autoconf     autoconf %{?debug:-Wall}
20 %__automake     automake -a -c -f --foreign
21 %__autopoint    autopoint --force
22
23 # add parallel build flags: -jN
24 #
25 # if you want to disable parallel build do:
26 # echo '%_smp_mflags %{nil}' >> ~/.rpmmacros
27 #
28 %__make         /usr/bin/make %{?_smp_mflags}
29 %__scons        /usr/bin/scons %{?_smp_mflags}
30 %__waf          /usr/bin/waf %{?_smp_mflags}
31 %__cmake        /usr/bin/cmake
32
33 %_smp_mflags %(_NCPUS=$(/usr/bin/getconf _NPROCESSORS_ONLN); \\\
34                                 [ "$_NCPUS" -gt 1 ] && echo "-j$(($_NCPUS * 2))")
35
36 %__gettextize { \
37         if grep -qs 'AM_GNU_GETTEXT.*external' configure.{ac,in} ; then \
38                 gettextize --copy --force --no-changelog; \
39         else \
40                 gettextize --copy --force --no-changelog --intl; \
41         fi; \
42         if [ ! -f po/Makevars ]; then \
43                 cp -f po/Makevars{.template,}; \
44         fi; \
45 }
46
47 %__glib_gettextize      glib-gettextize --copy --force
48 %__gnome_doc_common     gnome-doc-common --copy
49 %__gnome_doc_prepare    gnome-doc-prepare --copy --force
50 %__gtkdocize            gtkdocize --copy
51 %__intltoolize          intltoolize --copy --force
52 %__libtoolize           libtoolize --copy --force --install
53
54 #       Path to top of build area.
55 %_topdir                %{expand:%%global _topdir %(test -d ../SPECS -a -d ../SOURCES && (cd ..; pwd) || echo $HOME/rpm)}%_topdir
56
57 #       The number of cvs changelog entries kept when building package.
58 %_buildchangelogtruncate 20
59
60 %dependencytracking     %{nil}
61
62 #       Relations between package names that cause dependency loops
63 #       with legacy packages that cannot be fixed. Relations are
64 #       specified as
65 #               p>q
66 #       where package p has a Requires: on something that package q Provides:
67 #
68 # XXX   Note: that there cannot be any whitespace within the string "p>q",
69 #       and that both p and q are package names (i.e. no version/release).
70 %_dependency_whiteout   %{nil}
71
72 #-----------------------------------------------------------------
73 #
74 # (re)definition of %{rpm*flags} with %filterout_* support
75 # BuildRequires:        awk
76 # BuildRequires:        rpmbuild(macros) >= 1.315
77 #
78 # Flags specified in %filterout_* are removed from %rpm*flags, exactly:
79 # %rpmcflags    = %optflags - %filterout - %filterout_c   - %filterout_ld
80 # %rpmcxxflags  = %optflags - %filterout - %filterout_cxx - %filterout_ld
81 # %rpmcppflags  = %optcppflags - %filterout - %filterout_cpp - %filterout_ld
82 # %rpmldflags   = %optldflags - %filterout_ld
83 #
84 # Regular expressions are supported, but to avoid some character be treated
85 # as regular expression it must be escaped twice.
86
87 %filter_out                                             \
88         for (i = 1; i in I; i++) {      A=0;    \
89                 for (f in F) {                          \
90                         if (I[i] ~ "^" F[f] "$") A=1;   \
91                 };                                                      \
92                 if (!A) printf(I[i] FS);        \
93         }
94
95 %rpmcflags %(awk 'BEGIN {
96         split("%{?debug:%debugcflags}%{!?debug:%optflags}%{?debuginfocflags}",I);
97         split("%{?filterout} %{?filterout_c} %{?filterout_ld}",F);
98         %{filter_out}
99 }')
100
101 %rpmcxxflags %(awk 'BEGIN {
102         split("%{?debug:%debugcflags}%{!?debug:%optflags}%{?debuginfocflags}",I);
103         split("%{?filterout} %{?filterout_cxx} %{?filterout_ld}",F);
104         %{filter_out}
105 }')
106
107 %rpmcppflags %(awk 'BEGIN {
108         split("%{?debug:%debugcppflags}%{!?debug:%optcppflags}%{?debuginfocppflags}",I);
109         split("%{?filterout} %{?filterout_cpp} %{?filterout_cpp}",F);
110         %{filter_out}
111 }')
112
113 %rpmldflags %(awk 'BEGIN {
114         split("%{?optldflags}",I);
115         split("%{?filterout_ld}",F)
116         %{filter_out}
117 }')
118
119 # rpmldflags with stripped -Wl, -- in the form flags have to be passed to 'ld'
120 # but, don't use it, better use gcc as linker
121 %ld_rpmldflags %(awk 'BEGIN {
122         split("%{rpmldflags}",F);
123         for (f in F) {
124                 s = F[f];
125                 if (s ~ /^-Wl,/) {
126                         s = substr(s,5);
127                         gsub(/,/," ",s);
128                 };
129                 printf(s FS);
130         };
131 }')
132
133 #-----------------------------------------------------------------
134 #
135 #  Generate a command which cleans environment, leaving only the
136 # most important variables.
137 #  If any spec requires any additional environment it should
138 # redefine %_preserve_env in following manner:
139 #
140 #       # ADDITIONAL_VAR is required because [a good reason here]
141 #       %define _preserve_env ADDITIONAL_VAR
142
143 %_preserve_env_base     PATH HOME TMP TMPDIR SSH_AUTH_SOCK
144
145 # "env -i" must end in first line of expaned macros because it's used as first line of shell script (#! env...)
146 %_clean_env             %{!?_preserve_env:%global _preserve_env %{nil}}%{expand:%%global _preserve_env %{_preserve_env} %_preserve_env_base} env -i %(awk -vq="'" -vqq="\\"'\\"" -vq2q="'\\"'" 'BEGIN {
147         split("%{?_preserve_env}", P);
148         for (i in P) {
149                 p = P[i];
150                 if (!ENVIRON[p] || d[p]) {
151                         continue;
152                 }
153                 d[p] = 1;
154                 split(ENVIRON[p], V, "");
155                 val = p "=";
156                 for (j = 1; j in V; j++) {
157                         v = V[j];
158                         if (v == q)
159                                 v = qq;
160                         else if (v == "\\"")
161                                 v = q2q;
162                         else if (v == "\\\\")
163                                 v = "\\\\\\\\";
164                         else
165                                 gsub("[^a-zA-Z0-9/:._-]", "\\"&\\"", v);
166                         val = val "" v;
167                 }
168                 printf(val " ");
169         }
170 }')
171
172 #-----------------------------------------------------------------
173 %configure2_13 { \
174  if [ -n "$LINGUAS" ]; then unset LINGUAS; fi; \
175  LDFLAGS="${LDFLAGS:-%rpmldflags}" ; export LDFLAGS ; \
176  CFLAGS="${CFLAGS:-%rpmcflags}" ; export CFLAGS ; \
177  CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" ; export CXXFLAGS ; \
178  FFLAGS="${FFLAGS:-%rpmcflags}" ; export FFLAGS ; \
179  FCFLAGS="${FCFLAGS:-%rpmcflags}" ; export FCFLAGS ; \
180  CPPFLAGS="${CPPFLAGS:-%rpmcppflags}" ; export CPPFLAGS ; \
181  %{?__cc:CC="%{__cc}" ; export CC ; } \
182  %{?__cxx:CXX="%{__cxx}" ; export CXX ; } \
183  %{?configuredir:%{configuredir}}%{!?configuredir:.}/configure \
184         --host=%{_target_platform} \
185         --prefix=%{_prefix} \
186         --exec-prefix=%{_exec_prefix} \
187         --bindir=%{_bindir} \
188         --sbindir=%{_sbindir} \
189         --sysconfdir=%{_sysconfdir} \
190         --datadir=%{_datadir} \
191         --includedir=%{_includedir} \
192         --libdir=%{_libdir} \
193         --libexecdir=%{_libexecdir} \
194         --localstatedir=%{_localstatedir} \
195         --sharedstatedir=%{_sharedstatedir} \
196         --mandir=%{_mandir} \
197         --infodir=%{_infodir} \
198         --x-libraries=%{?_x_libraries}%{!?_x_libraries:%{_libdir}} \
199         %{dependencytracking} \
200 }
201
202 %cmake { \
203 CC="%{__cc}" \
204 CXX="%{__cxx}" \
205 CFLAGS="%{rpmcflags}" \
206 CXXFLAGS="%{rpmcxxflags}" \
207 LDFLAGS="%{rpmldflags}" \
208 %{__cmake} \
209 }
210
211 %scons { \
212 %{__scons} \
213         LDFLAGS="${LDFLAGS:-%rpmldflags}" \
214         CFLAGS="${CFLAGS:-%rpmcflags}" \
215         CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" \
216         FFLAGS="${FFLAGS:-%rpmcflags}" \
217         CPPFLAGS="${CPPFLAGS:-%rpmcppflags}" \
218         %{?__cc:CC="%{__cc}"} \
219         %{?__cxx:CXX="%{__cxx}"} \
220         libsuffix=%{_lib} \
221         prefix=%{_prefix} \
222 }
223
224 # waf. see waf.spec
225 %waf { \
226 CC="%{__cc}" \
227 CXX="%{__cxx}" \
228 CPP="%{__cpp}" \
229 CFLAGS="%{rpmcflags}" \
230 CXXFLAGS="%{rpmcxxflags}" \
231 %{__waf} \
232 }
233
234 #----------------------------------------------------------------
235 #%configure_cache 0
236 %configure_cache_file   %{buildroot}.configure.cache
237
238 %configure {./configure \
239         LDFLAGS="${LDFLAGS:-%rpmldflags}" \
240         CFLAGS="${CFLAGS:-%rpmcflags}" \
241         CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" \
242         FFLAGS="${FFLAGS:-%rpmcflags}" \
243         FCFLAGS="${FCFLAGS:-%rpmcflags}" \
244         CPPFLAGS="${CPPFLAGS:-%rpmcppflags}" \
245         %{?__cc:CC="%{__cc}"} \
246         %{?__cxx:CXX="%{__cxx}"} \
247         --host=%{_target_platform} \
248         --build=%{_target_platform} \
249         --prefix=%{_prefix} \
250         --exec-prefix=%{_exec_prefix} \
251         --bindir=%{_bindir} \
252         --sbindir=%{_sbindir} \
253         --sysconfdir=%{_sysconfdir} \
254         --datadir=%{_datadir} \
255         --includedir=%{_includedir} \
256         --libdir=%{_libdir} \
257         --libexecdir=%{_libexecdir} \
258         --localstatedir=%{_localstatedir} \
259         --sharedstatedir=%{_sharedstatedir} \
260         --mandir=%{_mandir} \
261         --infodir=%{_infodir} \
262         --x-libraries=%{?_x_libraries}%{!?_x_libraries:%{_libdir}} \
263         %{dependencytracking} \
264         %{?configure_cache:--cache-file=%{configure_cache_file}} \
265 }
266
267 # Simple macros to simplify adding bconded options to configure scripts.
268 #   Each macro requires bcond name and accepts optional option name, if option
269 # isn't specified bcond name is used as option name. Options returning
270 # --with and --enable also allow third argument which will be added as value
271 # ( --with-option=value or --enable-option=value ) in case or positive
272 # condition, but won't be added otherwise ( nothing or just --disable-option ).
273
274 # Requirements:
275 # BuildRequires: rpmbuild(macros) >= 1.527
276
277 # Usage example:
278 # %{__enable bcond} - returns --enable-bcond iff build condition is set
279 # %{__disable bcond option} - returns --enable-option iff bcond is not set
280 # %{__enable_disable bcond option value} - returns --enable-option=value if
281 #    bcond is set, returns --disable-option otherwise
282
283 # expand bconds to --enable-something and --disable-something
284 %__enable() %{expand:%%{?with_%{1}:--enable-%{?2}%{!?2:%{1}}%{?3:=%{3}}}}
285 %__disable() %{expand:%%{!?with_%{1}:--disable-%{?2}%{!?2:%{1}}}}
286 %__enable_disable() %{expand:%%{?with_%{1}:--enable-%{?2}%{!?2:%{1}}%{?3:=%{3}}}%%{!?with_%{1}:--disable-%{?2}%{!?2:%{1}}}}
287
288 # same as above, but condition inverted
289 %__enable_unless() %{expand:%%{!?with_%{1}:--enable-%{?2}%{!?2:%{1}}%{?3:=%{3}}}}
290 %__disable_if() %{expand:%%{?with_%{1}:--disable-%{?2}%{!?2:%{1}}}}
291 %__enable_disable_not() %{expand:%%{!?with_%{1}:--enable-%{?2}%{!?2:%{1}}%{?3:=%{3}}}%%{?with_%{1}:--disable-%{?2}%{!?2:%{1}}}}
292
293 # expand bconds to --with-something and --without-something
294 %__with() %{expand:%%{?with_%{1}:--with-%{?2}%{!?2:%{1}}%{?3:=%{3}}}}
295 %__without() %{expand:%%{!?with_%{1}:--without-%{?2}%{!?2:%{1}}}}
296 %__with_without() %{expand:%%{?with_%{1}:--with-%{?2}%{!?2:%{1}}%{?3:=%{3}}}%%{!?with_%{1}:--without-%{?2}%{!?2:%{1}}}}
297
298 # same as above, but condition inverted
299 %__with_unless() %{expand:%%{!?with_%{1}:--with-%{?2}%{!?2:%{1}}%{?3:=%{3}}}}
300 %__without_if() %{expand:%%{?with_%{1}:--without-%{?2}%{!?2:%{1}}}}
301 %__with_without_not() %{expand:%%{!?with_%{1}:--with-%{?2}%{!?2:%{1}}%{?3:=%{3}}}%%{?with_%{1}:--without-%{?2}%{!?2:%{1}}}}
302
303 #-----------------------------------------------------------------
304
305 # overload to insert debuginfo package
306 %prep \
307 %if 0%{?_enable_debug_packages}\
308 %{debug_package}\
309 %endif\
310 %%prep\
311 %{nil}
312
313 # Location of autoconf macros
314 %_aclocaldir    %{expand:%%global _aclocaldir %(aclocal --print-ac-dir || echo ERROR)}%_aclocaldir
315
316 # Location of omf files
317 %_omf_dest_dir  %{expand:%%global _omf_dest_dir %(scrollkeeper-config --omfdir || echo ERROR)}%_omf_dest_dir
318
319 # Location of pkgconfig files
320 %_pkgconfigdir  /usr/%{_lib}/pkgconfig
321 # noarch pkgconfig files
322 %_npkgconfigdir /usr/share/pkgconfig
323
324 # Location of desktop files
325 %_desktopdir    /usr/share/applications
326 %_applnkdir     ERROR:_applnkdir_is_obsolete_use_desktopdir_instead
327
328 # Location of pixmaps for applnk/desktop files
329 %_pixmapsdir    /usr/share/pixmaps
330
331 # Location of themable icons for applnk/desktop files
332 %_iconsdir      /usr/share/icons
333
334 # Location of fonts directories
335 %_fontsdir      /usr/share/fonts
336
337 # Location of Gtk and associated libraries documentation
338 %_gtkdocdir     %{_defaultdocdir}/gtk-doc/html
339
340 # Location of KDE documentation
341 %_kdedocdir     %{_defaultdocdir}/kde/HTML
342
343 # unsermake script
344 %__unsermake /usr/share/unsermake/unsermake
345
346 # Current date
347 %date           %(LC_ALL=C date +"%a %b %d %Y")
348
349 # Example files, programs, scripts...
350 %_examplesdir   /usr/src/examples
351
352 # Alternative kernel type/version
353 %_alt_kernel    %{nil}%{?alt_kernel:-%{?alt_kernel}}
354
355 # The directory holding Linux kernel sources
356 %_kernelsrcdir  /usr/src/linux%{_alt_kernel}
357
358 # SysV-style initscripts dir
359 %_initddir              /etc/rc.d/init.d
360
361 # If non-empty "debug" macro defined, add "dbg" suffix to release number
362 %_rpmfilename           %%{NAME}-%%{VERSION}-%%{RELEASE}%{?debug:dbg}.%%{ARCH}.rpm
363
364 # -n drm to generate kernel%{_alt_kernel}-drm dependency
365 %releq_kernel(n:)               %{expand:%%global releq_kernel %(R=$(LC_ALL=C rpm -q --qf '%{N}%{?-n:-%{-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
366 %releq_kernel_up(n:)    %{expand:%%global releq_kernel_up %(R=$(LC_ALL=C rpm -q --qf '%{N}%{?-n:-%{-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
367 %releq_kernel_smp(n:)   %{expand:%%global releq_kernel_smp %(R=$(LC_ALL=C rpm -q --qf '%{N}%{?-n:-%{-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
368
369 # -s post to generate Requires(post) dependency
370 %requires_releq_kernel(s:n:)            Requires%{-s:(%{-s*})}: %releq_kernel
371 %requires_releq_kernel_up(s:n:)         Requires%{-s:(%{-s*})}: %releq_kernel_up
372 %requires_releq_kernel_smp(s:n:)        Requires%{-s:(%{-s*})}: %releq_kernel_smp
373
374 # Requires name = version-release
375 %requires_releq()       %{!?1:ERROR}%{?2:ERROR}%{?1:%{!?2:%{expand:%%requires_eq_to -r %1 %1}}}
376 # Requires: name = version
377 %requires_eq()          %{!?1:ERROR}%{?2:ERROR}%{?1:%{!?2:%{expand:%%requires_eq_to %1 %1}}}
378 # Requires: name = version (version based on querying package %2)
379 %requires_eq_to(r)      %{!?2:ERROR}%{?3:ERROR}%{?2:%{!?3:%(if ! LC_ALL=C rpm -q --qf 'Requires: %1 = %|E?{%{E}:}|%{V}%{?-r:-%{R}}\\n' %2 | grep '^Requires:'; then echo "BuildRequires: %2"; fi)}}
380
381 %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
382
383 # kernel version-release handling
384 %__kernel_ver    %{expand:%%global __kernel_ver %( \\
385         Z=$(awk -F'"' '/UTS_RELEASE/{print $2}' %{_kernelsrcdir}/include/linux/{version,utsrelease}.h 2>/dev/null); \\
386         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)}; \\
387         echo ${Z:-ERROR}; \\
388 )}%__kernel_ver
389
390 %__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
391 %__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
392 %_kernel_ver    %{expand:%%global _kernel_ver %{__kernel_ver}%{?with_dist_kernel:%(echo %{__kernel_ver} | grep -q -e - || echo -%{__kernel_rel})}}%_kernel_ver
393 %_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
394
395 # `uname -r` to be used in @release field
396 %_kernel_vermagic       %{expand:%%global _kernel_vermagic %(echo %{_kernel_ver} | sed -e 's/-/_/g')}%_kernel_vermagic
397
398 # sgml macros
399 %xmlcat_add()           /usr/bin/xmlcatalog --noout --add nextCatalog \"\" %1 /etc/xml/catalog ;
400 %xmlcat_del()           /usr/bin/xmlcatalog --noout --del %1 /etc/xml/catalog ;
401 %xmlcat_add_rewrite     /usr/bin/xmlcatalog --noout --add rewriteSystem
402 %xmlcat_create()        /usr/bin/xmlcatalog --noout --create %1 ;
403 %sgmlcat_add()          /usr/bin/install-catalog --add %1 %2 > /dev/null ;
404 %sgmlcat_del()          /usr/bin/install-catalog --remove %1 %2 > /dev/null ;
405 %docbook_sgmlcat_fix() { for l in \
406 '' \
407 '  -- default decl --' \
408 'DTDDECL "-//OASIS//DTD DocBook XML V%2//EN" "../../xml.dcl"' \
409 '  -- hacks for opensp --' \
410 'SYSTEM "file://%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
411 'SYSTEM "http://www.oasis-open.org/docbook/xml/%2/docbookx.dtd"                  "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
412 '' \
413 ; do echo $l; done >> %1 \
414 }
415
416 # vim - "
417
418 # minimum file size needed for compressed documents.
419 # just smaller files than this get larger when compressed.
420 # some stats:
421 # - 0 byte file compressed was 25 bytes .gz
422 # - 39 byte file was compressed as 57
423 # - with test/test.spec@man 158 byte file was compressed also 158
424 %_min_compress_bytes    159
425
426 #-----------------------------------------------------------------
427 # find and gzip all files in %{_mandir} and %{infodir}
428 #
429 # Requires: xargs, find
430 #
431 #%no_install_post_compress_docs 1
432 %__spec_install_post_compress_docs { \
433 %{!?no_install_post_compress_docs:__spec_install_post_compress_docs() { \
434         for i in /usr/share/man /usr/X11R6/man; do \
435                 if [ -d "$RPM_BUILD_ROOT$i" ]; then \
436                         echo "Compress man pages: $i"; \
437                         find "$RPM_BUILD_ROOT$i" -name '*.bz2' -print | xargs -r %{__bzip2} -df; \
438                         find "$RPM_BUILD_ROOT$i" -name '*.gz' -print | xargs -r %{__gzip} -dnf; \
439                         find $RPM_BUILD_ROOT$i -type l | while read a; do \
440                                 m=$(readlink $a); \
441                                 rm -f $a; \
442                                 echo .so ${m##*/} > $a; \
443                                 echo >&2 "Converted ${a#$RPM_BUILD_ROOT} from symlink to man link: ${m##*/}"; \
444                         done; \
445                         find "$RPM_BUILD_ROOT$i" -type f -size +%{_min_compress_bytes}c -print | xargs -r %{__gzip} -9nf; \
446                 fi; \
447         done; \
448         if [ -d "$RPM_BUILD_ROOT%{_infodir}" ]; then \
449                 echo "Compress info pages: %{_infodir}"; \
450                 find "$RPM_BUILD_ROOT%{_infodir}" -name '*.bz2' -print | xargs -r %{__bzip2} -df; \
451                 find "$RPM_BUILD_ROOT%{_infodir}" -name '*.gz' -print | xargs -r %{__gzip} -dnf; \
452                 find "$RPM_BUILD_ROOT%{_infodir}" -name '*.info*' -type f -size +%{_min_compress_bytes}c -print | xargs -r %{__gzip} -9nf; \
453         fi; \
454 }; __spec_install_post_compress_docs } }
455
456 #-----------------------------------------------------------------
457 # Strip executable binaries and shared object files
458 #
459 # Requires: find, awk, strip, cut, xargs
460 #
461 # Special macros which affect this process:
462 #%no_install_post_strip 1               # disable stripping at all
463 #%_noautostrip                  regexp  # exclude files matching (anchored!) regex from stripping
464 #%_autostripall                 regexp  # strip files matching (anchored!) regex using plain strip
465 #%_autostripunneeded    regexp  # strip files matching (anchored!) regex using strip --strip-unneeded
466 #%_autostripdebug               regexp  # strip files matching (anchored!) regex using strip --strip-debug
467 #
468 %__spec_install_post_strip {%{!?debug: \
469 %{!?no_install_post_strip:__spec_install_post_strip() { \
470 if [ -d "$RPM_BUILD_ROOT" ]; then \
471         if [ -d $RPM_BUILD_ROOT/lib/modules ]; then \
472                 modulelist=$(find $RPM_BUILD_ROOT/lib/modules -name '*o' -type f -print); \
473                 if [ "$modulelist" ]; then \
474                         modulecount=$(echo "$modulelist" | wc -l); \
475                         printf "Stripping %d kernel modules..." $modulecount; \
476                         echo "$modulelist" | xargs -l512 chmod u+w; \
477                         echo "$modulelist" | xargs -l512 %{__strip} --strip-unneeded --remove-section=.comment --remove-section=.note.GNU-stack; \
478                         echo "DONE"; \
479                 fi; \
480         fi; \
481         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}"}); \
482         if [ -n "$filelist" ]; then \
483                 filetypes=`echo "$filelist" | xargs -r -d'\\n' file`; \
484                 elfexelist=`echo "$filetypes" | awk -F: '/ELF.*executable/ {print $1}'`; \
485                 elfsharedlist=`echo "$filetypes" | awk -F: '/LF.*shared object/ {print $1}'`; \
486                 archiveslist=`echo "$filetypes" | awk -F: '/current ar archive/ {print $1}'`; \
487                 if [ -n "$elfexelist" ]; then \
488                         printf "Stripping %d ELF executables..." $(echo "$elfexelist" | wc -l); \
489                         chmod u+w $elfexelist; \
490                         %{__strip} --remove-section=.note --remove-section=.comment $elfexelist; \
491                         echo "DONE"; \
492                 fi; \
493                 if [ -n "$elfsharedlist" ]; then \
494                         printf "Stripping %d ELF shared libraries..." $(echo "$elfsharedlist" | wc -l); \
495                         chmod u+w $elfsharedlist; \
496                         %{__strip} --strip-unneeded --remove-section=.note --remove-section=.comment $elfsharedlist; \
497                         echo "DONE"; \
498                 fi; \
499                 if [ -n "$archiveslist" ]; then \
500                         printf "Stripping %d ar archives..." $(echo "$archiveslist" | wc -l); \
501                         chmod u+w $archiveslist; \
502                         %{__strip} --strip-debug --remove-section=.note --remove-section=.comment $archiveslist; \
503                         echo "DONE"; \
504                 fi; \
505         fi; \
506     filelist_all=%{?_autostripall:$(find $RPM_BUILD_ROOT -type f -regex "%{_autostripall}")}; \
507     filelist_unneeded=%{?_autostripunneeded:$(find $RPM_BUILD_ROOT -type f -regex "%{_autostripunneeded}")}; \
508     filelist_debug=%{?_autostripdebug:$(find $RPM_BUILD_ROOT -type f -regex "%{_autostripdebug}")}; \
509         if [ -n "$filelist_all" ]; then \
510                 printf "Stripping everything from %d additional files..." $(echo "$filelist_all" | wc -l); \
511                 chmod u+w $filelist_all; \
512                 %{__strip} --remove-section=.note --remove-section=.comment $filelist_all; \
513                 echo "DONE"; \
514         fi; \
515         if [ -n "$filelist_unneeded" ]; then \
516                 printf "Stripping unneeded from %d additional files..." $(echo "$filelist_unneeded" | wc -l); \
517                 chmod u+w $filelist_unneeded; \
518                 %{__strip} --strip-unneeded --remove-section=.note --remove-section=.comment $filelist_unneeded; \
519                 echo "DONE"; \
520         fi; \
521         if [ -n "$filelist_debug" ]; then \
522                 printf "Stripping debuginfo from %d additional files..." $(echo "$filelist_debug" | wc -l); \
523                 chmod u+w $filelist_debug; \
524                 %{__strip} --strip-debug --remove-section=.note --remove-section=.comment $filelist_debug; \
525                 echo "DONE"; \
526         fi; \
527 fi; }; __spec_install_post_strip } } }
528
529 #-----------------------------------------------------------------
530 # remove all RPATH from executable binaries and shared object files
531 #
532 # Requires: find, awk, cut, xargs, chrpath, uname
533 #
534 # Special macros which affect this process
535 #%no_install_post_chrpath       1       # disable chrpath at all
536 #%_noautochrpath        regex           # exclude files matching (anchored!) regex from chrpath
537 #
538 %__spec_install_post_chrpath {%{!?debug: \
539 %{!?no_install_post_chrpath: __spec_install_post_chrpath() { \
540 if [ -d "$RPM_BUILD_ROOT" ]; then \
541         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}"}`; \
542         if [ -n "$files" ]; then \
543                 objs=`echo "$files" | xargs -r -d'\\n' file | awk -F: '/ELF.*(executable.*dynamically linked|shared object)/ {print $1}'`; \
544         fi; \
545         if [ -n "$objs" ]; then \
546                 printf "Remove RPATH from %d executable binaries and shared object files.\n" $(echo "$objs" | wc -l); \
547                 echo "$objs" | \
548                 while read file; do \
549                         rpath= ; \
550                         chmod u+w "$file"; \
551                         for dir in $(chrpath -l "$file" | awk '/RPATH=/ { gsub(/.*RPATH=/,""); gsub(/:/," "); print $0 }'); do \
552                                         case $dir in \
553                                         '$ORIGIN' ) \
554                                                 if [ "$rpath" = "" ] ; then rpath="$dir" ; \
555                                                 else rpath="$rpath:$dir" ; fi ; \
556                                                 continue ; \
557                                                 ;; \
558                                         esac ; \
559                                         newdir=$(readlink -m "$dir"); \
560                                         [ ${#newdir} -le ${#dir} ] && dir=$newdir; \
561                                         case $dir in \
562                                         /home/* | /tmp/* | /usr/lib | /usr/lib64 | /lib | /lib64 | /usr/local/lib | /usr/local/lib64 | /usr/X11R6/lib | /usr/X11R6/lib64 ) \
563                                                 echo "remove-rpath: $dir in $file"; \
564                                                 ;; \
565                                         * ) \
566                                                 if [ "$rpath" = "" ] ; then rpath="$dir" ; \
567                                                 else rpath="$rpath:$dir" ; fi ; \
568                                                 ;; \
569                                         esac ; \
570                         done ; \
571                         if [ "$rpath" = "" ] ; then chrpath -d "$file" > /dev/null ; \
572                         else chrpath -r "$rpath" "$file" > /dev/null ; fi ; \
573                 done; \
574         fi; \
575 fi; }; __spec_install_post_chrpath } } }
576
577 # vim: "
578
579 #-----------------------------------------------------------------
580 # Find all shared object files with unresolved symbols. Warn
581 # and terminate if any found (termination can be turned off by define).
582 #%no_install_post_check_so 1
583 %__spec_install_post_check_so { \
584  __spec_install_post_check_so() { \
585     fail=0; \
586     printf "Searching for shared objects with unresolved symbols..."; \
587     for f in $(find $RPM_BUILD_ROOT -type f -name '*.so.*' -print); do \
588         LC_ALL=C objdump -T $f 2> /dev/null | LC_ALL=C awk -v "file=$f" 'BEGIN { found=0; skip["program_name"]=1; symbols = "" } /^[0-9a-z]+ +D +\*UND\*/ { if ($NF in skip) { next; }; found = 1; symbols = symbols "\n\t" $NF } END { if (found) { print "\nUnresolved symbols found in: " file symbols; exit(1); } } ' || fail=1 ; \
589     done ; \
590     echo " DONE"; \
591     %{!?no_install_post_check_so:[ $fail -eq 1 ] && : || :;} \
592 }; __spec_install_post_check_so }}
593
594 #-----------------------------------------------------------------
595 # Find and gzip all kernel modules
596 #
597 # Requires: find
598 #
599 #%no_install_post_compress_modules      1
600 %__spec_install_post_compress_modules { \
601 %{!?no_install_post_compress_modules: __spec_install_post_compress_modules() { \
602         if [ -d $RPM_BUILD_ROOT/lib/modules ]; then \
603                 q=$(find $RPM_BUILD_ROOT/lib/modules -name '*o' -type f -print); \
604                 if [ "$q" ]; then \
605                         printf "Compress %d kernel modules..." $(echo "$q" | wc -l); \
606                         echo "$q" | xargs -r %{__gzip} -9nf; \
607                         echo "DONE"; \
608                         find $RPM_BUILD_ROOT/lib/modules -name '*o' -type l -printf "%p %l\n" | \
609                         while read a b; do ln -sf $b.gz $a.gz; rm -f $a; done; \
610                 fi; \
611         fi; \
612 }; __spec_install_post_compress_modules } }
613
614 # Remove common Perl files we don't package
615 %__spec_install_post_perl_clean {\
616 %{!?no_install_post_perl_clean: \
617 %{?pdir:rm -f $RPM_BUILD_ROOT{%{perl_archlib}/perllocal.pod,%{perl_vendorarch}/auto/%{pdir}%{?pnam:/%(echo %{pnam} | tr - /)}/.packlist}} \
618 } }
619
620 #-----------------------------------------------------------------
621 # Update GConf2 schemas
622 #
623 # Requires: GConf2
624 #
625 %gconf_schema_install() \
626         umask 022; \
627         GCONF_CONFIG_SOURCE="xml:readwrite:/etc/gconf/gconf.xml.defaults" \\\
628         /usr/bin/gconftool-2 --makefile-install-rule /etc/gconf/schemas/%{?1}%{!?1:*.schemas} > /dev/null; \
629 %{nil}
630
631 %gconf_schema_uninstall() \
632 if [ $1 = 0 -a -x /usr/bin/gconftool-2 ]; then \
633         umask 022; \
634         GCONF_CONFIG_SOURCE="xml:readwrite:/etc/gconf/gconf.xml.defaults" \\\
635         /usr/bin/gconftool-2 --makefile-uninstall-rule /etc/gconf/schemas/%{?1} > /dev/null \
636 fi; \
637 %{nil}
638
639 #-----------------------------------------------------------------
640 # Update desktop MIME database
641 # requires: desktop-file-utils
642 %update_desktop_database() {{ \
643         umask 022; \
644         /usr/bin/update-desktop-database -q; \
645 };} \
646 %{nil}
647
648 %update_desktop_database_post %update_desktop_database
649
650 %update_desktop_database_postun() {{ \
651 if [ "$1" = "0" ]; then \
652         %update_desktop_database \
653 fi; \
654 };} \
655 %{nil}
656
657 #-----------------------------------------------------------------
658 # Update shared MIME info database
659 # requires: shared-mime-info
660 #
661 %update_mime_database() {{ \
662         umask 022; \
663         /usr/bin/update-mime-database %{_datadir}/mime; \
664 };} \
665 %{nil}
666
667 #-----------------------------------------------------------------
668 # Update icon cache
669 # requires: gtk+
670 #
671 %update_icon_cache() {{ \
672         umask 022; \
673         /usr/bin/gtk-update-icon-cache -qf %{_datadir}/icons/%1; \
674 };} \
675 %{nil}
676
677 #-----------------------------------------------------------------
678 # Update scrollkeeper database
679 # requires: scrollkeeper
680 #
681 %scrollkeeper_update_post() \
682         /usr/bin/scrollkeeper-update -q; \
683 %{nil}
684
685 %scrollkeeper_update_postun() \
686 if [ "$1" = "0" ]; then \
687         /usr/bin/scrollkeeper-update -q; \
688 fi; \
689 %{nil}
690
691 #-----------------------------------------------------------------
692 # post %install sequence:
693 # - autodeps exceptions
694 # - compress all man and info pages,
695 # - strip all ELF executables and ELF shared objects if not %debug.
696 # - compress kernel modules if any
697
698 ###################################################################
699 # Requires/Provides automation
700 # exceptions system by Jacek Konieczny <jajcus@pld-linux.org>
701 #
702 %__noautoreqfiles       %(sed -e s'/#.*//' /etc/rpm/noautoreqfiles)%{?_noautoreqfiles: %{_noautoreqfiles}}
703 %__noautoprovfiles      %(sed -e s'/#.*//' /etc/rpm/noautoprovfiles)%{?_noautoprovfiles: %{_noautoprovfiles}}
704 %__noautoreq            %(sed -e s'/#.*//' /etc/rpm/noautoreq)%{?_noautoreq: %{_noautoreq}}
705 %__noautoreqdep         %(sed -e s'/#.*//' /etc/rpm/noautoreqdep)%{?_noautoreqdep: %{_noautoreqdep}}
706 %__noautoprov           %(sed -e s'/#.*//' /etc/rpm/noautoprov)%{?_noautoprov: %{_noautoprov}}
707
708 #%_noautocompressdoc    %{nil}
709 #
710 %_missing_doc_files_terminate_build     1%{nil}
711 %_unpackaged_files_terminate_build      %{nil}
712 # (X)emacs support
713 %___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;}'
714 %_emacs_lispdir %{expand:%%global _emacs_lispdir %(Z=$(emacs %___emacs_lispdir_helper); echo ${Z:-ERROR})}%_emacs_lispdir
715 %_xemacs_lispdir %{expand:%%global _xemacs_lispdir %(Z=$(xemacs %___emacs_lispdir_helper); echo ${Z:-ERROR})}%_xemacs_lispdir
716
717 %__php_provides %{nil}
718 %__php_requires %{nil}
719 %__perl_provides %{nil}
720 %__perl_requires %{nil}
721 %__mono_provides %{nil}
722 %__mono_requires %{nil}
723
724 # Perl specific macro definitions.
725 %perl_privlib           %{expand:%%global perl_privlib %(eval $(%{__perl} -V:installprivlib 2>/dev/null); echo ${installprivlib:-ERROR})}%perl_privlib
726 %perl_archlib           %{expand:%%global perl_archlib %(eval $(%{__perl} -V:installarchlib 2>/dev/null); echo ${installarchlib:-ERROR})}%perl_archlib
727 %perl_vendorlib         %{expand:%%global perl_vendorlib %(eval $(%{__perl} -V:installvendorlib 2>/dev/null); echo ${installvendorlib:-ERROR})}%perl_vendorlib
728 %perl_vendorarch        %{expand:%%global perl_vendorarch %(eval $(%{__perl} -V:installvendorarch 2>/dev/null); echo ${installvendorarch:-ERROR})}%perl_vendorarch
729 %perl_sitelib           %{expand:%%global perl_sitelib %(eval $(%{__perl} -V:installsitelib 2>/dev/null); echo ${installsitelib:-ERROR})}%perl_sitelib
730 %perl_sitearch          %{expand:%%global perl_sitearch %(eval $(%{__perl} -V:installsitearch 2>/dev/null); echo ${installsitearch:-ERROR})}%perl_sitearch
731
732 # Ruby
733 %__ruby                         /usr/bin/ruby
734 %ruby_archdir           %{expand:%%global ruby_archdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["archdir"]' 2>/dev/null || echo ERROR)}%ruby_archdir
735 %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
736 %ruby_rubylibdir        %{expand:%%global ruby_rubylibdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["rubylibdir"]' 2>/dev/null || echo ERROR)}%ruby_rubylibdir
737 %ruby_vendorarchdir     %{expand:%%global ruby_vendorarchdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["vendorarchdir"]' 2>/dev/null || echo ERROR)}%ruby_vendorarchdir
738 %ruby_vendorlibdir      %{expand:%%global ruby_vendorlibdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["vendorlibdir"]' 2>/dev/null || echo ERROR)}%ruby_vendorlibdir
739 %ruby_sitearchdir       %{expand:%%global ruby_sitearchdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["sitearchdir"]' 2>/dev/null || echo ERROR)}%ruby_sitearchdir
740 %ruby_sitelibdir        %{expand:%%global ruby_sitelibdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["sitelibdir"]' 2>/dev/null || echo ERROR)}%ruby_sitelibdir
741 %ruby_rdocdir           /usr/share/rdoc
742 %ruby_version           %{expand:%%global ruby_version %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["ruby_version"]' 2>/dev/null || echo ERROR)}%ruby_version
743 %ruby_ver_requires_eq   Requires:       ruby(ver) = %ruby_version
744 %ruby_mod_ver_requires_eq       Requires:       ruby-modules(ver) = %ruby_version
745
746 %php_pear_dir           /usr/share/pear
747 %php_data_dir           /usr/share/php
748 %php_extensiondir       %{expand:%%global php_extensiondir %(php-config --extension-dir 2>/dev/null || echo ERROR)}%php_extensiondir
749 %php_sysconfdir         %{expand:%%global php_sysconfdir %(php-config --sysconfdir 2>/dev/null || echo ERROR)}%php_sysconfdir
750 %php_includedir         %{expand:%%global php_includedir %(php-config --include-dir 2>/dev/null || echo ERROR)}%php_includedir
751
752 # extract php/zend api versions
753 %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
754 %php_minor_version              %{expand:%%global php_minor_version %(awk '/#define PHP_MINOR_VERSION/{print $3}' %{php_includedir}/main/php_version.h 2>/dev/null || echo ERROR)}%php_minor_version
755 %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
756 %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
757 %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
758 %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
759 %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
760 %zend_zts                               %{expand:%%global zend_zts %(Z=$(grep -sc '^#define ZTS 1' %{php_includedir}/main/php_config.h); echo ${Z:-ERROR})}%zend_zts
761
762 # helper macro
763 %__php_api_requires(v:) Requires: php%{-v*}(%{expand:%1}) = %{expand:%{%{!?2:%{1}}%{?2}}}
764
765 # macros for public use
766 # for php extensions (php-pecl)
767 %requires_php_extension %{__php_api_requires modules_api php_api_version} \
768 %{__php_api_requires zend_module_api} \
769 %{__php_api_requires -v %php_major_version debug php_debug} \
770 %{__php_api_requires -v %php_major_version thread-safety zend_zts}
771
772 # for zend extensions
773 %requires_zend_extension %{__php_api_requires zend_module_api} \
774 %{__php_api_requires zend_extension_api} \
775 %{__php_api_requires -v %php_major_version debug php_debug} \
776 %{__php_api_requires -v %php_major_version thread-safety zend_zts}
777
778 # for php pdo modules (php-pecl-PDO_*)
779 %requires_php_pdo_module %{__php_api_requires PDO_API php_pdo_api_version}
780
781 # for using PHP post scripts. for PHP >= 5.0
782 %php_webserver_restart \
783 [ ! -f /etc/apache/conf.d/??_mod_php.conf ] || %service -q apache restart \
784 [ ! -f /etc/httpd/conf.d/??_mod_php.conf ] || %service -q httpd restart \
785 if [ -x /etc/rc.d/init.d/php-fcgi ]; then \
786         PHP_FCGI_BINARY=; . /etc/sysconfig/php-fcgi 2>/dev/null \
787         if [[ ${PHP_FCGI_BINARY:-php.fcgi} = *php.fcgi* ]]; then \
788                 %service -q php-fcgi restart \
789         fi \
790 fi \
791 if [ -x /etc/rc.d/init.d/php-fpm ]; then \
792         %service -q php-fpm restart \
793 fi \
794 %{nil}
795
796 # for using php post scripts. for PHP >= 4.0 && PHP < 5.0
797 %php4_webserver_restart \
798 [ ! -f /etc/apache/conf.d/??_mod_php4.conf ] || %service -q apache restart \
799 [ ! -f /etc/httpd/conf.d/??_mod_php4.conf ] || %service -q httpd restart \
800 if [ -x /etc/rc.d/init.d/php-fcgi ]; then \
801         PHP_FCGI_BINARY=; . /etc/sysconfig/php-fcgi 2>/dev/null \
802         if [[ ${PHP_FCGI_BINARY:-php.fcgi} = *php4.fcgi* ]]; then \
803                 %service -q php-fcgi restart \
804         fi \
805 fi \
806 %{nil}
807
808 # X.org helper macros
809 %__xorg_abi_requires_ge() Requires: xorg-xserver-server(%{expand:%1}-abi) >= %{expand:%{%2}}
810 %__xorg_abi_requires_lt() Requires: xorg-xserver-server(%{expand:%1}-abi) < %(awk -vv=%{expand:%{%2}} 'BEGIN{split(v, a, "."); printf("%s.0", a[1] + 1); exit}')
811
812 %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
813 %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
814 %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
815 %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
816 %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
817 # vim: '
818
819 %requires_xorg_xserver_extension \
820 %{__xorg_abi_requires_ge ansic xorg_xserver_ansic_abi} \
821 %{__xorg_abi_requires_lt ansic xorg_xserver_ansic_abi} \
822 %{__xorg_abi_requires_ge extension xorg_xserver_extension_abi} \
823 %{__xorg_abi_requires_lt extension xorg_xserver_extension_abi} \
824 %{nil}
825
826 %requires_xorg_xserver_xinput \
827 %{__xorg_abi_requires_ge ansic xorg_xserver_ansic_abi} \
828 %{__xorg_abi_requires_lt ansic xorg_xserver_ansic_abi} \
829 %{__xorg_abi_requires_ge xinput xorg_xserver_xinput_abi} \
830 %{__xorg_abi_requires_lt xinput xorg_xserver_xinput_abi} \
831 %{nil}
832
833 %requires_xorg_xserver_font \
834 %{__xorg_abi_requires_ge ansic xorg_xserver_ansic_abi} \
835 %{__xorg_abi_requires_lt ansic xorg_xserver_ansic_abi} \
836 %{__xorg_abi_requires_ge font xorg_xserver_font_abi} \
837 %{__xorg_abi_requires_lt font xorg_xserver_font_abi} \
838 %{nil}
839
840 %requires_xorg_xserver_videodrv \
841 %{__xorg_abi_requires_ge ansic xorg_xserver_ansic_abi} \
842 %{__xorg_abi_requires_lt ansic xorg_xserver_ansic_abi} \
843 %{__xorg_abi_requires_ge videodrv xorg_xserver_videodrv_abi} \
844 %{__xorg_abi_requires_lt videodrv xorg_xserver_videodrv_abi} \
845 %{nil}
846
847 # TCL specific macro definitions.
848 # TODO: when th tcl is fixed use tclsh to get version: %(echo 'puts $tcl_version' | tclsh)
849 %tcl_version    %{expand:%%global tcl_version %(v=$(rpm -q --qf %{V} tcl | cut -d. -f1,2); echo ${v:-ERROR})}%tcl_version
850 %tcl_sitearch   %{_libdir}/tcl%{tcl_version}
851 %tcl_sitelib    %{_datadir}/tcl%{tcl_version}
852
853 # Python specific macro definitions.
854 # python main version
855 %py_ver                 %{expand:%%global py_ver %(%{__python} -c "import sys; print sys.version[:3]" 2>/dev/null || echo ERROR)}%py_ver
856
857 # directories
858 %py_prefix              %{expand:%%global py_prefix %(%{__python} -c "import sys; print sys.prefix" 2>/dev/null || echo ERROR)}%py_prefix
859 %py_libdir              %{py_prefix}/%{_lib}/python%{py_ver}
860 %py_scriptdir   %{py_prefix}/share/python%{py_ver}
861 %py_incdir              /usr/include/python%{py_ver}
862 %py_sitedir             %{py_libdir}/site-packages
863 %py_sitescriptdir %{py_scriptdir}/site-packages
864 %py_dyndir              %{py_libdir}/lib-dynload
865
866 # pure python modules compilation
867 %py_comp                python -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
868
869 %py_ocomp               python -O -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
870
871 # Software written in Python language require Python with main version
872 %pyrequires_eq() Requires:      %1
873
874 # Python 3.x
875 # python main version
876 %__python3                      python3
877 %py3_ver                        %{expand:%%global py3_ver %(%{__python3} -c "import sys; print(sys.version[:3])" 2>/dev/null || echo ERROR)}%py3_ver
878
879 # directories
880 %py3_prefix             %{expand:%%global py3_prefix %(%{__python3} -c "import sys; print(sys.prefix)" 2>/dev/null || echo ERROR)}%py3_prefix
881 %py3_libdir             %{py3_prefix}/%{_lib}/python%{py3_ver}
882 %py3_scriptdir  %{py3_prefix}/share/python%{py3_ver}
883 %py3_incdir             /usr/include/python%{py3_ver}
884 %py3_sitedir            %{py3_libdir}/site-packages
885 %py3_sitescriptdir %{py3_scriptdir}/site-packages
886 %py3_dyndir             %{py3_libdir}/lib-dynload
887
888 # pure python modules compilation
889 %py3_comp               %{__python3} -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
890
891 %py3_ocomp              %{__python3} -O -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
892
893 # Hardlink binary identical .pyc and .pyo files
894 %__spec_install_post_py_hardlink {\
895 %{!?no_install_post_py_hardlink: __spec_install_post_py_hardlink() { \
896 local a b c=0 t=0; \
897 if [ -d "$RPM_BUILD_ROOT" ]; then \
898         find "$RPM_BUILD_ROOT" -name '*.pyc' > __rpm_pyc; \
899         while read a; do \
900                 b="${a%.pyc}.pyo"; \
901                 if cmp -s "$a" "$b"; then \
902                         ln -f "$a" "$b"; \
903                         c=$((c + 1)); \
904                 fi; \
905                 t=$((t + 1)); \
906         done < __rpm_pyc; \
907         [ $t -gt 0 ] && printf "Hardlink Python files: %d/%d files hardlinked\n" $c $t; \
908         rm -f __rpm_pyc; \
909 fi; \
910 }; __spec_install_post_py_hardlink } }
911
912 # remove python sources, so that check-files won't complain
913 %py_postclean() \
914 for d in %{py_sitescriptdir} %{py_sitedir} %*; do \
915  [ ! -d "$RPM_BUILD_ROOT$d" ] || find "$RPM_BUILD_ROOT$d" -name '*.py' -print0 | xargs -0r -l512 rm;\
916 done \
917 %{nil}
918
919 %py3_postclean() \
920 for d in %{py3_sitescriptdir} %{py3_sitedir} %*; do \
921  [ ! -d "$RPM_BUILD_ROOT$d" ] || find "$RPM_BUILD_ROOT$d" -name '*.py' -print0 | xargs -0r -l512 rm;\
922 done \
923 %{nil}
924
925 # depmod macro
926 %depmod() { \
927 umask 022; \
928 if [ -e /boot/System.map-%1 ]; then \
929         /sbin/depmod -a -F /boot/System.map-%1 %1; \
930 else \
931         if [ -e /boot/System.map ]; then \
932                 /sbin/depmod -a -F /boot/System.map %1; \
933         else \
934                 /sbin/depmod -a %1; \
935         fi \
936 fi; \
937 }
938
939 # XMMS specific macros
940 %xmms_prefix                    %{expand:%%global xmms_prefix %(xmms-config --prefix 2>/dev/null || echo ERROR)}%xmms_prefix
941 %xmms_exec_prefix               %{expand:%%global xmms_exec_prefix %(xmms-config --exec-prefix 2>/dev/null || echo ERROR)}%xmms_exec_prefix
942 %xmms_version                   %{expand:%%global xmms_version %(xmms-config --version 2>/dev/null || echo ERROR)}%xmms_version
943 %xmms_datadir                   %{expand:%%global xmms_datadir %(xmms-config --data-dir 2>/dev/null || echo ERROR)}%xmms_datadir
944 %xmms_plugindir                 %{expand:%%global xmms_plugindir %(xmms-config --plugin-dir 2>/dev/null || echo ERROR)}%xmms_plugindir
945 %xmms_visualization_plugindir   %{expand:%%global xmms_visualization_plugindir %(xmms-config --visualization-plugin-dir 2>/dev/null || echo ERROR)}%xmms_visualization_plugindir
946 %xmms_input_plugindir           %{expand:%%global xmms_input_plugindir %(xmms-config --input-plugin-dir 2>/dev/null || echo ERROR)}%xmms_input_plugindir
947 %xmms_output_plugindir          %{expand:%%global xmms_output_plugindir %(xmms-config --output-plugin-dir 2>/dev/null || echo ERROR)}%xmms_output_plugindir
948 %xmms_effect_plugindir          %{expand:%%global xmms_effect_plugindir %(xmms-config --effect-plugin-dir 2>/dev/null || echo ERROR)}%xmms_effect_plugindir
949 %xmms_general_plugindir         %{expand:%%global xmms_general_plugindir %(xmms-config --general-plugin-dir 2>/dev/null || echo ERROR)}%xmms_general_plugindir
950
951 %_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/;s/sparcv./sparc/')}%_target_base_arch
952
953 # user/group checking macros
954 #
955 # Usage:
956 #       %userremove myuser
957 #
958 %userremove     /usr/lib/rpm/user_group.sh user del
959 %groupremove    /usr/lib/rpm/user_group.sh group del
960 #
961 # Usage:
962 #       if %usertestrm myuser; then
963 #               /usr/sbin/userdel -r myuser
964 # Note:
965 #       use these macros only if you need to call userdel/groupdel with
966 #       a non-standard option or take an extra action; otherwise use the
967 #       %userremove/%groupremove macros
968 #
969 %usertestrm     /usr/lib/rpm/user_group.sh user testrm
970 %grouptestrm    /usr/lib/rpm/user_group.sh group testrm
971 # user group membership management macros
972 #
973 # Usage:
974 #       %addusertogroup [-q] myuser agroup
975 #
976 #  -q if user or group don't exist, don't make big noise of it (MISSINGOK behaviour)
977 #
978 # Requirements:
979 # BuildRequires:        rpmbuild(macros) >= 1.515
980 %addusertogroup(q)      quiet=%{-q:1} /usr/lib/rpm/user_group.sh user addtogroup %*; \
981 %{nil}
982
983 # banner support (useful in {pre,post}{,un} and triggers)
984 #
985 # Usage:
986 #       %banner name [-a] [-e] [-n] [-tn] <<EOF
987 # the banner text, the banner text
988 # the banner text, and following line
989 #EOF
990 # You can use any form of here-document, <<'EOF' <<-EOT will do.
991 # NOTE: if your use "<<-EOF", then You can actually indent inside here-document.
992 #
993 # -a   - append to the banner
994 # -e   - send to stderr instead of stdout
995 # -n   - no show banner (overrides -t)
996 # -t   - show only, if RPM_SCRIPTVERBOSITY >= n; default n=5
997 #
998 # Tests:
999 # (rpm -E '%banner -e banner <<EOF'; echo -e 'hi\nEOF') > m; sh -x m
1000 # rpm -E 'date | %banner -e banner' > m; sh -x m
1001 #
1002 %banner(aent:) ( \
1003 RPM_SCRIPTVERBOSITY=5 \
1004 [ -r /etc/sysconfig/rpm ] && . /etc/sysconfig/rpm \
1005 if [ -x /usr/bin/banner.sh ]; then \
1006         CMD="/usr/bin/banner.sh %{-e:--stderr} %{!-n:$([ $RPM_SCRIPTVERBOSITY -ge %{-t:%{-t*}}%{!-t:5} ] && echo -s)} %{!-a:-m}%{-a:-M} %1" \
1007 else \
1008         CMD="cat%{-e: >&2}" \
1009 fi \
1010 eval $CMD %{?2:%2}%{?3: %3}) \
1011 %{nil}
1012
1013 # useradd/groupadd macros
1014 # Author: Elan Ruusamäe <glen@pld-linux.org>
1015 #
1016 # Usage:
1017 #   %useradd [-P package] [-u uid] [-d home_dir] [-s shell] [-c comment]
1018 #   [-g initial_group] [-G group[,...]] login
1019 #
1020 #  -u uid. REQUIRED
1021 #  -g gid/group. REQUIRED
1022 #  -s defaults to /bin/false
1023 #  -d defaults to /usr/share/empty
1024 #  -c No default
1025 #  -r is accepted but ignored (it's always set)
1026 #  -k skeleton dir. defaults to /usr/share/empty
1027 # rpm specific flags
1028 #  -P package name. defaults to %{name}
1029 #
1030 %useradd(c:d:e:f:g:G:Mmk:op:s:u:rP:) \
1031 %{!-u:%{error:useradd: Required argument -u missing}} \
1032 %{!-g:%{error:useradd: Required argument -g missing}} \
1033 %{!?1:%{error:useradd: Required parameter login missing}} \
1034 if [ -n "`/bin/id -u %{expand:%{%{#}}} 2>/dev/null`" ]; then \
1035         if [ "`/bin/id -u %{expand:%{%{#}}}`" != "%{-u*}" ]; then \
1036                 echo "Error: user %{expand:%{%{#}}} doesn't have uid=%{-u*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
1037                 exit 1 \
1038         fi \
1039 else \
1040         echo "Adding user %{expand:%{%{#}}} UID=%{-u*}." \
1041         /usr/sbin/useradd \\\
1042                 %{-m:-m -k %{-k*}%{!-k:/usr/share/empty}} \\\
1043                 -u %{-u*} \\\
1044                 -r \\\
1045                 -d %{-d*}%{!-d:/usr/share/empty} \\\
1046                 -s %{-s*}%{!-s:/bin/false} \\\
1047                 %{-c:-c "%(set -- %{-c*} %{*}; echo $1)"}\\\
1048                 -g %{-g*} \\\
1049                 %{-M} \\\
1050                 %{-G:-G %{-G*}} \\\
1051                 %{expand:%{%{#}}} 1>&2 || exit $? \
1052         [ ! -x /usr/sbin/nscd ] || /usr/sbin/nscd -i passwd || : \
1053 fi;
1054 # vim: "
1055
1056 # Usage:
1057 #   %groupadd [-P package] [-g gid] group
1058 #
1059 # -g gid. REQUIRED
1060 #
1061 # Sample:
1062 #   %groupadd -P %{name}-base -g %{gid} %{name}
1063
1064 %groupadd(g:P:rfo)      \
1065 %{!-g:%{error:groupadd: Required argument -g missing}} \
1066 %{!?1:%{error:groupadd: Required parameter group missing}} \
1067 if /usr/bin/getgid %{1} > /dev/null 2>&1; then \
1068         if [ "`/usr/bin/getgid %{1}`" != "%{-g*}" ]; then \
1069                 echo "Error: group %{1} doesn't have gid=%{-g*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
1070                 exit 1 \
1071         fi \
1072 else \
1073         echo "Adding group %{1} GID=%{-g*}." \
1074         /usr/sbin/groupadd -g %{-g*} -r %{1} 1>&2 || exit $? \
1075         [ ! -x /usr/sbin/nscd ] || /usr/sbin/nscd -i group || : \
1076 fi;
1077
1078 # webapp macros
1079 # Author: Elan Ruusamäe <glen@pld-linux.org>
1080 #
1081 # The config is installed/removed inside trigger, this means that you can any
1082 # time install apache1/apache/lighttpd package and the configuration file is
1083 # updated. if you don't need the config for various reason for specific
1084 # webserver, just remove the symlink from config directory using webapp
1085 # program. the trigger will not recreate the symlink on upgrades. In other
1086 # words the config is linked to webserver config directory on first install of
1087 # PACKAGE or WEBSERVER.
1088 #
1089 # Add package's webserver config to webserver webapps dir.
1090 # Usage:
1091 #   %webapp_register [-f] WEBSERVER WEBAPP
1092 #
1093 %webapp_register(f) \
1094 %{?debug:set -x; echo "webapp_register: %{name}-%{version}-%{release} 1:[$1]; 2:[$2]"} \
1095 if [ -n "%{-f:1}" ] || [ "$1" = "1" ] && [ "$2" = "1" ]; then\
1096         /usr/sbin/webapp register %1 %2\
1097 fi\
1098 # reload webserver if the config symlink is there and skip reload if webserver is upgraded\
1099 if [ -L /etc/%1/webapps.d/%(echo "%2" | tr '/' '-').conf ] && [ "$2" -lt "2" ]; then\
1100         %{expand:%service -q %%1 reload}\
1101 fi\
1102 %{nil}
1103
1104 # Remove package's config from webserver webapps dir.
1105 # Usage:
1106 #   %webapp_register [-f] WEBSERVER WEBAPP
1107 %webapp_unregister(f) \
1108 %{?debug:set -x; echo "webapp_unregister: %{name}-%{version}-%{release}: 1:[$1]; 2:[$2]"} \
1109 # remove link if either of the packages are gone \
1110 if [ -n "%{-f:1}" ] || [ "$1" = "0" ] || [ "$2" = "0" ] && [ -L /etc/%1/webapps.d/%(echo "%2" | tr '/' '-').conf ]; then \
1111         /usr/sbin/webapp unregister %1 %2\
1112         %{expand:%service -q %%1 reload}\
1113 fi \
1114 %{nil}
1115
1116 # service macro.
1117 # Author: Elan Ruusamäe <glen@pld-linux.org>
1118 #
1119 # calls usual service restart on package %post, but skips the restart if
1120 # administrator has disabled automatic service restarts in either global
1121 # /etc/sysconfig/rpm or per service /etc/sysconfig/SERVICE file.
1122 #
1123 # Usage:
1124 #   %service [-q] [-n] SERVICE ACTION ["SERVICE NICE DESCRIPTION"]
1125 #
1126 #  -q be silent when service isn't started (for scriplets restaring other package's services)
1127 #  -n NOOP mode, do not actually restart service
1128 #
1129 # Requirements:
1130 # BuildRequires:        rpmbuild(macros) >= 1.268
1131 # Requires:     rc-scripts
1132 # -n option:
1133 # BuildRequires:        rpmbuild(macros) >= 1.450
1134 %service(qn) {{%(export noop=%{-n:1} quiet=%{-q:1}; /usr/lib/rpm/service_generator.sh %{*}) };}
1135
1136
1137 # Java macros. based on jpackage macros.java
1138 #
1139 # Root directory where all Java VMs/SDK/JREs are installed.
1140 %_jvmdir                %{_libdir}/jvm
1141
1142 # Root directory where all Java VMs/SDK/JREs expose their jars
1143 %_jvmjardir             %{_libdir}/jvm-exports
1144
1145 # Root directory for all Java VM/SDK/JRE's private things.
1146 %_jvmprivdir    %{_libdir}/jvm-private
1147
1148 # Root directory for all architecture dependent parts of Java VM/SDK/JRE's
1149 %_jvmlibdir             %{_libdir}/jvm
1150
1151 # Root directory for all architecture independent parts of Java VM/SDK/JRE's
1152 %_jvmdatadir    %{_datadir}/jvm
1153
1154 # Root directory for all configurations parts of Java VM/SDK/JRE's
1155 %_jvmsysconfdir %{_sysconfdir}/jvm
1156
1157 # Root directory for all common architecture dependent parts of Java VM/SDK/JRE's
1158 %_jvmcommonlibdir       %{_libdir}/jvm-common
1159
1160 # Root directory for all common architecture independent parts of Java VM/SDK/JRE's
1161 %_jvmcommondatadir      %{_datadir}/jvm-common
1162
1163 # Root directory for all common configurations parts of Java VM/SDK/JRE's
1164 %_jvmcommonsysconfdir   %{_sysconfdir}/jvm-common
1165
1166 # Directory where arch-specific (JNI) version-independent jars are installed.
1167 %_jnidir                %{_libdir}/java
1168
1169 %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
1170
1171 %ant                    JAVA_HOME=%{java_home} CLASSPATH=$CLASSPATH ant
1172 %jar                    %{java_home}/bin/jar
1173 %java                   %{expand:%%global java %([ -f %{_javadir}-utils/java-functions ] || { echo ERROR; exit 0; }; unset JAVACMD; . %{_javadir}-utils/java-functions; set_javacmd; echo $JAVACMD)}%java
1174 %javac                  %{java_home}/bin/javac
1175 %javadoc                %{java_home}/bin/javadoc
1176
1177 %add_jvm_extension      JAVA_LIBDIR=%{buildroot}/%{_javadir}    %{_bindir}/jvmjar -l
1178
1179 %jpackage_script() \
1180 install -d $RPM_BUILD_ROOT%{_bindir}\
1181 cat > $RPM_BUILD_ROOT%{_bindir}/%5 << 'EOF' \
1182 #!/bin/sh\
1183 #\
1184 # %{name} script\
1185 # JPackage Project <http://www.jpackage.org/>\
1186 \
1187 # Source functions library\
1188 . %{_javadir}-utils/java-functions\
1189 \
1190 # Source system prefs\
1191 if [ -f %{_sysconfdir}/java/%{name}.conf ]; then\
1192     . %{_sysconfdir}/java/%{name}.conf\
1193 fi\
1194 \
1195 # Source user prefs\
1196 if [ -f $HOME/.%{name}rc ]; then\
1197     . $HOME/.%{name}rc\
1198 fi\
1199 \
1200 # Configuration\
1201 MAIN_CLASS=%1\
1202 BASE_FLAGS=%2\
1203 BASE_OPTIONS=%3\
1204 BASE_JARS="%(echo %4 | tr ':' ' ')"\
1205 \
1206 # Set parameters\
1207 set_jvm\
1208 set_classpath $BASE_JARS\
1209 set_flags $BASE_FLAGS\
1210 set_options $BASE_OPTIONS\
1211 \
1212 # Let's start\
1213 run "$@"\
1214 EOF
1215
1216 # jpackage 1.7
1217 # Directory for maven depmaps
1218 #
1219 %_mavendepmapdir /etc/maven
1220 %_mavendepmapfragdir /etc/maven/fragments
1221
1222 #
1223 # add_to_depmap adds an entry to the depmap. The arguments are:
1224 #
1225 # %1 the original groupid
1226 # %2 the original artifact id
1227 # %3 the version
1228 # %4 the new groupid
1229 # %5 the new artifactid
1230 #
1231
1232 %add_to_maven_depmap() \
1233 install -dm 755 $RPM_BUILD_ROOT/%{_mavendepmapfragdir}\
1234 cat >>$RPM_BUILD_ROOT/%{_mavendepmapfragdir}/%{name}<< EOF\
1235 <dependency>\
1236     <maven>\
1237         <groupId>%1</groupId>\
1238         <artifactId>%2</artifactId>\
1239         <version>%3</version>\
1240     </maven>\
1241     <jpp>\
1242         <groupId>%4</groupId>\
1243         <artifactId>%5</artifactId>\
1244         <version>%3</version>\
1245     </jpp>\
1246 </dependency>\
1247 \
1248 EOF\
1249 %{nil}
1250
1251 #==============================================================================
1252 #
1253 # update_maven_depmap updates the main maven depmap
1254 #
1255 %update_maven_depmap() \
1256 echo -e "<dependencies>\\n" > %{_mavendepmapdir}/maven2-depmap.xml\
1257 if [ -d %{_mavendepmapfragdir} ] && [ -n "`find %{_mavendepmapfragdir} -type f`" ]; then\
1258 cat %{_mavendepmapfragdir}/* >> %{_mavendepmapdir}/maven2-depmap.xml\
1259 fi\
1260 echo -e "</dependencies>\\n" >> %{_mavendepmapdir}/maven2-depmap.xml
1261
1262
1263 # PEAR install macros
1264 # Author: Elan Ruusamäe <glen@pld-linux.org>
1265 #
1266 # Usage:
1267 #       %%pear_package_setup ...
1268 #
1269 # -a #   - also unpack SOURCE#. for PEAR bootstrapping
1270 # -n FMT - create builddir with FMT, instead of default %%{_pearname}-%%{version}
1271 # -z     - unpack pear package and let pear use package.xml (not tarball) for install. for PEAR bootstrapping
1272 # -D     - pass -D to %setup (so the build dir is not removed)
1273 # -c     - register channel from local channel.xml file
1274 #
1275 # unpack PEAR package to %%{_builddir}/FMT. package is extracted with already
1276 # destination hierarchy. you should copy the tree to buildroot after
1277 # patching/reorganizing with %%pear_package_install.
1278 #
1279 # additionally BUILDROOT is stripped from files and files are converted to UNIX
1280 # line endings.
1281 #
1282 # the pear install process output is recorded to install.log, you should put it
1283 # to %%doc for later debug or just for information.
1284 #
1285 # additionally additional-packages.txt is produced if it was detected that the
1286 # package has optional dependencies. the file format is suitable of displaying
1287 # in %%post of a package. you should put this file to %%doc. noautocompressdoc is
1288 # automatically added for this file.
1289
1290
1291 # records install.log and transforms PEAR names to PLD Linux rpm package names.
1292 %__pear_install_log \
1293 tee install.log \
1294 # make post message of optional packages \
1295 grep 'can optionally use' install.log | sed -e 's,package "pear/,package "php-pear-,g;s,^pear/,php-pear-,;s,^pear/,php-pear-,;s,^channel://.*/,,' > optional-packages.txt \
1296 if [ -s optional-packages.txt ]; then \
1297         awk -F'"' '/use package/{print $2}' optional-packages.txt | sed -e "s,_,/,g;s,php-pear-, 'pear(,;s,$,.*)'," | tr -d '\\\n' > _noautoreq \
1298 else \
1299         rm -f optional-packages.txt \
1300 fi \
1301 %{nil}
1302
1303 # command invoking pear cli
1304 %__pear /usr/bin/pear
1305
1306 %pear_install(a:n:zD) \
1307 %__pear \\\
1308         -c %{builddir}/pearrc \\\
1309         -d doc_dir=/docs \\\
1310         -d temp_dir=/tmp \\\
1311         -d php_dir=%{-c:%{builddir}/}%{php_pear_dir} \\\
1312         -d bin_dir=%{_bindir} \\\
1313         -d data_dir=%{php_pear_dir}/data \\\
1314         -d test_dir=%{php_pear_dir}/tests \\\
1315         install \\\
1316         --packagingroot=%{builddir} \\\
1317         --offline \\\
1318         --nodeps \\\
1319         %{-f:--force} \\\
1320         %{!-z:%{S:%{-a*}%{!-a:0}}}%{-z:$_P} > .install.log || { c=$?; cat .install.log; exit $c; }; \
1321         %{-c:cp -a %{builddir}/%{builddir}/%{php_pear_dir} %{builddir}/%(dirname %{php_pear_dir}); rm -rf %{builddir}/%{builddir}; } \
1322 %{nil}
1323
1324 # The main macro.
1325 # using this macro will append optional-packages.txt to the nocompressdoc list
1326 # as it's displayed to user after package install. and adding additional gzip
1327 # dep is just waste ;)
1328 %pear_package_setup(a:n:zDc:) \
1329 %define srcdir %{-n*}%{!-n:%{_pearname}-%{version}} \
1330 %define builddir %{_builddir}/%{srcdir} \
1331 %setup -q -c -T %{-D:-D} -n %{srcdir} \
1332 %{-z:tar zxf %{S:0}; %{-a:tar zxf %{S:%{-a*}}}} \
1333 %{-z:_P=package2.xml; [ -f $_P ] || _P=package.xml; _N=%{srcdir}; mv $_P $_N; cd $_N} \
1334 %{-c:%{__pear} -c pearrc config-set php_dir %{builddir}/%{php_pear_dir}; %__pear -c %{builddir}/pearrc channel-add %{-c*}} \
1335 %pear_install \
1336 %{-z:cd ..} \
1337 cat %{-z:$_N/}.install.log | %__pear_install_log \
1338 \
1339 # undos sources \
1340 find -type f -print0 | xargs -0 sed -i -e 's,\\r$,,' \
1341 %{!?_noautocompressdoc:%global _noautocompressdoc %{nil}}%{expand:%%global _noautocompressdoc %{_noautocompressdoc} optional-packages.txt} \
1342 %{!?_noautoprov:%global _noautoprov %{nil}}%{expand:%%global _noautoprov %{_noautoprov} 'pear(tests/.*)'} \
1343 %{nil}
1344
1345 # Copies exctracted PEAR package structure and PEAR registry to buildroot.
1346 # Author: Elan Ruusamäe <glen@pld-linux.org>
1347 %pear_package_install() \
1348 cp -a ./%{php_pear_dir}/{.registry,*} $RPM_BUILD_ROOT%{php_pear_dir} \
1349 find $RPM_BUILD_ROOT%{php_pear_dir} '(' -name '*~' -o -name '*.orig' ')' | xargs -r rm -v \
1350 # help the developer out a little: \
1351 if [ -f _noautoreq ]; then \
1352         echo "AutoReqdep detected:" \
1353         echo "_noautoreq $(cat _noautoreq)" \
1354 fi \
1355 %{nil}
1356
1357
1358 # Register OpenLDAP schema.
1359 # Author: Elan Ruusamäe <glen@pld-linux.org>
1360 #
1361 # Usage:
1362 #   %%openldap_schema_register [-d core,nis] %{schemadir}/horde.schema
1363 #
1364 #  -d specify dependant schemas, separated by comma
1365 #
1366 %openldap_schema_register(d:) \
1367 for schema in %*; do \
1368         if ! grep -q "$schema" /etc/openldap/slapd.conf; then \
1369                 %{__sed} -i -e " \
1370                         /^include.*local.schema/{ \
1371                                 iinclude\\t     $schema\
1372                         } \
1373                 " /etc/openldap/slapd.conf \
1374         fi \
1375 done \
1376 # enable dependant schemas \
1377 if [ "%{-d*}" ]; then \
1378         %{__sed} -i -e ' \
1379         /^#include.*\\(%(echo '%{-d*}' | %{__sed} -e 's/,/\\\\|/g')\\)\\.schema/{ \
1380                 s/^#// \
1381         }' /etc/openldap/slapd.conf \
1382 fi \
1383 %{nil}
1384
1385 # Unregister OpenLDAP schema.
1386 # Author: Elan Ruusamäe <glen@pld-linux.org>
1387 #
1388 # Usage:
1389 #   %%openldap_schema_unregister %{schemadir}/horde.schema
1390 #
1391 %openldap_schema_unregister() \
1392 for schema in %*; do \
1393         if grep -q "$schema" /etc/openldap/slapd.conf; then \
1394                 %{__sed} -i -e " \
1395                 /^include.*$(echo "$schema" | %{__sed} -e 's,/,\\\\/,g')/d \
1396                 # for symmetry it would be nice if we disable enabled schemas in post, \
1397                 # but we really can not do that, it would break something else. \
1398                 " /etc/openldap/slapd.conf \
1399         fi \
1400 done \
1401 %{nil}
1402
1403 %env_update [ ! -x /sbin/env-update ] || /sbin/env-update -u || :
1404
1405
1406 # Build modules for kernels 2.6
1407 # Author: Przemyslaw Iskra <sparky@pld-linux.org>
1408 #
1409 # Usage:
1410 #       %build_kernel_modules -m <modules> -C <directory>
1411 #
1412 #  remember that proper Makefile is still required
1413 # Options:
1414 #  -m <modules> (required) -- comma-separated list of modules to save,
1415 #               without .ko extension, may be placed in subdirectory
1416 #  -C <directory> -- change to <directory> before doing anything
1417 #  -p <arg>, -P <arg> -- arguments passeed to make scripts
1418 #  -c -- do not execute make clean
1419 #  <additional arguments> -- all additional arguments will be passed to
1420 #               make modules
1421 #
1422 # Additional patching supported via here document. Try:
1423 #       %build_kernel_modules -m module <<'EOF'
1424 #       your patch script here
1425 #       EOF
1426 # Don't use it unless patching depends on config options.
1427
1428 # Developer note: don't touch it unless you know how to handle '\'.
1429 # - \ in script expands to nothing
1430 # - \\\ in script expands to \
1431 # - \\\ inside definition expands to nothing
1432 # - \\\\\\\ inside definition expands to \
1433 # - in last line \ has to touch arguments so arguments passing
1434 #   in new lines (using \) will be supported
1435
1436 %build_kernel_modules(p:P:m:C:c)                                                                        \
1437 %{!?-m:%{error:%{0}: Required module name/list missing} exit 1}         \
1438                                                                                                                                         \
1439 %define Opts                                                                                                            \\\\\\\
1440 %if "%{_target_base_arch}" != "%{_arch}"                                                        \\\
1441         %if "%{_arch}" == "x86_64" && "%{_target_base_arch}" == "i386"  \\\
1442         CC="%{kgcc}" ARCH=%{_target_base_arch}                                                  \\\
1443         %else                                                                                                                   \\\
1444         ARCH=%{_target_base_arch} CROSS_COMPILE=%{_target_cpu}-pld-linux- \\\
1445         %endif                                                                                                                  \\\
1446 %else                                                                                                                           \\\
1447         CC="%{kgcc}"                                                                                                    \\\
1448 %endif                                                                                                                          \
1449 %define MakeOpts HOSTCC="%{kgcc}" SYSSRC=%{_kernelsrcdir} SYSOUT=$PWD/o \\\\\\\
1450                 O=$PWD/o %{?with_verbose:V=1} %{Opts}                                           \
1451                                                                                                                                         \
1452 %{?-C:cd %{-C*}}                                                                                                        \
1453 compile() {                                                                                                                     \
1454         local L="<" PATCH_SH;                                                                                   \
1455         [[ '%{*}' != *$L$L* ]] || PATCH_SH="set -x -e;$(cat)"                   \
1456         set -e -x                                                                                                               \
1457         local cfgs='%{?with_dist_kernel:%{?with_smp: smp}%{?with_up: up}}%{!?with_dist_kernel: nondist}' \
1458                                                                                                                                         \
1459 for cfg in ${cfgs:-dist}; do                                        \
1460         [ -r "%{_kernelsrcdir}/config-$cfg" ] || exit 1                                 \
1461                                                                                                                                         \
1462         rm -rf o                                                                                                                \
1463         install -d o/include/linux o/arch/powerpc/lib                                   \
1464         ln -sf %{_kernelsrcdir}/config-$cfg o/.config                                   \
1465         ln -sf %{_kernelsrcdir}/Module.symvers-$cfg o/Module.symvers    \
1466         ln -sf %{_kernelsrcdir}/include/linux/autoconf-$cfg.h o/include/linux/autoconf.h \
1467                                                                                                                                         \
1468         set +x                                                                                                                  \
1469         [ -z "$PATCH_SH" ] || echo "$PATCH_SH" | %__spec_build_shell    \
1470         set -x                                                                                                                  \
1471                                                                                                                                         \
1472         %if %{with dist_kernel} || %(test -f %{_kernelsrcdir}/scripts/bin2c ; echo $?)  \
1473                 %{__make} -j1 -C %{_kernelsrcdir} prepare scripts                       \\\
1474                         %{-p*} %{-P*}                                                                                   \\\
1475                         %{MakeOpts}                                                                                             \
1476         %else                                                                                                                   \
1477                 install -d o/include/config                                                                     \
1478                 touch o/include/config/MARKER                                                           \
1479                 ln -sf %{_kernelsrcdir}/include/config/auto-$cfg.conf o/include/config/auto.conf        \
1480                 ln -sf %{_kernelsrcdir}/scripts o/scripts                                       \
1481         %endif                                                                                                                  \
1482                                                                                                                                         \
1483         %{!?-c:%{__make} -C %{_kernelsrcdir} clean                                              \\\
1484                 RCS_FIND_IGNORE="-name '*.ko' -o"                                                       \\\
1485                 ${1+"$@"}                                                                                                       \\\
1486                 M=$PWD %{MakeOpts}}                                                                                     \
1487                                                                                                                                         \
1488         %{__make} -C %{_kernelsrcdir} modules                                                   \\\
1489                 ${1+"$@"}                                                                                                       \\\
1490                 M=$PWD %{MakeOpts}                                                                                      \
1491                                                                                                                                         \
1492         for MODULE in {%{-m*},}; do                                                                             \
1493                 [ -z "${MODULE}" ] || mv ${MODULE}{,-$cfg}.ko                           \
1494         done                                                                                                                    \
1495 done                                                                                                                            \
1496 %{?-C:cd -}                                                                                                                     \
1497 }                                                                                                                                       \
1498 compile %{*}\
1499 %{nil}
1500
1501
1502 # Install kernel modules built by %build_kernel_modules
1503 # Author: Przemyslaw Iskra <sparky@pld-linux.org>
1504 #
1505 # Usage:
1506 #       %install_kernel_modules -m <modules> -d <directory>
1507 #
1508 # Options:
1509 #  -m <modules> (required) -- comma-separated list of modules to install,
1510 #               without .ko extension, may be placed in subdirectory
1511 #  -d <directory> (required) -- in what subdirectory modules should be
1512 #               installed (eg. misc, kernel/drivers/net)
1513 #  -s <suffix> -- suffix to use when installing modules, useful when module
1514 #               with same name exists in kernel already
1515 #  -n <file> -- name of modprobe config file to use (without .conf extension)
1516 #               for defining aliases, only useful with -s
1517
1518 %install_kernel_modules(m:d:s:n:)                                                                       \
1519 %{!?-m:%{error:%{0}: Required module name (-m) missing}exit 1}          \
1520 %{!?-d:%{error:%{0}: Required module directory missing}exit 1}          \
1521 %{?-n:%{!?-s:%{error:%{0}: Modprobe .conf file requires module suffix}exit 1}} \
1522                                                                                                                                         \
1523 %define KernelD $RPM_BUILD_ROOT/lib/modules/%{_kernel_ver}                      \
1524 %define ModprobeD $RPM_BUILD_ROOT%{_sysconfdir}/modprobe.d/%{_kernel_ver} \
1525                                                                                                                                         \
1526 __install_kernel_modules() {                                                                            \
1527 local cfgs='%{?with_dist_kernel:%{?with_smp: smp}%{?with_up: up}}%{!?with_dist_kernel: nondist}' \
1528                                                                                                                                         \
1529 for MODULE in {%{-m*},}; do                                                                                     \
1530         [ -n "${MODULE}" ] || continue                                                                  \
1531         for cfg in ${cfgs:-dist}; do                                    \
1532                 [ "$cfg" = smp ] && suf=smp || suf=                                                     \
1533                 MNAME=${MODULE##*/}                                                                                     \
1534                 install -D ${MODULE}-$cfg.ko                                                            \\\
1535                         %{KernelD}$suf/%{-d*}/${MNAME}%{-s:-%{-s*}}.ko                  \
1536                 %{?-s:install -d %{ModprobeD}$suf                                                       \
1537                         echo "alias ${MNAME} ${MNAME}-%{-s*}"                                   \\\
1538                         >> %{ModprobeD}$suf/%{-n*}.conf}                                                \
1539         done                                                                                                                    \
1540 done                                                                                                                            \
1541 }                                                                                                                                       \
1542 __install_kernel_modules                                                                                        \
1543 %{nil}
1544
1545 # patchset macros
1546 # Author: Elan Ruusamäe <glen@pld-linux.org>
1547 #
1548 # Usage:
1549 #   %patchset_source -f <seq(1) format> <start> [<end>]
1550 #   %patchset_patch <start> [<end>]
1551 #
1552 # If <end> is omited, it is assumed to be <start>.
1553 #
1554 # For example in preamble:
1555 #  %patchset_source -f ftp://ftp.vim.org/pub/editors/vim/patches/7.0/7.0.%03g 33 44
1556 # and in %prep:
1557 #  %patchset_patch 33 44
1558
1559 # generate SourceX urls from range START STOP
1560 # Format can be SINGLE format char of %e, %f, %g, see seq(1)
1561 # The sources start from 10000
1562 %patchset_source(f:b:) %(
1563         base=%{-b*}%{!-b*:10000};
1564         start=$(expr $base + %1);
1565         end=$(expr $base + %{?2}%{!?2:%{1}});
1566         # we need to call seq twice as it doesn't allow two formats
1567         seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
1568         seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
1569         paste %{tmpdir}/__ps{1,2};
1570         rm -f %{tmpdir}/__ps{1,2};
1571 ) \
1572 %{nil}
1573
1574 # apply sources from %patchset_source
1575 # -p specify -pX for %patch line
1576 # -b base offset: defaults to 10000
1577 %patchset_patch(f:p:b:) %(
1578         base=%{-b*}%{!-b*:10000};
1579         start=$(expr $base + %1);
1580         end=$(expr $base + %{?2}%{!?2:%{1}});
1581         echo ": patchset_patch %1%{?2: to %2}";
1582         seq -f 'patch%g %{-p*:-p%{-p*}}' $start $end | sed -e s,^,%%,;
1583 ) \
1584 %{nil}
1585
1586 # browser plugins v2
1587 # Author: Elan Ruusamäe <glen@pld-linux.org>
1588 #
1589 # Usage:
1590 #       %browser_plugins_add_browser <name> -p <plugindir>
1591 #
1592 #  <name> (required) -- name of the browser. usually %{name}.
1593 #  -p <plugindir> (required) -- in what directory browser searches for its plugins.
1594 #  -b -- default blacklists
1595 #  -a <arch> override arch
1596 #
1597 # Example:
1598 #   %browser_plugins_add_browser %{name} -p %{_firefoxdir}/plugins
1599
1600 %_browserpluginsconfdir         /etc/browser-plugins
1601 %_browserpluginsdir                     %{_libdir}/browser-plugins
1602 %update_browser_plugins         /usr/sbin/update-browser-plugins || :
1603
1604 %browser_plugins_add_browser(p:b:a:) \
1605         browser=%1.%{!-a:%{_target_base_arch}}%{-a*} \
1606         install -d $RPM_BUILD_ROOT%{_browserpluginsconfdir}/{blacklist,browsers}.d \
1607         ln -s %{-p*} $RPM_BUILD_ROOT%{_browserpluginsconfdir}/browsers.d/$browser \
1608         blacklist_file=$RPM_BUILD_ROOT%{_browserpluginsconfdir}/blacklist.d/$browser.blacklist \
1609         echo '# This file format is shell globs at base dir of plugindir' > $blacklist_file \
1610         %{-b:cat >> $blacklist_file %{-b*}} \
1611 %{nil}
1612
1613 # Helper for LUA.
1614 # split string separated by space into quoted list
1615 #
1616 # Author: Elan Ruusamäe <glen@pld-linux.org>
1617 #
1618 # %__lua_split /bin/sh /bin/pdksh -> "/bin/sh", "/bin/pdksh"
1619 %__lua_split() %(echo "%*" | awk '{for (i=1;i<=NF;i++) printf("\\"%%s\\"%%s", $i, i == NF ? "" : ", ")}')
1620
1621 # adjust /etc/shells by adding and removing shells from there
1622 # Author: Elan Ruusamäe <glen@pld-linux.org>
1623 #
1624 # Usage:
1625 #   %post       -p <lua>
1626 #   %lua_add_etc_shells /bin/sh /bin/pdksh
1627 #
1628 #   %preun      -p <lua>
1629 #   if arg[2] == 0 then
1630 #       %lua_remove_etc_shells /bin/bash /bin/rbash
1631 #   end
1632 #
1633 # Requirements:
1634 # BuildRequires:        rpmbuild(macros) >= 1.462
1635 #
1636
1637 %lua_add_etc_shells() \
1638 t = {}\
1639 f = io.open("/etc/shells", "r")\
1640 if f then\
1641         for l in f:lines() do t[l]=l; end\
1642         f:close()\
1643 end\
1644 for _, s in ipairs({%{expand:%%__lua_split %*}}) do\
1645         if not t[s] then\
1646                 print("Adding "..s.." to /etc/shells")\
1647                 f = io.open("/etc/shells", "a"); f:write(s.."\\n"); f:close()\
1648         end\
1649 end\
1650 %{nil}
1651
1652 %lua_remove_etc_shells() \
1653 t = {}\
1654 f = io.open("/etc/shells", "r")\
1655 if f then\
1656         for l in f:lines() do t[l]=l; end\
1657         f:close()\
1658 end\
1659 for _, l in pairs({%{expand:%%__lua_split %*}}) do\
1660         print("Removing "..l.." from /etc/shells")\
1661         t[l] = nil\
1662 end\
1663 s=""\
1664 for _, l in pairs(t) do\
1665         s=s..l.."\\n"\
1666 end\
1667 io.open("/etc/shells", "w"):write(s)\
1668 %{nil}
1669
1670 # Backwards compat. Use of %lua_ prefixed macros is preferred as these are cleaner to read.
1671 #
1672 # Author: Elan Ruusamäe <glen@pld-linux.org>
1673 #
1674 # Usage:
1675 #   %post       -p %add_etc_shells -p /bin/sh /bin/pdksh
1676 #   %preun      -p %remove_etc_shells -p /bin/sh /bin/pdksh
1677 #
1678 #  -p (optional) -- specifies that result is embeded %post script (prepends <lua> as first line)
1679 #
1680 # Requirements:
1681 # BuildRequires:        rpmbuild(macros) >= 1.429
1682 #
1683 %add_etc_shells(p) %{-p:<lua>}\
1684 %{expand:%%lua_add_etc_shells %*}\
1685 %{nil}
1686
1687 %remove_etc_shells(p) %{-p:<lua>}\
1688 %{-p:if arg[2] == 0 then}\
1689 %{expand:%%lua_remove_etc_shells %*}\
1690 %{-p:end} \
1691 %{nil}
1692
1693 # Check syntax for Python files
1694 #
1695 # Author: Elan Ruusamäe <glen@pld-linux.org>
1696 # Author: Arkadiusz Miśkiewicz <arekm@pld-linux.org>
1697 #
1698 # Usage:
1699 #   %py_lint src
1700 #
1701 # Requirements:
1702 # BuildRequires:        python
1703 # BuildRequires:        rpmbuild(macros) >= 1.469
1704
1705 %py_lint() \
1706 __py_lint() { \
1707 find "$@" -type f -name '*.py' | python -c ' \
1708 import sys \
1709 import compiler \
1710 \
1711 err = 0\
1712 for f in sys.stdin: \
1713         fd = open(f.strip()) \
1714         c = fd.read() \
1715         fd.close() \
1716         try: \
1717                 compiler.parse(c) \
1718         except SyntaxError, e: \
1719                 print "py_lint: %s: %s" % (f.strip(), e) \
1720                 err = err + 1\
1721 \
1722 if err: \
1723         print >> sys.stderr, "\\npy_lint: ERROR: Syntax errors in %d files.\\n" % err \
1724         sys.exit(1) \
1725 else: \
1726         print >> sys.stderr,  "py_lint: Found no syntax errors." \
1727 ' \
1728 }; __py_lint %* \
1729 %{nil}
1730
1731 # Undos files
1732 #
1733 # Author: Paweł Zuzelski <pawelz@pld-linux.org>
1734 #
1735 # Usage:
1736 #   %undos list_of_files
1737 #
1738 # Requirements:
1739 # BuildRequires:        sed >= 4.0
1740 # BuildRequires:        rpmbuild(macros) >= 1.533
1741
1742 %undos \
1743 %{__sed} -i -e 's,\\r$,,'
1744
1745 # vim:ts=4 sw=4 noet ft=spec
This page took 0.745542 seconds and 4 git commands to generate.