Rename build script to build-submodules and removed docker from the build process.

The script was originally named `build-docker-subpackages` and executed docker for every package built.
This has now changed so that the user could choose to do a docker or native build.
The readme is aldo updated to reflect this change.
This commit is contained in:
Runar Borge 2018-12-28 23:21:44 +01:00
parent 39948ad838
commit 396501bbbf
2 changed files with 44 additions and 23 deletions

View File

@ -175,14 +175,22 @@ for dir in packages/*; do
done done
``` ```
### Building packages ### Building packages
Most packages can be built by using the vyos-builder docker container with the same parameters, the vyos-builder container should include all dependencies for compiling supported packages. The script `./scripts/build-submodules` is created to automate the process of building packages, execute it in the root of `vyos-build` to start compilation on all supported packages that are checked out.
The script `./scripts/build-docker-subpackages` is created to automate the process of building packages, just execute it in the root of vyos-build to start compilation on all supported packages that are checked out.
The easiest way to compile is with the `vyos-builder` docker container, it includes all dependencies for compiling supported packages.
```bash
$ docker run --rm -it -v $(pwd):/vyos -w /vyos \
--sysctl net.ipv6.conf.lo.disable_ipv6=0 \
vyos-builder \
./scripts/build-submodules
```
NOTE: Prior to executing this script you need to create/build the `vyos-builder` container and checkout all packages you want to compile. NOTE: Prior to executing this script you need to create/build the `vyos-builder` container and checkout all packages you want to compile.
### Building one package ### Building one package
the script above runs a docker container for every build it does. this is also possible to do by hand using: the script above runs all package build inside a docker container, this is also possible to do by hand using:
Ecevuted from the root directory of vyos-build Executed from the root directory of vyos-build
```bash ```bash
$ docker run --rm -it -v $(pwd):/vyos -w /vyos/packages/PACKAGENAME \ $ docker run --rm -it -v $(pwd):/vyos -w /vyos/packages/PACKAGENAME \
--sysctl net.ipv6.conf.lo.disable_ipv6=0 \ --sysctl net.ipv6.conf.lo.disable_ipv6=0 \

View File

@ -5,6 +5,19 @@ if [ ! -d "packages" ]; then
exit 1 exit 1
fi fi
if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
echo "Script for building all subpackages to vyos"
echo "Execute this sctipt from the root of the vyos-build directory"
echo ""
echo "This script could be executed from a Debian Jessie installation with all dependencies"
echo "or from the vyos-builder docker container"
echo "docker instructions"
echo "Build the container:"
echo " docker build -t vyos-builder ."
echo "Compile packages:"
echo " docker run --rm -it -v $(pwd):/vyos -w /vyos --sysctl net.ipv6.conf.lo.disable_ipv6=0 vyos-builder scripts/build-docker-subpaclages"
fi
status_start() { status_start() {
echo -ne "[ ] $1" echo -ne "[ ] $1"
} }
@ -23,10 +36,13 @@ echo -ne "\r[SKIP] $1\n"
error_msg() { error_msg() {
echo -ne " $1\n" echo -ne " $1\n"
} }
ROOTDIR="$(pwd)"
PKGDIR="$(pwd)/packages"
echo "Cleaning up buildfiles..." echo "Cleaning up buildfiles..."
rm -rf packages/*.deb rm -rf $PKGDIR/*.deb
rm -rf packages/*.changes rm -rf $PKGDIR/*.changes
rm -rf $PKGDIR/*.buildlog
echo "-----------------------------------------------------" echo "-----------------------------------------------------"
echo "Starting build process for all packages" echo "Starting build process for all packages"
echo "" echo ""
@ -75,16 +91,15 @@ for PKG in mdns-repeater \
; do ; do
if [ -d "packages/$PKG/debian" ]; then if [ -d "packages/$PKG/debian" ]; then
status_start "Building package: $PKG" status_start "Building package: $PKG"
docker run --rm -it -v $(pwd):/vyos -w /vyos/packages/$PKG \ pushd $PKGDIR/$PKG > /dev/null
--sysctl net.ipv6.conf.lo.disable_ipv6=0 \ dpkg-buildpackage -uc -us -tc -b >$PKGDIR/$PKG.buildlog 2>&1
vyos-builder \
dpkg-buildpackage -uc -us -tc -b >packages/$PKG.buildlog 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
status_fail status_fail
error_msg "Failed to build package $PKG, look in $PKG.buildlog to examine the fault\n" error_msg "Failed to build package $PKG, look in $PKG.buildlog to examine the fault\n"
else else
status_ok status_ok
fi fi
popd > /dev/null
else else
status_skip "No source for: $PKG" status_skip "No source for: $PKG"
fi fi
@ -93,21 +108,20 @@ done
# KERNEL # KERNEL
if [ -f "packages/vyos-kernel/Makefile" ]; then if [ -f "packages/vyos-kernel/Makefile" ]; then
status_start "Building-package: vyos-kernel" status_start "Building-package: vyos-kernel"
docker run --rm -it -v $(pwd):/vyos -w /vyos/packages/vyos-kernel \ pushd packages/vyos-kernel > /dev/null
--sysctl net.ipv6.conf.lo.disable_ipv6=0 \ bash -c '../../scripts/build-kernel' >$PKGDIR/vyos-kernel.buildlog 2>&1
vyos-builder \
bash -c '../../scripts/build-kernel' >packages/vyos-kernel.buildlog 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
status_fail status_fail
error_msg "Failed to build package vyos-kernel, look in vyos-kernel.buildlog to examine the fault\n" error_msg "Failed to build package vyos-kernel, look in vyos-kernel.buildlog to examine the fault\n"
else else
VERSION=$(grep "^VERSION" packages/vyos-kernel/Makefile | grep -Eo '[0-9]{1,4}') VERSION=$(grep "^VERSION" Makefile | grep -Eo '[0-9]{1,4}')
PATCHLEVEL=$(grep "^PATCHLEVEL" packages/vyos-kernel/Makefile | grep -Eo '[0-9]{1,4}') PATCHLEVEL=$(grep "^PATCHLEVEL" Makefile | grep -Eo '[0-9]{1,4}')
SUBLEVEL=$(grep "^SUBLEVEL" packages/vyos-kernel/Makefile | grep -Eo '[0-9]{1,4}') SUBLEVEL=$(grep "^SUBLEVEL" Makefile | grep -Eo '[0-9]{1,4}')
ARCH=$(dpkg --print-architecture) ARCH=$(dpkg --print-architecture)
sed -i.bak "s/--linux-packages .* \\\/--linux-packages linux-image-$VERSION\.$PATCHLEVEL\.$SUBLEVEL \\\/" scripts/live-build-config sed -i.bak "s/--linux-packages .* \\\/--linux-packages linux-image-$VERSION\.$PATCHLEVEL\.$SUBLEVEL \\\/" $ROOTDIR/scripts/live-build-config
status_ok status_ok
fi fi
popd > /dev/null
else else
status_skip "No source for: vyos-kernel" status_skip "No source for: vyos-kernel"
fi fi
@ -123,17 +137,16 @@ if [ -d "packages/vyos-wireguard/debian" ]; then
PATCHLEVEL=$(grep "^PATCHLEVEL" packages/vyos-kernel/Makefile | grep -Eo '[0-9]{1,4}') PATCHLEVEL=$(grep "^PATCHLEVEL" packages/vyos-kernel/Makefile | grep -Eo '[0-9]{1,4}')
SUBLEVEL=$(grep "^SUBLEVEL" packages/vyos-kernel/Makefile | grep -Eo '[0-9]{1,4}') SUBLEVEL=$(grep "^SUBLEVEL" packages/vyos-kernel/Makefile | grep -Eo '[0-9]{1,4}')
ARCH=$(dpkg --print-architecture) ARCH=$(dpkg --print-architecture)
echo "src/wireguard.ko /lib/modules/$VERSION.$PATCHLEVEL.$SUBLEVEL-$ARCH-vyos/extra" > packages/vyos-wireguard/debian/wireguard-modules.install pushd packages/vyos-wireguard > /dev/null
docker run --rm -it -v $(pwd):/vyos -w /vyos/packages/vyos-wireguard \ echo "src/wireguard.ko /lib/modules/$VERSION.$PATCHLEVEL.$SUBLEVEL-$ARCH-vyos/extra" > debian/wireguard-modules.install
--sysctl net.ipv6.conf.lo.disable_ipv6=0 \ bash -c 'KERNELDIR=/vyos/packages/vyos-kernel dpkg-buildpackage -uc -us -tc -b' >$PKGDIR/vyos-wireguard.buildlog 2>&1
vyos-builder \
bash -c 'KERNELDIR=/vyos/packages/vyos-kernel dpkg-buildpackage -uc -us -tc -b' >packages/vyos-wireguard.buildlog 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
status_fail status_fail
error_msg "Failed to build package vyos-wireguard, look in vyos-wireguard.buildlog to examine the fault\n" error_msg "Failed to build package vyos-wireguard, look in vyos-wireguard.buildlog to examine the fault\n"
else else
status_ok status_ok
fi fi
popd > /dev/null
else else
status_fail status_fail
error_msg "Failed to build package vyos-wireguard, no kernel source found\n" error_msg "Failed to build package vyos-wireguard, no kernel source found\n"