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

And add the following:

#!/bin/bash

VM_NAME=baserock
IMAGE=baserock-current-build-system-x86_64.img
IMAGE_DOWNLOAD="$IMAGE.gz"
OS_TYPE=Linux26_64
IMAGEDIR=~/develop/baserock_images
VBVMDIR=~/"VirtualBox VMs"

if [ ! -f "$VBVMDIR/$VM_NAME" ]; then
    if [ ! -d $IMAGEDIR ]; then
        mkdir -p $IMAGEDIR
    fi

    cd $IMAGEDIR
    if [ ! -f $IMAGEDIR/$IMAGE ]; then
        if [ ! -f $IMAGEDIR/$IMAGE_DOWNLOAD ]; then
            echo "Image doesn't exist, start to download it."
            wget http://download.baserock.org/baserock/$IMAGE_DOWNLOAD
        fi

        if [ ! -f $IMAGEDIR/$IMAGE_DOWNLOAD ]; then
            echo "Couldn't download $IMAGEDIR/$IMAGE.gz"
            exit 1
        fi

        echo "Unpacking the image"
        gzip -d  $IMAGEDIR/$IMAGE_DOWNLOAD
    fi

    if [ ! -f "$IMAGEDIR/$VM_NAME.vdi" ]; then
        # Convert the baserock image to VDI
        VBoxManage convertdd $IMAGEDIR/$IMAGE "$IMAGEDIR/$VM_NAME.vdi" --format VDI
    fi

    # Create VM
    VBoxManage createvm --name $VM_NAME --ostype $OS_TYPE --register
fi

# Move image to Virtualbox folder
if [ -f $IMAGEDIR/$VM_NAME.vdi ]; then
    mv $IMAGEDIR/$VM_NAME.vdi ~/"VirtualBox VMs"/$VM_NAME
fi

# Set up VM
cd ~/"VirtualBox VMs"/$VM_NAME
VBoxManage modifyvm $VM_NAME --ioapic on --memory 6144 --nic1 bridged --bridgeadapter1 eth0 --nic2 hostonly --hostonlyadapter1 vboxnet0
VBoxManage storagectl $VM_NAME --name "SATA Controller" --add sata --bootable on --portcount 2
VBoxManage storageattach $VM_NAME --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "$VM_NAME.vdi"
VBoxManage createhd --filename "${VM_NAME}_src.vdi" --size $((30*1024))
VBoxManage storageattach $VM_NAME --storagectl "SATA Controller" --port 1 --device 0 --type hdd --medium "${VM_NAME}_src.vdi"
VBoxManage modifyvm $VM_NAME --cpus 2
VBoxManage modifyvm $VM_NAME --natpf1 "ssh,tcp,,5555,,22"

Make it executable:

chmod +x vm.sh

Then run:

./vm.sh

If the build is successful then you should see something like:

Converting from raw image file="/home/username/develop/baserock_images/baserock-current-build-system-x86_64.img" to file="/home/username/develop/baserock_images/baserock.vdi"...
Creating dynamic image with size 6442450944 bytes (6144MB)...
Virtual machine 'baserock' is created and registered.
UUID: 2a0ef08d-8596-44d8-bbc1-afd81b6a12fb
Settings file: '/home/username/VirtualBox VMs/baserock/baserock.vbox'
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Disk image created. UUID: b77800f4-e2bb-4dfb-abdc-0e138cd88a51

Then open VirtualBox and start the baserock image. If it fails the first time then open Settings and select network/adapter2 then power down the image and try again (this seems to be some odd foible of VirtualBox).

Within the emulator window enter the password 'root' and then use the passwd command to set a password. Then type:

ip addr

You'll need to know the IP address in order to log in. Typically it's 192.168.x.y

Then from another terminal (NOT within the QEMU window) you can ssh in with:

export BASEROCK_VM_IP=<ipaddr>
ssh-keygen -f "/home/$USER/.ssh/known_hosts" -R [$BASEROCK_VM_IP]:22
ssh -A -p22 root@$BASEROCK_VM_IP

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 [$BASEROCK_VM_IP]:22
scp -P 22 setup-devel.sh root@$BASEROCK_VM_IP:/root

Now log back into the virtual machine and run the setup script:

ssh -A -p22 root@$BASEROCK_VM_IP
./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.