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