How to properly build and smoketest VyOS?

Thanks to Simon at the slack-channel!

Here is some documentation in case somebody else stumbles upon this in future:

  1. Prerequisites.

0.1) Install docker-ce package:

sudo apt-get update
sudo apt-get install docker-ce

0.2) Put user in docker-group (and preferly logout/login to make this active):

sudo usermod -aG docker username

0.3) Create workdir:

mkdir vyos

0.4) Create /home/username/vyos/vybld.sh (and set permission 755 chmod +x /home/username/vyos/vybld.sh):

#/!bin/sh

docker run --rm -it \
    -v "$(pwd)":/vyos \
    -v "$HOME/.gitconfig":/etc/gitconfig \
    -v "$HOME/.bash_aliases":/home/vyos_bld/.bash_aliases \
    -v "$HOME/.bashrc":/home/vyos_bld/.bashrc \
    -w /vyos --privileged --sysctl net.ipv6.conf.lo.disable_ipv6=0 \
    -e GOSU_UID=$(id -u) -e GOSU_GID=$(id -g) \
    vyos/vyos-build:current bash

To build stuff (dont forget to logout/login to make use of updated groups if you not already did so).

  1. Enter workdirectory:
cd vyos
  1. Clone stuff from github:

'``
git clone -b current --single-branch GitHub - vyos/vyos-build: VyOS image build scripts
git clone -b current --single-branch GitHub - vyos/vyos-1x: VyOS command definitions, scripts, and utilities


Then if you are to test some new code you provide you can edit the content of the vyos-build and vyos-1x directories.

Or if you already sent a commit you can fetch that branch from your github:

'``
git clone -b current --single-branch https://github.com/vyos/vyos-build
git clone -b T1234 --single-branch https://github.com/username/vyos-1x
  1. Start docker:
./vybld.sh

If user not part of docker-group then sudo must be used:

sudo ./vybld.sh

You can see that docker have successfully started by looking at the prompt:

username@fddba08ee50d:/vyos
  1. Build the vyox-1x debian packages (.deb) by entering the vyos-1x folder and execute (while in docker):
cd vyos-1x
dpkg-buildpackage -uc -us -tc -b
  1. Move the .deb files created to vyos-build/packages directory:
mv ../*.deb ../vyos-build/packages/
  1. Enter vyos-build directory and create the ISO image.

6.1) To build release with smoketests:

cd ../vyos-build
./build-vyos-image --architecture amd64 --build-by "[email protected]" --vyos-mirror https://rolling-packages.vyos.net/current/ --debian-mirror http://deb.debian.org/debian/ --build-type release --custom-package vyos-1x-smoketest --version "1337-2023" iso

6.2) To build release without smoketests (remove some of the custom deb-files in vyos-build/packages directory aswell):

cd ../vyos-build
./build-vyos-image --architecture amd64 --build-by "[email protected]" --vyos-mirror https://rolling-packages.vyos.net/current/ --debian-mirror http://deb.debian.org/debian/ --build-type release --version "1337-2023" iso
  1. To run tests (this will start the iso within qemu still being in docker).

7.1) Smoketests:

sudo make test

7.2) Config tests:

sudo make testc

Done!

To use the iso-file elsewhere you can copy it from (example) /home/username/vyos/vyos-build/build/vyos-999.202309182137-amd64.iso (unless you set a custom version to it when calling ./build-vyos-image).

Any improvements?

How safe is it to run the “sudo make test” outside of the docker, Im thinking in order to gain some performance as in host(qemu(vyos(smoketests))) rather than host(docker(qemu(vyos(smoketests))))?

4 Likes