Skip to content

Instantly share code, notes, and snippets.

@psammarco
Created January 25, 2020 13:20
Show Gist options
  • Save psammarco/53c9efd0ca4437744a73a1eaa2617aa2 to your computer and use it in GitHub Desktop.
Save psammarco/53c9efd0ca4437744a73a1eaa2617aa2 to your computer and use it in GitHub Desktop.
kvm-port-chromeos
#!/bin/bash
workdir=/tmp/qemu-kvm
bin=/usr/local/opt/qemu-kvm/bin
lib=/usr/local/opt/qemu-kvm/lib
libextra=/usr/lib
share=/usr/share/qemu
rootfs="/dev/root"
ar=/usr/local/opt/qemu-kvm/bin/ar
NOTE!!! Since we removed the static variable path, we now need to export it manually for the script to work!!!
Also, the correct privileges for /usr/local should be chronos:chronos, so below command should actually do it!!!
#chown -R "$(id -u)":"$(id -g)" /usr/local && mkdir -p $bin && mkdir $lib
mkdir -p $bin && mkdir $lib
# The ar utility is needed to decompress .deb files.
curl -LJ https://github.com/psammarco/KVM-on-ChromeOS/blob/master/ar?raw=true -o $bin/ar
curl -LJ https://github.com/psammarco/KVM-on-ChromeOS/blob/master/libbfd-2.28-system.so?raw=true -o $lib/libbfd-2.28-system.so
chmod +x $bin/ar
### ChromeOS's Specific!!!
if grep $rootfs /proc/mounts | grep 'ro,'; then
mount -o remount,rw / &> mount.out
if
grep 'read-write' mount.out; then
echo '
ERROR!!! rootfs_verification for the root partition must to be disabled in order to remount,rw /
1. To disable rootfs_verification run the following command and note down the partition number
"sudo /usr/share/vboot/bin/make_dev_ssd.sh"
2. then run
"sudo /usr/share/vboot/bin/make_dev_ssd.sh --remove_rootfs_verification --partitions X"
3. lastly, reboot your chromebook' && exit 1
fi
fi
### End ChromeOS's Specific
echo -e '#! /bin/sh\nexec /usr/local/opt/qemu-kvm/bin/qemu-system-x86_64 -enable-kvm "$@"' > \
/usr/local/opt/qemu-kvm/bin/kvm && chmod +x $bin/kvm
mkdir -p $workdir/qemu-system-x86 && cd $workdir/qemu-system-x86
curl -O http://ftp.us.debian.org/debian/pool/main/q/qemu/qemu-system-x86_2.8+dfsg-6+deb9u5_amd64.deb
$ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
cp usr/bin/qemu-system* $bin/
else
exit 1
fi
mkdir $workdir/libnuma1 && cd ../libnuma1
curl -O http://ftp.us.debian.org/debian/pool/main/n/numactl/libnuma1_2.0.11-2.1_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libncursesw5 && cd ../libncursesw5
curl -O http://ftp.us.debian.org/debian/pool/main/n/ncurses/libncursesw5_6.0+20161126-1+deb9u2_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libpulse0 && cd ../libpulse0
curl -O http://ftp.us.debian.org/debian/pool/main/p/pulseaudio/libpulse0_10.0-1+deb9u1_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libvdeplug2 && cd ../libvdeplug2
curl -O http://ftp.us.debian.org/debian/pool/main/v/vde2/libvdeplug2_2.3.2+r586-2.1_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libsasl2 && cd ../libsasl2
curl -O http://ftp.us.debian.org/debian/pool/main/c/cyrus-sasl2/libsasl2-2_2.1.27~101-g0780600+dfsg-3_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libsdl1 && cd ../libsdl1
curl -O http://ftp.us.debian.org/debian/pool/main/libs/libsdl1.2/libsdl1.2debian_1.2.15+dfsg1-4_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libX11 && cd ../libX11
curl -O http://ftp.us.debian.org/debian/pool/main/libx/libx11/libx11-6_1.6.4-3+deb9u1_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libxenstore3 && cd ../libxenstore3
curl -O http://ftp.us.debian.org/debian/pool/main/x/xen/libxenstore3.0_4.8.5+shim4.10.2+xsa282-1+deb9u11_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libxen && cd ../libxen
curl -O http://ftp.us.debian.org/debian/pool/main/x/xen/libxen-4.8_4.8.5+shim4.10.2+xsa282-1+deb9u11_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libseccomp2 && cd ../libseccomp2
curl -O http://ftp.us.debian.org/debian/pool/main/libs/libseccomp/libseccomp2_2.3.1-2.1+deb9u1_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libspice-server1 && cd ../libspice-server1
curl -O http://ftp.us.debian.org/debian/pool/main/s/spice/libspice-server1_0.12.8-2.1+deb9u3_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libcacard0 && cd ../libcacard0
curl -O http://ftp.us.debian.org/debian/pool/main/libc/libcacard/libcacard0_2.5.0-3_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libusbredirparser1 && cd ../libusbredirparser1
curl -O http://ftp.us.debian.org/debian/pool/main/u/usbredir/libusbredirparser1_0.7.1-1_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libxext6 && cd ../libxext6
curl -O http://ftp.us.debian.org/debian/pool/main/libx/libxext/libxext6_1.3.3-1+b2_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libcaca && cd ../libcaca
curl -O http://ftp.us.debian.org/debian/pool/main/libc/libcaca/libcaca0_0.99.beta19-2+b2_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libxcb1 && cd ../libxcb1
curl -O http://ftp.us.debian.org/debian/pool/main/libx/libxcb/libxcb1_1.12-1_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libopus0 && cd ../libopus0
curl -O http://ftp.us.debian.org/debian/pool/main/o/opus/libopus0_1.2~alpha2-1_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libssl1 && cd ../libssl1
curl -O http://ftp.us.debian.org/debian/pool/main/o/openssl/libssl1.1_1.1.0j-1~deb9u1_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libx11-xcb1 && cd ../libx11-xcb1
curl -O http://ftp.us.debian.org/debian/pool/main/libx/libx11/libx11-xcb1_1.6.4-3+deb9u1_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libice6 && cd ../libice6
curl -O http://ftp.us.debian.org/debian/pool/main/libi/libice/libice6_1.0.9-2_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libsm6 && cd ../libsm6
curl -O http://ftp.us.debian.org/debian/pool/main/libs/libsm/libsm6_1.2.2-1+b3_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libxtst6 && cd ../libxtst6
curl -O http://ftp.us.debian.org/debian/pool/main/libx/libxtst/libxtst6_1.2.3-1_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libwrap0 && cd ../libwrap0
curl -O http://ftp.us.debian.org/debian/pool/main/t/tcp-wrappers/libwrap0_7.6.q-26_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libsndfile1 && cd ../libsndfile1
curl -O http://ftp.us.debian.org/debian/pool/main/libs/libsndfile/libsndfile1_1.0.27-3_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libasyncns0 && cd ../libasyncns0
curl -O http://ftp.us.debian.org/debian/pool/main/liba/libasyncns/libasyncns0_0.8-6_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libslang2 && cd ../libslang2
curl -O http://ftp.us.debian.org/debian/pool/main/s/slang2/libslang2_2.3.1-5_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libxau6 && cd ../libxau6
curl -O http://ftp.us.debian.org/debian/pool/main/libx/libxau/libxau6_1.0.8-1_amd64.deb
ar x *.deb; for file in *.tar.gz; do tar -zxf "$file"; done
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libxdmcp6 && cd ../libxdmcp6
curl -O http://ftp.us.debian.org/debian/pool/main/libx/libxdmcp/libxdmcp6_1.1.2-3_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libxi6 && cd ../libxi6
curl -O http://ftp.us.debian.org/debian/pool/main/libx/libxi/libxi6_1.7.9-1_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libflac8 && cd ../libflac8
curl -O http://ftp.us.debian.org/debian/pool/main/f/flac/libflac8_1.3.2-1_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libogg0 && cd ../libogg0
curl -O http://ftp.us.debian.org/debian/pool/main/libo/libogg/libogg0_1.3.2-1_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libvorbis0a && cd ../libvorbis0a
curl -O http://ftp.us.debian.org/debian/pool/main/libv/libvorbis/libvorbis0a_1.3.5-4+deb9u2_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libvorbisenc2 && cd ../libvorbisenc2
curl -O http://ftp.us.debian.org/debian/pool/main/libv/libvorbis/libvorbisenc2_1.3.5-4+deb9u2_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/libtinfo5 && cd ../libtinfo5
curl -O http://ftp.us.debian.org/debian/pool/main/n/ncurses/libtinfo5_6.0+20161126-1+deb9u2_amd64.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
find . |grep .so |xargs -I{} cp {} $lib/
else
exit 1
fi
mkdir $workdir/seabios && cd ../seabios
curl -O http://ftp.us.debian.org/debian/pool/main/s/seabios/seabios_1.10.2-1_all.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
mkdir $share && cp -r usr/share/seabios/* $share/
else
exit 1
fi
mkdir $workdir/ipxe-qemu && cd ../ipxe-qemu
curl -O http://ftp.us.debian.org/debian/pool/main/i/ipxe/ipxe-qemu_1.0.0+git-20161027.b991c67-1_all.deb
ar x *.deb; tar -xzvf control.tar.gz && tar -xvf data.tar.xz
if md5sum -c md5sums; then
cp -r usr/lib/ipxe $libextra/
else
exit 1
fi
mkdir $workdir/qemu-system-data && cd ../qemu-system-data
curl -O http://ftp.us.debian.org/debian/pool/main/q/qemu/qemu-system-data_3.1+dfsg-8_all.deb
ar x *.deb; for file in *.tar.xz; do tar -xvf "$file"; done
if md5sum -c md5sums; then
cp -r usr/share/qemu/keymaps $share/
else
exit 1
fi
# Symlinking
ln -s $bin/* /usr/local/bin/ && ln -s $lib/* /usr/local/lib64/
echo 'To uninstall qemu-kvm, simply run the following command as root to remove $bin, $lib, $share and to clear up broken symlinks.'
echo 'rm -r /usr/local/opt/qemu-kvm /usr/share/qemu /usr/lib/ipxe; find -L /usr/local/bin/ /usr/local/lib64/ -type l -delete'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment