Last active
May 1, 2019 19:53
-
-
Save ibizaman/f636bebcf0dbb82a8d08 to your computer and use it in GitHub Desktop.
installing mysql on raspberry under qemu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -x | |
| apt-get update \ | |
| || exit 1 | |
| apt-get -y install libncurses5 fakeroot debootstrap libstdc++6:i386 zlib1g:i386 libc6-dev-i386 | |
| # download .deb for qemu, scratchbox and gcc-toolchain | |
| debs_dir='/opt/raspberry-dev/debs' | |
| mkdir -p "$debs_dir" | |
| chown vagrant: "$debs_dir" | |
| cd "$debs_dir" | |
| test -f raspberry-qemu_1.3.0_amd64.deb || wget http://commondatastorage.googleapis.com/howling-fantods/raspberrypi/raspberry-qemu_1.3.0_amd64.deb | |
| test -f raspberry-scratchbox2_2.3.90_amd64.deb || wget http://commondatastorage.googleapis.com/howling-fantods/raspberrypi/raspberry-scratchbox2_2.3.90_amd64.deb | |
| test -f raspberry-gcc-toolchain_1.0_i386.deb || wget http://commondatastorage.googleapis.com/howling-fantods/raspberrypi/raspberry-gcc-toolchain_1.0_i386.deb | |
| dpkg -i -R *.deb | |
| # setup path to installed binairies | |
| bin_dir='/opt/raspberry-dev/bin' | |
| export PATH="$bin_dir":"$PATH" | |
| echo 'export PATH='"$bin_dir"':$PATH' > /etc/profile.d/rasperry-rootfs.sh | |
| # create chroot directory | |
| sbox2_container_path='/home/vagrant/raspberry-rootfs' | |
| mkdir -p "$sbox2_container_path" | |
| chown vagrant: "$sbox2_container_path" | |
| cd $sbox2_container_path | |
| # install qemu, scratchbox and gcc-toolchain | |
| sbox2_container_name='raspberry' | |
| export HOME=/home/vagrant | |
| if ! sudo -u vagrant sb2-config -l | grep "^$sbox2_container_name$" | |
| then sb2-init -n -c $bin_dir/qemu-arm $sbox2_container_name $bin_dir/arm-linux-gnueabihf-gcc | |
| fi | |
| # create base layout for raspberry OS | |
| if ! apt-key list | grep "Raspberry Pi Debian" | |
| then wget -O - http://archive.raspbian.org/raspbian.public.key | apt-key add - | |
| fi | |
| fakeroot debootstrap --verbose --foreign --variant=scratchbox --arch armhf --keyring /etc/apt/trusted.gpg wheezy "$sbox2_container_path" http://archive.raspbian.org/raspbian/ | |
| if [ -f "$sbox2_container_path"/debootstrap/debootstrap ] | |
| then sb2 -t raspberry -eR ./debootstrap/debootstrap --verbose --second-stage | |
| fi | |
| cat >"$sbox2_container_path"/etc/apt/sources.list <<EOF | |
| deb http://archive.raspbian.org/raspbian/ testing main contrib non-free rpi | |
| EOF | |
| cp /vagrant/vagrant/utils.sh $HOME | |
| function sb2_cmd() { | |
| sb2 -eR bash -c ". $HOME/utils.sh && set -x && $@" | |
| } | |
| sb2_cmd apt-get update | |
| sb2_cmd install_gpp_4_8 || exit 2 | |
| sb2_cmd install_make || exit 3 | |
| sb2_cmd install_boost_1_53 || exit 4 | |
| sb2_cmd install_mysql_5_5 || exit 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function install_make() { | |
| apt-get -y install make | |
| return $? | |
| } | |
| function install_gpp_4_8() { | |
| apt-get -y install g++-4.8 gdb && | |
| update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 20 && | |
| update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50 \ | |
| || return 1 | |
| update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 20 | |
| update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50 \ | |
| || return 1 | |
| return 0 | |
| } | |
| function install_boost_1_53() { | |
| apt-get -y install libboost-date-time1.53-dev libboost-system1.53-dev libboost-filesystem1.53-dev libboost-thread1.53-dev | |
| return $? | |
| } | |
| function install_mysql_5_5() { | |
| apt-get install -y debconf-utils && | |
| echo "mysql-server-5.5 mysql-server/root_password password root" | debconf-set-selections && | |
| echo "mysql-server-5.5 mysql-server/root_password_again password root" | debconf-set-selections && | |
| apt-get install -y mysql-server mysql-client | |
| return $? | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| VAGRANTFILE_API_VERSION = "2" | |
| Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
| config.vm.define :raspberry do |box| | |
| box.vm.box = "precise64" | |
| box.vm.box_url = "http://files.vagrantup.com/precise64.box" | |
| box.vm.network :private_network, ip: "192.168.42.12" | |
| box.vm.provision :shell, :path => "bootstrap_prod.sh" | |
| box.vm.provider :virtualbox do |vb| | |
| vb.name = "raspberrypi" | |
| vb.memory = 4096 | |
| end | |
| box.ssh.forward_x11 = true | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment