bootable/newinstaller
Revision | 9c63ab239f8bc07860da29dfd74d14f144b14ab4 (tree) |
---|---|
Time | 2017-04-24 11:57:16 |
Author | Chih-Wei Huang <cwhuang@linu...> |
Commiter | Chih-Wei Huang |
Add a script to run Android-x86 in QEMU
The qemu-android script is installed as a part of the rpm. Users
can run the script directly to launch Android-x86 in the QEMU
virtual machine.
The script could also be used on a build host to run the just
built images in the $OUT directory.
@@ -79,13 +79,13 @@ $(ISO_IMAGE): $(boot_dir) $(BUILT_IMG) | ||
79 | 79 | $(hide) isohybrid --uefi $@ || echo -e "isohybrid not found.\nInstall syslinux 4.0 or higher if you want to build a usb bootable iso." |
80 | 80 | @echo -e "\n\n$@ is built successfully.\n\n" |
81 | 81 | |
82 | -rpm: $(LOCAL_PATH)/rpm/rpm.spec $(BUILT_IMG) | |
82 | +rpm: $(wildcard $(LOCAL_PATH)/rpm/*) $(BUILT_IMG) | |
83 | 83 | @echo ----- Making an rpm ------ |
84 | - OUT=$(abspath $(PRODUCT_OUT)); mkdir -p $$OUT/rpm/BUILD; rm -rf mv $$OUT/rpm/RPMS/*; \ | |
84 | + OUT=$(abspath $(PRODUCT_OUT)); mkdir -p $$OUT/rpm/BUILD; rm -rf $$OUT/rpm/RPMS/*; $(ACP) $< $$OUT; \ | |
85 | 85 | rpmbuild -bb --target=$(if $(filter x86,$(TARGET_ARCH)),i686,x86_64) -D"cmdline $(BOARD_KERNEL_CMDLINE)" \ |
86 | 86 | -D"_topdir $$OUT/rpm" -D"_sourcedir $$OUT" -D"systemimg $(notdir $(systemimg))" -D"ver $(VER)" \ |
87 | 87 | $(if $(BUILD_NAME_VARIANT),-D"name $(BUILD_NAME_VARIANT)") \ |
88 | - -D"install_prefix $(if $(INSTALL_PREFIX),$(INSTALL_PREFIX),android-$(VER))" $<; \ | |
88 | + -D"install_prefix $(if $(INSTALL_PREFIX),$(INSTALL_PREFIX),android-$(VER))" $(filter %.spec,$^); \ | |
89 | 89 | mv $$OUT/rpm/RPMS/*/*.rpm $$OUT |
90 | 90 | |
91 | 91 | # Note: requires dosfstools |
@@ -3,7 +3,7 @@ | ||
3 | 3 | # By Chih-Wei Huang <cwhuang@linux.org.tw> |
4 | 4 | # and Thorsten Glaser <tg@mirbsd.org> |
5 | 5 | # |
6 | -# Last updated 2017/03/24 | |
6 | +# Last updated 2017/04/23 | |
7 | 7 | # |
8 | 8 | # License: GNU Public License |
9 | 9 | # We explicitely grant the right to use the scripts |
@@ -84,10 +84,14 @@ check_root() | ||
84 | 84 | mkdir /mnt/iso |
85 | 85 | mount -o loop /iso/$iso /mnt/iso |
86 | 86 | SRC=iso |
87 | - elif [ ! -e /mnt/$SRC/$RAMDISK ]; then | |
87 | + fi | |
88 | + if [ -e /mnt/$SRC/$RAMDISK ]; then | |
89 | + zcat /mnt/$SRC/$RAMDISK | cpio -id > /dev/null | |
90 | + elif [ -b /dev/$RAMDISK ]; then | |
91 | + zcat /dev/$RAMDISK | cpio -id > /dev/null | |
92 | + else | |
88 | 93 | return 1 |
89 | 94 | fi |
90 | - zcat /mnt/$SRC/$RAMDISK | cpio -id > /dev/null | |
91 | 95 | if [ -e /mnt/$SRC/system.sfs ]; then |
92 | 96 | mount -o loop,noatime /mnt/$SRC/system.sfs /sfs |
93 | 97 | mount -o loop,noatime /sfs/system.img system |
@@ -97,6 +101,8 @@ check_root() | ||
97 | 101 | elif [ -d /mnt/$SRC/system ]; then |
98 | 102 | remount_rw |
99 | 103 | mount --bind /mnt/$SRC/system system |
104 | + elif [ -e /mnt/build.prop ]; then | |
105 | + mount --bind /mnt system | |
100 | 106 | else |
101 | 107 | rm -rf * |
102 | 108 | return 1 |
@@ -128,7 +134,7 @@ debug_shell() | ||
128 | 134 | echo -n Detecting Android-x86... |
129 | 135 | |
130 | 136 | [ -z "$SRC" -a -n "$BOOT_IMAGE" ] && SRC=`dirname $BOOT_IMAGE` |
131 | -[ -z "$RAMDISK" ] && RAMDISK=ramdisk.img | |
137 | +[ -z "$RAMDISK" ] && RAMDISK=ramdisk.img || RAMDISK=${RAMDISK##/dev/} | |
132 | 138 | |
133 | 139 | for c in `cat /proc/cmdline`; do |
134 | 140 | case $c in |
@@ -1,6 +1,6 @@ | ||
1 | 1 | # |
2 | 2 | # By Chih-Wei Huang <cwhuang@linux.org.tw> |
3 | -# Last updated 2017/01/10 | |
3 | +# Last updated 2017/04/23 | |
4 | 4 | # |
5 | 5 | # License: GNU Public License |
6 | 6 | # We explicitely grant the right to use the scripts |
@@ -15,6 +15,9 @@ mount_data() | ||
15 | 15 | if [ -b "/dev/$blk" ]; then |
16 | 16 | [ ! -e /dev/block/$blk ] && ln /dev/$blk /dev/block |
17 | 17 | mount -o noatime /dev/block/$blk data |
18 | + elif [ "$DATA" = "9p" ]; then | |
19 | + modprobe 9pnet_virtio | |
20 | + mount -t 9p -o trans=virtio data data -oversion=9p2000.L,posixacl,cache=loose | |
18 | 21 | else |
19 | 22 | remount_rw |
20 | 23 | mkdir -p /mnt/$SRC/$DATA |
@@ -0,0 +1,53 @@ | ||
1 | +#!/bin/bash | |
2 | +# By Chih-Wei Huang <cwhuang@linux.org.tw> | |
3 | +# License: GNU Generic Public License v2 | |
4 | + | |
5 | +continue_or_stop() | |
6 | +{ | |
7 | + echo "Please Enter to continue or Ctrl-C to stop." | |
8 | + read | |
9 | +} | |
10 | + | |
11 | +QEMU_ARCH=`uname -m` | |
12 | +QEMU=qemu-system-${QEMU_ARCH} | |
13 | + | |
14 | +which $QEMU > /dev/null 2>&1 || QEMU=qemu-system-i386 | |
15 | +if ! which $QEMU > /dev/null 2>&1; then | |
16 | + echo -e "Please install $QEMU to run the program.\n" | |
17 | + exit 1 | |
18 | +fi | |
19 | + | |
20 | +cd ${OUT:-ANDROID_ROOT} | |
21 | + | |
22 | +[ -e system.img ] && SYSTEMIMG=system.img || SYSTEMIMG=system.sfs | |
23 | + | |
24 | +if [ -d data ]; then | |
25 | + if [ `id -u` -eq 0 ]; then | |
26 | + DATA="-virtfs local,id=data,path=data,security_model=passthrough,mount_tag=data" | |
27 | + DATADEV='DATA=9p' | |
28 | + else | |
29 | + echo -e "\n$(realpath data) subfolder exists.\nIf you want to save data to it, run $0 as root:\n\n$ sudo $0\n" | |
30 | + continue_or_stop | |
31 | + fi | |
32 | +elif [ -e data.img ]; then | |
33 | + if [ -w data.img ]; then | |
34 | + DATA="-drive index=2,if=virtio,id=data,file=data.img" | |
35 | + DATADEV='DATA=vdc' | |
36 | + else | |
37 | + echo -e "\n$(realpath data.img) exists but is not writable.\nPlease grant the write permission if you want to save data to it.\n" | |
38 | + continue_or_stop | |
39 | + fi | |
40 | +fi | |
41 | + | |
42 | +$QEMU -enable-kvm -vga std -sdl \ | |
43 | + -kernel kernel \ | |
44 | + -append "CMDLINE console=ttyS0 RAMDISK=vdb $DATADEV" \ | |
45 | + -initrd initrd.img \ | |
46 | + -m 2048 -smp 2 -cpu host \ | |
47 | + -soundhw ac97 \ | |
48 | + -net nic,model=e1000 -net user \ | |
49 | + -serial mon:stdio \ | |
50 | + -boot menu=on \ | |
51 | + -drive index=0,if=virtio,id=system,file=$SYSTEMIMG,format=raw,readonly \ | |
52 | + -drive index=1,if=virtio,id=ramdisk,file=ramdisk.img,format=raw,readonly \ | |
53 | + $DATA $@ |
@@ -6,6 +6,7 @@ Source1: kernel | ||
6 | 6 | Source2: initrd.img |
7 | 7 | Source3: ramdisk.img |
8 | 8 | Source4: %{systemimg} |
9 | +Source5: qemu-android | |
9 | 10 | License: Apache Public License / GPLv2 |
10 | 11 | Group: Operating system/Android |
11 | 12 | URL: http://www.android-x86.org |
@@ -22,8 +23,10 @@ or later. | ||
22 | 23 | |
23 | 24 | %install |
24 | 25 | rm -rf %{buildroot} |
25 | -mkdir -p %{buildroot}/%{install_prefix} | |
26 | +mkdir -p %{buildroot}/%{install_prefix} %{buildroot}%{_bindir} | |
26 | 27 | install -m644 %{S:1} %{S:2} %{S:3} %{S:4} %{buildroot}/%{install_prefix} |
28 | +install -m755 %{S:5} %{buildroot}%{_bindir} | |
29 | +sed -i "s|ANDROID_ROOT|/%{install_prefix}|; s|CMDLINE|%{cmdline}|" %{buildroot}%{_bindir}/`basename %{S:5}` | |
27 | 30 | |
28 | 31 | %post |
29 | 32 | . /etc/os-release |
@@ -69,3 +72,4 @@ rm -rf %{buildroot} | ||
69 | 72 | |
70 | 73 | %files |
71 | 74 | /%{install_prefix}/* |
75 | +%{_bindir}/* |