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