]>
Commit | Line | Data |
---|---|---|
1 | # | |
2 | # TODO: | |
3 | # - wait till the gcc bug http://gcc.gnu.org/PR16185 is fixed. | |
4 | # | |
5 | # Conditional build: | |
6 | %bcond_without kqemu # disable KQEMU ACCELERATOR support in QEMU | |
7 | %bcond_with cflags_passing # with passing rpmcflags to Makefiles | |
8 | %bcond_with dosguest # add special patch when use with DOS as guest os | |
9 | %bcond_with nosdlgui # do not use SDL gui (use X11 instead) | |
10 | # Note that gcc4 build is very problematic and not supported by qemu team | |
11 | %bcond_without gcc4 # use gcc4 patches (broke build on gcc33) | |
12 | %bcond_without dist_kernel # without distribution kernel | |
13 | %bcond_without kernel # build kqemu KERNEL MODULES | |
14 | %bcond_without userspace # don't build userspace | |
15 | %bcond_with grsec_kernel # build for kernel-grsecurity | |
16 | # | |
17 | %if %{with kernel} && %{with dist_kernel} && %{with grsec_kernel} | |
18 | %define alt_kernel grsecurity | |
19 | %endif | |
20 | ||
21 | # no kqemu for ppc | |
22 | %ifarch ppc | |
23 | %undefine with_kqemu | |
24 | %undefine with_kernel | |
25 | %endif | |
26 | %define _kqemu_version 1.3.0pre11 | |
27 | %define _rel 2 | |
28 | Summary: QEMU CPU Emulator | |
29 | Summary(pl.UTF-8): QEMU - emulator procesora | |
30 | Name: qemu | |
31 | Version: 0.9.0 | |
32 | Release: %{_rel}%{?with_kqemu:k} | |
33 | License: GPL | |
34 | Group: Applications/Emulators | |
35 | #Source0Download: http://fabrice.bellard.free.fr/qemu/download.html | |
36 | Source0: http://fabrice.bellard.free.fr/qemu/%{name}-%{version}.tar.gz | |
37 | # Source0-md5: ab11a03ba30cf4a70641f0f170473d69 | |
38 | Source1: http://fabrice.bellard.free.fr/qemu/k%{name}-%{_kqemu_version}.tar.gz | |
39 | # Source1-md5: 970521874ef8b1ba4598925ace5936c3 | |
40 | Patch0: %{name}-nostatic.patch | |
41 | Patch1: %{name}-cc.patch | |
42 | Patch3: %{name}-dot.patch | |
43 | Patch4: %{name}-gcc4_x86.patch | |
44 | Patch5: %{name}-gcc4_ppc.patch | |
45 | Patch6: %{name}-nosdlgui.patch | |
46 | # Proof of concept, for reference, do not remove | |
47 | Patch8: %{name}-kde_virtual_workspaces_hack.patch | |
48 | # http://gwenole.beauchesne.info/en/projects/qemu | |
49 | Patch9: %{name}-0.8.0-gcc4-hacks.patch | |
50 | Patch11: %{name}-0.7.2-gcc4-opts.patch | |
51 | #Patch12: %{name}-0.7.2-dyngen-check-stack-clobbers.patch | |
52 | Patch13: %{name}-dosguest.patch | |
53 | URL: http://fabrice.bellard.free.fr/qemu/ | |
54 | %if %{with kernel} && %{with dist_kernel} | |
55 | BuildRequires: kernel%{_alt_kernel}-module-build >= 3:2.6.7 | |
56 | BuildRequires: rpmbuild(macros) >= 1.379 | |
57 | %endif | |
58 | %if %{with userspace} | |
59 | BuildRequires: SDL-devel >= 1.2.1 | |
60 | BuildRequires: alsa-lib-devel | |
61 | %{!?with_gcc4:BuildRequires: gcc < 5:4.0} | |
62 | BuildRequires: perl-tools-pod | |
63 | BuildRequires: tetex | |
64 | BuildRequires: sed >= 4.0 | |
65 | %endif | |
66 | Requires: SDL >= 1.2.1 | |
67 | # sparc is currently unsupported (missing cpu_get_real_ticks() impl in vl.c) | |
68 | ExclusiveArch: %{ix86} %{x8664} ppc | |
69 | BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) | |
70 | ||
71 | # some SPARC boot image in ELF format | |
72 | %define _noautostrip .*%{_datadir}/qemu/openbios-sparc32 | |
73 | ||
74 | %description | |
75 | QEMU is a FAST! processor emulator. By using dynamic translation it | |
76 | achieves a reasonnable speed while being easy to port on new host | |
77 | CPUs. QEMU has two operating modes: | |
78 | ||
79 | - User mode emulation. In this mode, QEMU can launch Linux processes | |
80 | compiled for one CPU on another CPU. Linux system calls are converted | |
81 | because of endianness and 32/64 bit mismatches. Wine (Windows | |
82 | emulation) and DOSEMU (DOS emulation) are the main targets for QEMU. | |
83 | ||
84 | - Full system emulation. In this mode, QEMU emulates a full system, | |
85 | including a processor and various peripherials. It can also be used to | |
86 | provide virtual hosting of several virtual PC on a single server. | |
87 | ||
88 | %description -l pl.UTF-8 | |
89 | QEMU to szybki(!) emulator procesora. Poprzez użycie dynamicznego | |
90 | tłumaczenia osiąga rozsądną szybkość i jest łatwy do przeportowania, | |
91 | aby działał na kolejnych procesorach. QEMU ma dwa tryby pracy: | |
92 | ||
93 | - Emulacja trybu użytkownika. W tym trybie QEMU może uruchamiać | |
94 | procesy linuksowe skompilowane dla jednego procesora na innym | |
95 | procesorze. Linuksowe wywołania systemowe są tłumaczone ze względu na | |
96 | niezgodność kolejności bajtów w słowie i 32/64-bitowego rozmiaru | |
97 | słowa. Wine (emulacja Windows) i DOSEMU (emulacja DOS-a) to główne | |
98 | cele QEMU. | |
99 | ||
100 | - Pełna emulacja systemu. W tym trybie QEMU emuluje cały system, | |
101 | włączając w to procesor i różne urządzenia peryferyjne. Może być także | |
102 | używane do wirtualnego hostowania kilku wirtualnych pecetów na | |
103 | pojedynczym serwerze. | |
104 | ||
105 | %package -n kernel%{_alt_kernel}-misc-kqemu | |
106 | Summary: kqemu - kernel module | |
107 | Summary(pl.UTF-8): kqemu - moduł jądra | |
108 | Version: %{_kqemu_version} | |
109 | Release: %{_rel}@%{_kernel_ver_str} | |
110 | Group: Base/Kernel | |
111 | %{?with_dist_kernel:%requires_releq_kernel} | |
112 | License: GPL v2 | |
113 | Obsoletes: kernel%{_alt_kernel}-smp-misc-kqemu | |
114 | Requires(post,postun): /sbin/depmod | |
115 | Requires: module-init-tools >= 3.2.2-2 | |
116 | ||
117 | %description -n kernel%{_alt_kernel}-misc-kqemu | |
118 | kqemu - kernel module. | |
119 | ||
120 | %description -n kernel%{_alt_kernel}-misc-kqemu -l pl.UTF-8 | |
121 | kqemu - moduł jądra. | |
122 | ||
123 | %prep | |
124 | %setup -q %{?with_kernel:-a1} | |
125 | %patch0 -p1 | |
126 | %patch1 -p1 | |
127 | %patch3 -p1 | |
128 | %if %{with gcc4} | |
129 | %patch9 -p1 | |
130 | %patch11 -p1 | |
131 | #%patch12 -p1 | |
132 | #%patch4 -p0 | |
133 | %patch5 -p1 | |
134 | %endif | |
135 | %{?with_nosdlgui:%patch6 -p1} | |
136 | #%patch8 -p1 | |
137 | ||
138 | %{__sed} -i -e 's/sdl_static=yes/sdl_static=no/' configure | |
139 | %{__sed} -i 's/.*MAKE) -C kqemu$//' Makefile | |
140 | ||
141 | # cannot use optflags on x86 - they cause "no register to spill" errors | |
142 | %if %{with cflags_passing} | |
143 | %{__sed} -i -e 's/-Wall -O2 -g/-Wall %{rpmcflags}/' Makefile Makefile.target | |
144 | %else | |
145 | %{__sed} -i 's/-Wall -O2 -g/-Wall -O2/' Makefile Makefile.target | |
146 | %endif | |
147 | ||
148 | %if %{with kernel} | |
149 | echo -n > kqemu-%{_kqemu_version}/install.sh | |
150 | ||
151 | cat <<'EOF' > modprobe.conf | |
152 | # enable dynamic major | |
153 | options kqemu major=0 | |
154 | # for autoloading from static dev | |
155 | #alias char-major-250 kqemu | |
156 | EOF | |
157 | ||
158 | cat <<'EOF' > udev.conf | |
159 | KERNEL=="kqemu", NAME="%k", MODE="0666" | |
160 | EOF | |
161 | %endif | |
162 | ||
163 | %if %{with dosguest} | |
164 | %patch13 -p1 | |
165 | %endif | |
166 | ||
167 | %build | |
168 | %if %{with kernel} | |
169 | cd kqemu-%{_kqemu_version} | |
170 | ||
171 | %{__sed} -i 's#include ../config-host.mak##' ./common/Makefile | |
172 | %ifarch %{x8664} | |
173 | %{__sed} -i 's/^#ARCH=x86_64/ARCH=x86_64/' ./common/Makefile | |
174 | %{__make} -j1 -C common | |
175 | mv -f kqemu-mod-x86_64.o{,.bin} | |
176 | %else | |
177 | %{__sed} -i 's/^#ARCH=i386/ARCH=i386/' ./common/Makefile | |
178 | %{__make} -j1 -C common | |
179 | mv -f kqemu-mod-i386.o{,.bin} | |
180 | %endif | |
181 | ||
182 | mv -f kqemu-linux.c{,.orig} | |
183 | cat > Makefile <<'EOF' | |
184 | obj-m := kqemu.o | |
185 | kqemu-objs:= kqemu-linux.o kqemu-mod.o | |
186 | ||
187 | $(obj)/kqemu-mod.o: $(src)/kqemu-mod-$(ARCH).o.bin | |
188 | cp $< $@ | |
189 | EOF | |
190 | ||
191 | %build_kernel_modules -m kqemu <<'EOF' | |
192 | if grep -q "CONFIG_PREEMPT_RT" o/.config; then | |
193 | sed 's/SPIN_LOCK_UNLOCKED/SPIN_LOCK_UNLOCKED(kqemu_lock)/' \ | |
194 | kqemu-linux.c.orig > kqemu-linux.c | |
195 | else | |
196 | cat kqemu-linux.c.orig > kqemu-linux.c | |
197 | fi | |
198 | EOF | |
199 | cd - | |
200 | %endif | |
201 | ||
202 | %if %{with userspace} | |
203 | # --extra-cflags don't work (overridden by CFLAGS in Makefile*) | |
204 | # they can be passed if the cflags_passing bcond is used | |
205 | ./configure \ | |
206 | --prefix=%{_prefix} \ | |
207 | --cc="%{__cc}" \ | |
208 | --host-cc="%{__cc}" \ | |
209 | --make="%{__make}" \ | |
210 | %if %{with kqemu} | |
211 | --kernel-path=%{_kernelsrcdir} \ | |
212 | %else | |
213 | --disable-kqemu \ | |
214 | %endif | |
215 | %{?with_gcc4:--disable-gcc-check} \ | |
216 | --enable-alsa \ | |
217 | --interp-prefix=%{_libdir}/%{name} | |
218 | %{__make} | |
219 | %endif | |
220 | ||
221 | %install | |
222 | rm -rf $RPM_BUILD_ROOT | |
223 | ||
224 | %if %{with userspace} | |
225 | %{__make} install \ | |
226 | DESTDIR=$RPM_BUILD_ROOT | |
227 | ||
228 | install -d $RPM_BUILD_ROOT%{_sysconfdir} | |
229 | cat <<'EOF' > $RPM_BUILD_ROOT%{_sysconfdir}/qemu-ifup | |
230 | #!/bin/sh | |
231 | ||
232 | EOF | |
233 | %endif | |
234 | ||
235 | %if %{with kernel} | |
236 | %install_kernel_modules -m kqemu-%{_kqemu_version}/kqemu -d misc | |
237 | install -d $RPM_BUILD_ROOT/etc/{modprobe.d/%{_kernel_ver}{,smp},udev/rules.d} | |
238 | install modprobe.conf $RPM_BUILD_ROOT/etc/modprobe.d/%{_kernel_ver}/kqemu.conf | |
239 | install udev.conf $RPM_BUILD_ROOT/etc/udev/rules.d/kqemu.rules | |
240 | %endif | |
241 | ||
242 | # already packaged | |
243 | rm -rf $RPM_BUILD_ROOT%{_docdir}/qemu/qemu-{doc,tech}.html | |
244 | ||
245 | %clean | |
246 | rm -rf $RPM_BUILD_ROOT | |
247 | ||
248 | %if %{with kernel} | |
249 | %post | |
250 | %banner %{name} -e <<EOF | |
251 | To enable qemu accelerator (kqemu), the kqemu kernel module must be loaded: | |
252 | modprobe kqemu | |
253 | EOF | |
254 | %endif | |
255 | ||
256 | %post -n kernel%{_alt_kernel}-misc-kqemu | |
257 | %depmod %{_kernel_ver} | |
258 | ||
259 | %postun -n kernel%{_alt_kernel}-misc-kqemu | |
260 | %depmod %{_kernel_ver} | |
261 | ||
262 | %if %{with userspace} | |
263 | %files | |
264 | %defattr(644,root,root,755) | |
265 | %doc README qemu-doc.html qemu-tech.html | |
266 | %attr(755,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/qemu-ifup | |
267 | %attr(755,root,root) %{_bindir}/* | |
268 | %{_datadir}/qemu | |
269 | %{_mandir}/man1/qemu.1* | |
270 | %{_mandir}/man1/qemu-img.1* | |
271 | %endif | |
272 | ||
273 | %if %{with kernel} | |
274 | %files -n kernel%{_alt_kernel}-misc-kqemu | |
275 | %defattr(644,root,root,755) | |
276 | %doc kqemu-%{_kqemu_version}/LICENSE | |
277 | %config(noreplace) %verify(not md5 mtime size) /etc/udev/rules.d/kqemu.rules | |
278 | %config(noreplace) %verify(not md5 mtime size) /etc/modprobe.d/%{_kernel_ver}/kqemu.conf | |
279 | /lib/modules/%{_kernel_ver}/misc/kqemu.ko* | |
280 | %endif |