diff --git a/.gitignore b/.gitignore index 33134202..ff48881b 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ a/linux/latest.sh a/linux/patches/ xap/st/patches/st-scrollback* xap/st/patches/st-vertcenter* +*.rpm diff --git a/xap/android-x86/android-x86.SlackBuild b/xap/android-x86/android-x86.SlackBuild new file mode 100755 index 00000000..4f96bd33 --- /dev/null +++ b/xap/android-x86/android-x86.SlackBuild @@ -0,0 +1,81 @@ +#!/bin/sh + +CWD=$(pwd) + +PRGNAM=$(basename $CWD) +VERSION=${VERSION:-7.1-r1} +BUILD=1 +TAG=cyco +ARCH=$(uname -m) + +OUTPUT=/tmp +TMP=/tmp/$TAG +PKG=$TMP/pkg-$PRGNAM + +PREFIX=/usr + +mkdir -p $TMP + +# Cleaning +rm -fr $PRGNAM $PKG + +# Fetching binaries +[ ! -e $CWD/${PRGNAM}-${VERSION}.${ARCH}.rpm ] && wget -c http://bdownload.fosshub.com/programs/${PRGNAM}-${VERSION}.${ARCH}.rpm + +# Installation +mkdir -p $PKG$PREFIX/share/ +cd $PKG$PREFIX/share/ +rpm2targz $CWD/${PRGNAM}-${VERSION}.${ARCH}.rpm +tar xvf ${PRGNAM}-${VERSION}.${ARCH}.tar.gz +rm ${PRGNAM}-${VERSION}.${ARCH}.tar.gz + +rm -fr usr +mv android-${VERSION} ${PRGNAM} + +mkdir -p $PKG$PREFIX/bin/ +cp $CWD/${PRGNAM}.sh $PKG$PREFIX/bin/ +chmod 755 $PKG$PREFIX/bin/${PRGNAM}.sh + +mkdir -p $PKG$PREFIX/doc/${PRGNAM} +cat < $PKG$PREFIX/doc/${PRGNAM}/create-data-img.sh +#!/bin/sh + +SIZE=\${SIZE:-128G} + +mkdir -p \$HOME/.android-x86 +qemu-img create -f \$HOME/.android-x86/qcow2 data.img $SIZE +EOF + +cat < $PKG$PREFIX/doc/${PRGNAM}/create-data-dir.sh +#!/bin/sh + +mkdir -p \$HOME/.android-x86/data +EOF +chmod 755 $PKG$PREFIX/doc/${PRGNAM}/*.sh + +# Cleaning +cd $PKG +chown -R root:root . +find . \ + \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ + -exec chmod 755 {} \; -o \ + \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ + -exec chmod 644 {} \; + +# Packaging +mkdir install +cat < install/slack-desc +$PRGNAM: $PRGNAM (Run Android in QEMU) +$PRGNAM: +$PRGNAM: +$PRGNAM: +$PRGNAM: +$PRGNAM: +$PRGNAM: +$PRGNAM: +$PRGNAM: +$PRGNAM: http://www.android-x86.org/ +$PRGNAM: +EOF + +makepkg -l y -c n $OUTPUT/$PRGNAM-$(echo $VERSION | tr -d '-')-$ARCH-$BUILD$TAG.txz diff --git a/xap/android-x86/android-x86.sh b/xap/android-x86/android-x86.sh new file mode 100755 index 00000000..f11537d1 --- /dev/null +++ b/xap/android-x86/android-x86.sh @@ -0,0 +1,68 @@ +#!/bin/bash +# By Chih-Wei Huang +# adapted by Gwenhael Le Moine +# License: GNU Generic Public License v2 + +RAM=${RAM:-8192} +RESOLUTION=${RESOLUTION:-"1536x2048"} +ANDROID_DIR=${ANDROID_DIR:-/usr/share/android-x86} +ANDROID_DATA_DIR=${ANDROID_DATA_DIR:-$HOME/.android-x86} + +continue_or_stop() +{ + echo "Please Enter to continue or Ctrl-C to stop." + read +} + +QEMU_ARCH=`uname -m` +QEMU=qemu-system-${QEMU_ARCH} + +which $QEMU > /dev/null 2>&1 || QEMU=qemu-system-i386 +if ! which $QEMU > /dev/null 2>&1; then + echo -e "Please install $QEMU to run the program.\n" + exit 1 +fi + +[ -e $ANDROID_DIR/system.img ] && SYSTEMIMG=$ANDROID_DIR/system.img || SYSTEMIMG=$ANDROID_DIR/system.sfs + +if [ -e $ANDROID_DATA_DIR/data.img ]; then + if [ -w $ANDROID_DATA_DIR/data.img ]; then + DATA="-drive index=2,if=virtio,id=data,file=$ANDROID_DATA_DIR/data.img" + DATADEV='DATA=vdc' + else + echo -e "\n$(realpath $ANDROID_DATA_DIR/data.img) exists but is not writable.\nPlease grant the write permission if you want to save data to it.\n" + continue_or_stop + fi +elif [ -d $ANDROID_DATA_DIR/data ]; then + if [ `id -u` -eq 0 ]; then + DATA="-virtfs local,id=data,path=$ANDROID_DATA_DIR/data,security_model=passthrough,mount_tag=data" + DATADEV='DATA=9p' + else + echo -e "\n$(realpath $ANDROID_DATA_DIR/data) subfolder exists.\nIf you want to save data to it, run $0 as root:\n\n$ sudo $0\n" + continue_or_stop + fi +fi + +NET="-net nic,model=e1000 -net user -netdev user,id=mynet,hostfwd=tcp::5555-:5555 -device virtio-net-pci,netdev=mynet" + +run_qemu() +{ + $QEMU -enable-kvm \ + -kernel $ANDROID_DIR/kernel \ + -append "root=/dev/ram0 androidboot.selinux=permissive buildvariant=userdebug console=ttyS0 RAMDISK=vdb video=$RESOLUTION $DATADEV" \ + -initrd $ANDROID_DIR/initrd.img \ + -m $RAM -smp 2 -cpu host \ + -soundhw ac97 \ + -serial mon:stdio \ + -boot menu=on \ + -drive index=0,if=virtio,id=system,file=$SYSTEMIMG,format=raw,readonly \ + -drive index=1,if=virtio,id=ramdisk,file=$ANDROID_DIR/ramdisk.img,format=raw,readonly \ + $DATA \ + $NET \ + $@ +} + +# Try to run QEMU in several VGA modes +#run_qemu -vga std -display gtk,gl=on $@ +run_qemu -vga std -display gtk $@ || \ + run_qemu $@