]> git.pld-linux.org Git - packages/rpm-build-macros.git/blob - rpm.macros
- removed quotes from %%{x8664}.
[packages/rpm-build-macros.git] / rpm.macros
1 # PLD rpm macros
2
3 # other macros
4 %epoch          0
5 %_enable_debug_packages 1
6
7 %__id           @__ID@
8 %__id_u         %{__id} -u 
9 %__chown_Rhf           @__CHOWN_RHF@
10 %__chgrp_Rhf           @__CHGRP_RHF@
11
12 %_fixowner       [ `%{__id_u}` = '0' ] && %{__chown_Rhf} root:@ROOT_GROUP@
13 %_fixgroup       true
14 %_fixperms       %{__chmod} -Rf @FIXPERMS@
15 %_topdir         %(echo $HOME)/rpm
16 #-----------------------------------------------------------------
17 # CFLAGS and LDFLAGS used to build
18
19 %debuginfocflags        %{expand:%%define __dic_%{?_enable_debug_packages} 1}%{?__dic_1: -ggdb}%{expand:%%undefine __dic_%{?_enable_debug_packages}}
20
21 %debugcflags    -O0 -g -Wall
22 %rpmcflags      %{?debug:%debugcflags}%{!?debug:%optflags}%{?debuginfocflags}
23 %rpmcxxflags    %{rpmcflags}
24 # -fvisibility-inlines-hidden disabled. see gcc/PR(19664,20218) for details.
25 # %rpmcxxflags  %{rpmcflags} -fvisibility-inlines-hidden
26 %rpmldflags     %{nil}
27 # %rpmldflags   -Wl,--as-needed
28
29 # kernel compiler
30 %kgcc           gcc
31 %kgcc_package   gcc
32
33 # Build system path macros.
34 #
35 %__autoconf                     autoconf %{?debug:-Wall}
36 %__automake                     automake -a -c -f --foreign
37 %__autopoint            autopoint --force
38
39 %__gettextize { \
40     if ! gettextize --version | grep -q '0\.10\.' ; then \
41         if grep -qs 'AM_GNU_GETTEXT.*external' configure.{ac,in} ; then \
42             gettextize --copy --force --no-changelog; \
43         else \
44             gettextize --copy --force --no-changelog --intl; \
45         fi; \
46         if [ ! -f po/Makevars ]; then \
47             cp -f po/Makevars{.template,}; \
48         fi; \
49     else \
50         gettextize --copy --force; \
51     fi; \
52 }
53
54 %__glib_gettextize      glib-gettextize --copy --force
55 %__gnome_doc_common     gnome-doc-common --copy
56 %__gtkdocize            gtkdocize --copy
57 %__intltoolize          intltoolize --copy --force
58 %__libtoolize           libtoolize --copy --force
59
60 %dependencytracking     %{nil}
61 #-----------------------------------------------------------------
62 %configure2_13 { \
63  if [ -n "$LINGUAS" ]; then unset LINGUAS; fi; \
64  LDFLAGS="${LDFLAGS:-%rpmldflags}" ; export LDFLAGS ; \
65  CFLAGS="${CFLAGS:-%rpmcflags}" ; export CFLAGS ; \
66  CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" ; export CXXFLAGS ; \
67  FFLAGS="${FFLAGS:-%rpmcflags}" ; export FFLAGS ; \
68  CPPFLAGS="${CPPFLAGS:-}" ; export CPPFLAGS ; \
69  %{?__cc:CC="%{__cc}" ; export CC ; } \
70  %{?__cxx:CXX="%{__cxx}" ; export CXX ; } \
71  %{?configuredir:%{configuredir}}%{!?configuredir:.}/configure \
72         --host=%{_target_platform} \
73         --prefix=%{_prefix} \
74         --exec-prefix=%{_exec_prefix} \
75         --bindir=%{_bindir} \
76         --sbindir=%{_sbindir} \
77         --sysconfdir=%{_sysconfdir} \
78         --datadir=%{_datadir} \
79         --includedir=%{_includedir} \
80         --libdir=%{_libdir} \
81         --libexecdir=%{_libexecdir} \
82         --localstatedir=%{_localstatedir} \
83         --sharedstatedir=%{_sharedstatedir} \
84         --mandir=%{_mandir} \
85         --infodir=%{_infodir} \
86         --x-libraries=/usr/X11R6/%{_lib} \
87         %{dependencytracking} \
88 }
89
90 #----------------------------------------------------------------
91 %configure {./configure \
92         LDFLAGS="${LDFLAGS:-%rpmldflags}" \
93         CFLAGS="${CFLAGS:-%rpmcflags}" \
94         CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" \
95         FFLAGS="${FFLAGS:-%rpmcflags}" \
96         CPPFLAGS="${CPPFLAGS:-}" \
97         %{?__cc:CC="%{__cc}"} \
98         %{?__cxx:CXX="%{__cxx}"} \
99         --build=%{_target_platform} \
100         --prefix=%{_prefix} \
101         --exec-prefix=%{_exec_prefix} \
102         --bindir=%{_bindir} \
103         --sbindir=%{_sbindir} \
104         --sysconfdir=%{_sysconfdir} \
105         --datadir=%{_datadir} \
106         --includedir=%{_includedir} \
107         --libdir=%{_libdir} \
108         --libexecdir=%{_libexecdir} \
109         --localstatedir=%{_localstatedir} \
110         --sharedstatedir=%{_sharedstatedir} \
111         --mandir=%{_mandir} \
112         --infodir=%{_infodir} \
113         --x-libraries=/usr/X11R6/%{_lib} \
114         %{dependencytracking} \
115 }
116
117 # ------------------------------------------------------------------------
118 # Overloading of some basic macros
119 %prep \
120 %%prep\
121 LANG=C\
122 export LANG\
123 unset DISPLAY ||:\
124 unset LINGUAS ||:\
125 %{nil}
126
127 %build %%build\
128 LANG=C\
129 export LANG\
130 unset DISPLAY ||:\
131 unset LINGUAS ||:\
132 %{nil}
133
134 %install %{?_enable_debug_packages:%{?buildsubdir:%{debug_package}}}\
135 %%install\
136 LANG=C\
137 export LANG\
138 unset DISPLAY ||:\
139 unset LINGUAS ||:\
140 %{nil}
141
142 # ------------------------------------------------------------------------
143 # Conditional build stuff.
144
145 # Check if symbol is defined.
146 # Example usage: %if %{defined with_foo} && %{undefined with_bar} ...
147 %defined()      %{expand:%%{?%{1}:1}%%{!?%{1}:0}}
148 %undefined()    %{expand:%%{?%{1}:0}%%{!?%{1}:1}}
149
150 # Shorthand for %{defined with_...}
151 %with()         %{expand:%%{?with_%{1}:1}%%{!?with_%{1}:0}}
152 %without()      %{expand:%%{?with_%{1}:0}%%{!?with_%{1}:1}}
153
154 # Handle conditional builds. %bcond_with is for case when feature is
155 # default off and needs to be activated with --with ... command line 
156 # switch. %bcond_without is for the dual case.
157 #
158 # %bcond_with foo defines symbol with_foo if --with foo was specified on
159 # command line.
160 # %bcond_without foo defines symbol with_foo if --without foo was *not* 
161 # specified on command line.
162 #
163 # For example:
164 #
165 # %bcond_with extra_fonts
166 # %bcond_without static
167 # %if %{with extra_fonts}
168 # ...
169 # %endif
170 # %ifdef %{with static}
171 # ...
172 # %endif
173 # %{?with_static: ... }
174 # %{!?with_static: ... }
175 # %{?with_extra_fonts: ... }
176 # %{!?with_extra_fonts: ... }
177
178 # The bottom line: never use without_foo, _with_foo nor _without_foo, only
179 # with_foo. This way changing default set of bconds for given spec is just
180 # a matter of changing single line in it and syntax is more readable.
181 %bcond_with()           %{expand:%%{?_with_%{1}:%%global with_%{1} 1}}
182 %bcond_without()        %{expand:%%{!?_without_%{1}:%%global with_%{1} 1}}
183 # ------------------------------------------------------------------------
184
185 # Location of autoconf macros
186 %_aclocaldir    %(aclocal --print-ac-dir)
187
188 # Location of omf files
189 %_omf_dest_dir  %(scrollkeeper-config --omfdir)
190
191 # Location of pkgconfig files
192 %_pkgconfigdir  /usr/%{_lib}/pkgconfig
193
194 # Location of desktop files
195 %_desktopdir    /usr/share/applications
196 %_applnkdir     ERROR:_applnkdir_is_obsolete_use_desktopdir_instead
197
198 # Location of pixmaps for applnk/desktop files
199 %_pixmapsdir    /usr/share/pixmaps
200
201 # Location of themable icons for applnk/desktop files
202 %_iconsdir      /usr/share/icons
203
204 # Location of fonts directories
205 %_fontsdir      /usr/share/fonts
206
207 # Location of Gtk and associated libraries documentation
208 %_gtkdocdir  %{_defaultdocdir}/gtk-doc/html
209
210 # Location of KDE documentation
211 %_kdedocdir  %{_defaultdocdir}/kde/HTML
212
213 # unsermake script
214 %__unsermake /usr/share/unsermake/unsermake
215
216 # Current date
217 %date           %(LC_ALL="C" date +"%a %b %d %Y")
218
219 # tmp directory
220 %tmpdir         %(echo "${TMPDIR:-/tmp}")
221
222 # Example files, programs, scripts...
223 %_examplesdir   /usr/src/examples
224
225 # The directory holding Linux kernel sources
226 %_kernelsrcdir  /usr/src/linux
227
228 # If non-empty "debug" macro defined, add "dbg" suffix to release number
229 %_rpmfilename           %%{NAME}-%%{VERSION}-%%{RELEASE}%{?debug:dbg}.%%{ARCH}.rpm
230
231 # Requires name = version-release
232 %requires_releq()               %(LC_ALL="C" echo '%*' | xargs -r rpm -q --qf 'Requires: %%{name} = %%{epoch}:%%{version}-%%{release}\\n' | sed -e 's/ (none):/ /' | grep -v "is not")
233
234 %releq_kernel_up()              %(LC_ALL="C" rpm -qf --qf 'kernel-up = %%{epoch}:%%{version}-%%{release}\\n' %{_kernelsrcdir}/include/linux/version.h | sed -e 's/ (none):/ /' | grep -vE "(is not|no such)")
235 %releq_kernel_smp()             %(LC_ALL="C" rpm -qf --qf 'kernel-smp = %%{epoch}:%%{version}-%%{release}\\n' %{_kernelsrcdir}/include/linux/version.h | sed -e 's/ (none):/ /' | grep -vE "(is not|no such)")
236 %requires_releq_kernel_up()     %(LC_ALL="C" rpm -qf --qf 'PreReq: kernel-up = %%{epoch}:%%{version}-%%{release}\\n' %{_kernelsrcdir}/include/linux/version.h | sed -e 's/ (none):/ /' | grep -vE "(is not|no such)")
237 %requires_releq_kernel_smp()    %(LC_ALL="C" rpm -qf --qf 'PreReq: kernel-smp = %%{epoch}:%%{version}-%%{release}\\n' %{_kernelsrcdir}/include/linux/version.h | sed -e 's/ (none):/ /' | grep -vE "(is not|no such)")
238
239 %requires_eq_to() %(LC_ALL="C" rpm -q --qf 'Requires: %1 = %%{epoch}:%%{version}\\n' %2 | sed -e 's/ (none):/ /' | grep -v "is not")
240
241 %apache_modules_api %(awk '/#define MODULE_MAGIC_NUMBER_MAJOR/ {print $3}' /usr/include/apache/ap_mmn.h 2>/dev/null || echo ERROR)
242
243 # kernel version-release handling
244 %__kernel_ver    %([ -f %{_kernelsrcdir}/include/linux/version.h ] && (grep UTS_RELEASE %{_kernelsrcdir}/include/linux/version.h 2>/dev/null | head -n 1 | cut -d'"' -f2) || (awk '/^VERSION/ { ver = $0; gsub(/VERSION.*=/, NIL, ver); } /^PATCHLEVEL/ { plev = $0; gsub(/PATCHLEVEL.*=/, NIL, plev); } /^SUBLEVEL/ { slev = $0; gsub(/SUBLEVEL.*=/, NIL, slev); } /^EXTRAVERSION/ { ever = $0; gsub(/EXTRAVERSION.*=/, NIL, ever); gsub(/ /, NIL, ever); } END { printf("%d.%d.%d%s", ver, plev, slev, ever); }' %{_kernelsrcdir}/Makefile 2> /dev/null))
245 %__kernel_rel    %(LC_ALL="C" rpm -qf %{_kernelsrcdir}/include/linux/fs.h --queryformat "%{RELEASE}" | grep -v "is not")
246 %__kernel_rpmvr  %(LC_ALL="C" rpm -qf %{_kernelsrcdir}/include/linux/fs.h --queryformat "%{VERSION}-%{RELEASE}" | grep -v "is not")
247 %_kernel_ver     %{__kernel_ver}%{?with_dist_kernel:%(echo %{__kernel_ver} | grep -q -e - || echo -%{__kernel_rel})}
248 %_kernel_ver_str %(echo %{!?_without_dist_kernel:%{__kernel_rpmvr}}%{?_without_dist_kernel:%{__kernel_ver}} | sed -e 's/-/_/g')
249
250 # sgml macros
251 %xmlcat_add()            /usr/bin/xmlcatalog --noout --add nextCatalog \"\" %1 /etc/xml/catalog ;
252 %xmlcat_del()            /usr/bin/xmlcatalog --noout --del %1 /etc/xml/catalog ;
253 %xmlcat_add_rewrite      /usr/bin/xmlcatalog --noout --add rewriteSystem
254 %xmlcat_create()          /usr/bin/xmlcatalog --noout --create %1 ;
255 %sgmlcat_add()           /usr/bin/install-catalog --add %1 %2 > /dev/null ;
256 %sgmlcat_del()           /usr/bin/install-catalog --remove %1 %2 > /dev/null ;
257 %docbook_sgmlcat_fix() { for l in \
258 '' \
259 '  -- default decl --' \
260 'DTDDECL "-//OASIS//DTD DocBook XML V%2//EN" "../../xml.dcl"' \
261 '  -- hacks for opensp --' \
262 'SYSTEM "file://%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
263 'SYSTEM "http://www.oasis-open.org/docbook/xml/%2/docbookx.dtd"                  "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
264 '' \
265 ; do echo $l; done >> %1 \
266 }
267
268 #-----------------------------------------------------------------
269 # find and gzip all files in %{_mandir} and %{infodir}
270 #
271 # Requires: xargs, find
272 #
273 #%no_install_post_compress_docs 1
274 %__spec_install_post_compress_docs { \
275 %{!?no_install_post_compress_docs: \
276         echo "Compress man and info pages."; \
277         %{?verbose:set -x;} \
278         for i in /usr/share/man /usr/X11R6/man /usr/share/info; do \
279                 if [ -d "$RPM_BUILD_ROOT$i" ]; then \
280                         find "$RPM_BUILD_ROOT$i" -name \*.bz2 -print | xargs -r %{__bzip2} -df; \
281                         find "$RPM_BUILD_ROOT$i" -name \*.gz -print | xargs -r %{__gzip} -dnf; \
282                         find "$RPM_BUILD_ROOT$i" -type f -print | xargs -r %{__gzip} -9nf; \
283                 fi; \
284         done; \
285 } }
286
287 #-----------------------------------------------------------------
288 # Strip executable binaries and shared object files
289 #
290 # Requires: find, awk, strip, cut, xargs
291 #
292 #%no_install_post_strip 1
293 %__spec_install_post_strip {%{!?debug: \
294 %{!?no_install_post_strip: \
295     %{?verbose:set -x;} \
296     if [ -d "$RPM_BUILD_ROOT" ]; then \
297         echo "Strip executable binaries, archives and shared object files."; \
298         filelist=`find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*" %{?_noautostrip:! -regex "%{_noautostrip}"}`; \
299         elfexelist=`echo $filelist | xargs -r file | \
300                 awk '/ELF.*executable/ {print $1}' | cut -d: -f1`; \
301         elfsharedlist=`echo $filelist | xargs -r file | \
302                 awk '/LF.*shared object/ {print $1}' | cut -d: -f1`; \
303         elfarchiveslist=`echo $filelist | xargs -r file | \
304                 awk '/current ar archive/ {print $1}' | cut -d: -f1`; \
305         if [ -n "$elfexelist" ]; then \
306                 %{__strip} --remove-section=.note  --remove-section=.comment $elfexelist; \
307         fi; \
308         if [ -n "$elfsharedlist" ]; then \
309                 %{__strip} --strip-unneeded --remove-section=.note  --remove-section=.comment $elfsharedlist; \
310         fi; \
311         if [ -n "$elfarchiveslist" ]; then \
312                 %{__strip} --strip-debug --remove-section=.note  --remove-section=.comment $elfarchiveslist; \
313         fi; \
314     fi; } \
315 } }
316 #-----------------------------------------------------------------
317 # remove all RPATH from executable binaries and shared object files
318 #
319 # Requires: find, awk, cut, xargs, chrpath, uname
320 #
321 #%no_install_post_chrpath       1
322 %__spec_install_post_chrpath {%{!?debug: \
323 %{!?no_install_post_chrpath: \
324         %{?verbose:set -x;} \
325 if [ -d "$RPM_BUILD_ROOT" ]; then \
326 echo "Remove RPATH from executable binaries and shared object files."; \
327 find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*" ! -regex ".*/usr/lib[0-9]*/debug/.*" %{?_noautochrpath:! -regex "%{_noautochrpath}"} | xargs -r file | \
328         awk '/ELF.*(executable.*dynamically linked|shared object)/ {print $1}' | cut -d: -f1 | \
329 while read file ; do \
330         rpath= ; \
331         chmod u+w "$file"; \
332         for dir in `chrpath -l "$file" | \
333                     awk '/RPATH=/ { gsub(/.*RPATH=/,""); gsub(/:/," "); print $0 }'` ; do \
334                         case $dir in \
335                         /home/* | /tmp/* | /usr/lib | /usr/lib64 | /lib | /lib64 | /usr/local/lib | /usr/local/lib64 | /usr/X11R6/lib | /usr/X11R6/lib64 ) \
336                                 echo "remove-rpath: $dir in $file"; \
337                                 ;; \
338                         * ) \
339                                 if [ "$rpath" = "" ] ; then rpath="$dir" ; \
340                                 else rpath="$rpath:$dir" ; fi ; \
341                                 ;; \
342                         esac ; \
343         done ; \
344         if [ "$rpath" = "" ] ; then chrpath -d "$file" > /dev/null ; \
345         else chrpath -r "$rpath" "$file" > /dev/null ; fi ; \
346 done; \
347 fi; } \
348 } }
349 #-----------------------------------------------------------------
350 # Find and gzip all kernel modules
351 #
352 # Requires: find
353 #
354 #%no_install_post_compress_modules  1
355 %__spec_install_post_compress_modules { \
356 %{!?no_install_post_compress_modules: \
357     %{?verbose:set -x;} \
358     if [ -d "$RPM_BUILD_ROOT" ]; then \
359 echo "Compress kernel modules if any."; \
360     if test -d $RPM_BUILD_ROOT/lib/modules ; then \
361         find $RPM_BUILD_ROOT/lib/modules -name \*o -type f -print | \
362         xargs -r %{__gzip} -9nf; \
363            find $RPM_BUILD_ROOT/lib/modules -name \*o -type l -printf "%p %l\n" | \
364            while read a b; do ln -sf $b.gz $a.gz; rm -f $a; done; \
365     fi; \
366     fi; \
367 } }
368
369 %_source_payload        w9.gzdio
370 %_binary_payload        w9.bzdio
371
372 #-----------------------------------------------------------------
373 # Update GConf2 schemas
374 #
375 # Requires: GConf2
376 #
377 %gconf_schema_install() \
378     umask 022; \
379     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 \
380     %{nil}
381
382 %gconf_schema_uninstall() \
383 if [ $1 = 0 ]; then \
384     umask 022; \
385     GCONF_CONFIG_SOURCE="xml:readwrite:/etc/gconf/gconf.xml.defaults" /usr/bin/gconftool-2 --makefile-uninstall-rule /etc/gconf/schemas/%{?1} > /dev/null \
386 fi \
387 %{nil}
388
389 #-----------------------------------------------------------------
390 # Update desktop MIME database
391 # requries: desktop-file-utils
392 #
393 %update_desktop_database_post() {{\
394         umask 022; \
395         /usr/bin/update-desktop-database; \
396 }}
397
398 %update_desktop_database_postun() {{\
399 if [ $1 = 0 ]; then \
400         umask 022; \
401         /usr/bin/update-desktop-database; \
402 fi \
403 }}
404
405 #-----------------------------------------------------------------
406 # Update scrollkeeper database
407 # requires: scrollkeeper
408 #
409 %scrollkeeper_update_post() \
410         /usr/bin/scrollkeeper-update -q; \
411         %{nil}
412
413 %scrollkeeper_update_postun() \
414 if [ $1 = 0 ]; then \
415         /usr/bin/scrollkeeper-update -q; \
416 fi \
417 %{nil}
418
419 #-----------------------------------------------------------------
420 # Run ldconfig after installing/deinstalling libraries
421 #
422 %ldconfig_post() \
423         /sbin/ldconfig; \
424         %{nil}
425
426 %ldconfig_postun() \
427         /sbin/ldconfig; \
428         %{nil}
429
430 #-----------------------------------------------------------------
431 # post %install sequence:
432 # - autodeps exceptions
433 # - compress all man and info pages,
434 # - strip all ELF executables and ELF shared objects if not %debug.
435 # - compress kernel modules if any
436
437 ###################################################################
438 # Requires/Provides automation
439 # exceptions system by Jacek Konieczny <jajcus@pld.org.pl>
440 #
441 %__noautoreqfiles       %(sed -e s'/#.*//' /etc/rpm/noautoreqfiles)%{?_noautoreqfiles: %{_noautoreqfiles}}
442 %__noautoprovfiles      %(sed -e s'/#.*//' /etc/rpm/noautoprovfiles)%{?_noautoprovfiles: %{_noautoprovfiles}}
443 %__noautoreq            %(sed -e s'/#.*//' /etc/rpm/noautoreq)%{?_noautoreq: %{_noautoreq}}
444 %__noautoreqdep         %(sed -e s'/#.*//' /etc/rpm/noautoreqdep)%{?_noautoreqdep: %{_noautoreqdep}}
445 %__noautoprov           %(sed -e s'/#.*//' /etc/rpm/noautoprov)%{?_noautoprov: %{_noautoprov}}
446 #%_noautocompressdoc    %{nil}
447 #
448 %_missing_doc_files_terminate_build     1%{nil}
449 %_unpackaged_files_terminate_build      %{nil}
450 # (X)emacs support
451 %___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;}'
452 %_emacs_lispdir %(emacs %___emacs_lispdir_helper)
453 %_xemacs_lispdir %(xemacs %___emacs_lispdir_helper)
454
455 %__php_provides %{nil}
456 %__php_requires %{nil}
457 %__perl_provides %{nil}
458 %__perl_requires %{nil}
459
460 # Perl specific macro definitions.
461 %perl_privlib   %(eval "`%{__perl} -V:installprivlib`"; echo $installprivlib)
462 %perl_archlib   %(eval "`%{__perl} -V:installarchlib`"; echo $installarchlib)
463 %perl_vendorlib %(eval "`%{__perl} -V:installvendorlib`"; echo $installvendorlib)
464 %perl_vendorarch        %(eval "`%{__perl} -V:installvendorarch`"; echo $installvendorarch)
465 %perl_sitelib   %(eval "`%{__perl} -V:installsitelib`"; echo $installsitelib)
466 %perl_sitearch  %(eval "`%{__perl} -V:installsitearch`"; echo $installsitearch)
467
468 %php_pear_dir   %{_datadir}/pear
469
470 # Python specific macro definitions.
471 # python main version
472 %py_ver         %(echo `python -c "import sys; print sys.version[:3]"`)
473
474 # directories
475 %py_prefix      %(echo `python -c "import sys; print sys.prefix"`)
476 %py_libdir      %{py_prefix}/%{_lib}/python%{py_ver}
477 %py_scriptdir   %{py_prefix}/share/python%{py_ver}
478 %py_incdir      /usr/include/python%{py_ver}
479 %py_sitedir     %{py_libdir}/site-packages
480 %py_sitescriptdir %{py_scriptdir}/site-packages
481 %py_dyndir      %{py_libdir}/lib-dynload
482
483 # pure python modules compilation
484 %py_comp        python -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
485
486 %py_ocomp       python -O -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
487
488 # Software written in Python language require Python with main version
489 %pyrequires_eq() Requires:      %1
490
491
492 # Hardlink binary identical .pyc and .pyo files
493 # (idea by glen <at> pld-linux <dot> org)
494 %__spec_install_post_py_hardlink {\
495 %{!?no_install_post_py_hardlink: \
496 [ ! -d "$RPM_BUILD_ROOT" ] || find "$RPM_BUILD_ROOT" -name '*.pyc' | while read a; do \
497         b="$(echo $a|sed -e 's/.pyc$/.pyo/')"; \
498         if cmp -s "$a" "$b"; then \
499                 ln -f "$a" "$b"; \
500         fi; \
501 done \
502 } }
503
504 # remove python sources, so that check-files won't complain
505 # (idea by glen <at> pld-linux <dot> org)
506 %py_postclean() \
507 for d in %{py_sitescriptdir} %{py_sitedir}; do \
508  [ ! -d "$RPM_BUILD_ROOT$d" ] || find "$RPM_BUILD_ROOT$d" -name '*.py' -exec rm {} \; ;\
509 done \
510 %{nil}
511
512 # depmod macro
513 %depmod() { \
514 umask 022; \
515 if [ -e /boot/System.map-%1 ]; then \
516         /sbin/depmod -a -F /boot/System.map-%1 %1; \
517 else \
518         if [ -e /boot/System.map ]; then \
519                 /sbin/depmod -a -F /boot/System.map %1; \
520         else \
521                 /sbin/depmod -a %1; \
522         fi \
523 fi; \
524 }
525
526 # XMMS specific macros
527 %xmms_prefix                  %(xmms-config --prefix)
528 %xmms_exec_prefix             %(xmms-config --exec-prefix)
529 %xmms_version                 %(xmms-config --version)
530 %xmms_datadir                 %(xmms-config --data-dir)
531 %xmms_plugindir               %(xmms-config --plugin-dir)
532 %xmms_visualization_plugindir %(xmms-config --visualization-plugin-dir)
533 %xmms_input_plugindir         %(xmms-config --input-plugin-dir)
534 %xmms_output_plugindir        %(xmms-config --output-plugin-dir)
535 %xmms_effect_plugindir        %(xmms-config --effect-plugin-dir)
536 %xmms_general_plugindir       %(xmms-config --general-plugin-dir)
537
538 %_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/')
539
540 %x8664                  x86_64 amd64 ia32e
541
542 # user/group checking macros
543 #
544 # Usage:
545 #       %userremove myuser
546 #
547 %userremove     /usr/lib/rpm/user_group.sh user del
548 %groupremove    /usr/lib/rpm/user_group.sh group del
549 #
550 # Usage:
551 #       if %usertestrm myuser; then
552 #               /usr/sbin/userdel -r myuser
553 # Note:
554 #       use these macros only if you need to call userdel/groupdel with
555 #       a non-standard option or take an extra action; otherwise use the
556 #       %userremove/%groupremove macros
557 #
558 %usertestrm     /usr/lib/rpm/user_group.sh user testrm
559 %grouptestrm    /usr/lib/rpm/user_group.sh group testrm
560 # user group membership management macros
561 #
562 # Usage:
563 #       %addusertogroup myuser agroup
564 #
565 %addusertogroup /usr/lib/rpm/user_group.sh user addtogroup
566
567 # banner support (useful in {pre,post}{,un} and triggers)
568 #
569 # Usage:
570 #       %banner name [-a] [-e] [-n] [-tn] <<EOF
571 # the banner text, the banner text
572 # the banner text, and following line
573 #EOF
574 # You can use any form of here-document, <<'EOF' <<-EOT will do.
575 # NOTE: if your use "<<-EOF", then You can actually indent inside here-document.
576 #
577 # -a   - append to the banner
578 # -e   - send to stderr instead of stdout
579 # -n   - no show banner (overrides -t)
580 # -t   - show only, if RPM_SCRIPTVERBOSITY >= n; default n=5
581 %banner(aent:)  \
582 RPM_SCRIPTVERBOSITY=5 \
583 [ -r /etc/sysconfig/rpm ] && . /etc/sysconfig/rpm \
584 if [ -x /usr/bin/banner.sh ]; then \
585         CMD="/usr/bin/banner.sh %{-e:--stderr} %{!-n:$([ $RPM_SCRIPTVERBOSITY -ge %{-t:%{-t*}}%{!-t:5} ] && echo -s)} %{!-a:-m}%{-a:-M} %1" \
586 else \
587         CMD="cat%{-e: >&2}" \
588 fi \
589 $CMD %2%{?3: %3} \
590 %nil
591
592 # useradd/groupadd macros written by glen@pld-linux.org.
593 # All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
594 #
595 # Usage:
596 #   %useradd [-P package] [-u uid] [-d home_dir] [-s shell] [-c comment]
597 #   [-g initial_group] [-G group[,...]] login
598 #
599 #  -u uid. REQUIRED
600 #  -g gid/group. REQUIRED
601 #  -s defaults to /bin/false
602 #  -d defaults to /usr/share/empty
603 #  -c No default
604 #  -r is accepted but ignored (it's always set)
605 # rpm specific flags
606 #  -P package name. defaults to %{name}
607 #
608 %useradd(c:d:e:f:g:G:Mmk:op:s:u:rP:) \
609 %{!-u:%{error:useradd: Required argument -u missing}} \
610 %{!-g:%{error:useradd: Required argument -g missing}} \
611 %{!?1:%{error:useradd: Required parameter login missing}} \
612 if [ -n "`/bin/id -u %{expand:%{%{#}}} 2>/dev/null`" ]; then \
613         if [ "`/bin/id -u %{expand:%{%{#}}}`" != "%{-u*}" ]; then \
614                 echo "Error: user %{expand:%{%{#}}} doesn't have uid=%{-u*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
615                 exit 1 \
616         fi \
617 else \
618         echo "Adding user %{expand:%{%{#}}} UID=%{-u*}." \
619         /usr/sbin/useradd \\\
620                 -u %{-u*} \\\
621                 -r \\\
622                 -d %{-d*}%{!-d:/usr/share/empty} \\\
623                 -s %{-s*}%{!-s:/bin/false} \\\
624                 %{-c:-c "%(set -- %{-c*} %{*}; echo $1)"}\\\
625                 -g %{-g*} \\\
626                 %{-M} \\\
627                 %{-G:-G %{-G*}} \\\
628                 %{expand:%{%{#}}} 1>&2 \
629 fi;
630
631 # Usage:
632 #   %groupadd [-P package] [-g gid] group
633 #
634 # -g gid. REQUIRED
635 #
636 # Sample:
637 #   %groupadd -P %{name}-base -g %{gid} %{name}
638
639 %groupadd(g:P:rfo)      \
640 %{!-g:%{error:groupadd: Required argument -g missing}} \
641 %{!?1:%{error:groupadd: Required parameter group missing}} \
642 if [ -n "`/usr/bin/getgid %{1}`" ]; then \
643         if [ "`/usr/bin/getgid %{1}`" != "%{-g*}" ]; then \
644                 echo "Error: group %{1} doesn't have gid=%{-g*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
645                 exit 1 \
646         fi \
647 else \
648         echo "Adding group %{1} GID=%{-g*}." \
649         /usr/sbin/groupadd -g %{-g*} -r %{1} 1>&2 \
650 fi;
This page took 0.252687 seconds and 4 git commands to generate.