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