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