]>
Commit | Line | Data |
---|---|---|
397b586d | 1 | # $Revision$, $Date$ |
415f4a1a | 2 | # PLD Linux rpm macros |
d54662bf | 3 | |
e05017c1 | 4 | %epoch 0 |
3241033b | 5 | %x8664 x86_64 amd64 ia32e |
9c404149 | 6 | |
ba1fdedc | 7 | # kernel compiler |
345d14e5 | 8 | %kgcc %{__cc} |
d2e1bc22 | 9 | %kgcc_package gcc |
ba1fdedc | 10 | |
46763914 ER |
11 | # compiler version |
12 | %cc_version %{expand:%%global cc_version %(%{__cc} -dumpversion || echo ERROR)}%cc_version | |
de629430 | 13 | %cxx_version %{expand:%%global cxx_version %(%{__cxx} -dumpversion || echo ERROR)}%cxx_version |
46763914 | 14 | |
36eccf0d ER |
15 | %__rm /bin/rm --interactive=never |
16 | ||
33040789 | 17 | # Build system path macros. |
18 | # | |
bddadece JB |
19 | %__autoconf autoconf %{?debug:-Wall} |
20 | %__automake automake -a -c -f --foreign | |
f93109a0 | 21 | %__autopoint autopoint --force |
22 | ||
83094b62 | 23 | %__gettextize { \ |
8a995cff | 24 | if grep -qs 'AM_GNU_GETTEXT.*external' configure.{ac,in} ; then \ |
3241033b | 25 | gettextize --copy --force --no-changelog; \ |
97589b6e | 26 | else \ |
3241033b | 27 | gettextize --copy --force --no-changelog --intl; \ |
8a995cff JB |
28 | fi; \ |
29 | if [ ! -f po/Makevars ]; then \ | |
3241033b | 30 | cp -f po/Makevars{.template,}; \ |
8a995cff | 31 | fi; \ |
8a995cff | 32 | } |
f93109a0 | 33 | |
34 | %__glib_gettextize glib-gettextize --copy --force | |
35 | %__gnome_doc_common gnome-doc-common --copy | |
fb59e475 | 36 | %__gnome_doc_prepare gnome-doc-prepare --copy --force |
f93109a0 | 37 | %__gtkdocize gtkdocize --copy |
38 | %__intltoolize intltoolize --copy --force | |
c26f1b59 | 39 | %__libtoolize libtoolize --copy --force --install |
33040789 | 40 | |
384e1b2b | 41 | # Path to top of build area. |
f5f7156a | 42 | %_topdir %{expand:%%global _topdir %(test -d ../SPECS -a -d ../SOURCES && (cd ..; pwd) || echo $HOME/rpm)}%_topdir |
384e1b2b | 43 | |
81e450f7 ER |
44 | # The number of cvs changelog entries kept when building package. |
45 | %_buildchangelogtruncate 20 | |
46 | ||
6a5eda77 | 47 | %dependencytracking %{nil} |
3241033b | 48 | |
e5da9169 ER |
49 | # Relations between package names that cause dependency loops |
50 | # with legacy packages that cannot be fixed. Relations are | |
51 | # specified as | |
52 | # p>q | |
53 | # where package p has a Requires: on something that package q Provides: | |
54 | # | |
55 | # XXX Note: that there cannot be any whitespace within the string "p>q", | |
56 | # and that both p and q are package names (i.e. no version/release). | |
57 | %_dependency_whiteout %{nil} | |
58 | ||
7bf0526c AM |
59 | %_smp_mflags %([ -z "$RPM_BUILD_NCPUS" ] \\\ |
60 | && RPM_BUILD_NCPUS="`/usr/bin/getconf _NPROCESSORS_ONLN`"; \\\ | |
61 | [ "$RPM_BUILD_NCPUS" -gt 1 ] && echo "-j$RPM_BUILD_NCPUS") | |
810fa5c4 | 62 | |
63 | #----------------------------------------------------------------- | |
64 | # | |
65 | # (re)definition of %{rpm*flags} with %filterout_* support | |
b5e977c5 ER |
66 | # BuildRequires: awk |
67 | # BuildRequires: rpmbuild(macros) >= 1.315 | |
810fa5c4 | 68 | # |
69 | # Flags specified in %filterout_* are removed from %rpm*flags, exactly: | |
09a90176 | 70 | # %rpmcflags = %optflags - %filterout - %filterout_c - %filterout_ld |
71 | # %rpmcxxflags = %optflags - %filterout - %filterout_cxx - %filterout_ld | |
72 | # %rpmldflags = %optldflags - %filterout_ld | |
810fa5c4 | 73 | # |
74 | # Regular expressions are supported, but to avoid some character be treated | |
75 | # as regular expression it must be escaped twice. | |
76 | ||
77 | %filter_out \ | |
7b6f1112 | 78 | for (i = 1; i in I; i++) { A=0; \ |
810fa5c4 | 79 | for (f in F) { \ |
80 | if (I[i] ~ "^" F[f] "$") A=1; \ | |
81 | }; \ | |
82 | if (!A) printf(I[i] FS); \ | |
83 | } | |
84 | ||
85 | %rpmcflags %(awk 'BEGIN { | |
86 | split("%{?debug:%debugcflags}%{!?debug:%optflags}%{?debuginfocflags}",I); | |
09a90176 | 87 | split("%{?filterout} %{?filterout_c} %{?filterout_ld}",F); |
810fa5c4 | 88 | %{filter_out} |
89 | }') | |
90 | ||
91 | %rpmcxxflags %(awk 'BEGIN { | |
09a90176 | 92 | split("%{?debug:%debugcflags}%{!?debug:%optflags}%{?debuginfocflags}",I); |
93 | split("%{?filterout} %{?filterout_cxx} %{?filterout_ld}",F); | |
810fa5c4 | 94 | %{filter_out} |
95 | }') | |
96 | ||
97 | %rpmldflags %(awk 'BEGIN { | |
c05a0741 | 98 | split("%{?optldflags}",I); |
810fa5c4 | 99 | split("%{?filterout_ld}",F) |
100 | %{filter_out} | |
101 | }') | |
102 | ||
25f52d1a | 103 | # rpmldflags with stripped -Wl, -- in the form flags have to be passed to 'ld' |
104 | # but, don't use it, better use gcc as linker | |
105 | %ld_rpmldflags %(awk 'BEGIN { | |
106 | split("%{rpmldflags}",F); | |
107 | for (f in F) { | |
108 | s = F[f]; | |
109 | if (s ~ /^-Wl,/) { | |
110 | s = substr(s,5); | |
111 | gsub(/,/," ",s); | |
112 | }; | |
113 | printf(s FS); | |
114 | }; | |
115 | }') | |
116 | ||
9c404149 | 117 | #----------------------------------------------------------------- |
9f4ce098 | 118 | %configure2_13 { \ |
9c404149 AM |
119 | if [ -n "$LINGUAS" ]; then unset LINGUAS; fi; \ |
120 | LDFLAGS="${LDFLAGS:-%rpmldflags}" ; export LDFLAGS ; \ | |
121 | CFLAGS="${CFLAGS:-%rpmcflags}" ; export CFLAGS ; \ | |
f4cc8832 | 122 | CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" ; export CXXFLAGS ; \ |
9c404149 | 123 | FFLAGS="${FFLAGS:-%rpmcflags}" ; export FFLAGS ; \ |
e9d801f4 | 124 | FCFLAGS="${FCFLAGS:-%rpmcflags}" ; export FCFLAGS ; \ |
8ec1a12b | 125 | CPPFLAGS="${CPPFLAGS:-}" ; export CPPFLAGS ; \ |
8983c4c4 AM |
126 | %{?__cc:CC="%{__cc}" ; export CC ; } \ |
127 | %{?__cxx:CXX="%{__cxx}" ; export CXX ; } \ | |
8f74418b | 128 | %{?configuredir:%{configuredir}}%{!?configuredir:.}/configure \ |
2a7cfd3f | 129 | --host=%{_target_platform} \ |
9c404149 AM |
130 | --prefix=%{_prefix} \ |
131 | --exec-prefix=%{_exec_prefix} \ | |
132 | --bindir=%{_bindir} \ | |
133 | --sbindir=%{_sbindir} \ | |
134 | --sysconfdir=%{_sysconfdir} \ | |
135 | --datadir=%{_datadir} \ | |
136 | --includedir=%{_includedir} \ | |
137 | --libdir=%{_libdir} \ | |
138 | --libexecdir=%{_libexecdir} \ | |
139 | --localstatedir=%{_localstatedir} \ | |
140 | --sharedstatedir=%{_sharedstatedir} \ | |
141 | --mandir=%{_mandir} \ | |
142 | --infodir=%{_infodir} \ | |
b6c5da52 | 143 | --x-libraries=%{?_x_libraries}%{!?_x_libraries:%{_libdir}} \ |
93059874 | 144 | %{dependencytracking} \ |
9c404149 AM |
145 | } |
146 | ||
89f4ca1f ER |
147 | # override __cmake to add -j4 in your ~/.rpmmacros for parallel make |
148 | %__cmake /usr/bin/cmake | |
39b9534b ER |
149 | %cmake { \ |
150 | CC="%{__cc}" \ | |
151 | CXX="%{__cxx}" \ | |
152 | CFLAGS="%{rpmcflags}" \ | |
153 | CXXFLAGS="%{rpmcxxflags}" \ | |
89f4ca1f ER |
154 | %{__cmake} \ |
155 | } | |
156 | ||
157 | # override __scons to add -j4 in your ~/.rpmmacros for parallel make | |
158 | %__scons /usr/bin/scons | |
159 | %scons { \ | |
160 | %{__scons} \ | |
5c76736d ER |
161 | LDFLAGS="${LDFLAGS:-%rpmldflags}" \ |
162 | CFLAGS="${CFLAGS:-%rpmcflags}" \ | |
163 | CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" \ | |
164 | FFLAGS="${FFLAGS:-%rpmcflags}" \ | |
165 | CPPFLAGS="${CPPFLAGS:-}" \ | |
166 | %{?__cc:CC="%{__cc}"} \ | |
167 | %{?__cxx:CXX="%{__cxx}"} \ | |
168 | libsuffix=%{_lib} \ | |
169 | prefix=%{_prefix} \ | |
39b9534b ER |
170 | } |
171 | ||
6339d32d | 172 | # waf. see waf.spec |
89f4ca1f | 173 | # override __waf to add -j4 in your ~/.rpmmacros for parallel make |
6339d32d ER |
174 | %__waf /usr/bin/waf |
175 | %waf { \ | |
6339d32d ER |
176 | CC="%{__cc}" \ |
177 | CXX="%{__cxx}" \ | |
9e244007 | 178 | CPP="%{__cpp}" \ |
6339d32d ER |
179 | CFLAGS="%{rpmcflags}" \ |
180 | CXXFLAGS="%{rpmcxxflags}" \ | |
181 | %{__waf} \ | |
6339d32d ER |
182 | } |
183 | ||
4a6b0d54 | 184 | #---------------------------------------------------------------- |
9bacbb5b | 185 | #%configure_cache 0 |
fe6c4bdd | 186 | %configure_cache_file %{buildroot}.configure.cache |
73f832b3 | 187 | |
57f4166d | 188 | %configure {./configure \ |
4a6b0d54 AF |
189 | LDFLAGS="${LDFLAGS:-%rpmldflags}" \ |
190 | CFLAGS="${CFLAGS:-%rpmcflags}" \ | |
f4cc8832 | 191 | CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" \ |
4a6b0d54 | 192 | FFLAGS="${FFLAGS:-%rpmcflags}" \ |
e9d801f4 | 193 | FCFLAGS="${FCFLAGS:-%rpmcflags}" \ |
a2bd5992 | 194 | CPPFLAGS="${CPPFLAGS:-}" \ |
8983c4c4 AM |
195 | %{?__cc:CC="%{__cc}"} \ |
196 | %{?__cxx:CXX="%{__cxx}"} \ | |
8e4cb85a | 197 | --host=%{_target_platform} \ |
4a6b0d54 AF |
198 | --build=%{_target_platform} \ |
199 | --prefix=%{_prefix} \ | |
200 | --exec-prefix=%{_exec_prefix} \ | |
201 | --bindir=%{_bindir} \ | |
202 | --sbindir=%{_sbindir} \ | |
203 | --sysconfdir=%{_sysconfdir} \ | |
204 | --datadir=%{_datadir} \ | |
205 | --includedir=%{_includedir} \ | |
206 | --libdir=%{_libdir} \ | |
207 | --libexecdir=%{_libexecdir} \ | |
208 | --localstatedir=%{_localstatedir} \ | |
209 | --sharedstatedir=%{_sharedstatedir} \ | |
210 | --mandir=%{_mandir} \ | |
211 | --infodir=%{_infodir} \ | |
b6c5da52 | 212 | --x-libraries=%{?_x_libraries}%{!?_x_libraries:%{_libdir}} \ |
93059874 | 213 | %{dependencytracking} \ |
9bacbb5b | 214 | %{?configure_cache:--cache-file=%{configure_cache_file}} \ |
4a6b0d54 AF |
215 | } |
216 | ||
b3b1397b ER |
217 | # overload to insert debuginfo package |
218 | %prep \ | |
219 | %if 0%{?_enable_debug_packages}\ | |
220 | %{debug_package}\ | |
221 | %endif\ | |
222 | %%prep\ | |
223 | %{nil} | |
224 | ||
9c404149 | 225 | # Location of autoconf macros |
7f0f4a79 | 226 | %_aclocaldir %{expand:%%global _aclocaldir %(aclocal --print-ac-dir || echo ERROR)}%_aclocaldir |
9c404149 | 227 | |
e2804f99 | 228 | # Location of omf files |
7f0f4a79 | 229 | %_omf_dest_dir %{expand:%%global _omf_dest_dir %(scrollkeeper-config --omfdir || echo ERROR)}%_omf_dest_dir |
e2804f99 | 230 | |
e987a186 | 231 | # Location of pkgconfig files |
9a4e877a | 232 | %_pkgconfigdir /usr/%{_lib}/pkgconfig |
36219c36 JB |
233 | # noarch pkgconfig files |
234 | %_npkgconfigdir /usr/share/pkgconfig | |
e987a186 | 235 | |
486b0b5f | 236 | # Location of desktop files |
237 | %_desktopdir /usr/share/applications | |
86dff2d0 | 238 | %_applnkdir ERROR:_applnkdir_is_obsolete_use_desktopdir_instead |
486b0b5f | 239 | |
481463e9 | 240 | # Location of pixmaps for applnk/desktop files |
e1f0a822 | 241 | %_pixmapsdir /usr/share/pixmaps |
9c404149 | 242 | |
481463e9 | 243 | # Location of themable icons for applnk/desktop files |
b36c8e2a | 244 | %_iconsdir /usr/share/icons |
245 | ||
e987a186 JB |
246 | # Location of fonts directories |
247 | %_fontsdir /usr/share/fonts | |
248 | ||
b3282f3f | 249 | # Location of Gtk and associated libraries documentation |
fe6c4bdd | 250 | %_gtkdocdir %{_defaultdocdir}/gtk-doc/html |
b3282f3f | 251 | |
fc4d7771 | 252 | # Location of KDE documentation |
fe6c4bdd | 253 | %_kdedocdir %{_defaultdocdir}/kde/HTML |
fc4d7771 | 254 | |
5869828c | 255 | # unsermake script |
256 | %__unsermake /usr/share/unsermake/unsermake | |
257 | ||
9c404149 AM |
258 | # Current date |
259 | %date %(LC_ALL="C" date +"%a %b %d %Y") | |
260 | ||
9c404149 AM |
261 | # Example files, programs, scripts... |
262 | %_examplesdir /usr/src/examples | |
263 | ||
c8f7e820 | 264 | # Alternative kernel type/version |
261729d9 | 265 | %_alt_kernel %{nil}%{?alt_kernel:-%{?alt_kernel}} |
c8f7e820 | 266 | |
8377d27d | 267 | # The directory holding Linux kernel sources |
261729d9 | 268 | %_kernelsrcdir /usr/src/linux%{_alt_kernel} |
8377d27d | 269 | |
9c404149 | 270 | # If non-empty "debug" macro defined, add "dbg" suffix to release number |
8f74418b | 271 | %_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}%{?debug:dbg}.%%{ARCH}.rpm |
9c404149 | 272 | |
8f74418b | 273 | # Requires name = version-release |
d514eecd | 274 | %requires_releq() %(echo '%*' | LC_ALL="C" xargs -r rpm -q --qf 'Requires: %{N} = %|E?{%{E}:}|%{V}-%{R}\\n' | grep -v 'is not') |
8bf3719d | 275 | |
f5f7156a ER |
276 | %releq_kernel %{expand:%%global releq_kernel %(R=$(LC_ALL=C rpm -q --qf '%{N} = %|E?{%{E}:}|%{V}-%{R}' -f %{_kernelsrcdir}/include/linux/version.h 2>/dev/null | grep -v 'is not' | sed -e 's:-headers::;s:-config::'); echo ${R:-ERROR})}%releq_kernel |
277 | %releq_kernel_up %{expand:%%global releq_kernel_up %(R=$(LC_ALL=C rpm -q --qf '%{N}-up = %|E?{%{E}:}|%{V}-%{R}' -f %{_kernelsrcdir}/include/linux/version.h 2>/dev/null | grep -v 'is not' | sed -e 's:-headers::;s:-config::'); echo ${R:-ERROR})}%releq_kernel_up | |
278 | %releq_kernel_smp() %{expand:%%global releq_kernel_smp %(R=$(LC_ALL=C rpm -q --qf '%{N}-smp = %|E?{%{E}:}|%{V}-%{R}' -f %{_kernelsrcdir}/include/linux/version.h 2>/dev/null | grep -v 'is not' | sed -e 's:-headers::;s:-config::'); echo ${R:-ERROR})}%releq_kernel_smp | |
730239f9 ER |
279 | %requires_releq_kernel(s:) Requires%{-s:(%{-s*})}: %releq_kernel |
280 | %requires_releq_kernel_up(s:) Requires%{-s:(%{-s*})}: %releq_kernel_up | |
281 | %requires_releq_kernel_smp(s:) Requires%{-s:(%{-s*})}: %releq_kernel_smp | |
8bf3719d | 282 | |
d514eecd ER |
283 | # XXX: why epoch 0 is stripped? |
284 | %requires_eq() %(echo '%*' | LC_ALL="C" xargs -r rpm -q --qf 'Requires: %{N} = %|E?{%{E}:}|%{V}\\n' | sed -e 's/ 0:/ /' | grep -v 'is not') | |
285 | %requires_eq_to() %(LC_ALL="C" rpm -q --qf 'Requires: %1 = %|E?{%{E}:}|%{V}' %2 | grep -v "is not") | |
01a9f990 | 286 | |
c94807f3 | 287 | %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 | 288 | |
289 | # kernel version-release handling | |
95125403 ER |
290 | %__kernel_ver %{expand:%%global __kernel_ver %( \\ |
291 | Z=$(awk -F'"' '/UTS_RELEASE/{print $2}' %{_kernelsrcdir}/include/linux/{version,utsrelease}.h 2>/dev/null); \\ | |
292 | Z=${Z:-$(awk -F' = ' '/^VERSION/{v=$2} /^PATCHLEVEL/{p=$2} /^SUBLEVEL/{s=$2} /^EXTRAVERSION/{e=$2} END {printf("%d.%d.%d%s", v, p, s, e)}' %{_kernelsrcdir}/Makefile 2>/dev/null)}; \\ | |
293 | echo ${Z:-ERROR}; \\ | |
1a7d3518 | 294 | )}%__kernel_ver |
95125403 | 295 | |
c94807f3 ER |
296 | %__kernel_rel %{expand:%%global __kernel_rel %(Z=$(LC_ALL=C rpm -qf %{_kernelsrcdir}/include/linux/fs.h 2>/dev/null --qf "%{R}" | grep -v "is not"); echo ${Z:-ERROR})}%__kernel_rel |
297 | %__kernel_rpmvr %{expand:%%global __kernel_rpmvr %(Z=$(LC_ALL=C rpm -qf %{_kernelsrcdir}/include/linux/fs.h 2>/dev/null --qf "%{V}-%{R}" | grep -v "is not"); echo ${Z:-ERROR})}%__kernel_rpmvr | |
298 | %_kernel_ver %{expand:%%global _kernel_ver %{__kernel_ver}%{?with_dist_kernel:%(echo %{__kernel_ver} | grep -q -e - || echo -%{__kernel_rel})}}%_kernel_ver | |
299 | %_kernel_ver_str %{expand:%%global _kernel_ver_str %(echo %{!?_without_dist_kernel:%{__kernel_rpmvr}}%{?_without_dist_kernel:%{__kernel_ver}} | sed -e 's/-/_/g')}%_kernel_ver_str | |
87be1cf0 | 300 | |
6262f001 ER |
301 | # `uname -r` to be used in @release field |
302 | %_kernel_vermagic %{expand:%%global _kernel_vermagic %(echo %{_kernel_ver} | sed -e 's/-/_/g')}%_kernel_vermagic | |
303 | ||
e00dd7f6 | 304 | # sgml macros |
3241033b ER |
305 | %xmlcat_add() /usr/bin/xmlcatalog --noout --add nextCatalog \"\" %1 /etc/xml/catalog ; |
306 | %xmlcat_del() /usr/bin/xmlcatalog --noout --del %1 /etc/xml/catalog ; | |
307 | %xmlcat_add_rewrite /usr/bin/xmlcatalog --noout --add rewriteSystem | |
308 | %xmlcat_create() /usr/bin/xmlcatalog --noout --create %1 ; | |
309 | %sgmlcat_add() /usr/bin/install-catalog --add %1 %2 > /dev/null ; | |
310 | %sgmlcat_del() /usr/bin/install-catalog --remove %1 %2 > /dev/null ; | |
e00dd7f6 | 311 | %docbook_sgmlcat_fix() { for l in \ |
312 | '' \ | |
313 | ' -- default decl --' \ | |
314 | 'DTDDECL "-//OASIS//DTD DocBook XML V%2//EN" "../../xml.dcl"' \ | |
315 | ' -- hacks for opensp --' \ | |
316 | 'SYSTEM "file://%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \ | |
317 | 'SYSTEM "http://www.oasis-open.org/docbook/xml/%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \ | |
318 | '' \ | |
319 | ; do echo $l; done >> %1 \ | |
320 | } | |
321 | ||
eea64748 ER |
322 | # vim - " |
323 | ||
4f044018 ER |
324 | # minimum file size needed for compressed documents. |
325 | # just smaller files than this get larger when compressed. | |
a88ae20f ER |
326 | # some stats: |
327 | # - 0 byte file compressed was 25 bytes .gz | |
328 | # - 39 byte file was compressed as 57 | |
329 | # - with test/test.spec@man 158 byte file was compressed also 158 | |
330 | %_min_compress_bytes 159 | |
4f044018 | 331 | |
9c404149 AM |
332 | #----------------------------------------------------------------- |
333 | # find and gzip all files in %{_mandir} and %{infodir} | |
334 | # | |
335 | # Requires: xargs, find | |
336 | # | |
337 | #%no_install_post_compress_docs 1 | |
338 | %__spec_install_post_compress_docs { \ | |
53d5af13 | 339 | %{!?no_install_post_compress_docs:__spec_install_post_compress_docs() { \ |
4e10ec06 | 340 | for i in /usr/share/man /usr/X11R6/man; do \ |
9c404149 | 341 | if [ -d "$RPM_BUILD_ROOT$i" ]; then \ |
4e10ec06 | 342 | echo "Compress man pages: $i"; \ |
4f044018 ER |
343 | find "$RPM_BUILD_ROOT$i" -name '*.bz2' -print | xargs -r %{__bzip2} -df; \ |
344 | find "$RPM_BUILD_ROOT$i" -name '*.gz' -print | xargs -r %{__gzip} -dnf; \ | |
6375241c ER |
345 | find $RPM_BUILD_ROOT$i -type l | while read a; do \ |
346 | m=$(readlink $a); \ | |
347 | rm -f $a; \ | |
348 | echo .so ${m##*/} > $a; \ | |
349 | echo >&2 "Converted ${a#$RPM_BUILD_ROOT} from symlink to man link: ${m##*/}"; \ | |
350 | done; \ | |
4f044018 | 351 | find "$RPM_BUILD_ROOT$i" -type f -size +%{_min_compress_bytes}c -print | xargs -r %{__gzip} -9nf; \ |
9c404149 AM |
352 | fi; \ |
353 | done; \ | |
728ad671 JB |
354 | if [ -d "$RPM_BUILD_ROOT%{_infodir}" ]; then \ |
355 | echo "Compress info pages: %{_infodir}"; \ | |
356 | find "$RPM_BUILD_ROOT%{_infodir}" -name '*.bz2' -print | xargs -r %{__bzip2} -df; \ | |
357 | find "$RPM_BUILD_ROOT%{_infodir}" -name '*.gz' -print | xargs -r %{__gzip} -dnf; \ | |
358 | find "$RPM_BUILD_ROOT%{_infodir}" -name '*.info*' -type f -size +%{_min_compress_bytes}c -print | xargs -r %{__gzip} -9nf; \ | |
4e10ec06 | 359 | fi; \ |
53d5af13 | 360 | }; __spec_install_post_compress_docs } } |
9c404149 AM |
361 | |
362 | #----------------------------------------------------------------- | |
363 | # Strip executable binaries and shared object files | |
364 | # | |
365 | # Requires: find, awk, strip, cut, xargs | |
366 | # | |
a2ad2754 JB |
367 | # Special macros which affect this process: |
368 | #%no_install_post_strip 1 # disable stripping at all | |
369 | #%_noautostrip regexp # exclude files matching (anchored!) regex from stripping | |
370 | #%_autostripall regexp # strip files matching (anchored!) regex using plain strip | |
371 | #%_autostripunneeded regexp # strip files matching (anchored!) regex using strip --strip-unneeded | |
372 | #%_autostripdebug regexp # strip files matching (anchored!) regex using strip --strip-debug | |
373 | # | |
9c404149 | 374 | %__spec_install_post_strip {%{!?debug: \ |
53d5af13 | 375 | %{!?no_install_post_strip:__spec_install_post_strip() { \ |
98a06bad | 376 | if [ -d "$RPM_BUILD_ROOT" ]; then \ |
eea64748 ER |
377 | if [ -d $RPM_BUILD_ROOT/lib/modules ]; then \ |
378 | modulelist=$(find $RPM_BUILD_ROOT/lib/modules -name '*o' -type f -print); \ | |
4d5370ac ER |
379 | if [ "$modulelist" ]; then \ |
380 | modulecount=$(echo "$modulelist" | wc -l); \ | |
737fefdc | 381 | printf "Stripping %d kernel modules..." $modulecount; \ |
3df8db34 ER |
382 | echo "$modulelist" | xargs -l512 chmod u+w; \ |
383 | echo "$modulelist" | xargs -l512 %{__strip} --strip-unneeded --remove-section=.comment --remove-section=.note.GNU-stack; \ | |
384 | echo "DONE"; \ | |
385 | fi; \ | |
eea64748 | 386 | fi; \ |
0ac49134 | 387 | filelist=$(find $RPM_BUILD_ROOT -type f ! -regex ".*/usr/lib[0-9]*/debug/.*\.debug" ! -regex ".*/lib/modules/.*" ! -regex ".*%{_docdir}/.*" ! -regex ".*%{_includedir}/.*" %{?_noautostrip:! -regex "%{_noautostrip}"} %{?_autostripall:! -regex "%{_autostripall}"} %{?_autostripunneeded:! -regex "%{_autostripunneeded}"} %{?_autostripdebug:! -regex "%{_autostripdebug}"}); \ |
f89ccb5f JB |
388 | if [ -n "$filelist" ]; then \ |
389 | filetypes=`echo "$filelist" | xargs -r -d'\\n' file`; \ | |
390 | elfexelist=`echo "$filetypes" | awk -F: '/ELF.*executable/ {print $1}'`; \ | |
391 | elfsharedlist=`echo "$filetypes" | awk -F: '/LF.*shared object/ {print $1}'`; \ | |
a2ad2754 | 392 | archiveslist=`echo "$filetypes" | awk -F: '/current ar archive/ {print $1}'`; \ |
f89ccb5f | 393 | if [ -n "$elfexelist" ]; then \ |
4d5370ac | 394 | printf "Stripping %d ELF executables..." $(echo "$elfexelist" | wc -l); \ |
f89ccb5f JB |
395 | chmod u+w $elfexelist; \ |
396 | %{__strip} --remove-section=.note --remove-section=.comment $elfexelist; \ | |
397 | echo "DONE"; \ | |
398 | fi; \ | |
399 | if [ -n "$elfsharedlist" ]; then \ | |
4d5370ac | 400 | printf "Stripping %d ELF shared libraries..." $(echo "$elfsharedlist" | wc -l); \ |
f89ccb5f JB |
401 | chmod u+w $elfsharedlist; \ |
402 | %{__strip} --strip-unneeded --remove-section=.note --remove-section=.comment $elfsharedlist; \ | |
403 | echo "DONE"; \ | |
404 | fi; \ | |
405 | if [ -n "$archiveslist" ]; then \ | |
4d5370ac | 406 | printf "Stripping %d ar archives..." $(echo "$archiveslist" | wc -l); \ |
f89ccb5f JB |
407 | chmod u+w $archiveslist; \ |
408 | %{__strip} --strip-debug --remove-section=.note --remove-section=.comment $archiveslist; \ | |
409 | echo "DONE"; \ | |
410 | fi; \ | |
98a06bad | 411 | fi; \ |
0ac49134 ER |
412 | filelist_all=%{?_autostripall:$(find $RPM_BUILD_ROOT -type f -regex "%{_autostripall}")}; \ |
413 | filelist_unneeded=%{?_autostripunneeded:$(find $RPM_BUILD_ROOT -type f -regex "%{_autostripunneeded}")}; \ | |
414 | filelist_debug=%{?_autostripdebug:$(find $RPM_BUILD_ROOT -type f -regex "%{_autostripdebug}")}; \ | |
f89ccb5f | 415 | if [ -n "$filelist_all" ]; then \ |
4d5370ac | 416 | printf "Stripping everything from %d additional files..." $(echo "$filelist_all" | wc -l); \ |
a2ad2754 | 417 | chmod u+w $filelist_all; \ |
f89ccb5f | 418 | %{__strip} --remove-section=.note --remove-section=.comment $filelist_all; \ |
322f84b9 | 419 | echo "DONE"; \ |
9c404149 | 420 | fi; \ |
f89ccb5f | 421 | if [ -n "$filelist_unneeded" ]; then \ |
4d5370ac | 422 | printf "Stripping unneeded from %d additional files..." $(echo "$filelist_unneeded" | wc -l); \ |
a2ad2754 | 423 | chmod u+w $filelist_unneeded; \ |
f89ccb5f | 424 | %{__strip} --strip-unneeded --remove-section=.note --remove-section=.comment $filelist_unneeded; \ |
322f84b9 | 425 | echo "DONE"; \ |
8f74418b | 426 | fi; \ |
f89ccb5f | 427 | if [ -n "$filelist_debug" ]; then \ |
4d5370ac | 428 | printf "Stripping debuginfo from %d additional files..." $(echo "$filelist_debug" | wc -l); \ |
a2ad2754 | 429 | chmod u+w $filelist_debug; \ |
f89ccb5f | 430 | %{__strip} --strip-debug --remove-section=.note --remove-section=.comment $filelist_debug; \ |
322f84b9 | 431 | echo "DONE"; \ |
9f0d4f36 | 432 | fi; \ |
53d5af13 | 433 | fi; }; __spec_install_post_strip } } } |
3241033b | 434 | |
fc5d7e20 | 435 | #----------------------------------------------------------------- |
436 | # remove all RPATH from executable binaries and shared object files | |
437 | # | |
438 | # Requires: find, awk, cut, xargs, chrpath, uname | |
439 | # | |
a2ad2754 JB |
440 | # Special macros which affect this process |
441 | #%no_install_post_chrpath 1 # disable chrpath at all | |
442 | #%_noautochrpath regex # exclude files matching (anchored!) regex from chrpath | |
443 | # | |
fc5d7e20 | 444 | %__spec_install_post_chrpath {%{!?debug: \ |
53d5af13 | 445 | %{!?no_install_post_chrpath: __spec_install_post_chrpath() { \ |
9f0d4f36 | 446 | if [ -d "$RPM_BUILD_ROOT" ]; then \ |
0ac49134 | 447 | 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 | 448 | if [ -n "$files" ]; then \ |
d5517264 | 449 | objs=`echo "$files" | xargs -r -d'\\n' file | awk -F: '/ELF.*(executable.*dynamically linked|shared object)/ {print $1}'`; \ |
3401a2cd | 450 | fi; \ |
98a06bad | 451 | if [ -n "$objs" ]; then \ |
4d5370ac | 452 | printf "Remove RPATH from %d executable binaries and shared object files.\n" $(echo "$objs" | wc -l); \ |
98a06bad ER |
453 | echo "$objs" | \ |
454 | while read file; do \ | |
455 | rpath= ; \ | |
456 | chmod u+w "$file"; \ | |
5541bf26 | 457 | for dir in $(chrpath -l "$file" | awk '/RPATH=/ { gsub(/.*RPATH=/,""); gsub(/:/," "); print $0 }'); do \ |
eda6b510 AM |
458 | case $dir in \ |
459 | '$ORIGIN' ) \ | |
460 | if [ "$rpath" = "" ] ; then rpath="$dir" ; \ | |
461 | else rpath="$rpath:$dir" ; fi ; \ | |
462 | continue ; \ | |
463 | ;; \ | |
464 | esac ; \ | |
f9abaddb AM |
465 | newdir=$(readlink -m "$dir"); \ |
466 | [ ${#newdir} -le ${#dir} ] && dir=$newdir; \ | |
98a06bad ER |
467 | case $dir in \ |
468 | /home/* | /tmp/* | /usr/lib | /usr/lib64 | /lib | /lib64 | /usr/local/lib | /usr/local/lib64 | /usr/X11R6/lib | /usr/X11R6/lib64 ) \ | |
469 | echo "remove-rpath: $dir in $file"; \ | |
470 | ;; \ | |
471 | * ) \ | |
472 | if [ "$rpath" = "" ] ; then rpath="$dir" ; \ | |
473 | else rpath="$rpath:$dir" ; fi ; \ | |
474 | ;; \ | |
475 | esac ; \ | |
476 | done ; \ | |
477 | if [ "$rpath" = "" ] ; then chrpath -d "$file" > /dev/null ; \ | |
478 | else chrpath -r "$rpath" "$file" > /dev/null ; fi ; \ | |
479 | done; \ | |
480 | fi; \ | |
53d5af13 | 481 | fi; }; __spec_install_post_chrpath } } } |
3241033b | 482 | |
d72c185f | 483 | #----------------------------------------------------------------- |
ccb8ae8d | 484 | # Find and gzip all kernel modules |
485 | # | |
486 | # Requires: find | |
487 | # | |
fe6c4bdd | 488 | #%no_install_post_compress_modules 1 |
ccb8ae8d | 489 | %__spec_install_post_compress_modules { \ |
53d5af13 | 490 | %{!?no_install_post_compress_modules: __spec_install_post_compress_modules() { \ |
f3bfe4ac | 491 | if [ -d $RPM_BUILD_ROOT/lib/modules ]; then \ |
f3bfe4ac | 492 | q=$(find $RPM_BUILD_ROOT/lib/modules -name '*o' -type f -print); \ |
4d5370ac ER |
493 | if [ "$q" ]; then \ |
494 | printf "Compress %d kernel modules..." $(echo "$q" | wc -l); \ | |
495 | echo "$q" | xargs -r %{__gzip} -9nf; \ | |
496 | echo "DONE"; \ | |
497 | find $RPM_BUILD_ROOT/lib/modules -name '*o' -type l -printf "%p %l\n" | \ | |
498 | while read a b; do ln -sf $b.gz $a.gz; rm -f $a; done; \ | |
499 | fi; \ | |
3241033b | 500 | fi; \ |
53d5af13 | 501 | }; __spec_install_post_compress_modules } } |
9c404149 | 502 | |
ef64802f ER |
503 | # Remove common Perl files we don't package |
504 | %__spec_install_post_perl_clean {\ | |
505 | %{!?no_install_post_perl_clean: \ | |
506 | %{?pdir:rm -f $RPM_BUILD_ROOT{%{perl_archlib}/perllocal.pod,%{perl_vendorarch}/auto/%{pdir}%{?pnam:/%(echo %{pnam} | tr - /)}/.packlist}} \ | |
507 | } } | |
508 | ||
83094b62 | 509 | #----------------------------------------------------------------- |
0e4cb4dd | 510 | # Update GConf2 schemas |
83094b62 | 511 | # |
512 | # Requires: GConf2 | |
513 | # | |
46885239 | 514 | %gconf_schema_install() \ |
3241033b | 515 | umask 022; \ |
f27cf2fd ER |
516 | GCONF_CONFIG_SOURCE="xml:readwrite:/etc/gconf/gconf.xml.defaults" /usr/bin/gconftool-2 --makefile-install-rule /etc/gconf/schemas/%{?1}%{!?1:*.schemas} > /dev/null; \ |
517 | %{nil} | |
46885239 | 518 | |
519 | %gconf_schema_uninstall() \ | |
f93109a0 | 520 | if [ $1 = 0 ]; then \ |
3241033b ER |
521 | umask 022; \ |
522 | GCONF_CONFIG_SOURCE="xml:readwrite:/etc/gconf/gconf.xml.defaults" /usr/bin/gconftool-2 --makefile-uninstall-rule /etc/gconf/schemas/%{?1} > /dev/null \ | |
f27cf2fd | 523 | fi; \ |
f93109a0 | 524 | %{nil} |
525 | ||
526 | #----------------------------------------------------------------- | |
527 | # Update desktop MIME database | |
c0a4caa0 | 528 | # requires: desktop-file-utils |
c3bcd10e | 529 | %update_desktop_database() {{ \ |
f93109a0 | 530 | umask 022; \ |
fb59e475 | 531 | /usr/bin/update-desktop-database -q; \ |
1c744c87 | 532 | }}%{nil} |
f93109a0 | 533 | |
c3bcd10e ER |
534 | %update_desktop_database_post %update_desktop_database |
535 | ||
536 | %update_desktop_database_postun() {{ \ | |
f27cf2fd | 537 | if [ "$1" = "0" ]; then \ |
c3bcd10e | 538 | %update_desktop_database; \ |
f27cf2fd | 539 | fi; \ |
1c744c87 | 540 | }}%{nil} |
f93109a0 | 541 | |
fb59e475 | 542 | #----------------------------------------------------------------- |
543 | # Update shared MIME info database | |
544 | # requires: shared-mime-info | |
545 | # | |
c3bcd10e | 546 | %update_mime_database() {{ \ |
fb59e475 | 547 | umask 022; \ |
548 | /usr/bin/update-mime-database %{_datadir}/mime; \ | |
1c744c87 | 549 | }}%{nil} |
fb59e475 | 550 | |
551 | #----------------------------------------------------------------- | |
552 | # Update icon cache | |
553 | # requires: gtk+ | |
554 | # | |
c3bcd10e | 555 | %update_icon_cache() {{ \ |
fb59e475 | 556 | umask 022; \ |
072f4b80 | 557 | /usr/bin/gtk-update-icon-cache -qf %{_datadir}/icons/%1; \ |
1c744c87 | 558 | }}%{nil} |
fb59e475 | 559 | |
f93109a0 | 560 | #----------------------------------------------------------------- |
561 | # Update scrollkeeper database | |
562 | # requires: scrollkeeper | |
563 | # | |
564 | %scrollkeeper_update_post() \ | |
f93109a0 | 565 | /usr/bin/scrollkeeper-update -q; \ |
f27cf2fd | 566 | %{nil} |
f93109a0 | 567 | |
568 | %scrollkeeper_update_postun() \ | |
f27cf2fd | 569 | if [ "$1" = "0" ]; then \ |
f93109a0 | 570 | /usr/bin/scrollkeeper-update -q; \ |
f27cf2fd | 571 | fi; \ |
f93109a0 | 572 | %{nil} |
573 | ||
9c404149 AM |
574 | #----------------------------------------------------------------- |
575 | # post %install sequence: | |
576 | # - autodeps exceptions | |
577 | # - compress all man and info pages, | |
578 | # - strip all ELF executables and ELF shared objects if not %debug. | |
8f74418b | 579 | # - compress kernel modules if any |
9c404149 AM |
580 | |
581 | ################################################################### | |
582 | # Requires/Provides automation | |
3e202b06 | 583 | # exceptions system by Jacek Konieczny <jajcus@pld-linux.org> |
338726a6 | 584 | # |
2892b5df JB |
585 | %__noautoreqfiles %(sed -e s'/#.*//' /etc/rpm/noautoreqfiles)%{?_noautoreqfiles: %{_noautoreqfiles}} |
586 | %__noautoprovfiles %(sed -e s'/#.*//' /etc/rpm/noautoprovfiles)%{?_noautoprovfiles: %{_noautoprovfiles}} | |
587 | %__noautoreq %(sed -e s'/#.*//' /etc/rpm/noautoreq)%{?_noautoreq: %{_noautoreq}} | |
588 | %__noautoreqdep %(sed -e s'/#.*//' /etc/rpm/noautoreqdep)%{?_noautoreqdep: %{_noautoreqdep}} | |
589 | %__noautoprov %(sed -e s'/#.*//' /etc/rpm/noautoprov)%{?_noautoprov: %{_noautoprov}} | |
c94807f3 | 590 | |
338726a6 JB |
591 | #%_noautocompressdoc %{nil} |
592 | # | |
8f74418b MM |
593 | %_missing_doc_files_terminate_build 1%{nil} |
594 | %_unpackaged_files_terminate_build %{nil} | |
8781dc74 | 595 | # (X)emacs support |
d77dcb61 | 596 | %___emacs_lispdir_helper -batch -q -eval '(while load-path (princ (concat (car load-path) "\\n")) (setq load-path (cdr load-path)))' 2> /dev/null|sed -n '/\\(.*\\/x\\?emacs\\/site-lisp\\)\\/\\?$/{s,,\\1,p;q;}' |
c94807f3 ER |
597 | %_emacs_lispdir %{expand:%%global _emacs_lispdir %(Z=$(emacs %___emacs_lispdir_helper); echo ${Z:-ERROR})}%_emacs_lispdir |
598 | %_xemacs_lispdir %{expand:%%global _xemacs_lispdir %(Z=$(xemacs %___emacs_lispdir_helper); echo ${Z:-ERROR})}%_xemacs_lispdir | |
25043cd4 | 599 | |
02b58f60 JK |
600 | %__php_provides %{nil} |
601 | %__php_requires %{nil} | |
602 | %__perl_provides %{nil} | |
603 | %__perl_requires %{nil} | |
fa3497cd | 604 | %__mono_provides %{nil} |
605 | %__mono_requires %{nil} | |
25043cd4 AF |
606 | |
607 | # Perl specific macro definitions. | |
c94807f3 ER |
608 | %perl_privlib %{expand:%%global perl_privlib %(eval $(%{__perl} -V:installprivlib 2>/dev/null); echo ${installprivlib:-ERROR})}%perl_privlib |
609 | %perl_archlib %{expand:%%global perl_archlib %(eval $(%{__perl} -V:installarchlib 2>/dev/null); echo ${installarchlib:-ERROR})}%perl_archlib | |
610 | %perl_vendorlib %{expand:%%global perl_vendorlib %(eval $(%{__perl} -V:installvendorlib 2>/dev/null); echo ${installvendorlib:-ERROR})}%perl_vendorlib | |
611 | %perl_vendorarch %{expand:%%global perl_vendorarch %(eval $(%{__perl} -V:installvendorarch 2>/dev/null); echo ${installvendorarch:-ERROR})}%perl_vendorarch | |
612 | %perl_sitelib %{expand:%%global perl_sitelib %(eval $(%{__perl} -V:installsitelib 2>/dev/null); echo ${installsitelib:-ERROR})}%perl_sitelib | |
613 | %perl_sitearch %{expand:%%global perl_sitearch %(eval $(%{__perl} -V:installsitearch 2>/dev/null); echo ${installsitearch:-ERROR})}%perl_sitearch | |
25043cd4 | 614 | |
45c00b39 | 615 | # Ruby |
c94807f3 ER |
616 | %__ruby /usr/bin/ruby |
617 | %ruby_archdir %{expand:%%global ruby_archdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["archdir"]' 2>/dev/null || echo ERROR)}%ruby_archdir | |
618 | %ruby_ridir %{expand:%%global ruby_ridir %(%{__ruby} -r rbconfig -e 'include Config; print File.join(CONFIG["datadir"], "ri", CONFIG["ruby_version"], "system")' 2>/dev/null || echo ERROR)}%ruby_ridir | |
619 | %ruby_rubylibdir %{expand:%%global ruby_rubylibdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["rubylibdir"]' 2>/dev/null || echo ERROR)}%ruby_rubylibdir | |
620 | %ruby_vendorarchdir %{expand:%%global ruby_vendorarchdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["vendorarchdir"]' 2>/dev/null || echo ERROR)}%ruby_vendorarchdir | |
621 | %ruby_vendorlibdir %{expand:%%global ruby_vendorlibdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["vendorlibdir"]' 2>/dev/null || echo ERROR)}%ruby_vendorlibdir | |
622 | %ruby_sitearchdir %{expand:%%global ruby_sitearchdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["sitearchdir"]' 2>/dev/null || echo ERROR)}%ruby_sitearchdir | |
623 | %ruby_sitelibdir %{expand:%%global ruby_sitelibdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["sitelibdir"]' 2>/dev/null || echo ERROR)}%ruby_sitelibdir | |
624 | %ruby_version %{expand:%%global ruby_version %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["ruby_version"]' 2>/dev/null || echo ERROR)}%ruby_version | |
669604db ER |
625 | %ruby_ver_requires_eq Requires: ruby(ver) = %ruby_version |
626 | %ruby_mod_ver_requires_eq Requires: ruby-modules(ver) = %ruby_version | |
45c00b39 | 627 | |
7ccf7643 | 628 | %php_pear_dir /usr/share/pear |
7813c433 | 629 | %php_data_dir /usr/share/php |
c94807f3 ER |
630 | %php_extensiondir %{expand:%%global php_extensiondir %(php-config --extension-dir 2>/dev/null || echo ERROR)}%php_extensiondir |
631 | %php_sysconfdir %{expand:%%global php_sysconfdir %(php-config --sysconfdir 2>/dev/null || echo ERROR)}%php_sysconfdir | |
632 | %php_includedir %{expand:%%global php_includedir %(php-config --include-dir 2>/dev/null || echo ERROR)}%php_includedir | |
25043cd4 | 633 | |
0c5d1b9b | 634 | # extract php/zend api versions |
c94807f3 ER |
635 | %php_major_version %{expand:%%global php_major_version %(awk '/#define PHP_MAJOR_VERSION/{print $3}' %{php_includedir}/main/php_version.h 2>/dev/null || echo ERROR)}%php_major_version |
636 | %php_api_version %{expand:%%global php_api_version %(awk '/#define PHP_API_VERSION/{print $3}' %{php_includedir}/main/php.h 2>/dev/null || echo ERROR)}%php_api_version | |
637 | %php_pdo_api_version %{expand:%%global php_pdo_api_version %(awk '/#define PDO_DRIVER_API/{print $3}' %{php_includedir}/ext/pdo/php_pdo_driver.h 2>/dev/null || echo ERROR)}%php_pdo_api_version | |
638 | %php_debug %{expand:%%global php_debug %(awk '/#define ZEND_DEBUG/{print $3}' %{php_includedir}/main/php_config.h 2>/dev/null || echo ERROR)}%php_debug | |
639 | %zend_module_api %{expand:%%global zend_module_api %(awk '/#define ZEND_MODULE_API_NO/{print $3}' %{php_includedir}/Zend/zend_modules.h 2>/dev/null || echo ERROR)}%zend_module_api | |
640 | %zend_extension_api %{expand:%%global zend_extension_api %(awk '/#define ZEND_EXTENSION_API_NO/{print $3}' %{php_includedir}/Zend/zend_extensions.h 2>/dev/null || echo ERROR)}%zend_extension_api | |
641 | %zend_zts %{expand:%%global zend_zts %(Z=$(grep -sc '^#define ZTS 1' %{php_includedir}/main/php_config.h); echo ${Z:-ERROR})}%zend_zts | |
c1b2705c ER |
642 | |
643 | # helper macro | |
f952c0f3 | 644 | %__php_api_requires(v:) Requires: php%{-v*}(%{expand:%1}) = %{expand:%{%{!?2:%{1}}%{?2}}} |
c1b2705c ER |
645 | |
646 | # macros for public use | |
647 | # for php extensions (php-pecl) | |
68b68193 | 648 | %requires_php_extension %{__php_api_requires modules_api php_api_version} \ |
415f4a1a | 649 | %{__php_api_requires zend_module_api} \ |
f952c0f3 ER |
650 | %{__php_api_requires -v %php_major_version debug php_debug} \ |
651 | %{__php_api_requires -v %php_major_version thread-safety zend_zts} | |
68b68193 | 652 | |
c1b2705c ER |
653 | # for zend extensions |
654 | %requires_zend_extension %{__php_api_requires zend_module_api} \ | |
68b68193 | 655 | %{__php_api_requires zend_extension_api} \ |
f952c0f3 ER |
656 | %{__php_api_requires -v %php_major_version debug php_debug} \ |
657 | %{__php_api_requires -v %php_major_version thread-safety zend_zts} | |
c1b2705c | 658 | |
934c685f ER |
659 | # for php pdo modules (php-pecl-PDO_*) |
660 | %requires_php_pdo_module %{__php_api_requires PDO_API php_pdo_api_version} | |
661 | ||
6c3b8203 ER |
662 | # for using PHP post scripts. for PHP >= 5.0 |
663 | %php_webserver_restart \ | |
664 | [ ! -f /etc/apache/conf.d/??_mod_php.conf ] || %service -q apache restart \ | |
578e7794 | 665 | [ ! -f /etc/httpd/conf.d/??_mod_php.conf ] || %service -q httpd restart \ |
ba1800dc ER |
666 | if [ -f /etc/rc.d/init.d/php-fcgi ]; then \ |
667 | PHP_FCGI_BINARY=; . /etc/sysconfig/php-fcgi 2>/dev/null \ | |
668 | if [[ ${PHP_FCGI_BINARY:-php.fcgi} = *php.fcgi* ]]; then \ | |
669 | %service -q php-fcgi restart \ | |
670 | fi \ | |
671 | fi \ | |
6c3b8203 ER |
672 | %{nil} |
673 | ||
674 | # for using php post scripts. for PHP >= 4.0 && PHP < 5.0 | |
675 | %php4_webserver_restart \ | |
676 | [ ! -f /etc/apache/conf.d/??_mod_php4.conf ] || %service -q apache restart \ | |
578e7794 | 677 | [ ! -f /etc/httpd/conf.d/??_mod_php4.conf ] || %service -q httpd restart \ |
ba1800dc ER |
678 | if [ -f /etc/rc.d/init.d/php-fcgi ]; then \ |
679 | PHP_FCGI_BINARY=; . /etc/sysconfig/php-fcgi 2>/dev/null \ | |
680 | if [[ ${PHP_FCGI_BINARY:-php.fcgi} = *php4.fcgi* ]]; then \ | |
681 | %service -q php-fcgi restart \ | |
682 | fi \ | |
683 | fi \ | |
6c3b8203 ER |
684 | %{nil} |
685 | ||
578e9248 | 686 | # X.org helper macros |
434ab5a2 ER |
687 | %__xorg_abi_requires_ge() Requires: xorg-xserver-server(%{expand:%1}-abi) >= %{expand:%{%2}} |
688 | %__xorg_abi_requires_lt() Requires: xorg-xserver-server(%{expand:%1}-abi) < %(awk -vv=%{expand:%{%2}} 'BEGIN{split(v, a, "."); printf("%s.0", a[1] + 1); exit}') | |
689 | ||
c94807f3 ER |
690 | %xorg_xserver_ansic_abi %{expand:%%global xorg_xserver_ansic_abi %(awk '/#define ABI_ANSIC_VERSION/ { split($0,A,/[(,)]/); printf("%d.%d",A[2], A[3]); }' /usr/include/xorg/xf86Module.h 2> /dev/null || echo ERROR)}%xorg_xserver_ansic_abi |
691 | %xorg_xserver_extension_abi %{expand:%%global xorg_xserver_extension_abi %(awk '/#define ABI_EXTENSION_VERSION/ { split($0,A,/[(,)]/); printf("%d.%d",A[2], A[3]); }' /usr/include/xorg/xf86Module.h 2> /dev/null || echo ERROR)}%xorg_xserver_extension_abi | |
692 | %xorg_xserver_font_abi %{expand:%%global xorg_xserver_font_abi %(awk '/#define ABI_FONT_VERSION/ { split($0,A,/[(,)]/); printf("%d.%d",A[2], A[3]); }' /usr/include/xorg/xf86Module.h 2> /dev/null | echo ERROR)}%xorg_xserver_font_abi | |
693 | %xorg_xserver_videodrv_abi %{expand:%%global xorg_xserver_videodrv_abi %(awk '/#define ABI_VIDEODRV_VERSION/ { split($0,A,/[(,)]/); printf("%d.%d",A[2], A[3]); }' /usr/include/xorg/xf86Module.h 2> /dev/null || echo ERROR)}%xorg_xserver_videodrv_abi | |
694 | %xorg_xserver_xinput_abi %{expand:%%global xorg_xserver_xinput_abi %(awk '/#define ABI_XINPUT_VERSION/ { split($0,A,/[(,)]/); printf("%d.%d",A[2], A[3]); }' /usr/include/xorg/xf86Module.h 2> /dev/null || echo ERROR)}%xorg_xserver_xinput_abi | |
578e9248 | 695 | |
434ab5a2 | 696 | %requires_xorg_xserver_extension \ |
97486460 AM |
697 | %{__xorg_abi_requires_ge ansic xorg_xserver_ansic_abi} \ |
698 | %{__xorg_abi_requires_lt ansic xorg_xserver_ansic_abi} \ | |
699 | %{__xorg_abi_requires_ge extension xorg_xserver_extension_abi} \ | |
700 | %{__xorg_abi_requires_lt extension xorg_xserver_extension_abi} \ | |
434ab5a2 ER |
701 | %{nil} |
702 | ||
703 | %requires_xorg_xserver_xinput \ | |
97486460 AM |
704 | %{__xorg_abi_requires_ge ansic xorg_xserver_ansic_abi} \ |
705 | %{__xorg_abi_requires_lt ansic xorg_xserver_ansic_abi} \ | |
706 | %{__xorg_abi_requires_ge xinput xorg_xserver_xinput_abi} \ | |
707 | %{__xorg_abi_requires_lt xinput xorg_xserver_xinput_abi} \ | |
434ab5a2 ER |
708 | %{nil} |
709 | ||
710 | %requires_xorg_xserver_font \ | |
97486460 AM |
711 | %{__xorg_abi_requires_ge ansic xorg_xserver_ansic_abi} \ |
712 | %{__xorg_abi_requires_lt ansic xorg_xserver_ansic_abi} \ | |
713 | %{__xorg_abi_requires_ge font xorg_xserver_font_abi} \ | |
714 | %{__xorg_abi_requires_lt font xorg_xserver_font_abi} \ | |
434ab5a2 ER |
715 | %{nil} |
716 | ||
717 | %requires_xorg_xserver_videodrv \ | |
97486460 AM |
718 | %{__xorg_abi_requires_ge ansic xorg_xserver_ansic_abi} \ |
719 | %{__xorg_abi_requires_lt ansic xorg_xserver_ansic_abi} \ | |
720 | %{__xorg_abi_requires_ge videodrv xorg_xserver_videodrv_abi} \ | |
721 | %{__xorg_abi_requires_lt videodrv xorg_xserver_videodrv_abi} \ | |
434ab5a2 | 722 | %{nil} |
578e9248 | 723 | |
25043cd4 AF |
724 | # Python specific macro definitions. |
725 | # python main version | |
2383a9da | 726 | %py_ver %{expand:%%global py_ver %(%{__python} -c "import sys; print sys.version[:3]" 2>/dev/null || echo ERROR)}%py_ver |
25043cd4 AF |
727 | |
728 | # directories | |
2383a9da | 729 | %py_prefix %{expand:%%global py_prefix %(%{__python} -c "import sys; print sys.prefix" 2>/dev/null || echo ERROR)}%py_prefix |
3241033b | 730 | %py_libdir %{py_prefix}/%{_lib}/python%{py_ver} |
ef7ec0a8 | 731 | %py_scriptdir %{py_prefix}/share/python%{py_ver} |
3241033b | 732 | %py_incdir /usr/include/python%{py_ver} |
7ccf7643 | 733 | %py_sitedir %{py_libdir}/site-packages |
ef7ec0a8 | 734 | %py_sitescriptdir %{py_scriptdir}/site-packages |
3241033b | 735 | %py_dyndir %{py_libdir}/lib-dynload |
25043cd4 AF |
736 | |
737 | # pure python modules compilation | |
3241033b | 738 | %py_comp python -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])" |
25043cd4 | 739 | |
3241033b | 740 | %py_ocomp python -O -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])" |
25043cd4 AF |
741 | |
742 | # Software written in Python language require Python with main version | |
e63cd81d | 743 | %pyrequires_eq() Requires: %1 |
25043cd4 | 744 | |
f12c2314 AF |
745 | # Hardlink binary identical .pyc and .pyo files |
746 | # (idea by glen <at> pld-linux <dot> org) | |
747 | %__spec_install_post_py_hardlink {\ | |
53d5af13 | 748 | %{!?no_install_post_py_hardlink: __spec_install_post_py_hardlink() { \ |
f12c2314 | 749 | [ ! -d "$RPM_BUILD_ROOT" ] || find "$RPM_BUILD_ROOT" -name '*.pyc' | while read a; do \ |
83f0d22e | 750 | b="${a%.pyc}.pyo"; \ |
f12c2314 AF |
751 | if cmp -s "$a" "$b"; then \ |
752 | ln -f "$a" "$b"; \ | |
753 | fi; \ | |
754 | done \ | |
53d5af13 | 755 | }; __spec_install_post_py_hardlink } } |
f12c2314 | 756 | |
9227b3f9 | 757 | # remove python sources, so that check-files won't complain |
f12c2314 AF |
758 | # (idea by glen <at> pld-linux <dot> org) |
759 | %py_postclean() \ | |
0f82e280 | 760 | for d in %{py_sitescriptdir} %{py_sitedir} %*; do \ |
820792a9 | 761 | [ ! -d "$RPM_BUILD_ROOT$d" ] || find "$RPM_BUILD_ROOT$d" -name '*.py' -print0 | xargs -0r -l512 rm;\ |
f12c2314 AF |
762 | done \ |
763 | %{nil} | |
764 | ||
0fc5cff8 | 765 | # depmod macro |
766 | %depmod() { \ | |
f6148427 | 767 | umask 022; \ |
0fc5cff8 | 768 | if [ -e /boot/System.map-%1 ]; then \ |
3241033b | 769 | /sbin/depmod -a -F /boot/System.map-%1 %1; \ |
0fc5cff8 | 770 | else \ |
3241033b ER |
771 | if [ -e /boot/System.map ]; then \ |
772 | /sbin/depmod -a -F /boot/System.map %1; \ | |
773 | else \ | |
774 | /sbin/depmod -a %1; \ | |
775 | fi \ | |
0fc5cff8 | 776 | fi; \ |
777 | } | |
778 | ||
2afc6e64 | 779 | # XMMS specific macros |
c94807f3 ER |
780 | %xmms_prefix %{expand:%%global xmms_prefix %(xmms-config --prefix 2>/dev/null || echo ERROR)}%xmms_prefix |
781 | %xmms_exec_prefix %{expand:%%global xmms_exec_prefix %(xmms-config --exec-prefix 2>/dev/null || echo ERROR)}%xmms_exec_prefix | |
782 | %xmms_version %{expand:%%global xmms_version %(xmms-config --version 2>/dev/null || echo ERROR)}%xmms_version | |
783 | %xmms_datadir %{expand:%%global xmms_datadir %(xmms-config --data-dir 2>/dev/null || echo ERROR)}%xmms_datadir | |
784 | %xmms_plugindir %{expand:%%global xmms_plugindir %(xmms-config --plugin-dir 2>/dev/null || echo ERROR)}%xmms_plugindir | |
785 | %xmms_visualization_plugindir %{expand:%%global xmms_visualization_plugindir %(xmms-config --visualization-plugin-dir 2>/dev/null || echo ERROR)}%xmms_visualization_plugindir | |
786 | %xmms_input_plugindir %{expand:%%global xmms_input_plugindir %(xmms-config --input-plugin-dir 2>/dev/null || echo ERROR)}%xmms_input_plugindir | |
787 | %xmms_output_plugindir %{expand:%%global xmms_output_plugindir %(xmms-config --output-plugin-dir 2>/dev/null || echo ERROR)}%xmms_output_plugindir | |
788 | %xmms_effect_plugindir %{expand:%%global xmms_effect_plugindir %(xmms-config --effect-plugin-dir 2>/dev/null || echo ERROR)}%xmms_effect_plugindir | |
789 | %xmms_general_plugindir %{expand:%%global xmms_general_plugindir %(xmms-config --general-plugin-dir 2>/dev/null || echo ERROR)}%xmms_general_plugindir | |
790 | ||
791 | %_target_base_arch %{expand:%%global _target_base_arch %(echo %{_target_cpu} | sed 's/i.86/i386/;s/athlon/i386/;s/pentium./i386/;s/amd64/x86_64/;s/ia32e/x86_64/')}%_target_base_arch | |
d1537778 | 792 | |
848c0d68 | 793 | # user/group checking macros |
794 | # | |
795 | # Usage: | |
796 | # %userremove myuser | |
797 | # | |
798 | %userremove /usr/lib/rpm/user_group.sh user del | |
799 | %groupremove /usr/lib/rpm/user_group.sh group del | |
800 | # | |
801 | # Usage: | |
802 | # if %usertestrm myuser; then | |
803 | # /usr/sbin/userdel -r myuser | |
804 | # Note: | |
805 | # use these macros only if you need to call userdel/groupdel with | |
806 | # a non-standard option or take an extra action; otherwise use the | |
807 | # %userremove/%groupremove macros | |
808 | # | |
809 | %usertestrm /usr/lib/rpm/user_group.sh user testrm | |
810 | %grouptestrm /usr/lib/rpm/user_group.sh group testrm | |
08d9b1f6 JK |
811 | # user group membership management macros |
812 | # | |
813 | # Usage: | |
814 | # %addusertogroup myuser agroup | |
815 | # | |
816 | %addusertogroup /usr/lib/rpm/user_group.sh user addtogroup | |
72fcfcb3 | 817 | |
818 | # banner support (useful in {pre,post}{,un} and triggers) | |
819 | # | |
820 | # Usage: | |
aa41c920 | 821 | # %banner name [-a] [-e] [-n] [-tn] <<EOF |
72fcfcb3 | 822 | # the banner text, the banner text |
aa41c920 ER |
823 | # the banner text, and following line |
824 | #EOF | |
825 | # You can use any form of here-document, <<'EOF' <<-EOT will do. | |
826 | # NOTE: if your use "<<-EOF", then You can actually indent inside here-document. | |
827 | # | |
72fcfcb3 | 828 | # -a - append to the banner |
a8b9562a | 829 | # -e - send to stderr instead of stdout |
628754cb | 830 | # -n - no show banner (overrides -t) |
831 | # -t - show only, if RPM_SCRIPTVERBOSITY >= n; default n=5 | |
276a7b45 ER |
832 | # |
833 | # Tests: | |
834 | # (rpm -E '%banner -e banner <<EOF'; echo -e 'hi\nEOF') > m; sh -x m | |
835 | # rpm -E 'date | %banner -e banner' > m; sh -x m | |
836 | # | |
afb54f6c | 837 | %banner(aent:) ( \ |
1b334fe4 | 838 | RPM_SCRIPTVERBOSITY=5 \ |
839 | [ -r /etc/sysconfig/rpm ] && . /etc/sysconfig/rpm \ | |
840 | if [ -x /usr/bin/banner.sh ]; then \ | |
aa41c920 | 841 | CMD="/usr/bin/banner.sh %{-e:--stderr} %{!-n:$([ $RPM_SCRIPTVERBOSITY -ge %{-t:%{-t*}}%{!-t:5} ] && echo -s)} %{!-a:-m}%{-a:-M} %1" \ |
1b334fe4 | 842 | else \ |
a8b9562a | 843 | CMD="cat%{-e: >&2}" \ |
1b334fe4 | 844 | fi \ |
276a7b45 ER |
845 | eval $CMD %{?2:%2}%{?3: %3}) \ |
846 | %{nil} | |
628754cb | 847 | |
990bd03f | 848 | # useradd/groupadd macros |
4c73bc69 | 849 | # Author: Elan Ruusamäe <glen@pld-linux.org> |
90627280 ER |
850 | # |
851 | # Usage: | |
852 | # %useradd [-P package] [-u uid] [-d home_dir] [-s shell] [-c comment] | |
853 | # [-g initial_group] [-G group[,...]] login | |
854 | # | |
855 | # -u uid. REQUIRED | |
856 | # -g gid/group. REQUIRED | |
857 | # -s defaults to /bin/false | |
858 | # -d defaults to /usr/share/empty | |
859 | # -c No default | |
860 | # -r is accepted but ignored (it's always set) | |
6bd4c218 | 861 | # -k skeleton dir. defaults to /usr/share/empty |
90627280 ER |
862 | # rpm specific flags |
863 | # -P package name. defaults to %{name} | |
864 | # | |
90627280 | 865 | %useradd(c:d:e:f:g:G:Mmk:op:s:u:rP:) \ |
9ba02ba9 ER |
866 | %{!-u:%{error:useradd: Required argument -u missing}} \ |
867 | %{!-g:%{error:useradd: Required argument -g missing}} \ | |
868 | %{!?1:%{error:useradd: Required parameter login missing}} \ | |
90627280 ER |
869 | if [ -n "`/bin/id -u %{expand:%{%{#}}} 2>/dev/null`" ]; then \ |
870 | if [ "`/bin/id -u %{expand:%{%{#}}}`" != "%{-u*}" ]; then \ | |
871 | echo "Error: user %{expand:%{%{#}}} doesn't have uid=%{-u*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \ | |
872 | exit 1 \ | |
873 | fi \ | |
874 | else \ | |
875 | echo "Adding user %{expand:%{%{#}}} UID=%{-u*}." \ | |
876 | /usr/sbin/useradd \\\ | |
b5a7d552 | 877 | %{-m:-m -k %{-k*}%{!-k:/usr/share/empty}} \\\ |
90627280 ER |
878 | -u %{-u*} \\\ |
879 | -r \\\ | |
880 | -d %{-d*}%{!-d:/usr/share/empty} \\\ | |
881 | -s %{-s*}%{!-s:/bin/false} \\\ | |
840e7b00 | 882 | %{-c:-c "%(set -- %{-c*} %{*}; echo $1)"}\\\ |
90627280 ER |
883 | -g %{-g*} \\\ |
884 | %{-M} \\\ | |
885 | %{-G:-G %{-G*}} \\\ | |
1aac682a | 886 | %{expand:%{%{#}}} 1>&2 || exit $? \ |
bcf63b58 | 887 | [ ! -x /usr/sbin/nscd ] || /usr/sbin/nscd -i passwd || : \ |
90627280 ER |
888 | fi; |
889 | ||
90627280 ER |
890 | # Usage: |
891 | # %groupadd [-P package] [-g gid] group | |
892 | # | |
893 | # -g gid. REQUIRED | |
894 | # | |
895 | # Sample: | |
896 | # %groupadd -P %{name}-base -g %{gid} %{name} | |
897 | ||
898 | %groupadd(g:P:rfo) \ | |
9ba02ba9 ER |
899 | %{!-g:%{error:groupadd: Required argument -g missing}} \ |
900 | %{!?1:%{error:groupadd: Required parameter group missing}} \ | |
90627280 ER |
901 | if [ -n "`/usr/bin/getgid %{1}`" ]; then \ |
902 | if [ "`/usr/bin/getgid %{1}`" != "%{-g*}" ]; then \ | |
903 | echo "Error: group %{1} doesn't have gid=%{-g*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \ | |
904 | exit 1 \ | |
905 | fi \ | |
906 | else \ | |
907 | echo "Adding group %{1} GID=%{-g*}." \ | |
1aac682a | 908 | /usr/sbin/groupadd -g %{-g*} -r %{1} 1>&2 || exit $? \ |
bcf63b58 | 909 | [ ! -x /usr/sbin/nscd ] || /usr/sbin/nscd -i group || : \ |
90627280 | 910 | fi; |
7cb77741 | 911 | |
7c50f037 | 912 | # webapp macros |
4c73bc69 | 913 | # Author: Elan Ruusamäe <glen@pld-linux.org> |
35663282 ER |
914 | # |
915 | # The config is installed/removed inside trigger, this means that you can any | |
916 | # time install apache1/apache/lighttpd package and the configuration file is | |
fe6c4bdd | 917 | # updated. if you don't need the config for various reason for specific |
35663282 ER |
918 | # webserver, just remove the symlink from config directory using webapp |
919 | # program. the trigger will not recreate the symlink on upgrades. In other | |
920 | # words the config is linked to webserver config directory on first install of | |
921 | # PACKAGE or WEBSERVER. | |
922 | # | |
7c50f037 ER |
923 | # Add package's webserver config to webserver webapps dir. |
924 | # Usage: | |
df979130 | 925 | # %webapp_register WEBSERVER WEBAPP |
35663282 ER |
926 | # |
927 | %webapp_register() \ | |
928 | %{?debug:set -x; echo "webapp_register: %{name}-%{version}-%{release} 1:[$1]; 2:[$2]"} \ | |
929 | if [ "$1" = "1" ] && [ "$2" = "1" ]; then\ | |
930 | /usr/sbin/webapp register %1 %2\ | |
931 | fi\ | |
694a8f2e | 932 | # reload webserver if the config symlink is there and skip reload if webserver is upgraded\ |
5d3a09a3 | 933 | if [ -L /etc/%1/webapps.d/%(echo "%2" | tr '/' '-').conf ] && [ "$2" -lt "2" ]; then\ |
16897aea | 934 | %{expand:%service -q %%1 reload}\ |
35663282 ER |
935 | fi\ |
936 | %{nil} | |
937 | ||
938 | # Remove package's config from webserver webapps dir. | |
35663282 | 939 | # Usage: |
531c0efc ER |
940 | # %webapp_register [-f] WEBSERVER WEBAPP |
941 | %webapp_unregister(f) \ | |
35663282 ER |
942 | %{?debug:set -x; echo "webapp_unregister: %{name}-%{version}-%{release}: 1:[$1]; 2:[$2]"} \ |
943 | # remove link if either of the packages are gone \ | |
5d3a09a3 | 944 | if [ -n "%{-f:1}" ] || [ "$1" = "0" ] || [ "$2" = "0" ] && [ -L /etc/%1/webapps.d/%(echo "%2" | tr '/' '-').conf ]; then \ |
df979130 | 945 | /usr/sbin/webapp unregister %1 %2\ |
16897aea | 946 | %{expand:%service -q %%1 reload}\ |
35663282 ER |
947 | fi \ |
948 | %{nil} | |
949 | ||
462b26fa | 950 | # service macro. |
4c73bc69 | 951 | # Author: Elan Ruusamäe <glen@pld-linux.org> |
462b26fa ER |
952 | # |
953 | # calls usual service restart on package %post, but skips the restart if | |
954 | # administrator has disabled automatic service restarts in either global | |
955 | # /etc/sysconfig/rpm or per service /etc/sysconfig/SERVICE file. | |
956 | # | |
462b26fa | 957 | # Usage: |
7377b5ca | 958 | # %service [-q] [-n] SERVICE ACTION ["SERVICE NICE DESCRIPTION"] |
462b26fa | 959 | # |
a0bbe604 | 960 | # -q be silent when service isn't started (for scriplets restaring other package's services) |
7377b5ca | 961 | # -n NOOP mode, do not actually restart service |
462b26fa | 962 | # |
7377b5ca ER |
963 | # Requirements: |
964 | # BuildRequires: rpmbuild(macros) >= 1.268 | |
965 | # Requires: rc-scripts | |
966 | # -n option: | |
967 | # BuildRequires: rpmbuild(macros) >= 1.450 | |
968 | %service(qn) {{%(export noop=%{-n:1} quiet=%{-q:1}; /usr/lib/rpm/service_generator.sh %{*}) };} | |
6aedae62 ER |
969 | |
970 | ||
f9aa75bf ER |
971 | # Java macros. based on jpackage macros.java |
972 | # | |
973 | # Root directory where all Java VMs/SDK/JREs are installed. | |
2d4659a1 | 974 | %_jvmdir %{_libdir}/jvm |
f9aa75bf ER |
975 | |
976 | # Root directory where all Java VMs/SDK/JREs expose their jars | |
2d4659a1 | 977 | %_jvmjardir %{_libdir}/jvm-exports |
f9aa75bf ER |
978 | |
979 | # Root directory for all Java VM/SDK/JRE's private things. | |
980 | %_jvmprivdir %{_libdir}/jvm-private | |
981 | ||
982 | # Root directory for all architecture dependent parts of Java VM/SDK/JRE's | |
2d4659a1 | 983 | %_jvmlibdir %{_libdir}/jvm |
f9aa75bf ER |
984 | |
985 | # Root directory for all architecture independent parts of Java VM/SDK/JRE's | |
986 | %_jvmdatadir %{_datadir}/jvm | |
987 | ||
988 | # Root directory for all configurations parts of Java VM/SDK/JRE's | |
989 | %_jvmsysconfdir %{_sysconfdir}/jvm | |
990 | ||
991 | # Root directory for all common architecture dependent parts of Java VM/SDK/JRE's | |
f5ed4276 | 992 | %_jvmcommonlibdir %{_libdir}/jvm-common |
f9aa75bf ER |
993 | |
994 | # Root directory for all common architecture independent parts of Java VM/SDK/JRE's | |
f5ed4276 | 995 | %_jvmcommondatadir %{_datadir}/jvm-common |
f9aa75bf ER |
996 | |
997 | # Root directory for all common configurations parts of Java VM/SDK/JRE's | |
f5ed4276 | 998 | %_jvmcommonsysconfdir %{_sysconfdir}/jvm-common |
f9aa75bf ER |
999 | |
1000 | # Directory where arch-specific (JNI) version-independent jars are installed. | |
2d4659a1 | 1001 | %_jnidir %{_libdir}/java |
f9aa75bf | 1002 | |
c94807f3 | 1003 | %java_home %{expand:%%global java_home %([ -f %{_javadir}-utils/java-functions ] || { echo ERROR; exit 0; }; unset JAVA_HOME; . %{_javadir}-utils/java-functions; set_jvm; echo ${JAVA_HOME:-ERROR})}%java_home |
6aedae62 | 1004 | |
fe6c4bdd ER |
1005 | %ant JAVA_HOME=%{java_home} ant |
1006 | %jar %{java_home}/bin/jar | |
c94807f3 | 1007 | %java %{expand:%%global java %([ -f %{_javadir}-utils/java-functions ] || { echo ERROR; exit 0; }; unset JAVACMD; . %{_javadir}-utils/java-functions; set_javacmd; echo $JAVACMD)}%java |
fe6c4bdd ER |
1008 | %javac %{java_home}/bin/javac |
1009 | %javadoc %{java_home}/bin/javadoc | |
6aedae62 | 1010 | |
fe6c4bdd | 1011 | %add_jvm_extension JAVA_LIBDIR=%{buildroot}/%{_javadir} %{_bindir}/jvmjar -l |
6aedae62 ER |
1012 | |
1013 | %jpackage_script() \ | |
3ca65b87 ER |
1014 | install -d $RPM_BUILD_ROOT%{_bindir}\ |
1015 | cat > $RPM_BUILD_ROOT%{_bindir}/%5 << 'EOF' \ | |
6aedae62 ER |
1016 | #!/bin/sh\ |
1017 | #\ | |
1018 | # %{name} script\ | |
1019 | # JPackage Project <http://www.jpackage.org/>\ | |
1020 | \ | |
1021 | # Source functions library\ | |
1022 | . %{_javadir}-utils/java-functions\ | |
1023 | \ | |
1024 | # Source system prefs\ | |
3ca65b87 | 1025 | if [ -f %{_sysconfdir}/java/%{name}.conf ]; then\ |
fe6c4bdd | 1026 | . %{_sysconfdir}/java/%{name}.conf\ |
6aedae62 ER |
1027 | fi\ |
1028 | \ | |
1029 | # Source user prefs\ | |
3ca65b87 ER |
1030 | if [ -f $HOME/.%{name}rc ]; then\ |
1031 | . $HOME/.%{name}rc\ | |
6aedae62 ER |
1032 | fi\ |
1033 | \ | |
1034 | # Configuration\ | |
1035 | MAIN_CLASS=%1\ | |
1036 | BASE_FLAGS=%2\ | |
1037 | BASE_OPTIONS=%3\ | |
3ca65b87 | 1038 | BASE_JARS="%(echo %4 | tr ':' ' ')"\ |
6aedae62 ER |
1039 | \ |
1040 | # Set parameters\ | |
1041 | set_jvm\ | |
3ca65b87 ER |
1042 | set_classpath $BASE_JARS\ |
1043 | set_flags $BASE_FLAGS\ | |
1044 | set_options $BASE_OPTIONS\ | |
6aedae62 ER |
1045 | \ |
1046 | # Let's start\ | |
3ca65b87 | 1047 | run "$@"\ |
6aedae62 ER |
1048 | EOF |
1049 | ||
06f11871 ER |
1050 | # jpackage 1.7 |
1051 | # Directory for maven depmaps | |
1052 | # | |
1053 | %_mavendepmapdir /etc/maven | |
1054 | %_mavendepmapfragdir /etc/maven/fragments | |
1055 | ||
1056 | # | |
1057 | # add_to_depmap adds an entry to the depmap. The arguments are: | |
1058 | # | |
1059 | # %1 the original groupid | |
1060 | # %2 the original artifact id | |
1061 | # %3 the version | |
1062 | # %4 the new groupid | |
1063 | # %5 the new artifactid | |
1064 | # | |
1065 | ||
1066 | %add_to_maven_depmap() \ | |
1067 | install -dm 755 $RPM_BUILD_ROOT/%{_mavendepmapfragdir}\ | |
1068 | cat >>$RPM_BUILD_ROOT/%{_mavendepmapfragdir}/%{name}<< EOF\ | |
1069 | <dependency>\ | |
1070 | <maven>\ | |
1071 | <groupId>%1</groupId>\ | |
1072 | <artifactId>%2</artifactId>\ | |
1073 | <version>%3</version>\ | |
1074 | </maven>\ | |
1075 | <jpp>\ | |
1076 | <groupId>%4</groupId>\ | |
1077 | <artifactId>%5</artifactId>\ | |
1078 | <version>%3</version>\ | |
1079 | </jpp>\ | |
1080 | </dependency>\ | |
1081 | \ | |
1082 | EOF\ | |
1083 | %{nil} | |
1084 | ||
1085 | #============================================================================== | |
1086 | # | |
1087 | # update_maven_depmap updates the main maven depmap | |
1088 | # | |
1089 | %update_maven_depmap() \ | |
1090 | echo -e "<dependencies>\\n" > %{_mavendepmapdir}/maven2-depmap.xml\ | |
1091 | if [ -d %{_mavendepmapfragdir} ] && [ -n "`find %{_mavendepmapfragdir} -type f`" ]; then\ | |
1092 | cat %{_mavendepmapfragdir}/* >> %{_mavendepmapdir}/maven2-depmap.xml\ | |
1093 | fi\ | |
1094 | echo -e "</dependencies>\\n" >> %{_mavendepmapdir}/maven2-depmap.xml | |
1095 | ||
1096 | ||
59d3ebe9 | 1097 | # PEAR install macros |
4c73bc69 | 1098 | # Author: Elan Ruusamäe <glen@pld-linux.org> |
dfce8b19 ER |
1099 | # |
1100 | # Usage: | |
1101 | # %%pear_package_setup [-a #] [-n FMT] | |
1102 | # | |
59d3ebe9 | 1103 | # -a # - also unpack SOURCE#. for PEAR bootstrapping |
dfce8b19 | 1104 | # -n FMT - create builddir with FMT, instead of default %%{_pearname}-%%{version} |
59d3ebe9 | 1105 | # -z - unpack pear package and let pear use package.xml (not tarball) for install. for PEAR bootstrapping |
dfce8b19 ER |
1106 | # |
1107 | # unpack PEAR package to %%{_builddir}/FMT. package is extracted with already | |
1108 | # destination hierarchy. you should copy the tree to buildroot after | |
1109 | # patching/reorganizing with %%pear_package_install. | |
1110 | # | |
1111 | # additionally BUILDROOT is stripped from files and files are converted to UNIX | |
1112 | # line endings. | |
1113 | # | |
1114 | # the pear install process output is recorded to install.log, you should put it | |
8763f51e | 1115 | # to %%doc for later debug or just for information. |
dfce8b19 ER |
1116 | # |
1117 | # additionally additional-packages.txt is produced if it was detected that the | |
1118 | # package has optional dependencies. the file format is suitable of displaying | |
1119 | # in %%post of a package. you should put this file to %%doc. noautocompressdoc is | |
1120 | # automatically added for this file. | |
59d3ebe9 ER |
1121 | |
1122 | ||
1123 | # records install.log and transforms PEAR names to PLD Linux rpm package names. | |
1124 | %__pear_install_log \ | |
1125 | tee install.log \ | |
1126 | # make post message of optional packages \ | |
1127 | grep 'can optionally use' install.log | sed -e 's,package "pear/,package "php-pear-,g;s,^pear/,php-pear-,' > optional-packages.txt \ | |
1128 | if [ -s optional-packages.txt ]; then \ | |
1129 | awk -F'"' '/use package/{print $2}' optional-packages.txt | sed -e "s,_,/,g;s,php-pear-, 'pear(,;s,$,.*)'," | tr -d '\\\n' > _noautoreq \ | |
1130 | else \ | |
1131 | rm -f optional-packages.txt \ | |
1132 | fi \ | |
1133 | %{nil} | |
1134 | ||
1135 | # command invoking pear cli | |
1136 | %__pear /usr/bin/pear | |
1137 | ||
67a089ff | 1138 | %pear_install(a:n:zD) \ |
59d3ebe9 ER |
1139 | %__pear \\\ |
1140 | -c pearrc \\\ | |
dfce8b19 ER |
1141 | -d doc_dir=/docs \\\ |
1142 | -d php_dir=%{php_pear_dir} \\\ | |
1143 | -d bin_dir=%{_bindir} \\\ | |
1144 | -d data_dir=%{php_pear_dir}/data \\\ | |
1145 | -d test_dir=%{php_pear_dir}/tests \\\ | |
1146 | install \\\ | |
59d3ebe9 | 1147 | --packagingroot=%{builddir} \\\ |
dfce8b19 ER |
1148 | --offline \\\ |
1149 | --nodeps \\\ | |
1150 | %{-f:--force} \\\ | |
67a089ff ER |
1151 | %{!-z:%{S:%{-a*}%{!-a:0}}}%{-z:$_P} > .install.log || { c=$?; cat .install.log; exit $c; }; \ |
1152 | %{nil} | |
1153 | ||
1154 | # The main macro. | |
1155 | # using this macro will append optional-packages.txt to the nocompressdoc list | |
1156 | # as it's displayed to user after package install. and adding additional gzip | |
1157 | # dep is just waste ;) | |
1158 | %pear_package_setup(a:n:zD) \ | |
1159 | %define srcdir %{-n*}%{!-n:%{_pearname}-%{version}} \ | |
1160 | %define builddir %{_builddir}/%{srcdir} \ | |
1161 | %setup -q -c -T %{-D:-D} -n %{srcdir} \ | |
1162 | %{-z:tar zxf %{S:0}; %{-a:tar zxf %{S:%{-a*}}}} \ | |
1163 | %{-z:_P=package2.xml; [ -f $_P ] || _P=package.xml; _N=%{srcdir}; mv $_P $_N; cd $_N} \ | |
1164 | %pear_install \ | |
59d3ebe9 ER |
1165 | %{-z:cd ..} \ |
1166 | cat %{-z:$_N/}.install.log | %__pear_install_log \ | |
1167 | \ | |
dfce8b19 | 1168 | # undos sources \ |
2a80e4cf | 1169 | find -type f -print0 | xargs -0 sed -i -e 's,\\r$,,' \ |
dfce8b19 ER |
1170 | %{!?_noautocompressdoc:%global _noautocompressdoc %{nil}}%{expand:%%global _noautocompressdoc %{_noautocompressdoc} optional-packages.txt} \ |
1171 | %{!?_noautoprov:%global _noautoprov %{nil}}%{expand:%%global _noautoprov %{_noautoprov} 'pear(tests/.*)'} \ | |
1172 | %{nil} | |
1173 | ||
7bef60e8 | 1174 | # Copies exctracted PEAR package structure and PEAR registry to buildroot. |
4c73bc69 | 1175 | # Author: Elan Ruusamäe <glen@pld-linux.org> |
dfce8b19 ER |
1176 | %pear_package_install() \ |
1177 | cp -a ./%{php_pear_dir}/{.registry,*} $RPM_BUILD_ROOT%{php_pear_dir} \ | |
1178 | find $RPM_BUILD_ROOT%{php_pear_dir} '(' -name '*~' -o -name '*.orig' ')' | xargs -r rm -v \ | |
1179 | # help the developer out a little: \ | |
1180 | if [ -f _noautoreq ]; then \ | |
1181 | echo "AutoReqdep detected:" \ | |
1182 | echo "_noautoreq $(cat _noautoreq)" \ | |
1183 | fi \ | |
1184 | %{nil} | |
1185 | ||
0d5dd00c ER |
1186 | |
1187 | # Register OpenLDAP schema. | |
4c73bc69 | 1188 | # Author: Elan Ruusamäe <glen@pld-linux.org> |
0d5dd00c ER |
1189 | # |
1190 | # Usage: | |
1191 | # %%openldap_schema_register [-d core,nis] %{schemadir}/horde.schema | |
1192 | # | |
1193 | # -d specify dependant schemas, separated by comma | |
1194 | # | |
1195 | %openldap_schema_register(d:) \ | |
1196 | for schema in %*; do \ | |
1197 | if ! grep -q "$schema" /etc/openldap/slapd.conf; then \ | |
1198 | %{__sed} -i -e " \ | |
1199 | /^include.*local.schema/{ \ | |
1200 | iinclude\\t $schema\ | |
1201 | } \ | |
1202 | " /etc/openldap/slapd.conf \ | |
1203 | fi \ | |
1204 | done \ | |
1205 | # enable dependant schemas \ | |
1206 | if [ "%{-d*}" ]; then \ | |
1207 | %{__sed} -i -e ' \ | |
1208 | /^#include.*\\(%(echo '%{-d*}' | %{__sed} -e 's/,/\\\\|/g')\\)\\.schema/{ \ | |
1209 | s/^#// \ | |
1210 | }' /etc/openldap/slapd.conf \ | |
1211 | fi \ | |
1212 | %{nil} | |
1213 | ||
1214 | # Unregister OpenLDAP schema. | |
4c73bc69 | 1215 | # Author: Elan Ruusamäe <glen@pld-linux.org> |
0d5dd00c ER |
1216 | # |
1217 | # Usage: | |
1218 | # %%openldap_schema_unregister %{schemadir}/horde.schema | |
1219 | # | |
1220 | %openldap_schema_unregister() \ | |
1221 | for schema in %*; do \ | |
1222 | if grep -q "$schema" /etc/openldap/slapd.conf; then \ | |
1223 | %{__sed} -i -e " \ | |
1224 | /^include.*$(echo "$schema" | %{__sed} -e 's,/,\\\\/,g')/d \ | |
1225 | # for symmetry it would be nice if we disable enabled schemas in post, \ | |
1226 | # but we really can not do that, it would break something else. \ | |
1227 | " /etc/openldap/slapd.conf \ | |
1228 | fi \ | |
1229 | done \ | |
1230 | %{nil} | |
1231 | ||
b0bc2936 | 1232 | %env_update [ ! -x /sbin/env-update ] || /sbin/env-update -u || : |
d834e0a1 | 1233 | |
dcc6baf7 | 1234 | |
1235 | # Build modules for kernels 2.6 | |
1236 | # Author: Przemyslaw Iskra <sparky@pld-linux.org> | |
1237 | # | |
1238 | # Usage: | |
aa559e46 | 1239 | # %build_kernel_modules -m <modules> -C <directory> |
dcc6baf7 | 1240 | # |
1241 | # remember that proper Makefile is still required | |
1242 | # Options: | |
990bd03f | 1243 | # -m <modules> (required) -- comma-separated list of modules to save, |
dcc6baf7 | 1244 | # without .ko extension, may be placed in subdirectory |
aa559e46 | 1245 | # -C <directory> -- change to <directory> before doing anything |
dcc6baf7 | 1246 | # -p <arg>, -P <arg> -- arguments passeed to make scripts |
5a81d83e | 1247 | # -c -- do not execute make clean |
dcc6baf7 | 1248 | # <additional arguments> -- all additional arguments will be passed to |
1249 | # make modules | |
1250 | # | |
1251 | # Additional patching supported via here document. Try: | |
1252 | # %build_kernel_modules -m module <<'EOF' | |
1253 | # your patch script here | |
1254 | # EOF | |
1255 | # Don't use it unless patching depends on config options. | |
1256 | ||
1257 | # Developer note: don't touch it unless you know how to handle '\'. | |
1258 | # - \ in script expands to nothing | |
1259 | # - \\\ in script expands to \ | |
566398b4 | 1260 | # - \\\ inside definition expands to nothing |
dcc6baf7 | 1261 | # - \\\\\\\ inside definition expands to \ |
1262 | # - in last line \ has to touch arguments so arguments passing | |
1263 | # in new lines (using \) will be supported | |
1264 | ||
5a81d83e | 1265 | %build_kernel_modules(p:P:m:C:c) \ |
dcc6baf7 | 1266 | %{!?-m:%{error:%{0}: Required module name/list missing} exit 1} \ |
1267 | \ | |
1268 | %define Opts \\\\\\\ | |
1269 | %if "%{_target_base_arch}" != "%{_arch}" \\\ | |
1270 | %if "%{_arch}" == "x86_64" && "%{_target_base_arch}" == "i386" \\\ | |
88608ef7 | 1271 | CC="%{kgcc}" ARCH=%{_target_base_arch} \\\ |
dcc6baf7 | 1272 | %else \\\ |
1273 | ARCH=%{_target_base_arch} CROSS_COMPILE=%{_target_cpu}-pld-linux- \\\ | |
1274 | %endif \\\ | |
1275 | %else \\\ | |
88608ef7 | 1276 | CC="%{kgcc}" \\\ |
dcc6baf7 | 1277 | %endif \ |
88608ef7 | 1278 | %define MakeOpts HOSTCC="%{kgcc}" SYSSRC=%{_kernelsrcdir} SYSOUT=$PWD/o \\\\\\\ |
dcc6baf7 | 1279 | O=$PWD/o %{?with_verbose:V=1} %{Opts} \ |
1280 | \ | |
e364bc26 | 1281 | %{?-C:cd %{-C*}} \ |
dcc6baf7 | 1282 | compile() { \ |
ba9de9b2 ER |
1283 | local L="<" PATCH_SH; \ |
1284 | [[ '%{*}' != *$L$L* ]] || PATCH_SH="set -x -e;$(cat)" \ | |
dcc6baf7 | 1285 | set -e -x \ |
730239f9 | 1286 | local cfgs='%{?with_dist_kernel:%{?with_smp: smp}%{?with_up: up}}%{!?with_dist_kernel: nondist}' \ |
dcc6baf7 | 1287 | \ |
730239f9 | 1288 | for cfg in ${cfgs:-dist}; do \ |
dcc6baf7 | 1289 | [ -r "%{_kernelsrcdir}/config-$cfg" ] || exit 1 \ |
1290 | \ | |
c546f6fb | 1291 | rm -rf o \ |
dcc6baf7 | 1292 | install -d o/include/linux \ |
1293 | ln -sf %{_kernelsrcdir}/config-$cfg o/.config \ | |
1294 | ln -sf %{_kernelsrcdir}/Module.symvers-$cfg o/Module.symvers \ | |
1295 | ln -sf %{_kernelsrcdir}/include/linux/autoconf-$cfg.h o/include/linux/autoconf.h \ | |
1296 | \ | |
1297 | set +x \ | |
1298 | [ -z "$PATCH_SH" ] || echo "$PATCH_SH" | %__spec_build_shell \ | |
1299 | set -x \ | |
1300 | \ | |
1301 | %if %{with dist_kernel} \ | |
1302 | %{__make} -j1 -C %{_kernelsrcdir} prepare scripts \\\ | |
1303 | %{-p*} %{-P*} \\\ | |
1304 | %{MakeOpts} \ | |
1305 | %else \ | |
1306 | install -d o/include/config \ | |
1307 | touch o/include/config/MARKER \ | |
1308 | ln -sf %{_kernelsrcdir}/scripts o/scripts \ | |
1309 | %endif \ | |
1310 | \ | |
5a81d83e | 1311 | %{!?-c:%{__make} -C %{_kernelsrcdir} clean \\\ |
dcc6baf7 | 1312 | RCS_FIND_IGNORE="-name '*.ko' -o" \\\ |
f635907b | 1313 | ${1+"$@"} \\\ |
5a81d83e | 1314 | M=$PWD %{MakeOpts}} \ |
f635907b | 1315 | \ |
dcc6baf7 | 1316 | %{__make} -C %{_kernelsrcdir} modules \\\ |
1317 | ${1+"$@"} \\\ | |
1318 | M=$PWD %{MakeOpts} \ | |
1319 | \ | |
1320 | for MODULE in {%{-m*},}; do \ | |
1321 | [ -z "${MODULE}" ] || mv ${MODULE}{,-$cfg}.ko \ | |
1322 | done \ | |
1323 | done \ | |
aa559e46 | 1324 | %{?-C:cd -} \ |
dcc6baf7 | 1325 | } \ |
1326 | compile %{*}\ | |
1327 | %{nil} | |
1328 | ||
1329 | ||
1330 | # Install kernel modules built by %build_kernel_modules | |
1331 | # Author: Przemyslaw Iskra <sparky@pld-linux.org> | |
1332 | # | |
1333 | # Usage: | |
1334 | # %install_kernel_modules -m <modules> -d <directory> | |
1335 | # | |
1336 | # Options: | |
990bd03f | 1337 | # -m <modules> (required) -- comma-separated list of modules to install, |
dcc6baf7 | 1338 | # without .ko extension, may be placed in subdirectory |
1339 | # -d <directory> (required) -- in what subdirectory modules should be | |
1340 | # installed (eg. misc, kernel/drivers/net) | |
1341 | # -s <suffix> -- suffix to use when installing modules, useful when module | |
1342 | # with same name exists in kernel already | |
1343 | # -n <file> -- name of modprobe config file to use (without .conf extension) | |
00395cf1 | 1344 | # for defining aliases, only useful with -s |
dcc6baf7 | 1345 | |
1346 | %install_kernel_modules(m:d:s:n:) \ | |
1347 | %{!?-m:%{error:%{0}: Required module name (-m) missing}exit 1} \ | |
1348 | %{!?-d:%{error:%{0}: Required module directory missing}exit 1} \ | |
1349 | %{?-n:%{!?-s:%{error:%{0}: Modprobe .conf file requires module suffix}exit 1}} \ | |
1350 | \ | |
1351 | %define KernelD $RPM_BUILD_ROOT/lib/modules/%{_kernel_ver} \ | |
1352 | %define ModprobeD $RPM_BUILD_ROOT%{_sysconfdir}/modprobe.d/%{_kernel_ver} \ | |
412786d1 | 1353 | \ |
730239f9 | 1354 | local cfgs='%{?with_dist_kernel:%{?with_smp: smp}%{?with_up: up}}%{!?with_dist_kernel: nondist}' \ |
dcc6baf7 | 1355 | \ |
1356 | for MODULE in {%{-m*},}; do \ | |
1357 | [ -n "${MODULE}" ] || continue \ | |
730239f9 ER |
1358 | for cfg in ${cfgs:-dist}; do \ |
1359 | [ "$cfg" = smp ] && suf=smp || suf= \ | |
1360 | MNAME=${MODULE##*/} \ | |
1361 | install -D ${MODULE}-$cfg.ko \\\ | |
1362 | %{KernelD}$suf/%{-d*}/${MNAME}%{-s:-%{-s*}}.ko \ | |
b9460afb | 1363 | %{?-s:install -d %{ModprobeD}$suf \ |
730239f9 ER |
1364 | echo "alias ${MNAME} ${MNAME}-%{-s*}" \\\ |
1365 | >> %{ModprobeD}$suf/%{-n*}.conf} \ | |
1366 | done \ | |
dcc6baf7 | 1367 | done \ |
1368 | %{nil} | |
1369 | ||
fa65356c | 1370 | # patchset macros |
4c73bc69 | 1371 | # Author: Elan Ruusamäe <glen@pld-linux.org> |
fa65356c ER |
1372 | # |
1373 | # Usage: | |
1374 | # %patchset_source -f <seq(1) format> <start> [<end>] | |
1375 | # %patchset_patch <start> [<end>] | |
1376 | # | |
1377 | # If <end> is omited, it is assumed to be <start>. | |
1378 | # | |
1379 | # For example in preamble: | |
1380 | # %patchset_source -f ftp://ftp.vim.org/pub/editors/vim/patches/7.0/7.0.%03g 33 44 | |
1381 | # and in %prep: | |
1382 | # %patchset_patch 33 44 | |
1383 | ||
1384 | # generate SourceX urls from range START STOP | |
1385 | # Format can be SINGLE format char of %e, %f, %g, see seq(1) | |
1386 | # The sources start from 10000 | |
e91610db | 1387 | %patchset_source(f:b:) %( |
44f733ef | 1388 | base=%{-b*}%{!-b*:10000}; |
962f9ecf ER |
1389 | start=$(expr $base + %1); |
1390 | end=$(expr $base + %{?2}%{!?2:%{1}}); | |
e91610db ER |
1391 | # we need to call seq twice as it doesn't allow two formats |
1392 | seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1; | |
1393 | seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2; | |
1394 | paste %{tmpdir}/__ps{1,2}; | |
1395 | rm -f %{tmpdir}/__ps{1,2}; | |
962f9ecf ER |
1396 | ) \ |
1397 | %{nil} | |
fa65356c ER |
1398 | |
1399 | # apply sources from %patchset_source | |
1400 | # -p specify -pX for %patch line | |
1401 | # -b base offset: defaults to 10000 | |
1402 | %patchset_patch(f:p:b:) %( | |
44f733ef | 1403 | base=%{-b*}%{!-b*:10000}; |
962f9ecf ER |
1404 | start=$(expr $base + %1); |
1405 | end=$(expr $base + %{?2}%{!?2:%{1}}); | |
e91610db ER |
1406 | echo ": patchset_patch %1%{?2: to %2}"; |
1407 | seq -f 'patch%g %{-p*:-p%{-p*}}' $start $end | sed -e s,^,%%,; | |
962f9ecf ER |
1408 | ) \ |
1409 | %{nil} | |
fa65356c | 1410 | |
5730b44b | 1411 | # browser plugins v2 |
4c73bc69 | 1412 | # Author: Elan Ruusamäe <glen@pld-linux.org> |
5730b44b ER |
1413 | # |
1414 | # Usage: | |
1415 | # %browser_plugins_add_browser <name> -p <plugindir> | |
1416 | # | |
1417 | # <name> (required) -- name of the browser. usually %{name}. | |
1418 | # -p <plugindir> (required) -- in what directory browser searches for its plugins. | |
02ebf70f ER |
1419 | # -b -- default blacklists |
1420 | # -a <arch> override arch | |
5730b44b ER |
1421 | # |
1422 | # Example: | |
1423 | # %browser_plugins_add_browser %{name} -p %{_firefoxdir}/plugins | |
1424 | ||
1425 | %_browserpluginsconfdir /etc/browser-plugins | |
5e19a4dc | 1426 | %_browserpluginsdir %{_libdir}/browser-plugins |
5730b44b ER |
1427 | %update_browser_plugins /usr/sbin/update-browser-plugins || : |
1428 | ||
02ebf70f | 1429 | %browser_plugins_add_browser(p:b:a:) \ |
9efd458e | 1430 | browser=%1.%{!-a:%{_target_base_arch}}%{-a*} \ |
5730b44b | 1431 | install -d $RPM_BUILD_ROOT%{_browserpluginsconfdir}/{blacklist,browsers}.d \ |
02ebf70f ER |
1432 | ln -s %{-p*} $RPM_BUILD_ROOT%{_browserpluginsconfdir}/browsers.d/$browser \ |
1433 | blacklist_file=$RPM_BUILD_ROOT%{_browserpluginsconfdir}/blacklist.d/$browser.blacklist \ | |
5730b44b ER |
1434 | echo '# This file format is shell globs at base dir of plugindir' > $blacklist_file \ |
1435 | %{-b:cat >> $blacklist_file %{-b*}} \ | |
1436 | %{nil} | |
1437 | ||
ad17b654 ER |
1438 | # Helper for LUA. |
1439 | # split string separated by space into quoted list | |
1440 | # | |
4c73bc69 | 1441 | # Author: Elan Ruusamäe <glen@pld-linux.org> |
ad17b654 ER |
1442 | # |
1443 | # %__lua_split /bin/sh /bin/pdksh -> "/bin/sh", "/bin/pdksh" | |
1444 | %__lua_split() %(echo "%*" | awk '{for (i=1;i<=NF;i++) printf("\\"%%s\\"%%s", $i, i == NF ? "" : ", ")}') | |
1445 | ||
1446 | # adjust /etc/shells by adding and removing shells from there | |
4c73bc69 | 1447 | # Author: Elan Ruusamäe <glen@pld-linux.org> |
ad17b654 ER |
1448 | # |
1449 | # Usage: | |
d9b789d9 ER |
1450 | # %post -p <lua> |
1451 | # %lua_add_etc_shells /bin/sh /bin/pdksh | |
ad17b654 | 1452 | # |
d9b789d9 ER |
1453 | # %preun -p <lua> |
1454 | # if arg[2] == 0 then | |
1455 | # %lua_remove_etc_shells /bin/bash /bin/rbash | |
1456 | # end | |
7377b5ca ER |
1457 | # |
1458 | # Requirements: | |
d9b789d9 ER |
1459 | # BuildRequires: rpmbuild(macros) >= 1.462 |
1460 | # | |
ad17b654 | 1461 | |
d9b789d9 | 1462 | %lua_add_etc_shells() \ |
ad17b654 ER |
1463 | t = {}\ |
1464 | f = io.open("/etc/shells", "r")\ | |
1465 | if f then\ | |
1466 | for l in f:lines() do t[l]=l; end\ | |
1467 | f:close()\ | |
1468 | end\ | |
1469 | for _, s in ipairs({%{expand:%%__lua_split %*}}) do\ | |
1470 | if not t[s] then\ | |
b8c0bc18 | 1471 | print("Adding "..s.." to /etc/shells")\ |
ad17b654 ER |
1472 | f = io.open("/etc/shells", "a"); f:write(s.."\\n"); f:close()\ |
1473 | end\ | |
1474 | end\ | |
1475 | %{nil} | |
1476 | ||
d9b789d9 ER |
1477 | %lua_remove_etc_shells() \ |
1478 | t = {}\ | |
1479 | f = io.open("/etc/shells", "r")\ | |
1480 | if f then\ | |
1481 | for l in f:lines() do t[l]=l; end\ | |
1482 | f:close()\ | |
1483 | end\ | |
1484 | for _, l in pairs({%{expand:%%__lua_split %*}}) do\ | |
1485 | print("Removing "..l.." from /etc/shells")\ | |
1486 | t[l] = nil\ | |
1487 | end\ | |
1488 | s=""\ | |
1489 | for _, l in pairs(t) do\ | |
1490 | s=s..l.."\\n"\ | |
1491 | end\ | |
1492 | io.open("/etc/shells", "w"):write(s)\ | |
1493 | %{nil} | |
1494 | ||
1495 | # Backwards compat. Use of %lua_ prefixed macros is preferred as these are cleaner to read. | |
1496 | # | |
1497 | # Author: Elan Ruusamäe <glen@pld-linux.org> | |
1498 | # | |
1499 | # Usage: | |
1500 | # %post -p %add_etc_shells -p /bin/sh /bin/pdksh | |
1501 | # %preun -p %remove_etc_shells -p /bin/sh /bin/pdksh | |
1502 | # | |
1503 | # -p (optional) -- specifies that result is embeded %post script (prepends <lua> as first line) | |
1504 | # | |
1505 | # Requirements: | |
1506 | # BuildRequires: rpmbuild(macros) >= 1.429 | |
1507 | # | |
1508 | %add_etc_shells(p) %{-p:<lua>}\ | |
1509 | %{expand:%%lua_add_etc_shells %*}\ | |
1510 | %{nil} | |
1511 | ||
ad17b654 | 1512 | %remove_etc_shells(p) %{-p:<lua>}\ |
b8c0bc18 | 1513 | %{-p:if arg[2] == 0 then}\ |
d9b789d9 | 1514 | %{expand:%%lua_remove_etc_shells %*}\ |
750e19f4 | 1515 | %{-p:end} \ |
ad17b654 ER |
1516 | %{nil} |
1517 | ||
59d3ebe9 | 1518 | # vim:ts=4 sw=4 noet syn=spec |