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