Before starting this tutorial, you will need to setup your development machine. These instructions were tested on an x86_64 based machine using Ubuntu 20.04.
These tools are required for building both the toolkit and the images built from the toolkit. These are the same prerequisites needed for building CBL-Mariner.
# Add a backports repo in order to install the necessary version of Go.
sudo add-apt-repository ppa:longsleep/golang-backports
sudo apt-get update
# Install required dependencies.
sudo apt -y install git make tar wget curl rpm qemu-utils golang-1.17-go genisoimage python bison gawk
# Recommended but not required: `pigz` for faster compression operations.
sudo apt -y install pigz
# Fix go 1.17 link
sudo ln -vsf /usr/lib/go-1.17/bin/go /usr/bin/go
# Install Docker.
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USER
You will need to log out and lock back in for user changes to take effect.
To build the CBL-MarinerTutorials repository you will need the same toolkit and makefile from the CBL-Mariner repository. So, first clone CBL-Mariner, and then checkout the stable release of interest (e.g. 1.0-stable or 2.0-stable), then build the toolkit.
git clone https://github.com/microsoft/CBL-Mariner.git
pushd CBL-Mariner/toolkit
git checkout 1.0-stable
sudo make package-toolkit REBUILD_TOOLS=y
popd
git clone https://github.com/microsoft/CBL-Mariner.git
pushd CBL-Mariner/toolkit
git checkout 2.0-stable
sudo make package-toolkit REBUILD_TOOLS=y
popd
Now clone the CBL-MarinerTutorials repo and extract the toolkit to the CBL-MarinerTutorials repository.
git clone https://github.com/microsoft/CBL-MarinerTutorials.git
pushd CBL-MarinerTutorials
cp ../CBL-Mariner/out/toolkit-*.tar.gz ./
tar -xzvf toolkit-*.tar.gz
The toolkit folder now contains the makefile, support scripts and the go tools compiled from the section. The toolkit will preserve the previously compiled tool binaries, however the toolkit is also able to rebuild them if desired. (Not recommended: set REBUILD_TOOLS=y
to use locally rebuilt tool binaries during a build). For more information on our toolkit see How The Build System Works in the CBL-Mariner repo.
The remainder of this tutorial assumes you are using CBL-Mariner 2.0. However, it is possible to build the same from this tutorial using the CBL-Mariner 1.0 release as well.