Skip to content

Commit

Permalink
add config
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuichiro Nakada committed Feb 14, 2023
1 parent 1a7754b commit 47f8bfb
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 15 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ $ berry-os
* Epic Seven
* Echocalypse
* Guitar Girl
* Asphalt 9

* Arcaea
* Astral Fable
Expand All @@ -89,6 +90,11 @@ $ berry-os

## Tips

```
# KMS
echo 1 > /sys/kernel/mm/ksm/run
```

```default.prop
ro.adb.secure=1
ro.secure=1
Expand Down Expand Up @@ -134,11 +140,15 @@ persist.sys.strictmode.disable=1
* Android-x86
* https://sourceforge.net/projects/blissos-dev/files/Android-Generic/PC/
* https://www.android-x86.org/download
* https://osdn.net/projects/android-x86/releases/67834
* https://developer.android.com/topic/generic-system-image/releases
* houdini
* https://github.com/tony-cloud/houdini9
* https://threedots.ovh/blog/2020/12/houdini-run-arm-32-bit-and-64-bit-applications-on-an-x86_64-system/
* https://github.com/m9rco/Genymotion_ARM_Translation
* QEMU
* https://github.com/Gamesmes90/qemu-android-x86/blob/master/qemu-android
* https://github.com/refutationalist/saur/blob/master/qemu-android-x86/qemu-android
* Open GApps
* https://github.com/geeks-r-us/anbox-playstore-installer
* Bootanimations
Expand All @@ -147,3 +157,4 @@ persist.sys.strictmode.disable=1
* https://github.com/TrinityEmulator/TrinityEmulator
* https://github.com/openthos/openthos
* https://github.com/cnrd/MagiskHide-Props-Config
* https://gist.github.com/wuhx/bfd814bba5f2523449f1
91 changes: 76 additions & 15 deletions berry-os.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,53 @@
#!/bin/sh

sys=/opt/berry-os/berry-os.img
ram=/opt/berry-os/ramdisk.img
initrd=/opt/berry-os/initrd.img
kernel=/opt/berry-os/kernel

datasize=1000
#data=~/.local/share/berry-os/data.img
data=~/.local/share/berry-os/data.vmdk
config=$HOME/.local/share/berry-os/config
GUI=1

nope() {
if [ $GUI -eq 1 ]; then
zenity --width=240 --error --text="$1" --title="Error"
else
echo "$1"
fi
exit 1
}

# Check for config file, source
if [ -e ${config} ]; then
. ${config}
else
#nope "Copy /opt/berry-os/config to ${config} and modify. It explains things."
cp /opt/berry-os/config ${config}
fi

# Set meaningful defaults
#IN_SUDO=0
IN_TERMINAL=0
RAM=${RAM:-8192}
CORES=${CORES:-2}
data=${DATA:-"${HOME}/.local/share/berry-os/data.vmdk"}
datasize=${DATASIZE:-2048}
CPU=${CPU:-"host"}
NETPORT=${NETPORT:-4444}
# TODO figure out why GTK doesn't work on all my machines. Might obviate the need to URXVT for serial console
VGALINE=${VGALINE:-"-device virtio-vga-gl -display gtk,grab-on-hover=on,gl=on"}

# Test for system images:
# TODO add ability for r/w system image
sys=${SYSTEMIMG:-"/opt/berry-os/berry-os.img"}
initrd=${INITRD:-"/opt/berry-os/initrd.img"}
ram=${RAMDISK:-"/opt/berry-os/ramdisk.img"}
kernel=${KERNEL:-"/opt/berry-os/kernel"}

if [ ! -e $sys ] || [ ! -e $initrd ] || [ ! -e $ram ] || [ ! -e $kernel ]; then
nope "System images aren't installed. Check your berry-os package."
fi

QEMU="/usr/bin/qemu-system-x86_64"
if [ ! -x $QEMU ]; then
nope "Please install the 'qemu' package to run."
fi

if [ ! -r ${data} ]; then
mkdir -p ~/.local/share/berry-os/
pushd ~/.local/share/berry-os/
Expand All @@ -18,20 +58,41 @@ if [ ! -r ${data} ]; then
#qemu-img create -f vmdk ${data} 40G
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"

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
#-net nic,model=virtio-net-pci -net user,hostfwd=tcp::4444-:5555 \

#DO_CMD=""
#[ $IN_TERMINAL -eq 1 ] && [ $GUI -eq 1 ] && DO_CMD+="$URXVT -title Console -e "

# KMS
echo 1 > /sys/kernel/mm/ksm/run

#-device qemu-xhci,id=xhci0 -device usb-tablet,bus=xhci0.0 -device usb-kbd \
qemu-system-x86_64 \
-enable-kvm \
-M q35 \
-m 8192 -smp 2 -cpu host \
-device AC97 \
-net nic,model=virtio-net-pci -net user,hostfwd=tcp::4444-:5555 \
-m $RAM -smp $CORES -cpu $CPU \
-machine vmport=off \
-audiodev alsa,id=snd0,out.dev=hw:0.0 \
-usb \
-device usb-tablet \
-device usb-kbd \
-usb -device usb-tablet -device usb-kbd \
-device virtio-vga-gl -display gtk,grab-on-hover=on,gl=on \
-drive index=0,if=virtio,id=system,file=${sys},format=raw \
-drive index=1,if=virtio,id=ramdisk,file=${ram},format=raw \
-drive index=2,if=virtio,id=data,file=${data},format=vmdk \
-initrd ${initrd} \
-kernel ${kernel} -append "root=/dev/ram0 RAMDISK=vdb DATA=vdc SRC=/berry SETUPWIZARD=0"
-kernel ${kernel} -append "root=/dev/ram0 RAMDISK=vdb DATA=vdc SRC=/berry SETUPWIZARD=0" \
$NET_QEMULINE $SERIAL_QEMULINE
52 changes: 52 additions & 0 deletions config
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# RAM in megabytes, defaults to 4096.
#RAM=4096

# 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"
1 change: 1 addition & 0 deletions make_berry-os.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ cp -a ${sys} ${ram} ${initrd} ${kernel} ${tdir}/opt/berry-os/
cp -a berry-os.sh ${tdir}/opt/berry-os/
cp -a berry-os.spec ${tdir}/opt/berry-os/
cp -a data.zip ${tdir}/opt/berry-os/
cp -a config ${tdir}/opt/berry-os/

pushd ${tdir}

Expand Down

0 comments on commit 47f8bfb

Please sign in to comment.