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