The aim here is to get to a position where you have a working Baserock virtual machine with an environment set up suitable for development, with the minimum amount of effort and without needing to jump around to different wiki pages.
Create a script:
emacs vm.sh
If you use KVM, add the following:
#!/bin/bash
DRIVE_SIZE_GB=64
MEMORY_SIZE_MB=6144
IMAGE=baserock-current-build-system-x86_64.img
IMAGE_DOWNLOAD="$IMAGE.gz"
BRDIR=~/develop/baserock
IMAGESDIR=$BRDIR/images
sudo apt-get install qemu-kvm
sudo adduser `id -un` kvm
cd $BRDIR
if [ ! -d $IMAGESDIR ]; then
mkdir -p $IMAGESDIR
fi
if [ ! -f $IMAGESDIR/$IMAGE_DOWNLOAD ]; then
if [ ! -f $IMAGESDIR/$IMAGE_DOWNLOAD.gz ]; then
cd $IMAGESDIR
wget http://download.baserock.org/baserock/$IMAGE_DOWNLOAD
cd ..
fi
fi
if [ ! -f $IMAGESDIR/$IMAGE_DOWNLOAD ]; then
echo "Couldn't download $IMAGE.gz"
exit 1
fi
if [ ! -f $IMAGESDIR/$IMAGE ]; then
gzip -d $IMAGESDIR/$IMAGE_DOWNLOAD
fi
if [ -f $IMAGESDIR/baserock_src.img ]; then
rm -f $IMAGESDIR/baserock_src.img
fi
fallocate -l $(($DRIVE_SIZE_GB*1024*1024*1024)) $IMAGESDIR/baserock_src.img
# Start the virtual machine
kvm -hda $IMAGESDIR/$IMAGE -hdb $IMAGESDIR/baserock_src.img -net nic -net user,hostfwd=tcp::5555-:22 -m $MEMORY_SIZE_MB
exit 0
Make it executable:
chmod +x vm.sh
Then run:
./vm.sh
Within the emulator window enter the password 'root' and then use the passwd command to set a password.
Then from another terminal (NOT within the QEMU window) you can ssh in with:
ssh-keygen -f "/home/$USER/.ssh/known_hosts" -R [0]:5555
ssh -A -p5555 root@0
You can then run the following commands to set up a development environment.
mkfs.btrfs -L src /dev/sdb
mkdir /src
echo 'LABEL=src /src btrfs defaults 0 2' >> /etc/fstab
reboot
Now we'll make a script which can be run to set up the development system:
emacs setup-devel.sh
Add the following:
#!/bin/bash
BASEROCK_VERSION='15.02'
MY_FULL_NAME="Citizen Five"
EMAIL_ADDRESS=c5@domain
CONF_FILE=/src/morph.conf
TROVE='my-trove.domain'
if [ ! -d /src ]; then
mkdir /src
if [ -b /dev/sdb ]; then
mkfs.btrfs -L src /dev/sdb
echo 'LABEL=src /src btrfs defaults 0 2' >> /etc/fstab
reboot
fi
fi
btrfs filesystem resize max /
echo '[config]' > $CONF_FILE
echo 'log = /src/morph.log' >> $CONF_FILE
echo 'log-max = 200M' >> $CONF_FILE
echo 'cachedir = /src/cache' >> $CONF_FILE
echo 'tempdir = /src/tmp' >> $CONF_FILE
#echo "trove-host = $TROVE" >> $CONF_FILE
ln -sv $CONF_FILE /etc/morph.conf
cd /src
git config --global user.name "$MY_FULL_NAME"
git config --global user.email "$EMAIL_ADDRESS"
git clone git://git.baserock.org/baserock/baserock/definitions --branch baserock-$BASEROCK_VERSION
cd definitions
echo 'name: upgrade-devel' > systems/devel-system-x86_64-generic.morph
echo 'kind: cluster' >> systems/devel-system-x86_64-generic.morph
echo 'systems:' >> systems/devel-system-x86_64-generic.morph
echo '- morph: systems/devel-system-x86_64-generic.morph' >> systems/devel-system-x86_64-generic.morph
echo ' deploy:' >> systems/devel-system-x86_64-generic.morph
echo ' self:' >> systems/devel-system-x86_64-generic.morph
echo ' type: extensions/ssh-rsync' >> systems/devel-system-x86_64-generic.morph
echo ' location: root@127.0.0.1' >> systems/devel-system-x86_64-generic.morph
morph --verbose build systems/devel-system-x86_64-generic.morph
cd /src
git clone git://git.baserock.org/delta/linux.git
exit 0
Move the script to the virtual machine:
chmod +x setup-devel.sh
ssh-keygen -f "/home/$USER/.ssh/known_hosts" -R [0]:5555
scp -P 5555 setup-devel.sh root@0:/root
Now log back into the virtual machine and run the setup script:
ssh -A -p5555 root@0
./setup-devel.sh
If you mess up your development environment then you can easily start again from scratch by running:
rm ~/develop/baserock/images/*.img
and then going through these instructions again.