OSDN Git Service

Add a script to run Android-x86 in QEMU
[android-x86/bootable-newinstaller.git] / rpm / rpm.spec
1 Summary: %{?title}%{!?title:Android-x86} - Run Android on your PC
2 Name: %{?name}%{!?name:android-x86}
3 Version: %(echo %{ver} | cut -d- -f1)
4 Release: %(echo %{ver} | cut -d- -f2)
5 Source1: kernel
6 Source2: initrd.img
7 Source3: ramdisk.img
8 Source4: %{systemimg}
9 Source5: qemu-android
10 License: Apache Public License / GPLv2
11 Group: Operating system/Android
12 URL: http://www.android-x86.org
13
14 %description
15 Android-x86 is an open source project to port AOSP to x86 platform. Most
16 components of the project is licensed under Apache Public License 2.0.
17 Some components are licensed under GNU General Public License (GPL) 2.0
18 or later.
19
20 %prep
21
22 %build
23
24 %install
25 rm -rf %{buildroot}
26 mkdir -p %{buildroot}/%{install_prefix} %{buildroot}%{_bindir}
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}`
30
31 %post
32 . /etc/os-release
33 mkdir -p /%{install_prefix}/data
34 if [ "$ID" = "debian" -o "$ID_LIKE" = "debian" ]; then
35         grubcfg=/boot/grub/custom.cfg
36 elif mountpoint -q /boot/efi; then
37         grubcfg=/boot/efi/EFI/$ID/custom.cfg && efi=efi
38 else
39         grubcfg=/boot/grub2/custom.cfg
40 fi
41 echo -e "menuentry \"%{?title}%{!?title:Android-x86} %{ver}\" {\n\tsearch --set=root --file /%{install_prefix}/kernel\n\tlinux$efi /%{install_prefix}/kernel quiet %{cmdline} \n\tinitrd$efi /%{install_prefix}/initrd.img\n}" > $grubcfg
42 echo -e "menuentry \"%{?title}%{!?title:Android-x86} %{ver} (DEBUG mode)\" {\n\tsearch --set=root --file /%{install_prefix}/kernel\n\tlinux$efi /%{install_prefix}/kernel %{cmdline} DEBUG=2\n\tinitrd$efi /%{install_prefix}/initrd.img\n}" >> $grubcfg
43
44 if [ "$ID" = "debian" -o "$ID_LIKE" = "debian" ]; then
45         sed -i 's/^GRUB_HIDDEN_/#GRUB_HIDDEN_/' /etc/default/grub
46         update-grub
47 fi
48
49 %postun
50 . /etc/os-release
51 if [ "$ID" = "debian" -o "$ID_LIKE" = "debian" ]; then
52         grubcfg=/boot/grub/custom.cfg
53 elif mountpoint -q /boot/efi; then
54         grubcfg=/boot/efi/EFI/$ID/custom.cfg
55 else
56         grubcfg=/boot/grub2/custom.cfg
57 fi
58 if [ "$1" = "1" ]; then
59         new_prefix=`dirname $(grep initrd $grubcfg | head -1 | awk '{print $2}')`
60         if [ "$new_prefix" != "/%{install_prefix}" ]; then
61                 rmdir $new_prefix/data
62                 mv /%{install_prefix}/data $new_prefix
63                 rmdir /%{install_prefix}
64         fi
65 else
66         rmdir /%{install_prefix}/data /%{install_prefix}
67         rm -f $grubcfg
68 fi
69
70 %clean
71 rm -rf %{buildroot}
72
73 %files
74 /%{install_prefix}/*
75 %{_bindir}/*