diff options
author | Sam Mulvey (mercury) | 2019-04-26 16:52:31 -0700 |
---|---|---|
committer | Sam Mulvey (mercury) | 2019-04-26 16:52:31 -0700 |
commit | 07d412c936db75acb6c1f8e732f36d33fb43a0f3 (patch) | |
tree | 5847e0afb5a496a44c9e555ee2bac8ddd411df11 | |
download | aur-07d412c936db75acb6c1f8e732f36d33fb43a0f3.tar.gz |
initial commit from personal repo
-rw-r--r-- | .SRCINFO | 28 | ||||
-rw-r--r-- | PKGBUILD | 41 | ||||
-rw-r--r-- | config | 52 | ||||
-rw-r--r-- | qemu-android | 158 | ||||
-rw-r--r-- | qemu-android-x86.install | 17 | ||||
-rw-r--r-- | qemu-android.desktop | 8 |
6 files changed, 304 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..909b2fec389a --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,28 @@ +pkgbase = qemu-android-x86 + pkgdesc = Android-x86 environment via QEMU and VirGL + pkgver = 8.1.r1 + pkgrel = 1 + url = http://www.android-x86.org/ + install = qemu-android-x86.install + arch = x86_64 + license = Apache + license = GPL2 + license = custom:Creative Commons 3.0 Attribution Unported + makedepends = inkscape + depends = rxvt-unicode + depends = zenity + depends = qemu + depends = hicolor-icon-theme + source = android-x86-8.1-r1.x86_64.rpm::https://osdn.net/frs/redir.php?m=auto&f=android-x86%2F69704%2Fandroid-x86-8.1-r1.x86_64.rpm + source = https://upload.wikimedia.org/wikipedia/commons/d/d7/Android_robot.svg + source = qemu-android + source = config + source = qemu-android.desktop + sha256sums = a97db25c96bf0e2f4574177a59d9c8399141238154beae122f70ce0edf488a59 + sha256sums = 8c80b881727efc8831c8ef53806e7c1d0427607e145aae09061c4870b6cd402f + sha256sums = e53911e378a6048d88d4fbaeb870c58f57c44142450527ee99b3c12baa15099a + sha256sums = e9524cdb27c57e6650af763b2231d67ff3e2beb12f52133e7e95eda4f16b0881 + sha256sums = 8a5ed6a6c1a4dfd1c8af0ff5de48965ec2dc6b50f87e5f990d33c7025f63c8ec + +pkgname = qemu-android-x86 + diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..fe09c167b687 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,41 @@ +# Maintainer: Sam Mulvey <archlinux -at- sammulvey.com> +pkgname=qemu-android-x86 +_pkgver="8.1-r1" +pkgver=8.1.r1 +pkgrel=1 +pkgdesc="Android-x86 environment via QEMU and VirGL" +arch=("x86_64") +url="http://www.android-x86.org/" +license=('Apache' 'GPL2' 'custom:Creative Commons 3.0 Attribution Unported') +depends=('rxvt-unicode' 'zenity' 'qemu' 'hicolor-icon-theme') +makedepends=('inkscape') +install="qemu-android-x86.install" +source=("android-x86-${_pkgver}.${arch}.rpm::https://osdn.net/frs/redir.php?m=auto&f=android-x86%2F69704%2Fandroid-x86-${_pkgver}.${arch}.rpm" + "https://upload.wikimedia.org/wikipedia/commons/d/d7/Android_robot.svg" + "qemu-android" + "config" + "qemu-android.desktop") +sha256sums=('a97db25c96bf0e2f4574177a59d9c8399141238154beae122f70ce0edf488a59' + '8c80b881727efc8831c8ef53806e7c1d0427607e145aae09061c4870b6cd402f' + 'e53911e378a6048d88d4fbaeb870c58f57c44142450527ee99b3c12baa15099a' + 'e9524cdb27c57e6650af763b2231d67ff3e2beb12f52133e7e95eda4f16b0881' + '8a5ed6a6c1a4dfd1c8af0ff5de48965ec2dc6b50f87e5f990d33c7025f63c8ec') + +#PKGEXT=".pkg.tar" + +package() { + + mkdir -p $pkgdir/usr/share/android-x86 $pkgdir/usr/bin $pkgdir/usr/share/applications + install -m0644 $srcdir/android-${_pkgver}/* $pkgdir/usr/share/android-x86 + install -m0644 $srcdir/usr/bin/qemu-android $pkgdir/usr/share/android-x86/original.qemu-android + install -m0644 $srcdir/config $pkgdir/usr/share/android-x86 + install -m0644 $srcdir/qemu-android.desktop $pkgdir/usr/share/applications + install -m0755 $srcdir/qemu-android $pkgdir/usr/bin/qemu-android + + iconsizes=(16 32 64 128 256 512) + for size in "${iconsizes[@]}"; do + mkdir -p $pkgdir/usr/share/icons/hicolor/${size}x${size}/apps + inkscape -z -e $pkgdir/usr/share/icons/hicolor/${size}x${size}/apps/qemu-android.png -w $size -h $size $srcdir/Android_robot.svg + done + +} diff --git a/config b/config new file mode 100644 index 000000000000..5a961b735142 --- /dev/null +++ b/config @@ -0,0 +1,52 @@ +# RAM in megabytes, defaults to 2048. +#RAM=2048 + +# Number of CPU cores, defaults to 2. +#CORES=2 + +# CPU definition, defaults to "host" +# Default Example: +#CPU="host" +# Test with old CPU: +#CPU="core2duo" + +# "video=" string to pass to the kernel. Defaults to no string set. +#VIDEO="1280x720x32" + +# Data partition location. +# If a file is specified it will be a raw image and created if it does not +# exist. By default, it will create a file at $HOME/.config/android-x86/data.img +# as a sparse file with an EXT4 filesystem. +# If a directory is specified, it'll be mounted as a 9p share. QEMU must run under +# sudo and will pop a terminal if run graphically. +# If set to "none", no data partition will be set. +# Example: +#DATA="none" # Save no data +#DATA="/tmp/data.img" # Create a data file in /tmp. + +# Data partition size in megabytes. Only used on creation of a partition image. +# defaults to 2048. +#DATASIZE=2048 + +# Note: right now the only thing that's working right now with VirGL on machines tested +# is SDL with an external serial0. GTK shows the serial but no video, SDL shows +# the windows all overlayed with each other. + +# Serial output. Currently a rootshell. Defaults to no serial. +# +# Examples: +# default stdio, will pop a terminal in graphical mode +SERIAL="mon:stdio" # console on terminal or in urxvt if gui mode. +#SERIAL="telnet:127.0.0.1:9000,server,nowait" # telnet to port 900 for root, might be insecure + +# Bridged networking. +# +# If you use a bridged network for vitual machines, you can set it here. +# Otherwise it uses user networking. Make sure to allow the bridge in /etc/qemu/bridge.conf +#BRIDGE=outer0 + +# Method to launch QEMU. Example is default, which uses SDL and allow for +# VirGL, which is a feature as of 8.1-r1. For some reason GTK isn't working on all +# the tested machines, only SDL. +# Example (default): +#VGALINE="-vga virtio -display sdl,gl=on" diff --git a/qemu-android b/qemu-android new file mode 100644 index 000000000000..3ae16d34b0f9 --- /dev/null +++ b/qemu-android @@ -0,0 +1,158 @@ +#!/bin/bash +# By Sam Mulvey <archlinux@sammulvey.com> +# based on script from Chih-Wei Huang <cwhuang@linux.org.tw> +# License: GNU Generic Public License v2 + +# Sanity checks +if [ `id -u` -eq 0 ]; then + echo "Don't run this as root. It'll call sudo if it needs it." + exit 1 +fi +if [ -z ${HOME+x} ]; then echo "HOME isn't set!" ; exit 1 ; fi +[ ! -z ${1+x} ] && [ $1 == "gui" ] && GUI=1 || GUI=0 + + +# Things needed for early checks +# Package depends on these, so I won't test for them (for now.) +# But hey, someone might want to replace them with their terminal of choice or whatever. + + +URXVT="/usr/bin/urxvt" +ZENITY="/usr/bin/zenity" + + +nope() { + if [ $GUI -eq 1 ]; then + $ZENITY --width=240 --error --text="$1" --title="Android-x86 Error" + else + echo "$1" + fi + exit 1 +} + + +# Check for config file, source +if [ -e $HOME/.config/android-x86/config ]; then + . $HOME/.config/android-x86/config +else + nope "Copy /usr/share/android-x86/config to ${HOME}/.config/android-x86 and modify. It explains things." +fi + +# Set meaningful defaults +IN_SUDO=0 +IN_TERMINAL=0 +RAM=${RAM:-2048} +CORES=${CORES:-2} +DATA=${DATA:-"${HOME}/.config/android-x86/data.img"} +DATASIZE=${DATASIZE:-2048} +CPU=${CPU:-"host"} +NETPORT=${NETPORT:-47000} +# TODO figure out why GTK doesn't work on all my machines. Might obviate the need to URXVT for serial console +VGALINE=${VGALINE:-"-vga virtio -display sdl,gl=on"} + +# Test for system images: +# TODO add ability for r/w system image +SYSTEMIMG=${SYSTEMIMG:-"/usr/share/android-x86/system.sfs"} +INITRD=${INITRD:-"/usr/share/android-x86/initrd.img"} +RAMDISK=${RAMDISK:-"/usr/share/android-x86/ramdisk.img"} +KERNEL=${KERNEL:-"/usr/share/android-x86/kernel"} + +if [ ! -e $SYSTEMIMG ] || [ ! -e $INITRD ] || [ ! -e $RAMDISK ] || [ ! -e $KERNEL ]; then + nope "System images aren't installed. Check your android-x86 package." +fi + +#QEMU=qemu-system-${QEMU_ARCH} +# Archlinux is x86_64 only +QEMU="/usr/bin/qemu-system-x86_64" +if [ ! -x $QEMU ]; then + nope "Please install the 'qemu' package to run Android-x86." +fi + +if [ $DATA == "none" ]; then + DATA_QEMULINE="" + DATA_CMDLINE="" +elif [ -d $DATA ]; then + echo "9p mode selected." + IN_SUDO=1 + DATA_QEMULINE="-virtfs local,id=data,path=${DATA},security_model=passthrough,mount_tag=data" + DATA_CMDLINE="DATA=9p" +else + # sudo should only be needed for 9p, if KVM is set up right + # so a data partition sparse file will always be owned by the calling user + + if [ ! -e $DATA ]; then + if [ ! -w `dirname $DATA` ]; then + nope "Location for $DATA doesn't exist or isn't writeable." + fi + + if [ $GUI -eq 1 ]; then + $URXVT -title "Android-x86 Data Partition Create" -e \ + bash -c "/usr/bin/truncate -s ${DATASIZE}M $DATA && \ + /usr/bin/mkfs.ext4 $DATA && \ + echo && echo Hit enter to continue. && read" + else + truncate -s ${DATASIZE}M $DATA + mkfs.ext4 $DATA + fi + + elif [ ! -w $DATA ]; then + nope "Data partition $DATA isn't writeable." + fi + + DATA_QEMULINE="-drive index=2,if=virtio,id=data,file=${DATA},format=raw" + DATA_CMDLINE="DATA=vdc" + +fi + + + +VIDEO_CMDLINE="" +if [ ! -z ${VIDEO+x} ]; then + VIDEO_CMDLINE="video=$VIDEO" +fi + +SERIAL_QEMULINE="" +if [ ! -z ${SERIAL:+x} ]; then + SERIAL_QEMULINE="-serial $SERIAL" + + [ $SERIAL == "mon:stdio" ] && IN_TERMINAL=1 +fi + +#echo -e "CPU: $CPU\nRAM: $RAM\nCORES: $CORES\nDATA: $DATA\n" +#echo -e "DATASIZE: $DATASIZE\nSERIAL: $SERIAL\nVIDEO: $VIDEO\n" +#echo -e "VGALINE: $VGALINE\nBRIDGE: $BRIDGE" + + + +do_qemu() { + + if [ -z $BRIDGE ]; then + NET_QEMULINE="-netdev user,id=anet0,hostfwd=tcp::$NETPORT-:5000 -device virtio-net-pci,netdev=anet0" + else + NET_QEMULINE="-netdev bridge,br=$BRIDGE,id=anet0 -device virtio-net-pci,netdev=anet0" + fi + + DO_CMD="" + + [ $IN_TERMINAL -eq 1 ] && [ $GUI -eq 1 ] && DO_CMD+="$URXVT -title Android-x86_Console -e " + [ $IN_SUDO -eq 1 ] && DO_CMD+="/usr/bin/sudo " + DO_CMD+=$QEMU + + + exec $DO_CMD -enable-kvm \ + -kernel $KERNEL \ + -append "root=/dev/ram0 androidboot.selinux=permissive console=ttyS0 RAMDISK=vdb $DATA_CMDLINE $VIDEO_CMDLINE" \ + -initrd $INITRD \ + -m $RAM -smp $CORES -cpu $CPU \ + -device qemu-xhci,id=xhci0 -device usb-tablet,bus=xhci0.0 -machine vmport=off \ + -soundhw hda \ + -boot menu=on \ + -drive index=0,if=virtio,id=system,file=$SYSTEMIMG,format=raw,readonly \ + -drive index=1,if=virtio,id=ramdisk,file=$RAMDISK,format=raw,readonly \ + $NET_QEMULINE $DATA_QEMULINE $SERIAL_QEMULINE $VGALINE +} + +while [ $NETPORT -lt 48000 ]; do + do_qemu && break + let $NETPORT++ +done diff --git a/qemu-android-x86.install b/qemu-android-x86.install new file mode 100644 index 000000000000..9d4465920911 --- /dev/null +++ b/qemu-android-x86.install @@ -0,0 +1,17 @@ +post_install() { + gtk-update-icon-cache -q -t -f usr/share/icons/hicolor + update-desktop-database -q + echo "To use, per user:" + echo " mkdir ~/.config/android-x86 &&" + echo " cp /usr/share/android-x86/config ~/.config/android-x86" + echo "And then edit the config file to taste." +} + +post_upgrade() { + post_install +} + +post_remove() { + post_install +} + diff --git a/qemu-android.desktop b/qemu-android.desktop new file mode 100644 index 000000000000..8add9eaad285 --- /dev/null +++ b/qemu-android.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=qemu-android +Comment=Android-x86 environment via QEMU and VirGL +Exec=/usr/bin/qemu-android gui +Terminal=false +Icon=qemu-android.png +Type=Application +Categories=Development; |