]> git.pld-linux.org Git - packages/rpm-pld-macros.git/blob - macros.pld
extract %_kernel_arch macro; 2.030
[packages/rpm-pld-macros.git] / macros.pld
1 # vim:ts=4 sw=4 noet ft=spec
2 #
3 # PLD Linux rpm macros.
4 # <http://www.pld-linux.org/>
5
6 %distribution   PLD Linux
7 %vendor         pld
8 %bugurl         http://bugs.pld-linux.org/
9 %disturl        http://www.pld-linux.org/
10 %pld_release    th
11 %disttag        %{pld_release}
12
13 # can be used by builder script to check for version
14 %rpm_build_macros       {Revision}
15
16 %epoch          0
17
18 #==============================================================================
19 # ---- configure macros.  note that most of these are inherited
20 #      from the defaults.
21 #
22 %_sharedstatedir        /var/lib
23 %_localstatedir         /var
24 %_localedir                     %{_datadir}/locale
25 %_lispdir                       %{_datadir}/emacs/site-lisp
26 %_initddir                      %{_sysconfdir}/rc.d/init.d
27
28 %_metainfodir   %{_datadir}/metainfo
29
30 %_defaultdocdir         %{_usr}/share/doc
31
32 %_fmoddir               %{_libdir}/gfortran/modules
33
34 # Location of autoconf macros
35 %_aclocaldir    %{expand:%%global _aclocaldir %(aclocal --print-ac-dir 2>/dev/null || echo ERROR)}%_aclocaldir
36
37 # Location of omf files
38 %_omf_dest_dir  %{expand:%%global _omf_dest_dir %(scrollkeeper-config --omfdir || echo ERROR)}%_omf_dest_dir
39
40 # Location of pkgconfig files
41 %_pkgconfigdir  /usr/%{_lib}/pkgconfig
42 # noarch pkgconfig files (since 1.446)
43 %_npkgconfigdir /usr/share/pkgconfig
44
45 # Location of desktop files
46 %_desktopdir    /usr/share/applications
47 %_applnkdir     ERROR:_applnkdir_is_obsolete_use_desktopdir_instead
48
49 # Location of pixmaps for applnk/desktop files
50 %_pixmapsdir    /usr/share/pixmaps
51
52 # Location of themable icons for applnk/desktop files
53 %_iconsdir      /usr/share/icons
54
55 # Location of fonts directories
56 %_fontsdir      /usr/share/fonts
57
58 # Location of Gtk and associated libraries documentation (since 1.98)
59 %_gtkdocdir     %{_defaultdocdir}/gtk-doc/html
60
61 # Common subdirectory for gi-docgen generated libraries documentation (since 2.029)
62 %_gidocdir      %{_defaultdocdir}/gi-doc
63
64 # Location of KDE documentation (since 1.129)
65 %_kdedocdir     %{_defaultdocdir}/kde/HTML
66
67 # unsermake script
68 %__unsermake /usr/share/unsermake/unsermake
69
70 # Current date
71 %date           %(LC_ALL=C date +"%a %b %d %Y")
72
73 # Example files, programs, scripts...
74 %_examplesdir   /usr/src/examples
75
76 # SysV-style initscripts dir
77 %_initddir              /etc/rc.d/init.d
78
79 # Executed at after copying %doc to DOCDIR, with $DOCDIR set
80 # TODO: teach rpm.org that compressed %doc is the same thing as uncompressed
81 #__compress_doc         %{_rpmconfigdir}/compress-doc%{?_noautocompressdoc: --noautocompressdoc='%{_noautocompressdoc}'}
82
83 %__os_install_post \
84 %{__spec_install_post_strip}\
85 %{__spec_install_post_chrpath}\
86 %{__spec_install_post_compress_modules}\
87 %{__spec_install_post_check_so}\
88 %{__spec_install_post_check_tmpfiles}\
89 %{__spec_install_post_check_shebangs}\
90 %{__spec_install_post_compress_docs}\
91 %{__spec_install_post_py_hardlink}\
92 %{__spec_install_post_perl_clean}\
93 %{__arch_install_post}\
94 %{nil}
95
96 %__spec_install_post\
97 %{expand:%%define __sip_%{?_enable_debug_packages} 1}%{?__sip_1:%{?__debug_package:%{__debug_install_post}}}%{expand:%%undefine __sip_%{?_enable_debug_packages}}\
98 %{__arch_install_post}\
99 %{__os_install_post}\
100 %{nil}
101
102 #---------------------------------------------------------------------
103 #       Template for debug information sub-package.
104 %_enable_debug_packages         1
105
106 %_debuginfo_template \
107 %package debuginfo\
108 Summary: Debug information for package %{name}\
109 Summary(pl.UTF-8): Informacje dla debuggera dla pakietu %{name}\
110 Group: Development/Debug\
111 Requires: filesystem-debuginfo >= 3.0-16\
112 AutoReqProv: 0\
113 %description debuginfo\
114 This package provides debug information for package %{name}.\
115 Debug information is useful when developing applications that use this\
116 package or when debugging this package.\
117 %description debuginfo -l pl.UTF-8\
118 Ten pakiet dostarcza informacje dla debuggera dla pakietu %{name}.\
119 Informacje te są przydatne przy rozwijaniu aplikacji używających tego\
120 pakietu oraz przy odpluskwianiu samego pakietu.\
121 %files debuginfo -f debugfiles.list\
122 %defattr(-,root,root)\
123 %{nil}
124
125 %_debugsource_template \
126 %package debugsource\
127 Summary: Debug sources for package %{name}\
128 Summary(pl.UTF-8): Źródła dla debuggera dla pakietu %{name}\
129 Group: Development/Debug\
130 AutoReqProv: 0\
131 %description debugsource\
132 This package provides debug sources for package %{name}.\
133 Debug sources are useful when developing applications that use this\
134 package or when debugging this package.\
135 %description debugsource -l pl.UTF-8\
136 Ten pakiet dostarcza źródła dla debuggera dla pakietu %{name}.\
137 Źródła te są przydatne przy rozwijaniu aplikacji używających tego\
138 pakietu oraz przy odpluskwianiu samego pakietu.\
139 %files debugsource -f debugsourcefiles.list\
140 %{nil}
141
142 %debug_package \
143 %ifnarch noarch\
144 %global __debug_package 1\
145 %_debuginfo_template\
146 %if 0%{?_debugsource_packages}\
147 %_debugsource_template\
148 %endif\
149 %endif\
150 %{nil}
151
152 #---------------------------------------------------------------------
153 # Overwrite RPM macros with PLD specific one here.
154
155 %__find                 /usr/bin/find
156 %__lua                  %{_bindir}/lua
157 %__rc                   %{_bindir}/rc
158 %__xar                  %{_bindir}/xar
159
160 %_source_payload        w9.gzdio
161 %_binary_payload        w6.xzdio
162
163 %_rpmfc_magic_path      /usr/share/file/magic
164
165 # provides don't obsolete
166 %_upgrade_tag           name
167
168 # Disable automatic dependencies on symlinks for now (debuginfo packages pull too many deps)
169 %_check_symlink_deps    0 
170  
171 # Do not generate executable() dependencies for scriptlets,
172 # as it may give false positives, for example:
173 # [ ! -x /bin/prog ] || /bin/prog
174 # will generate R:/bin/prog and we don't want that as /bin/prog is optional in this case
175 # 0 - Use external generator
176 # 1 - Use internal generator if available
177 # 2 - Use __scriptlet_requires to process scriptlet dependencies
178 %_use_internal_dependency_generator     1
179
180 %_duplicate_files_terminate_build       1
181 %_files_listed_twice_terminate_build    1
182 %_unpackaged_files_terminate_build      0
183 %_unpackaged_subdirs_terminate_build    0
184
185 #
186 # Export package NEVRA (stamped with install tid) info for HRMIB on this path.
187 #
188 # XXX   Note: escaped %% for use in headerSprintf()
189 %_hrmib_path    /var/cache/hrmib/%{___NVRA}
190
191 #-----------------------------------------------------------------
192 # CFLAGS and LDFLAGS used to build
193
194 %debuginfocflags        %{expand:%%define __dic_%{?_enable_debug_packages} 1}%{?__dic_1: -gdwarf-4 -fno-debug-types-section -fvar-tracking-assignments -g2}%{expand:%%undefine __dic_%{?_enable_debug_packages}}
195 # -feliminate-dwarf2-dups disabled until PR ld/3290 is fixed.
196
197 %debugcflags    -O0 -g -Wall
198 %debugcppflags  %{nil}
199 %debugldflags   %{nil}
200
201 %optldflags     -Wl,--as-needed -Wl,--no-copy-dt-needed-entries -Wl,-z,relro -Wl,-z,combreloc %{?use_ld:-Wl,-fuse-ld=%{use_ld}}
202 %optcppflags    %{nil}
203
204 # common compilation flags
205 %_fortify_cflags        -Wp,-D_FORTIFY_SOURCE=2
206
207 # cf http://wiki.mandriva.com/en/Development/Packaging/Problems#format_not_a_string_literal_and_no_format_arguments
208 %Werror_cflags          -Wformat -Werror=format-security
209
210 # Use -Werror=trampolines to prevent GCC from generating code that require executable stack
211 %_ssp_cflags            -fstack-protector-strong --param=ssp-buffer-size=4 -Werror=trampolines
212 %__common_cflags        -O2 -fwrapv -pipe %{Werror_cflags} %{debuginfocflags} %{?_fortify_cflags} %{!?nospecflags:%{?specflags}}
213 %__common_cflags_with_ssp       %{__common_cflags} %{?_ssp_cflags}
214
215 # arch macros
216 %ix86  i386 i486 i586 i686 pentium3 pentium4 athlon geode
217 %x8664 x86_64 amd64 ia32e
218 %ppc   ppc ppc7400 ppc7450
219
220 # avoid fdatasync syscall flood during database operations.
221 %__nofsync      nofsync
222
223 #---------------------------------------------------------------------
224 #       Expanded at end of %prep
225 #
226 %__chown_Rhf    %{__chown} -Rhf
227 %__chgrp_Rhf    %{__chgrp} -Rhf
228 %_fixowner      [ `%{__id_u}` = '0' ] && %{__chown_Rhf} root
229 %_fixgroup      [ `%{__id_u}` = '0' ] && %{__chgrp_Rhf} root
230
231 # compiler version
232 %cc_version     %{expand:%%global cc_version %(%{__cc} -dumpversion 2>/dev/null || echo 0.0)}%cc_version
233 %cxx_version    %{expand:%%global cxx_version %(%{__cxx} -dumpversion 2>/dev/null || echo 0.0)}%cxx_version
234
235 %__rm           /bin/rm --interactive=never
236
237 # Build system path macros.
238 %__autoconf             autoconf %{?debug:-Wall}
239 %__automake             automake -a -c -f --foreign
240 %__autopoint    autopoint --force
241 %__aclocal              aclocal
242 %__autoheader   autoheader
243
244 # add parallel build flags: -jN
245 # jobs macro is available since 1.657
246 #
247 # if you want to disable parallel build do:
248 # echo '%__jobs %{nil}' >> ~/.rpmmacros
249 %__jobs         %{expand:%%global __jobs %(_NCPUS=$(/usr/bin/getconf _NPROCESSORS_ONLN); [ "$_NCPUS" -gt 3 ] && echo $(($_NCPUS / 2)))%%{nil}}%__jobs
250
251 # expands to -jN if %__jobs has a value
252 %_smp_mflags    %{expand:%%global _smp_mflags %(jobs=%{__jobs}; echo ${jobs:+-j$jobs}%%{nil})}%_smp_mflags
253
254 %__make         /usr/bin/make %{?_make_opts} %{?_smp_mflags}
255 %__scons        /usr/bin/scons %{?_smp_mflags}
256 %__waf          /usr/bin/waf %{?_smp_mflags}
257 %__cmake        /usr/bin/cmake
258 %__meson        /usr/bin/meson
259 %__meson_wrap_mode      nodownload
260 %__ninja        /usr/bin/ninja
261 %__ninja_common_opts    -v %{?_smp_mflags}
262
263 %__gettextize { \
264         gettextize --copy --force --no-changelog; \
265         if [ ! -f po/Makevars ]; then \
266                 cp -f po/Makevars{.template,}; \
267         fi; \
268 }
269
270 %__glib_gettextize      glib-gettextize --copy --force
271 %__gnome_doc_common     gnome-doc-common --copy
272 %__gnome_doc_prepare    gnome-doc-prepare --copy --force
273 %__gtkdocize            gtkdocize --copy
274 %__intltoolize          intltoolize --copy --force
275 %__libtoolize           libtoolize --copy --force --install
276
277 # topdir is where builder script lives,
278 # fallback to old style if SPECS/SOURCES dirs were found.
279 %_topdir    %{expand:%%global _topdir %(
280         if [ -d SPECS -a -d SOURCES ]; then
281                 # old style rpmdir: in topdir
282                 pwd
283         elif [ -d ../SPECS -a -d ../SOURCES ]; then
284                 # old style rpmdir: in subdir
285                 cd ..; pwd
286         elif [ -d $HOME/rpm/SPECS -a -d $HOME/rpm/SOURCES ]; then \
287                 # if old style rpm dir exist, go with it
288                 echo $HOME/rpm; \
289         elif [ -x ../builder -a ! -d ../builder ] && [ "$(realpath -s ../builder)" != "/usr/bin/builder" ]; then
290                 # relative new style rpmdir: in package dir
291                 cd ..; pwd
292         elif [ -x builder -a ! -d builder ] && [ "$(realpath -s builder)" != "/usr/bin/builder" ]; then
293                 # relative new style rpmdir: in packages
294                 pwd
295         elif [ -x packages/builder -a ! -d packages/builder ]; then
296                 # relative new style rpmdir: packages dir in current dir
297                 cd packages; pwd
298         else
299                 # fallback to new style rpmdir
300                 echo $HOME/rpm/packages
301         fi; \
302 )}%_topdir
303
304 %_tmppath               %(echo "${TMPDIR:-/var/tmp}")
305 %tmpdir                 %{_tmppath}
306
307 %_buildrootdir  %{_tmppath}
308 %buildroot              %{_buildrootdir}/%{name}-%{version}-%{_arch}-root-%(id -u -n)
309
310 # if %{_topdir}/SPECS exists, it's old style structure
311 %_specdir               %{expand:%%global _specdir %([ ! -d %{_topdir}/SPECS ] && echo %{_topdir}/%{name} || echo %{_topdir}/SPECS)}%_specdir
312 %_sourcedir             %{expand:%%global _sourcedir %([ ! -d %{_topdir}/SOURCES ] && echo %{_specdir} || echo %{_topdir}/SOURCES)}%_sourcedir
313
314 # BUILD/RPMS/SRPMS are on same level by default as packages dir, if these exist
315 # if they don't exist assume we are having custom topdir (which is not named as
316 # "packages", i.e ~/rpm/kde/{kdelibs,BUILD/RPMS/SRPMS})
317 # NOTE: readlink fails if some parent dir is not readable (/home/services/builder for example can't read /home/services), therefore the extra echo
318 %_builddir              %{expand:%%global _builddir %(if [ -d %{_topdir}/BUILD ]; then echo %{_topdir}/BUILD; else readlink -m %{_topdir}/../BUILD || echo %{_topdir}/../BUILD; fi)}%_builddir
319 %_rpmdir                %{expand:%%global _rpmdir %(if [ -d %{_topdir}/RPMS ]; then echo %{_topdir}/RPMS; else readlink -m %{_topdir}/../RPMS || echo readlink -m %{_topdir}/../RPMS; fi)}%_rpmdir
320 %_srcrpmdir             %{expand:%%global _srcrpmdir %(if [ -d %{_topdir}/SRPMS ]; then echo %{_topdir}/SRPMS; else readlink -m %{_topdir}/../SRPMS || echo readlink -m %{_topdir}/../SRPMS; fi)}%_srcrpmdir
321
322 #       The number of cvs changelog entries kept when building package.
323 %_buildchangelogtruncate 20
324
325 %dependencytracking     %{nil}
326
327 #       Relations between package names that cause dependency loops
328 #       with legacy packages that cannot be fixed. Relations are
329 #       specified as
330 #               p>q
331 #       where package p has a Requires: on something that package q Provides:
332 #
333 # XXX   Note: that there cannot be any whitespace within the string "p>q",
334 #       and that both p and q are package names (i.e. no version/release).
335 %_dependency_whiteout   %{nil}
336
337 #-----------------------------------------------------------------
338 #
339 # (re)definition of %{rpm*flags} with %filterout_* support
340 # BuildRequires:        awk
341 # BuildRequires:        rpmbuild(macros) >= 1.315
342 #
343 # Flags specified in %filterout_* are removed from %rpm*flags, exactly:
344 # %rpmcflags    = %optflags - %filterout - %filterout_c   - %filterout_ld
345 # %rpmcxxflags  = %optflags - %filterout - %filterout_cxx - %filterout_ld
346 # %rpmcppflags  = %optcppflags - %filterout - %filterout_cpp - %filterout_ld
347 # %rpmldflags   = %optldflags - %filterout_ld
348 #
349 # Regular expressions are supported, but to avoid some character be treated
350 # as regular expression it must be escaped twice.
351
352 %filter_out                                                     \
353         for (i = 1; i in I; i++) { A=0; \
354                 for (f in F) {                          \
355                         if (I[i] ~ "^" F[f] "$") A=1;   \
356                 };                                                      \
357                 if (!A) printf(I[i] FS);        \
358         }
359
360 %rpmcflags %(awk 'BEGIN {
361         split("%{?debug:%debugcflags}%{!?debug:%optflags}%{?debuginfocflags}",I);
362         split("%{?filterout} %{?filterout_c} %{?filterout_ld}",F);
363         %{filter_out}
364 }')
365
366 %rpmcxxflags %(awk 'BEGIN {
367         split("%{?debug:%debugcflags}%{!?debug:%optflags}%{?debuginfocflags}",I);
368         split("%{?filterout} %{?filterout_cxx} %{?filterout_ld}",F);
369         %{filter_out}
370 }')
371
372 %rpmcppflags %(awk 'BEGIN {
373         split("%{?debug:%debugcppflags}%{!?debug:%optcppflags}%{?debuginfocppflags}",I);
374         split("%{?filterout} %{?filterout_cpp} %{?filterout_cpp}",F);
375         %{filter_out}
376 }')
377
378 %rpmldflags %(awk 'BEGIN {
379         split("%{?optldflags}",I);
380         split("%{?filterout_ld}",F)
381         %{filter_out}
382 }')
383
384 # rpmldflags with stripped -Wl, -- in the form flags have to be passed to 'ld'
385 # but, don't use it, better use gcc as linker
386 %ld_rpmldflags %(awk 'BEGIN {
387         split("%{rpmldflags}",F);
388         for (f in F) {
389                 s = F[f];
390                 if (s ~ /^-Wl,/) {
391                         s = substr(s,5);
392                         gsub(/,/," ",s);
393                 };
394                 printf(s FS);
395         };
396 }')
397
398 #-----------------------------------------------------------------
399 #
400 #  Generate a command which cleans environment, leaving only the
401 # most important variables.
402 #  If any spec requires any additional environment it should
403 # redefine %_preserve_env in following manner:
404 #
405 #       # ADDITIONAL_VAR is required because [a good reason here]
406 #       %define _preserve_env ADDITIONAL_VAR
407
408 %_preserve_env_base     PATH HOME TMP TMPDIR SSH_AUTH_SOCK
409
410 # "env -i" must end in first line of expaned macros because it's used as first line of shell script (#! env...)
411 %_clean_env env -i %(awk -vq="'" -vqq="\\"'\\"" -vq2q="'\\"'" 'BEGIN {
412         split("%{?_preserve_env:%_preserve_env %_preserve_env_base}%{!?_preserve_env:%_preserve_env_base}", P);
413         for (i in P) {
414                 p = P[i];
415                 if (!ENVIRON[p] || d[p]) {
416                         continue;
417                 }
418                 d[p] = 1;
419                 split(ENVIRON[p], V, "");
420                 val = p "=";
421                 for (j = 1; j in V; j++) {
422                         v = V[j];
423                         if (v == q)
424                                 v = qq;
425                         else if (v == "\\"")
426                                 v = q2q;
427                         else if (v == "\\\\")
428                                 v = "\\\\\\\\";
429                         else
430                                 gsub("[^a-zA-Z0-9/:._-]", "\\"&\\"", v);
431                         val = val "" v;
432                 }
433                 printf(val " ");
434         }
435 }')
436
437 # override %__spec_build_pre and %__spec_install_pre from macros.rpmbuild
438 # adding %{_clean_env}
439 %__spec_build_pre       %{_clean_env}\
440 %{___build_pre}\
441 %{nil}
442 %__spec_install_pre     %{_clean_env}\
443 %{___build_pre}\
444 %{?buildroot:%{__rm} -rf '%{buildroot}'; %{__mkdir_p} '%{buildroot}'}\
445 %{nil}
446
447 #-----------------------------------------------------------------
448 %configure2_13 { \
449  if [ -n "$LINGUAS" ]; then unset LINGUAS; fi; \
450  LDFLAGS="${LDFLAGS:-%rpmldflags}" ; export LDFLAGS ; \
451  CFLAGS="${CFLAGS:-%rpmcflags}" ; export CFLAGS ; \
452  CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" ; export CXXFLAGS ; \
453  FFLAGS="${FFLAGS:-%rpmcflags}" ; export FFLAGS ; \
454  FCFLAGS="${FCFLAGS:-%rpmcflags}" ; export FCFLAGS ; \
455  CPPFLAGS="${CPPFLAGS:-%rpmcppflags}" ; export CPPFLAGS ; \
456  %{?__cc:CC="%{__cc}" ; export CC ; } \
457  %{?__cxx:CXX="%{__cxx}" ; export CXX ; } \
458  %{?configuredir:%{configuredir}}%{!?configuredir:.}/configure \
459         --host=%{_target_platform} \
460         --prefix=%{_prefix} \
461         --exec-prefix=%{_exec_prefix} \
462         --bindir=%{_bindir} \
463         --sbindir=%{_sbindir} \
464         --sysconfdir=%{_sysconfdir} \
465         --datadir=%{_datadir} \
466         --includedir=%{_includedir} \
467         --libdir=%{_libdir} \
468         --libexecdir=%{_libexecdir} \
469         --localstatedir=%{_localstatedir} \
470         --sharedstatedir=%{_sharedstatedir} \
471         --mandir=%{_mandir} \
472         --infodir=%{_infodir} \
473         --x-libraries=%{?_x_libraries}%{!?_x_libraries:%{_libdir}} \
474         %{dependencytracking} \
475 }
476
477 # Note: pass only standard cmake macros here.
478 # The only exception is SYSCONF_INSTALL_DIR, used commonly in KDE packages,
479 # where the default (${CMAKE_INSTALL_PREFIX}/etc) is not FHS-compliant and
480 # absolute path MUST be used to comply with FHS.
481 # The other non-standard cmake macros used commonly in KDE
482 # (INCLUDE_INSTALL_DIR, LIB_INSTALL_DIR, SHARE_INSTALL_PREFIX)
483 # have sane default values in KDE, and some packages use these names
484 # in different way (e.g. expect them to be always relative or always
485 # absolute).
486 %cmake \
487 %{?__cc:CC="${CC:-%{__cc}}"} \\\
488 %{?__cxx:CXX="${CXX:-%{__cxx}}"} \\\
489 CPPFLAGS="${CPPFLAGS:-%{rpmcppflags}}" \\\
490 %{__cmake} \\\
491         -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \\\
492         -DCMAKE_BUILD_TYPE=%{!?debug:PLD}%{?debug:Debug} \\\
493         -DCMAKE_SYSTEM_NAME=Linux \\\
494         -DCMAKE_SYSTEM_VERSION="%(uname -r)" \\\
495         -DCMAKE_CROSSCOMPILING:BOOL=FALSE \\\
496 %ifarch x32\
497         -DCMAKE_SYSTEM_PROCESSOR=x86_64 \\\
498 %else\
499         -DCMAKE_SYSTEM_PROCESSOR=%{_target_cpu} \\\
500 %endif\
501         -DCMAKE_INSTALL_BINDIR:PATH=%{_bindir} \\\
502         -DCMAKE_INSTALL_SBINDIR:PATH=%{_sbindir} \\\
503         -DCMAKE_INSTALL_LIBEXECDIR:PATH=%{_libexecdir} \\\
504         -DCMAKE_INSTALL_SYSCONFDIR:PATH=%{_sysconfdir} \\\
505         -DCMAKE_INSTALL_SHAREDSTATEDIRPATH:PATH=%{_sharedstatedir} \\\
506         -DCMAKE_INSTALL_LOCALSTATEDIRPATH:PATH=%{_localstatedir} \\\
507         -DCMAKE_INSTALL_LIBDIR:PATH=%{_libdir} \\\
508         -DCMAKE_INSTALL_INCLUDEDIR:PATH=%{_includedir} \\\
509         -DCMAKE_INSTALL_OLDINCLUDEDIR:PATH=%{_includedir} \\\
510         -DCMAKE_INSTALL_DATAROOTDIR:PATH=%{_datadir} \\\
511         -DCMAKE_INSTALL_DATADIR:PATH=%{_datadir} \\\
512         -DCMAKE_INSTALL_INFODIR:PATH=%{_infodir} \\\
513         -DCMAKE_INSTALL_LOCALEDIR:PATH=%{_localedir} \\\
514         -DCMAKE_INSTALL_MANDIR:PATH=%{_mandir} \\\
515         -DCMAKE_INSTALL_DOCDIR:PATH=%{_docdir} \\\
516         -DCMAKE_INSTALL_PREFIX:PATH=%{_prefix} \\\
517         -DSYSCONF_INSTALL_DIR:PATH=%{_sysconfdir} \\\
518         -DCMAKE_CXX_FLAGS_PLD="${CXXFLAGS:-%{rpmcxxflags} -DNDEBUG -DQT_NO_DEBUG}" \\\
519         -DCMAKE_C_FLAGS_PLD="${CFLAGS:-%{rpmcflags} -DNDEBUG -DQT_NO_DEBUG}" \\\
520         -DCMAKE_Fortran_FLAGS_PLD="${CFLAGS:-%{rpmcflags} -DNDEBUG -DQT_NO_DEBUG}" \\\
521         -DCMAKE_EXE_LINKER_FLAGS_PLD="${LDFLAGS:-%{rpmldflags}}" \\\
522         -DCMAKE_SHARED_LINKER_FLAGS_PLD="${LDFLAGS:-%{rpmldflags}}" \\\
523         -DCMAKE_MODULE_LINKER_FLAGS_PLD="${LDFLAGS:-%{rpmldflags}}" \\\
524 %if "%{_lib}" == "lib64" \
525         -DLIB_SUFFIX=64 \\\
526 %endif \
527 %if "%{_lib}" == "libx32" \
528         -DLIB_SUFFIX=x32 \\\
529 %endif \
530         -DBUILD_SHARED_LIBS:BOOL=ON \\\
531 %{nil}
532
533 # scons (since 1.385)
534 %scons { \
535 %{__scons} \
536         LDFLAGS="${LDFLAGS:-%rpmldflags}" \
537         CFLAGS="${CFLAGS:-%rpmcflags}" \
538         CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" \
539         FFLAGS="${FFLAGS:-%rpmcflags}" \
540         CPPFLAGS="${CPPFLAGS:-%rpmcppflags}" \
541         %{?__cc:CC="%{__cc}"} \
542         %{?__cxx:CXX="%{__cxx}"} \
543         libsuffix=%{_lib} \
544         prefix=%{_prefix} \
545 }
546
547 # waf. see waf.spec (since 1.336)
548 %waf { \
549 CC="%{__cc}" \
550 CXX="%{__cxx}" \
551 CPP="%{__cpp}" \
552 CFLAGS="%{rpmcflags}" \
553 CXXFLAGS="%{rpmcxxflags}" \
554 LINKFLAGS="%{rpmldflags}" \
555 %{__waf} \
556 }
557
558 # meson (since 1.727)
559 %meson { \
560 %{?__cc:CC="${CC:-%{__cc}}"} \
561 %{?__cxx:CXX="${CXX:-%{__cxx}}"} \
562 CFLAGS="${CFLAGS:-%{rpmcflags}}" \
563 CPPFLAGS="${CPPFLAGS:-%{rpmcppflags}}" \
564 CXXFLAGS="${CXXFLAGS:-%{rpmcxxflags}}" \
565 LDFLAGS="${LDFLAGS:-%{rpmldflags}}" \
566 RUSTC="${RUSTC:-%{__rustc}}" \
567 RUSTFLAGS="${RUSTFLAGS:-%{rpmrustflags} --target %rust_target}" \
568 LC_ALL=C.UTF-8 %{__meson} \
569         --buildtype=plain \
570         --bindir=%{_bindir} \
571         --datadir=%{_datadir} \
572         --includedir=%{_includedir} \
573         --infodir=%{_infodir} \
574         --libdir=%{_libdir} \
575         --libexecdir=%{_libexecdir} \
576         --localedir=%{_localedir} \
577         --localstatedir=%{_localstatedir} \
578         --mandir=%{_mandir} \
579         --prefix=%{_prefix} \
580         --sbindir=%{_sbindir} \
581         --sharedstatedir=%{_sharedstatedir} \
582         --sysconfdir=%{_sysconfdir} \
583         --wrap-mode=%{__meson_wrap_mode} \
584         --default-library='both' \
585 }
586
587 %___meson_deprecate() {echo >&2 "DEPRECATED: %%%1 must be replaced with %%%2"; %{expand:%%%2} }
588 %meson_build %___meson_deprecate meson_build ninja_build
589 %meson_install %___meson_deprecate meson_install ninja_install
590 %meson_test %___meson_deprecate meson_test ninja_test
591
592 # ninja (since 1.736)
593 %ninja_build LC_ALL=C.UTF-8 %{__ninja} %{__ninja_common_opts}
594 %ninja_install LC_ALL=C.UTF-8 DESTDIR=%{buildroot} %{__ninja} install %{__ninja_common_opts}
595 %ninja_test LC_ALL=C.UTF-8 %{__ninja} test %{__ninja_common_opts}
596
597 #----------------------------------------------------------------
598 #%configure_cache 0
599 %configure_cache_file   %{buildroot}.configure.cache
600
601 %configure {./configure \
602         LDFLAGS="${LDFLAGS:-%rpmldflags}" \
603         CFLAGS="${CFLAGS:-%rpmcflags}" \
604         CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" \
605         FFLAGS="${FFLAGS:-%rpmcflags}" \
606         FCFLAGS="${FCFLAGS:-%rpmcflags}" \
607         CPPFLAGS="${CPPFLAGS:-%rpmcppflags}" \
608         %{?__cc:CC="%{__cc}"} \
609         %{?__cxx:CXX="%{__cxx}"} \
610         --host=%{_target_platform} \
611         --build=%{_target_platform} \
612         --prefix=%{_prefix} \
613         --exec-prefix=%{_exec_prefix} \
614         --bindir=%{_bindir} \
615         --sbindir=%{_sbindir} \
616         --sysconfdir=%{_sysconfdir} \
617         --datadir=%{_datadir} \
618         --includedir=%{_includedir} \
619         --libdir=%{_libdir} \
620         --libexecdir=%{_libexecdir} \
621         --localstatedir=%{_localstatedir} \
622         --sharedstatedir=%{_sharedstatedir} \
623         --mandir=%{_mandir} \
624         --infodir=%{_infodir} \
625         --x-libraries=%{?_x_libraries}%{!?_x_libraries:%{_libdir}} \
626         %{dependencytracking} \
627         %{?configure_cache:--cache-file=%{configure_cache_file}} \
628 }
629
630 # Simple macros to simplify adding bconded options to configure scripts.
631 #   Each macro requires bcond name and accepts optional option name, if option
632 # isn't specified bcond name is used as option name. Options returning
633 # --with and --enable also allow third argument which will be added as value
634 # ( --with-option=value or --enable-option=value ) in case or positive
635 # condition, but won't be added otherwise ( nothing or just --disable-option ).
636
637 # Requirements:
638 # BuildRequires: rpmbuild(macros) >= 1.527
639
640 # Usage example:
641 # %{__enable bcond} - returns --enable-bcond iff build condition is set
642 # %{__disable bcond option} - returns --enable-option iff bcond is not set
643 # %{__enable_disable bcond option value} - returns --enable-option=value if
644 #    bcond is set, returns --disable-option otherwise
645
646 # expand bconds to --enable-something and --disable-something
647 %__enable() %{expand:%%{?with_%{1}:--enable-%{?2}%{!?2:%{1}}%{?3:=%{3}}}}
648 %__disable() %{expand:%%{!?with_%{1}:--disable-%{?2}%{!?2:%{1}}}}
649 %__enable_disable() %{expand:%%{?with_%{1}:--enable-%{?2}%{!?2:%{1}}%{?3:=%{3}}}%%{!?with_%{1}:--disable-%{?2}%{!?2:%{1}}}}
650
651 # same as above, but condition inverted
652 %__enable_unless() %{expand:%%{!?with_%{1}:--enable-%{?2}%{!?2:%{1}}%{?3:=%{3}}}}
653 %__disable_if() %{expand:%%{?with_%{1}:--disable-%{?2}%{!?2:%{1}}}}
654 %__enable_disable_not() %{expand:%%{!?with_%{1}:--enable-%{?2}%{!?2:%{1}}%{?3:=%{3}}}%%{?with_%{1}:--disable-%{?2}%{!?2:%{1}}}}
655
656 # expand bconds to --with-something and --without-something
657 %__with() %{expand:%%{?with_%{1}:--with-%{?2}%{!?2:%{1}}%{?3:=%{3}}}}
658 %__without() %{expand:%%{!?with_%{1}:--without-%{?2}%{!?2:%{1}}}}
659 %__with_without() %{expand:%%{?with_%{1}:--with-%{?2}%{!?2:%{1}}%{?3:=%{3}}}%%{!?with_%{1}:--without-%{?2}%{!?2:%{1}}}}
660
661 # same as above, but condition inverted
662 %__with_unless() %{expand:%%{!?with_%{1}:--with-%{?2}%{!?2:%{1}}%{?3:=%{3}}}}
663 %__without_if() %{expand:%%{?with_%{1}:--without-%{?2}%{!?2:%{1}}}}
664 %__with_without_not() %{expand:%%{!?with_%{1}:--with-%{?2}%{!?2:%{1}}%{?3:=%{3}}}%%{?with_%{1}:--without-%{?2}%{!?2:%{1}}}}
665
666 # expands to true or false based on bcond; for use with meson or cmake (since 1.729)
667 %__true_false() %{expand:%%{?with_%{1}:true}%%{!?with_%{1}:false}}
668 %__true_false_not() %{expand:%%{?with_%{1}:false}%%{!?with_%{1}:true}}
669
670 # expands to enabled or disabled based on bcond; for use with meson or cmake (since 2.000)
671 %__enabled_disabled() %{expand:%%{?with_%{1}:enabled}%%{!?with_%{1}:disabled}}
672 %__enabled_disabled_not() %{expand:%%{?with_%{1}:disabled}%%{!?with_%{1}:enabled}}
673
674 # for use with cmake:
675 # Usage: cmake_on_off BCOND_NAME [OPTION_NAME]
676 # BuildRequires: rpmbuild(macros) >= 1.742
677 %cmake_on_off() -D%{?2}%{!?2:%{1}}:BOOL=%{expand:%%{?with_%{1}:ON}%%{!?with_%{1}:OFF}}
678
679 #-----------------------------------------------------------------
680
681 # overload to insert debuginfo package
682 %prep \
683 %if 0%{?_enable_debug_packages}\
684 %{debug_package}\
685 %endif\
686 %%prep\
687 %{nil}
688
689 %_build_id_links        %{expand:%%define __dic_%{?_enable_debug_packages} 1}%{?__dic_1:alldebug}%{?__dic_0:none}%{expand:%%undefine __dic_%{?_enable_debug_packages}}
690
691 # If non-empty "debug" macro defined, add "dbg" suffix to release number
692 %_rpmfilename           %%{NAME}-%%{VERSION}-%%{RELEASE}%{?debug:dbg}.%%{ARCH}.rpm
693
694 # Bootstrap release macros.
695 # Usage:
696 #       %bcond_with     bootstrap
697 #       Release:        %{bootstrap_release 1}
698 #
699 # Package will have release 1 if built normally,
700 # and release 0.zzz.bootstrap if built with bootstrap
701 %bootstrap_release() %{!?with_bootstrap:%{1}%{?2:.%{2}}}%{?with_bootstrap:%{!?2:%(expr %{1} - 1)}%{?2:%{1}.%(expr %{2} - 1)}.zzz.bootstrap}
702
703 # Requires name = version-release
704 %requires_releq()       %{!?1:ERROR}%{?2:ERROR}%{?1:%{!?2:%{expand:%%requires_eq_to -r %1 %1}}}
705 # Requires: name = version
706 %requires_eq()          %{!?1:ERROR}%{?2:ERROR}%{?1:%{!?2:%{expand:%%requires_eq_to %1 %1}}}
707 # Requires: name = version (version based on querying package %2)
708 %requires_eq_to(r)      %{!?2:ERROR}%{?3:ERROR}%{?2:%{!?3:%(if ! LC_ALL=C rpm -q --whatprovides --qf 'Requires: %1 = %|E?{%{E}:}|%{V}%{?-r:-%{R}}\\n' %2 | grep '^Requires:'; then echo "BuildRequires: %2"; fi)}}
709
710 # Requires: name >= version
711 %requires_ge()          %{!?1:ERROR}%{?2:ERROR}%{?1:%{!?2:%{expand:%%requires_ge_to %1 %1}}}
712 # Requires: name >= version (version based on querying package %2)
713 %requires_ge_to(r)      %{!?2:ERROR}%{?3:ERROR}%{?2:%{!?3:%(if ! LC_ALL=C rpm -q --whatprovides --qf 'Requires: %1 >= %|E?{%{E}:}|%{V}%{?-r:-%{R}}\\n' %2 | grep '^Requires:'; then echo "BuildRequires: %2"; fi)}}
714
715 # helper for renaming packages
716 # %rename old-package
717 %rename() \
718 Obsoletes: %{1} < %{?epoch:%{epoch}:}%{?version:%{version}}%{?release:-%{release}} \
719 Provides: %{1} = %{?epoch:%{epoch}:}%{?version:%{version}}%{?release:-%{release}}
720
721 # for package versions comparison (incl. cc_version or _rpmversion)
722 # BuildRequires:        rpmbuild(macros) >= 1.749
723 %_ver_lt()      %(test $(rpmvercmp "%{1}" "%{2}" >/dev/null 2>&1; echo $?) -ne 2; echo $?)
724 %_ver_ge()      %(test $(rpmvercmp "%{1}" "%{2}" >/dev/null 2>&1; echo $?) -eq 2; echo $?)
725
726 # noarch subpackage helper
727 # BuildRequires:        rpmbuild(macros) >= 1.752
728 %noarchpackage \
729 BuildArch:              noarch \
730 %{nil}
731
732 %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
733
734 # sgml macros
735 %xmlcat_add()           /usr/bin/xmlcatalog --noout --add nextCatalog \"\" %1 /etc/xml/catalog ;
736 %xmlcat_del()           /usr/bin/xmlcatalog --noout --del %1 /etc/xml/catalog ;
737 %xmlcat_add_rewrite     /usr/bin/xmlcatalog --noout --add rewriteSystem
738 %xmlcat_create()        /usr/bin/xmlcatalog --noout --create %1 ;
739 %sgmlcat_add()          /usr/bin/install-catalog --add %1 %2 > /dev/null ;
740 %sgmlcat_del()          /usr/bin/install-catalog --remove %1 %2 > /dev/null ;
741 %docbook_sgmlcat_fix() { for l in \
742 '' \
743 '  -- default decl --' \
744 'DTDDECL "-//OASIS//DTD DocBook XML V%2//EN" "../../xml.dcl"' \
745 '  -- hacks for opensp --' \
746 'SYSTEM "file://%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
747 'SYSTEM   "http://www.oasis-open.org/docbook/xml/%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
748 '' \
749 ; do echo $l; done >> %1 \
750 }
751
752 # vim - "
753
754 # minimum file size needed for compressed documents.
755 # just smaller files than this get larger when compressed.
756 # some stats:
757 # - 0 byte file compressed was 25 bytes .gz
758 # - 39 byte file was compressed as 57
759 # - with test/test.spec@man 158 byte file was compressed also 158
760 %_min_compress_bytes    159
761
762 #-----------------------------------------------------------------
763 # find and gzip all files in %{_mandir} and %{infodir}
764 #
765 # Requires: xargs, find
766 #
767 #%no_install_post_compress_docs 1
768 %__spec_install_post_compress_docs { \
769 %{!?no_install_post_compress_docs:__spec_install_post_compress_docs() { \
770         %{!?debug:set +x;} \
771         for i in /usr/share/man /usr/X11R6/man; do \
772                 if [ -d "$RPM_BUILD_ROOT$i" ]; then \
773                         echo "Compress man pages: $i"; \
774                         find "$RPM_BUILD_ROOT$i" -name '*.bz2' -print0 | xargs -0 -r %{__bzip2} -df; \
775                         find "$RPM_BUILD_ROOT$i" -name '*.gz' -print0 | xargs -0 -r %{__gzip} -dnf; \
776                         find $RPM_BUILD_ROOT$i -type l | while read a; do \
777                                 m=$(readlink "$a"); \
778                                 if [[ "$m" = */* ]]; then \
779                                         # handle links to different man section \
780                                         l=$(readlink -f "$a"); \
781                                         # full/relative paths that resolve symlink \
782                                         l=${l#$RPM_BUILD_ROOT/usr/share/man/}; \
783                                         l=${l#$RPM_BUILD_ROOT/usr/X11R6/man/}; \
784                                         # full paths that do not resolve symlink \
785                                         l=${l#/usr/share/man/}; \
786                                         l=${l#/usr/X11R6/man/}; \
787                                 else \
788                                         l=${a#$RPM_BUILD_ROOT$i/}; \
789                                         l=${l%/*}; \
790                                         l="$l/$m"; \
791                                 fi; \
792                                 rm -f $a; \
793                                 echo ".so $l" > $a; \
794                                 echo >&2 "Converted ${a#$RPM_BUILD_ROOT} from symlink to man link: $l"; \
795                         done; \
796                         # verify that .so links point to existing files (not allowed to point to "other package") \
797                         # TODO: iterate over all man dirs, but in Th there is only one true man dir \
798                         err=$(grep -rl '^\.so ' "$RPM_BUILD_ROOT$i" | while read doc; do \
799                                 l=$(grep -r '^\.so ' "$doc"); \
800                                 l=${l#.so }; \
801                                 d=$(dirname $doc); \
802                                 test -e $RPM_BUILD_ROOT$i/$l || test -e $d/$(basename $l) || echo "  ${doc#$RPM_BUILD_ROOT} points to inexistent manpage: $l"; \
803                         done); \
804                         test "$err" != "" && { echo >&2 "Man page link errors:"; echo >&2 "$err"; exit 1; }; \
805                         find "$RPM_BUILD_ROOT$i" -type f -size +%{_min_compress_bytes}c -print0 | xargs -0 -r %{__gzip} -9nf; \
806                 fi; \
807         done; \
808         if [ -d "$RPM_BUILD_ROOT%{_infodir}" ]; then \
809                 echo "Compress info pages: %{_infodir}"; \
810                 find "$RPM_BUILD_ROOT%{_infodir}" -name '*.bz2' -print0 | xargs -0 -r %{__bzip2} -df; \
811                 find "$RPM_BUILD_ROOT%{_infodir}" -name '*.gz' -print0 | xargs -0 -r %{__gzip} -dnf; \
812                 find "$RPM_BUILD_ROOT%{_infodir}" -name '*.info*' -type f -size +%{_min_compress_bytes}c -print0 | xargs -0 -r %{__gzip} -9nf; \
813         fi; \
814 }; __spec_install_post_compress_docs } }
815
816 #-----------------------------------------------------------------
817 # Strip executable binaries and shared object files
818 #
819 # Requires: find, awk, strip, cut, xargs
820 #
821 # Special macros which affect this process:
822 #%no_install_post_strip 1               # disable stripping at all
823 #%_noautostrip                  regexp  # exclude files matching (anchored!) regex from stripping
824 #%_autostripall                 regexp  # strip files matching (anchored!) regex using plain strip
825 #%_autostripunneeded    regexp  # strip files matching (anchored!) regex using strip --strip-unneeded
826 #%_autostripdebug               regexp  # strip files matching (anchored!) regex using strip --strip-debug
827 #
828 %__spec_install_post_strip {%{!?debug: \
829 %{!?no_install_post_strip:__spec_install_post_strip() { \
830 %{!?debug:set +x;} \
831 if [ -d "$RPM_BUILD_ROOT" ]; then \
832         if [ -d $RPM_BUILD_ROOT/lib/modules ]; then \
833                 modulelist=$(find $RPM_BUILD_ROOT/lib/modules \( -name '*.o' -o -name '*.ko' \) -type f -print); \
834                 if [ "$modulelist" ]; then \
835                         modulecount=$(echo "$modulelist" | wc -l); \
836                         printf "Stripping %d kernel modules..." $modulecount; \
837                         echo "$modulelist" | xargs -l512 chmod u+w; \
838                         echo "$modulelist" | xargs -l512 %{__strip} -g --remove-section=.comment --remove-section=.note.GNU-stack; \
839                         echo "DONE"; \
840                 fi; \
841         fi; \
842         filelist=$(find $RPM_BUILD_ROOT  ! \( -path "*/usr/src/debug" -prune \) -type f ! -regex ".*/usr/lib[x0-9]*/debug/.*\.debug" ! -regex ".*/usr/lib[x0-9]*.*/guile/.*\.go" ! -regex ".*/lib/modules/.*" ! -regex ".*%{_docdir}/.*" ! -regex ".*%{_includedir}/.*" %{?_noautostrip:! -regex "%{_noautostrip}"} %{?_autostripall:! -regex "%{_autostripall}"} %{?_autostripunneeded:! -regex "%{_autostripunneeded}"} %{?_autostripdebug:! -regex "%{_autostripdebug}"}); \
843         if [ -n "$filelist" ]; then \
844                 filetypes=`echo "$filelist" | xargs -r -d'\\n' file`; \
845                 elfexelist=`echo "$filetypes" | awk -F: '/ELF.*executable/ {print $1}'`; \
846                 elfsharedlist=`echo "$filetypes" | awk -F: '/LF.*shared object/ {print $1}'`; \
847                 archiveslist=`echo "$filetypes" | awk -F: '/current ar archive/ {print $1}'`; \
848                 if [ -n "$elfexelist" ]; then \
849                         printf "Stripping %d ELF executables..." $(echo "$elfexelist" | wc -l); \
850                         echo "$elfexelist" | xargs -r -d'\n' chmod u+w; \
851                         echo "$elfexelist" | xargs -r -d'\n' %{__strip} --remove-section=.note --remove-section=.comment; \
852                         echo "DONE"; \
853                 fi; \
854                 if [ -n "$elfsharedlist" ]; then \
855                         printf "Stripping %d ELF shared libraries..." $(echo "$elfsharedlist" | wc -l); \
856                         echo "$elfsharedlist" | xargs -r -d'\n' chmod u+w; \
857                         echo "$elfsharedlist" | xargs -r -d'\n' %{__strip} --strip-unneeded --remove-section=.note --remove-section=.comment; \
858                         echo "DONE"; \
859                 fi; \
860                 if [ -n "$archiveslist" ]; then \
861                         printf "Stripping %d ar archives..." $(echo "$archiveslist" | wc -l); \
862                         echo "$archiveslist" | xargs -r -d'\n' chmod u+w; \
863                         echo "$archiveslist" | xargs -r -d'\n' %{__strip} --strip-debug --remove-section=.note --remove-section=.comment; \
864                         echo "DONE"; \
865                 fi; \
866         fi; \
867     filelist_all=%{?_autostripall:$(find $RPM_BUILD_ROOT -type f -regex "%{_autostripall}")}; \
868     filelist_unneeded=%{?_autostripunneeded:$(find $RPM_BUILD_ROOT -type f -regex "%{_autostripunneeded}")}; \
869     filelist_debug=%{?_autostripdebug:$(find $RPM_BUILD_ROOT -type f -regex "%{_autostripdebug}")}; \
870         if [ -n "$filelist_all" ]; then \
871                 printf "Stripping everything from %d additional files..." $(echo "$filelist_all" | wc -l); \
872                 chmod u+w $filelist_all; \
873                 %{__strip} --remove-section=.note --remove-section=.comment $filelist_all; \
874                 echo "DONE"; \
875         fi; \
876         if [ -n "$filelist_unneeded" ]; then \
877                 printf "Stripping unneeded from %d additional files..." $(echo "$filelist_unneeded" | wc -l); \
878                 chmod u+w $filelist_unneeded; \
879                 %{__strip} --strip-unneeded --remove-section=.note --remove-section=.comment $filelist_unneeded; \
880                 echo "DONE"; \
881         fi; \
882         if [ -n "$filelist_debug" ]; then \
883                 printf "Stripping debuginfo from %d additional files..." $(echo "$filelist_debug" | wc -l); \
884                 chmod u+w $filelist_debug; \
885                 %{__strip} --strip-debug --remove-section=.note --remove-section=.comment $filelist_debug; \
886                 echo "DONE"; \
887         fi; \
888 fi; }; __spec_install_post_strip } } }
889
890 #-----------------------------------------------------------------
891 # remove all RPATH/RUNPATH from executable binaries and shared object files
892 #
893 # Requires: find, awk, cut, xargs, chrpath, uname
894 #
895 # Special macros which affect this process
896 #%no_install_post_chrpath       1       # disable chrpath at all
897 #%_noautochrpath        regex           # exclude files matching (anchored!) regex from chrpath
898 #
899 %__spec_install_post_chrpath {%{!?debug: \
900 %{!?no_install_post_chrpath: __spec_install_post_chrpath() { \
901 %{!?debug:set +x;} \
902 if [ -d "$RPM_BUILD_ROOT" ]; then \
903         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}"}`; \
904         if [ -n "$files" ]; then \
905                 objs=`echo "$files" | xargs -r -d'\\n' file | awk -F: '/ELF.*(executable.*dynamically linked|shared object)/ {print $1}'`; \
906         fi; \
907         if [ -n "$objs" ]; then \
908                 printf "Remove RPATH/RUNPATH from %d executable binaries and shared object files.\n" $(echo "$objs" | wc -l); \
909                 echo "$objs" | \
910                 while read file; do \
911                         rpath= ; \
912                         chmod u+w "$file"; \
913                         for dir in $(chrpath -l "$file" | awk '/(R|RUN)PATH=/ { gsub(/.*RPATH=/,""); gsub(/.*RUNPATH=/,""); gsub(/:/," "); print $0 }'); do \
914                                         case $dir in \
915                                         '$ORIGIN' ) \
916                                                 if [ "$rpath" = "" ] ; then rpath="$dir" ; \
917                                                 else rpath="$rpath:$dir" ; fi ; \
918                                                 continue ; \
919                                                 ;; \
920                                         esac ; \
921                                         newdir=$(readlink -m "$dir"); \
922                                         [ ${#newdir} -le ${#dir} ] && dir=$newdir; \
923                                         case $dir in \
924                                         /home/* | /tmp/* | /usr/lib | /usr/lib64 | /lib | /lib64 | /usr/local/lib | /usr/local/lib64 | /usr/X11R6/lib | /usr/X11R6/lib64 ) \
925                                                 echo "remove-rpath: $dir in $file"; \
926                                                 ;; \
927                                         * ) \
928                                                 if [ "$rpath" = "" ] ; then rpath="$dir" ; \
929                                                 else rpath="$rpath:$dir" ; fi ; \
930                                                 ;; \
931                                         esac ; \
932                         done ; \
933                         if [ "$rpath" = "" ] ; then chrpath -d "$file" > /dev/null ; \
934                         else chrpath -r "$rpath" "$file" > /dev/null ; fi ; \
935                 done; \
936         fi; \
937 fi; }; __spec_install_post_chrpath } } }
938
939 # vim: "
940
941 #-----------------------------------------------------------------
942 # Find all shared object files with unresolved symbols. Warn
943 # and terminate if any found (termination can be turned off by define).
944 #%no_install_post_check_so 1
945 #%skip_post_check_so libwithunresolvedok.so.*
946 #
947 # NOTE: define skip_post_check_so only if such library really requires
948 #       unresolved symbols and always leave a comment why it is required:
949 #       # executable provides symbols foo, bar for those libraries:
950 #       %define skip_post_check_so libwithoutfoo.so.* libwithoutbar.so.*
951 #
952 %__spec_install_post_check_so { \
953 __spec_install_post_check_so() { \
954 %{!?debug:set +x;} \
955         fail=0; \
956         printf "Searching for shared objects with unresolved symbols..."; \
957         for f in $(find $RPM_BUILD_ROOT -type f -name '*.so.*' -print); do \
958                 LC_ALL=C objdump -T $f 2> /dev/null | LC_ALL=C awk -v "file=$f" 'BEGIN { found=0; skip["program_name"]=1; skip["_ZSt15__once_callable"]=1; skip["_ZSt11__once_call"]=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; %{?skip_post_check_so:split("%{skip_post_check_so}", R); for (i=1; i in R; i++) { if (file ~ "(^|/)" R[i] "$") { print "Library marked with skip_post_check_so, ignoring errors.\n"; exit(0); } } } exit(1); } } ' || fail=1 ; \
959         done ; \
960         echo " DONE"; \
961         %{!?no_install_post_check_so:return $fail;} \
962 }; __spec_install_post_check_so }}
963
964 #-----------------------------------------------------------------
965 # Find all ELF files with executable stac. Warn and terminate if any found
966 # (termination can be turned off by define).
967 # Details: https://wiki.gentoo.org/wiki/Hardened/GNU_stack_quickstart
968 #%no_install_post_check_stackexec 1
969 #%skip_post_check_stackexec libwithexecstackok.so.*
970 #
971 # NOTE: define skip_post_check_stackexec only if such program or library
972 #       really requires executable stack and always leave a comment why
973 #       it is required:
974 #       # Programs full of nested functions that cannot be fixed
975 #       %define skip_post_check_execstack /bin/foo libwithexecstack.so.*
976 #
977 %__spec_install_post_check_execstack { \
978 __spec_install_post_check_execstack() { \
979 %{!?debug:set +x;} \
980         fail=0; \
981         printf "Searching for ELF programs with executable stack..."; \
982         for f in $(find $RPM_BUILD_ROOT -type f -print) ; do \
983                 LC_ALL=C readelf -lW $f 2>/dev/null | \
984                 LC_ALL=C awk -v "file=$f" 'BEGIN { found=0; } /GNU_STACK/ { if ($7 ~ "E") { found=1 } } END { if (found) { print "\nExecutable stack found in: " file; %{?skip_post_check_execstack:split("%{skip_post_check_execstack}", R); for (i=1; i in R; i++) { if (file ~ "(^|/)" R[i] "$") { print "File marked with skip_post_check_execstack, ignoring errors.\n"; exit(0); } } } exit(1); } }' || fail=1 ; \
985         done ; \
986         echo " DONE"; \
987         %{!?no_install_post_check_execstack:return $fail;} \
988 }; __spec_install_post_check_execstack }}
989
990 #-----------------------------------------------------------------
991 # Verify that for each directory under /var/run package contains
992 # tmpfiles.d configuration. Warn and terminate build if config is
993 # missing.
994 #
995 #%no_install_post_check_tmpfiles 1
996 #
997 %__spec_install_post_check_tmpfiles { \
998 __spec_install_post_check_tmpfiles() { \
999 %{!?debug:set +x;} \
1000         fail=0; \
1001         echo "Checking /var/run <-> tmpfiles.d completeness..."; \
1002         for d in $RPM_BUILD_ROOT/var/run/*; do \
1003                 [ -d "$d" ] || continue; \
1004                 d=${d##$RPM_BUILD_ROOT}; \
1005                 if ! grep -qsF "$d" $RPM_BUILD_ROOT/usr/lib/tmpfiles.d/*.conf $RPM_BUILD_ROOT/etc/tmpfiles.d/*.conf; then\
1006                         echo "No tmpfiles configuration for '$d'";\
1007                         fail=1 ; \
1008                 fi \
1009         done ; \
1010         echo " DONE"; \
1011         %{!?no_install_post_check_tmpfiles:return $fail;} \
1012 }; __spec_install_post_check_tmpfiles }}
1013
1014 #-----------------------------------------------------------------
1015 # Verify that scripts have reasonable shebangs
1016 # Test spec: see "test/spec_install_post_check_shebangs" branch on packages/test.spec
1017 #
1018 #%no_install_post_check_shebangs 1
1019 #
1020 %__spec_install_post_check_shebangs { \
1021 __spec_install_post_check_shebangs() { \
1022 %{!?debug:set +x;} \
1023         echo "Checking script shebangs..."; \
1024         fail=` \
1025         find $RPM_BUILD_ROOT -type f -perm -500 -print | { fail=0; while IFS= read -r f; do \
1026                 shebang="$(sed -e'1s/#! *\(.*\)/\1/;t;d;q' "$f")" ; \
1027                 f="${f##$RPM_BUILD_ROOT}"; \
1028                 case "$shebang" in \
1029                         "%{__python}"|"%{__python3}"|"%{__python} "*|"%{__python3} "* \
1030                         |"/usr/bin/python%{py_ver}"|"/usr/bin/python%{py_ver} "* \
1031                         |"/usr/bin/python%{py3_ver}"|"/usr/bin/python%{py3_ver} "*) \
1032                                 ;; \
1033                         "/usr/bin/env python"*|"/usr/bin/python"|"/usr/bin/python "*) \
1034                                 echo "$f starts with '#!$shebang', should be '#!%{__python}' or '#!%{__python3}'" >&2;\
1035                                 fail=1 ; \
1036                                 ;; \
1037                         "/usr/bin/env "*) \
1038                                 echo "$f starts with '#!$shebang', should be explicit interpreter path" >&2;\
1039                                 fail=1 ; \
1040                                 ;; \
1041                         *) ;;\
1042                 esac ; \
1043         done ; \
1044         echo "$fail" ; \
1045         }`; \
1046         echo " DONE" ; \
1047         %{!?no_install_post_check_shebangs:return $fail;} \
1048 }; __spec_install_post_check_shebangs }}
1049
1050 # Remove common Perl files we don't package
1051 %__spec_install_post_perl_clean {\
1052 %{!?no_install_post_perl_clean: \
1053 %{?pdir:rm -f $RPM_BUILD_ROOT{%{perl_archlib}/perllocal.pod,%{perl_vendorarch}/auto/%{pdir}%{?pnam:/%(echo %{pnam} | tr - /)}/.packlist}} \
1054 } }
1055
1056 # Helpers to specify SONAME depdendencies, e.g.:
1057 #   Requires: %{_soname_prov libfoo.so.1}
1058 #   Requires: %{_soname_prov libfoo.so.1(SOME_SYMVER)}
1059 #
1060 # BuildRequires:        rpmbuild(macros) >= 1.721
1061 #
1062 %_soname_tag %(echo %{_lib} | sed -e 's/^lib//' -e 's/^\\(.\\+\\)$/(\\1bit)/')
1063 %_soname_prov() %(echo "%{1}()%{_soname_tag}" | sed -e 's/^\\([^(]*([^)]\\+)\\)()%{_soname_tag}$/\\1%{_soname_tag}/;s/()$//')
1064
1065 #-----------------------------------------------------------------
1066 # Update GConf2 schemas (since 1.198)
1067 #
1068 # Requires: GConf2
1069 #
1070 %gconf_schema_install() \
1071         umask 022; \
1072         GCONF_CONFIG_SOURCE="xml:readwrite:/etc/gconf/gconf.xml.defaults" \\\
1073         /usr/bin/gconftool-2 --makefile-install-rule /etc/gconf/schemas/%{?1}%{!?1:*.schemas} > /dev/null; \
1074 %{nil}
1075
1076 %gconf_schema_uninstall() \
1077 if [ $1 = 0 -a -x /usr/bin/gconftool-2 ]; then \
1078         umask 022; \
1079         GCONF_CONFIG_SOURCE="xml:readwrite:/etc/gconf/gconf.xml.defaults" \\\
1080         /usr/bin/gconftool-2 --makefile-uninstall-rule /etc/gconf/schemas/%{?1} > /dev/null \
1081 fi; \
1082 %{nil}
1083
1084 #-----------------------------------------------------------------
1085 # Update desktop MIME database (since 1.198)
1086 # requires: desktop-file-utils
1087 %update_desktop_database() {{ \
1088         umask 022; \
1089         /usr/bin/update-desktop-database -q; \
1090 };} \
1091 %{nil}
1092
1093 %update_desktop_database_post %update_desktop_database
1094
1095 %update_desktop_database_postun() {{ \
1096 if [ "$1" = "0" ]; then \
1097         %update_desktop_database \
1098 fi; \
1099 };} \
1100 %{nil}
1101
1102 #-----------------------------------------------------------------
1103 # Update shared MIME info database (since 1.311)
1104 # requires: shared-mime-info
1105 # Note: https://bugs.freedesktop.org/show_bug.cgi?id=70366#c19
1106 #       https://bugzilla.redhat.com/show_bug.cgi?id=1052173
1107 # TODO: if you want this running with fdatasync(), make sure it's:
1108 #       1. announcing ~minute delay by echoing appropriate message,
1109 #       2. running only once after rpm transaction.
1110 #
1111 %update_mime_database() {{ \
1112         umask 022; \
1113         PKGSYSTEM_ENABLE_FSYNC=0 \
1114         /usr/bin/update-mime-database %{_datadir}/mime; \
1115 };} \
1116 %{nil}
1117
1118 #-----------------------------------------------------------------
1119 # Update icon cache
1120 # BuildRequires:        rpmbuild(macros) >= 1.596
1121 # Requires:             hicolor-icon-theme
1122 #
1123 %update_icon_cache() {{ \
1124         %{!?1:%{error:%{0}: Required theme name missing}} \
1125         if [ -x /usr/bin/gtk-update-icon-cache ]; then \
1126                 umask 022; \
1127                 touch --no-create %{_iconsdir}/%1; \
1128                 /usr/bin/gtk-update-icon-cache -qf %{_iconsdir}/%1; \
1129         fi; \
1130 };} \
1131 %{nil}
1132
1133 #-----------------------------------------------------------------
1134 # Update scrollkeeper database (since 1.198)
1135 # requires: scrollkeeper
1136 #
1137 %scrollkeeper_update_post() \
1138         /usr/bin/scrollkeeper-update -q; \
1139 %{nil}
1140
1141 %scrollkeeper_update_postun() \
1142 if [ "$1" = "0" ]; then \
1143         /usr/bin/scrollkeeper-update -q; \
1144 fi; \
1145 %{nil}
1146
1147 #-----------------------------------------------------------------
1148 # Compile GSettings schemas (since 1.592)
1149 # requires: glib2 >= 1:2.26.0
1150 #
1151 %glib_compile_schemas() {{ \
1152         umask 022; \
1153         /usr/bin/glib-compile-schemas %{_datadir}/glib-2.0/schemas; \
1154 };} \
1155 %{nil}
1156
1157 # BuildRequires:        rpmbuild(macros) >= 1.751
1158 # Requires(post,postun):        /usr/bin/texhash        # if you want to ensure cache is updated
1159 %texhash() {{ \
1160         umask 022; \
1161         /usr/bin/texhash >&2; \
1162 };} \
1163 %{nil}
1164
1165 #-----------------------------------------------------------------
1166 # post %install sequence:
1167 # - autodeps exceptions
1168 # - compress all man and info pages,
1169 # - strip all ELF executables and ELF shared objects if not %debug.
1170 # - compress kernel modules if any
1171
1172 ###################################################################
1173 # Requires/Provides automation
1174 # exceptions system by Jacek Konieczny <jajcus@pld-linux.org>
1175 #
1176 %__noautoreqfiles       %(sed -e s'/#.*//' /etc/rpm/noautoreqfiles)%{?_noautoreqfiles: %{_noautoreqfiles}}
1177 %__noautoprovfiles      %(sed -e s'/#.*//' /etc/rpm/noautoprovfiles)%{?_noautoprovfiles: %{_noautoprovfiles}}
1178 %__noautoprov           %(sed -e s'/#.*//' /etc/rpm/noautoprov) \
1179         %{?_noautoprov: %{_noautoprov}} \
1180         %{?_noautoprov_java: %{__noauto_regexp_helper -p java %{_noautoprov_java}}} \
1181         %{?_noautoprov_mono: %{__noauto_regexp_helper -p mono %{_noautoprov_mono}}} \
1182         %{?_noautoprov_pear: %{__noauto_regexp_helper -p pear %{_noautoprov_pear}}} \
1183         %{?_noautoprov_perl: %{__noauto_regexp_helper -p perl %{_noautoprov_perl}}} \
1184         %{?_noautoprov_pyegg: %{__noauto_regexp_helper -p pythonegg %{_noautoprov_pyegg}}} \
1185         %{?_noautoprov_py3egg: %{__noauto_regexp_helper -p python3egg %{_noautoprov_py3egg}}} \
1186         %{nil}
1187 %__noautoreq            %(sed -e s'/#.*//' /etc/rpm/noautoreq) \
1188         %{?_noautoreq: %{_noautoreq}} \
1189         %{?_noautoreqdep: %{_noautoreqdep}} \
1190         %{?_noautoreq_java: %{__noauto_regexp_helper -p java %{_noautoreq_java}}} \
1191         %{?_noautoreq_mono: %{__noauto_regexp_helper -p mono %{_noautoreq_mono}}} \
1192         %{?_noautoreq_pear: %{__noauto_regexp_helper -p pear %{_noautoreq_pear}}} \
1193         %{?_noautoreq_perl: %{__noauto_regexp_helper -p perl %{_noautoreq_perl}}} \
1194         %{?_noautoreq_pyegg: %{__noauto_regexp_helper -p pythonegg %{_noautoreq_pyegg}}} \
1195         %{?_noautoreq_py3egg: %{__noauto_regexp_helper -p python3egg %{_noautoreq_py3egg}}} \
1196         %{nil}
1197
1198 %__noautodep_helper() %(echo '%*' | awk 'BEGIN {
1199         RS = "\n([ \t]+\n)+";
1200         FS = " ";
1201 }
1202 {
1203         split($0, F);
1204         if (length(F) > 0) {
1205                 printf("(");
1206                 for (i=1; i<=length(F); i++) {
1207                         s = F[i];
1208                         sub(/#.*/, "z&z", s);
1209                         if (s ~ /^$/) { continue; };
1210                         printf(s);
1211                         if (i != length(F)) { printf("|"); };
1212                 };
1213                 printf(")");
1214         }
1215 }')
1216 %__requires_exclude_from        %{__noautodep_helper %{__noautoreqfiles}}%{nil}
1217 %__provides_exclude_from        %{__noautodep_helper %{__noautoprovfiles}}%{nil}
1218 %__requires_exclude                     %{__noautodep_helper %{__noautoreq}}%{nil}
1219 %__provides_exclude                     %{__noautodep_helper %{__noautoprov}}%{nil}
1220
1221 # helper for wrapping _noautoreq between perl() or pear()
1222 # Author: Elan Ruusamäe <glen@pld-linux.org>
1223 # Usage:
1224 # BuildRequires:        rpmbuild(macros) >= 1.654
1225 # %define _noautoreq_pear Excluded.php PEAR/Something.php
1226 # %define _noautoreq_perl Apache::.*
1227 # BuildRequires:        rpmbuild(macros) >= 1.672
1228 # %define _noautoreq_java ClassDataVersion
1229 # BuildRequires:        rpmbuild(macros) >= 1.709
1230 # %define _noautoreq_pyegg argparse
1231 # %define _noautoreq_py3egg backports.ssl-match-hostname ipaddress
1232 # BuildRequires:        rpmbuild(macros) >= 1.730
1233 # %define _noautoreq_mono Gendarme.Framework
1234 # BuildRequires:        rpmbuild(macros) >= 1.737
1235 # %define _noautoprov_java Class
1236 # %define _noautoprov_mono Excluded.Provide
1237 # %define _noautoprov_pear Excluded.php
1238 # %define _noautoprov_perl Excluded::Module
1239 # %define _noautoprov_pyegg excluded
1240 # %define _noautoprov_py3egg excluded3
1241 #
1242 %__noauto_regexp_helper(p:) %(echo '%*' | awk 'BEGIN{RS=" "}{printf("%{-p*}%{__qchar}(%%s%{__qchar}) ", $1)}')
1243 # detect quote character runtime
1244 %__qchar_4 \\\\%{nil}
1245 %__qchar_5 \\\\\\%{nil}
1246 %__qchar %{expand:%%global __qchar %%__qchar_%(echo %{_rpmversion} | cut -c1)}%__qchar
1247
1248 #%_noautocompressdoc    %{nil}
1249 #
1250 %_missing_doc_files_terminate_build     1%{nil}
1251 %_unpackaged_files_terminate_build      %{nil}
1252
1253 # node.js libdir
1254 # Requirements:
1255 # BuildRequires: rpmbuild(macros) >= 1.634
1256 %nodejs_libdir          /usr/lib/node_modules
1257
1258 # bash-completion 2.0 completions dir
1259 # Requirements:
1260 # BuildRequires:        rpmbuild(macros) >= 1.673
1261 # Requires:     bash-completion >= 2.0
1262 %bash_compdir           /usr/share/bash-completion/completions
1263
1264 # fish completions dir
1265 # Requirements:
1266 # BuildRequires:        rpmbuild(macros) >= 1.720
1267 %fish_compdir           /usr/share/fish/vendor_completions.d
1268
1269 # zsh completions dir
1270 # Requirements:
1271 # BuildRequires:        rpmbuild(macros) >= 1.719
1272 %zsh_compdir            /usr/share/zsh/site-functions
1273
1274 # depmod macro (since 1.184)
1275 %depmod() { \
1276 umask 022; \
1277 if [ -e /boot/System.map-%1 ]; then \
1278         /sbin/depmod -a -F /boot/System.map-%1 %1; \
1279 else \
1280         if [ -e /boot/System.map ]; then \
1281                 /sbin/depmod -a -F /boot/System.map %1; \
1282         else \
1283                 /sbin/depmod -a %1; \
1284         fi \
1285 fi; \
1286 }
1287
1288 # user/group checking macros (since 1.202)
1289 #
1290 # Usage:
1291 #       %userremove myuser
1292 #
1293 %userremove     /usr/lib/rpm/user_group.sh user del
1294 %groupremove    /usr/lib/rpm/user_group.sh group del
1295 #
1296 # Usage:
1297 #       if %usertestrm myuser; then
1298 #               /usr/sbin/userdel -r myuser
1299 # Note:
1300 #       use these macros only if you need to call userdel/groupdel with
1301 #       a non-standard option or take an extra action; otherwise use the
1302 #       %userremove/%groupremove macros
1303 #
1304 %usertestrm     /usr/lib/rpm/user_group.sh user testrm
1305 %grouptestrm    /usr/lib/rpm/user_group.sh group testrm
1306 # user group membership management macros
1307 #
1308 # Usage:
1309 #       %addusertogroup [-q] myuser agroup
1310 #
1311 #  -q if user or group don't exist, don't make big noise of it (MISSINGOK behaviour)
1312 #
1313 # Requirements:
1314 # BuildRequires:        rpmbuild(macros) >= 1.515
1315 %addusertogroup(q)      quiet=%{-q:1} /usr/lib/rpm/user_group.sh user addtogroup %*; \
1316 %{nil}
1317
1318 # banner support (useful in {pre,post}{,un} and triggers) (since 1.194)
1319 #
1320 # Usage:
1321 #       %banner name [-a] [-e] [-n] [-tn] [-o] <<EOF
1322 # the banner text, the banner text
1323 # the banner text, and following line
1324 #EOF
1325 # You can use any form of here-document, <<'EOF' <<-EOT will do.
1326 # NOTE: if your use "<<-EOF", then You can actually indent inside here-document.
1327 #
1328 # -a    - append to the banner
1329 # -e    - send to stderr instead of stdout
1330 # -n    - don't show banner (overrides -t)
1331 # -t    - show only, if RPM_SCRIPTVERBOSITY >= n; default n=5
1332 # -o    - show only once, i.e when package is installed for the first time (since 1.595)
1333 #
1334 # Tests:
1335 # (rpm -E '%banner -e banner <<EOF'; echo -e 'hi\nEOF') > m; sh -x m
1336 # (rpm -E '%banner -o -e banner <<EOF'; echo -e 'hi\nEOF') > m; sh -x m
1337 # (rpm -E '%banner -o -e banner <<EOF'; echo -e 'hi\nEOF') > m; sh -x m 1
1338 # rpm -E 'date | %banner -e banner' > m; sh -x m
1339 # rpm -E 'date | %banner -o -e banner' > m; sh -x m
1340 #
1341 %banner(aenot:) %{-o:([ "$1" != 1 ] ||} ( \
1342 RPM_SCRIPTVERBOSITY=5 \
1343 [ -r /etc/sysconfig/rpm ] && . /etc/sysconfig/rpm \
1344 if [ -x /usr/bin/banner.sh ]; then \
1345         CMD="/usr/bin/banner.sh %{-e:--stderr} %{!-n:$([ $RPM_SCRIPTVERBOSITY -ge %{-t:%{-t*}}%{!-t:5} ] && echo -s)} %{!-a:-m}%{-a:-M} %1" \
1346 else \
1347         CMD="cat%{-e: >&2}" \
1348 fi \
1349 eval $CMD %{?2:%2}%{?3: %3})%{-o:)} \
1350 %{nil}
1351
1352 # useradd/groupadd macros (since 1.202)
1353 # Author: Elan Ruusamäe <glen@pld-linux.org>
1354 #
1355 # Usage:
1356 #   %useradd [-P package] [-u uid] [-d home_dir] [-s shell] [-c comment]
1357 #   [-g initial_group] [-G group[,...]] login
1358 #
1359 #  -u uid. REQUIRED
1360 #  -g gid/group. REQUIRED
1361 #  -s defaults to /bin/false
1362 #  -d defaults to /usr/share/empty
1363 #  -c No default
1364 #  -r is accepted but ignored (it's always set)
1365 #  -k skeleton dir. defaults to /usr/share/empty
1366 # rpm specific flags
1367 #  -P package name. defaults to %{name}
1368 #
1369 %useradd(c:d:e:f:g:G:Mmk:op:s:u:rP:) \
1370 %{!-u:%{error:useradd: Required argument -u missing}} \
1371 %{!-g:%{error:useradd: Required argument -g missing}} \
1372 %{!?1:%{error:useradd: Required parameter login missing}} \
1373 if [ -n "`/bin/id -u %{expand:%{%{#}}} 2>/dev/null`" ]; then \
1374         if [ "`/bin/id -u %{expand:%{%{#}}}`" != "%{-u*}" ]; then \
1375                 echo "Error: user %{expand:%{%{#}}} doesn't have uid=%{-u*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
1376                 exit 1 \
1377         fi \
1378 else \
1379         echo "Adding user %{expand:%{%{#}}} UID=%{-u*}." \
1380         /usr/sbin/useradd \\\
1381                 %{-m:-m -k %{-k*}%{!-k:/usr/share/empty}} \\\
1382                 -u %{-u*} \\\
1383                 -r \\\
1384                 -d %{-d*}%{!-d:/usr/share/empty} \\\
1385                 -s %{-s*}%{!-s:/bin/false} \\\
1386                 %{-c:-c "%(set -- %{-c*} %{*}; echo $1)"}\\\
1387                 -g %{-g*} \\\
1388                 %{-M} \\\
1389                 %{-G:-G %{-G*}} \\\
1390                 %{expand:%{%{#}}} 1>&2 || exit $? \
1391         [ ! -x /usr/sbin/nscd ] || /usr/sbin/nscd -i passwd || : \
1392 fi;
1393 # vim: "
1394
1395 # Usage:
1396 #   %groupadd [-P package] [-g gid] group
1397 #
1398 # -g gid. REQUIRED
1399 #
1400 # Sample:
1401 #   %groupadd -P %{name}-base -g %{gid} %{name}
1402
1403 %groupadd(g:P:rfo)      \
1404 %{!-g:%{error:groupadd: Required argument -g missing}} \
1405 %{!?1:%{error:groupadd: Required parameter group missing}} \
1406 if /usr/bin/getgid %{1} > /dev/null 2>&1; then \
1407         if [ "`/usr/bin/getgid %{1}`" != "%{-g*}" ]; then \
1408                 echo "Error: group %{1} doesn't have gid=%{-g*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
1409                 exit 1 \
1410         fi \
1411 else \
1412         echo "Adding group %{1} GID=%{-g*}." \
1413         /usr/sbin/groupadd -g %{-g*} -r %{1} 1>&2 || exit $? \
1414         [ ! -x /usr/sbin/nscd ] || /usr/sbin/nscd -i group || : \
1415 fi;
1416
1417 # service macro.
1418 # Author: Elan Ruusamäe <glen@pld-linux.org>
1419 #
1420 # calls usual service restart on package %post, but skips the restart if
1421 # administrator has disabled automatic service restarts in either global
1422 # /etc/sysconfig/rpm or per service /etc/sysconfig/SERVICE file.
1423 # NOTE: systemd_booted machines do not print
1424 #               Run "{command}" to restart {service}.
1425 # message for packages without native systemd unit (not here, no %systemd_post).
1426 #
1427 # Usage:
1428 #   %service [-q] [-n] SERVICE ACTION ["SERVICE NICE DESCRIPTION"]
1429 #
1430 #  -q be silent when service isn't started (for scriplets restaring other package's services)
1431 #  -n NOOP mode, do not actually restart service
1432 #
1433 # Requirements:
1434 # BuildRequires:        rpmbuild(macros) >= 1.268
1435 # Requires:     rc-scripts
1436 # -n option:
1437 # BuildRequires:        rpmbuild(macros) >= 1.450
1438 %service(qn) {{%(export noop=%{-n:1} quiet=%{-q:1} RPM_BUILD_ROOT=%{buildroot}; /usr/lib/rpm/service_generator.sh %{*}) };}
1439
1440 %env_update [ ! -x /sbin/env-update ] || /sbin/env-update -u || :
1441
1442 # patchset macros
1443 # generate SourceX urls from range START STOP
1444 # Format can be SINGLE format char of %e, %f, %g, see seq(1)
1445 # The sources start from 10000
1446 #
1447 # Author: Elan Ruusamäe <glen@pld-linux.org>
1448 #
1449 # Usage:
1450 #   %patchset_source -f <seq(1) format> <start> [<end>]
1451 #   %patchset_patch <start> [<end>]
1452 # If <end> is omited, it is assumed to be <start>.
1453 #
1454 # For example in preamble:
1455 #  %patchset_source -f ftp://ftp.vim.org/pub/editors/vim/patches/7.0/7.0.%03g 33 44
1456 # and in %prep:
1457 #  %patchset_patch 33 44
1458 #
1459 # Using sources list:
1460 #   BuildRequires:      rpmbuild(macros) >= 1.426
1461 #   %patchset_source -f <url> -s <filelist>
1462 #   %patchset_patch -s <filelist>
1463 # For example (ncurses):
1464 #   BuildRequires:      rpmbuild(macros) >= 1.683
1465 #   %patchset_source -f ftp://dickey.his.com/ncurses/%{basever}/ -s sources
1466 #   %patchset_patch -s sources -p1
1467 #
1468
1469 %patchset_source(f:b:s:) %(
1470         base=%{-b*}%{!-b*:10000}
1471 %{-s:
1472         baseurl='%{-f*}'
1473         filelist='%{-s*}'
1474         i=$base
1475         while read checksum file; do
1476                 printf "Patch%d: %s%s\\n" $i "$baseurl" "$file"
1477                 i=$((i+1))
1478         done < $filelist
1479 }
1480 %{!-s:
1481         start=$(expr $base + %1);
1482         end=$(expr $base + %{?2}%{!?2:%{1}});
1483         # we need to call seq twice as it doesn't allow two formats
1484         seq -f 'Patch%g:' $start $end > %{_tmppath}/__ps1;
1485         seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{_tmppath}/__ps2;
1486         paste %{_tmppath}/__ps{1,2};
1487         rm -f %{_tmppath}/__ps{1,2};
1488 }
1489 ) \
1490 %{nil}
1491
1492 # apply sources from %patchset_source
1493 # -p specify -pX for %patch line
1494 # -b base offset: defaults to 10000
1495 # -s filelist to read files from
1496 %patchset_patch(f:p:b:s:) %(
1497         base=%{-b*}%{!-b*:10000}
1498         patchlevel=%{-p*:-p%{-p*}}
1499 %{-s:
1500         filelist='%{-s*}'
1501         i=$base
1502         while read checksum file; do
1503                 printf "patch%d %s\\n" $i "$patchlevel" | sed -e s,^,%%,
1504                 i=$((i+1))
1505         done < $filelist
1506 }
1507 %{!-s:
1508         start=$(expr $base + %1);
1509         end=$(expr $base + %{?2}%{!?2:%{1}});
1510         echo ": patchset_patch %1%{?2: to %2}";
1511         seq -f "patch%g $patchlevel" $start $end | sed -e s,^,%%,;
1512 }
1513 ) \
1514 %{nil}
1515
1516 # return EXPANDED source url N from current spec
1517 %sourceurl(n:) %(test "$IN_RPM" = 1 && exit 1; export IN_RPM=1; rpmbuild --nodigest --nosignature --nobuild -D "prep %%dump" %{_specdir}/%{name}.spec 2>&1 | awk '$2 ~ /^SOURCEURL%{-n*}/ {print $3}')
1518
1519 # Helper for LUA.
1520 # split string separated by space into quoted list
1521 #
1522 # Author: Elan Ruusamäe <glen@pld-linux.org>
1523 #
1524 # %__lua_split /bin/sh /bin/pdksh -> "/bin/sh", "/bin/pdksh"
1525 %__lua_split() %(echo "%*" | awk '{for (i=1;i<=NF;i++) printf("\\"%%s\\"%%s", $i, i == NF ? "" : ", ")}')
1526
1527 # adjust /etc/shells by adding and removing shells from there
1528 # Author: Elan Ruusamäe <glen@pld-linux.org>
1529 #
1530 # Usage:
1531 #   %post       -p <lua>
1532 #   %lua_add_etc_shells /bin/sh /bin/pdksh
1533 #
1534 #   %preun      -p <lua>
1535 #   if arg[2] == 0 then
1536 #       %lua_remove_etc_shells /bin/bash /bin/rbash
1537 #   end
1538 #
1539 # Requirements:
1540 # BuildRequires:        rpmbuild(macros) >= 1.462
1541 #
1542
1543 %lua_add_etc_shells() \
1544 t = {}\
1545 f = io.open("/etc/shells", "r")\
1546 if f then\
1547         for l in f:lines() do t[l]=l; end\
1548         f:close()\
1549 end\
1550 for _, s in ipairs({%{expand:%%__lua_split %*}}) do\
1551         if not t[s] then\
1552                 print("Adding "..s.." to /etc/shells")\
1553                 f = io.open("/etc/shells", "a")\
1554                 if f then\
1555                         f:write(s.."\\n")\
1556                         f:close()\
1557                 end\
1558         end\
1559 end\
1560 %{nil}
1561
1562 %lua_remove_etc_shells() \
1563 t = {}\
1564 f = io.open("/etc/shells", "r")\
1565 if f then\
1566         for l in f:lines() do t[l]=l; end\
1567         f:close()\
1568 end\
1569 for _, l in pairs({%{expand:%%__lua_split %*}}) do\
1570         print("Removing "..l.." from /etc/shells")\
1571         t[l] = nil\
1572 end\
1573 s=""\
1574 for _, l in pairs(t) do\
1575         s=s..l.."\\n"\
1576 end\
1577 f = io.open("/etc/shells", "w")\
1578 if f then\
1579         f:write(s)\
1580         f:close()\
1581 end\
1582 %{nil}
1583
1584 # Backwards compat. Use of %lua_ prefixed macros is preferred as these are cleaner to read.
1585 #
1586 # Author: Elan Ruusamäe <glen@pld-linux.org>
1587 #
1588 # Usage:
1589 #   %post       -p %add_etc_shells -p /bin/sh /bin/pdksh
1590 #   %preun      -p %remove_etc_shells -p /bin/sh /bin/pdksh
1591 #
1592 #  -p (optional) -- specifies that result is embeded %post script (prepends <lua> as first line)
1593 #
1594 # Requirements:
1595 # BuildRequires:        rpmbuild(macros) >= 1.429
1596 #
1597 %add_etc_shells(p) %{-p:<lua>}\
1598 %{expand:%%lua_add_etc_shells %*}\
1599 %{nil}
1600
1601 %remove_etc_shells(p) %{-p:<lua>}\
1602 %{-p:if arg[2] == 0 then}\
1603 %{expand:%%lua_remove_etc_shells %*}\
1604 %{-p:end} \
1605 %{nil}
1606
1607 # Undos files
1608 #
1609 # Author: Paweł Zuzelski <pawelz@pld-linux.org>
1610 # Author: Elan Ruusamäe <glen@pld-linux.org>
1611 #
1612 # Usage:
1613 #   %undos list_of_files
1614 #   %undos -f EXT[,EXT]
1615 #   %undos -i -f EXT[,EXT]
1616 #
1617 #  -f EXT[,EXT] - find(1) files by extensions
1618 #  -i - case insensitive file search
1619 #
1620 # Example:
1621 #   Un-DOS all *.js, *.css files
1622 #   %undos -f js,css
1623 #   Un-DOS all *.js, *.JS files
1624 #   %undos -f js -i
1625 #   undos all Makefiles
1626 #   %{__find} -name Makefile | xargs %undos
1627 #
1628 # Requirements:
1629 # BuildRequires:        sed >= 4.0
1630 # BuildRequires:        rpmbuild(macros) >= 1.674
1631
1632 # NB: make sure this macro stays on one line
1633 # NB: make sure it includes newline escape
1634 %undos(f:i)     %{-f:%{__find} -type f -regextype posix-extended -%{-i:i}regex '^.+\\.(%(echo %{-f*} | tr ',' '|'))$' -print0 | xargs -0} %{__sed} -i -e 's,\\r$,,' %* \
1635 %{nil}
1636
1637 #-----------------------------------------------------------------
1638 # Update hardware database index
1639 #
1640 # Requirements:
1641 # BuildRequires:        rpmbuild(macros) >= 1.691
1642 # Requires:             udev-core >= 1:196
1643
1644 %udev_hwdb_update() \
1645 /sbin/udevadm hwdb --update >/dev/null 2>&1 || : \
1646 %{nil}
1647
1648 # Generate vim help tags file
1649 #
1650 # Requirements:
1651 # BuildRequires:        rpmbuild(macros) >= 1.718
1652 # Requires(post,postun):        /usr/bin/vim
1653 # Requires(post,postun):        vim-rt >= 4:7.4.2054-2
1654 %vim_doc_helptags() \
1655 umask 022; \
1656 /usr/bin/vim -c ':helptags /usr/share/vim/doc' -c ':q' 2>/dev/null \
1657 %{nil}
This page took 0.152276 seconds and 3 git commands to generate.