diff options
author | Christian Poessinger <christian@poessinger.com> | 2019-01-06 17:39:44 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2019-01-06 17:39:44 +0100 |
commit | 4327fe1f2fc03729b8ae3dc8c409a697d66c89ed (patch) | |
tree | 6301654ae4142a2e70eab0e0137fced5f23b0943 | |
parent | d0d363186d180f9d16d0d33983e088726214f25d (diff) | |
parent | 081bf77f86881b9c2438902595193c2a311b02cd (diff) | |
download | vyos-build-4327fe1f2fc03729b8ae3dc8c409a697d66c89ed.tar.gz vyos-build-4327fe1f2fc03729b8ae3dc8c409a697d66c89ed.zip |
Merge remote-tracking branch 'runborg/current' into current
* runborg/current:
Added build-kernel script and almost total rewrite of build-submodules
-rwxr-xr-x | scripts/build-kernel | 36 | ||||
-rwxr-xr-x | scripts/build-submodules | 251 |
2 files changed, 196 insertions, 91 deletions
diff --git a/scripts/build-kernel b/scripts/build-kernel new file mode 100755 index 00000000..80229d5d --- /dev/null +++ b/scripts/build-kernel @@ -0,0 +1,36 @@ +#!/bin/bash +if [ ! -f "Makefile" ]; then + echo "Makefile missing, This script needs to be executed inside the vyos-kernel package directory" + exit 1 +fi + +if grep -Fxq "KBUILD_OUTPUT" Makefile; then + echo "Wrong Makefile?, This script needs to be executed inside the vyos-kernel package directory" + exit 1 +fi + + +# newer Kernel versions come with a "# SPDX-License-Identifier: GPL-2.0" identifier +# as the first line in the file - use compatible approach with grep rather then sed +VERSION=$(grep "^VERSION" Makefile | grep -Eo '[0-9]{1,4}') +PATCHLEVEL=$(grep "^PATCHLEVEL" Makefile | grep -Eo '[0-9]{1,4}') +SUBLEVEL=$(grep "^SUBLEVEL" Makefile | grep -Eo '[0-9]{1,4}') +ARCH=$(dpkg --print-architecture) + +case "$ARCH" in + amd64) + make x86_64_vyos_defconfig + TARGETS="kernel_source kernel_debug kernel_headers kernel_image" + # the following targets are not supported for Linux Kernels > 4.14 as + # they have been removed from the Makefile (commits 18afab8c1d3c2 & + # 22cba31bae9dc). + if [ ${PATCHLEVEL} -lt 14 ]; then + TARGETS+=" kernel_manual kernel_doc" + fi + CONCURRENCY_LEVEL=4 LOCALVERSION="" make-kpkg --rootcmd fakeroot --initrd --append_to_version -amd64-vyos --revision=$VERSION.$PATCHLEVEL.$SUBLEVEL-1+vyos1+current1 -j4 ${TARGETS} + ;; + + armhf) + make armhf_vyos_defconfig + ;; +esac diff --git a/scripts/build-submodules b/scripts/build-submodules index 294f5404..3a7ea3a5 100755 --- a/scripts/build-submodules +++ b/scripts/build-submodules @@ -5,18 +5,43 @@ if [ ! -d "packages" ]; then exit 1 fi -if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then + +print_help() { 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 "or from the vyos-builder docker container." + echo "" 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 + echo " docker run --rm -it -v $(pwd):/vyos -w /vyos --sysctl net.ipv6.conf.lo.disable_ipv6=0 vyos-builder scripts/build-submodules" + echo "" + echo "Parameters:" + echo " --init-packages - Initiate all subpackages before building" +} + +while test $# -gt 0 +do + case "$1" in + -h|-?|--help) + print_help + exit 0 + ;; + --init-packages) + INIT_PACKAGES=1 + ;; + *) + (>&2 echo "Error: Argument $1 is not valid") + echo "" + print_help + exit 1 + ;; + esac + shift +done + status_start() { echo -ne "[ ] $1" @@ -39,6 +64,41 @@ echo -ne " $1\n" ROOTDIR="$(pwd)" PKGDIR="$(pwd)/packages" +initiate_package() { + PKG=$1 + status_start "Initializing subpackage: $PKG" + ( set -e + git submodule update --init packages/$PKG >>$PKGDIR/$PKG.buildlog 2>&1 + cd $PKGDIR/$PKG + git checkout current + ) + if [ $? -ne 0 ]; then + status_fail "Failed to initiate package $PKG, look in $PKG.buildlog to examine the fault\n" + return 1 + fi + status_ok + return 0 +} + +build_package() { + PKG=$1 + status_start "Building package: $PKG" + if [ ! -d "packages/$PKG/debian" ]; then + status_skip "No source for: $PKG" + return 1 + fi + ( set -e + cd $PKGDIR/$PKG > /dev/null + dpkg-buildpackage -uc -us -tc -b >>$PKGDIR/$PKG.buildlog 2>&1 + ) + if [ $? -ne 0 ]; then + status_fail + error_msg "Failed to build package $PKG, look in $PKG.buildlog to examine the fault\n" + return 2 + fi + status_ok +} + echo "Cleaning up buildfiles..." rm -rf $PKGDIR/*.deb rm -rf $PKGDIR/*.changes @@ -89,107 +149,116 @@ for PKG in mdns-repeater \ vyos-strongswan \ vyos-world \ ; do - if [ -d "packages/$PKG/debian" ]; then - status_start "Building package: $PKG" - pushd $PKGDIR/$PKG > /dev/null - dpkg-buildpackage -uc -us -tc -b >$PKGDIR/$PKG.buildlog 2>&1 - if [ $? -ne 0 ]; then - status_fail - error_msg "Failed to build package $PKG, look in $PKG.buildlog to examine the fault\n" - else - status_ok - fi - popd > /dev/null - else - status_skip "No source for: $PKG" + if [ $INIT_PACKAGES ]; then + initiate_package "$PKG" fi + build_package "$PKG" done + # KERNEL -if [ -f "packages/vyos-kernel/Makefile" ]; then +build_kernel() { status_start "Building-package: vyos-kernel" - pushd packages/vyos-kernel > /dev/null - bash -c '../../scripts/build-kernel' >$PKGDIR/vyos-kernel.buildlog 2>&1 + if [ ! -f "packages/vyos-kernel/Makefile" ]; then + status_skip "No source for: vyos-kernel" + return 0 + fi + + ( set -e + cd packages/vyos-kernel > /dev/null + bash -c '../../scripts/build-kernel' >$PKGDIR/vyos-kernel.buildlog 2>&1 + ) if [ $? -ne 0 ]; then status_fail - cat $PKGDIR/vyos-kernel.buildlog error_msg "Failed to build package vyos-kernel, look in vyos-kernel.buildlog to examine the fault\n" - else - VERSION=$(grep "^VERSION" Makefile | grep -Eo '[0-9]{1,4}') - PATCHLEVEL=$(grep "^PATCHLEVEL" Makefile | grep -Eo '[0-9]{1,4}') - SUBLEVEL=$(grep "^SUBLEVEL" Makefile | grep -Eo '[0-9]{1,4}') - ARCH=$(dpkg --print-architecture) - echo "$VERSION.$PATCHLEVEL.$SUBLEVEL" > $ROOTDIR/data/kernel_version - status_ok + return 1 fi - popd > /dev/null -else - status_skip "No source for: vyos-kernel" -fi - + VERSION=$(grep "^VERSION" Makefile | grep -Eo '[0-9]{1,4}') + PATCHLEVEL=$(grep "^PATCHLEVEL" Makefile | grep -Eo '[0-9]{1,4}') + SUBLEVEL=$(grep "^SUBLEVEL" Makefile | grep -Eo '[0-9]{1,4}') + ARCH=$(dpkg --print-architecture) + echo "$VERSION.$PATCHLEVEL.$SUBLEVEL" > $ROOTDIR/data/kernel_version + status_ok +} +build_kernel # WIREGUARD -if [ -d "packages/vyos-wireguard/debian" ]; then - if [ -f "packages/vyos-kernel/Makefile" ]; then - status_start "Building package: vyos-wireguard" - if grep -q "KBUILD_OUTPUT" packages/vyos-kernel/Makefile; then - VERSION=$(grep "^VERSION" 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}') - ARCH=$(dpkg --print-architecture) - pushd packages/vyos-wireguard > /dev/null - echo "src/wireguard.ko /lib/modules/$VERSION.$PATCHLEVEL.$SUBLEVEL-$ARCH-vyos/extra" > debian/wireguard-modules.install - bash -c 'KERNELDIR=/vyos/packages/vyos-kernel dpkg-buildpackage -uc -us -tc -b' >$PKGDIR/vyos-wireguard.buildlog 2>&1 - if [ $? -ne 0 ]; then - status_fail - cat $PKGDIR/vyos-wireguard.buildlog - error_msg "Failed to build package vyos-wireguard, look in vyos-wireguard.buildlog to examine the fault\n" - else - status_ok - fi - popd > /dev/null - else - status_fail - error_msg "Failed to build package vyos-wireguard, no kernel source found\n" - fi - else - seeor_msg "Something wrong with the kernel module?" - fi -else +build_wireguard() { + status_start "Building package: vyos-wireguard" + + if [ ! -d "packages/vyos-wireguard/debian" ]; then status_skip "No source for: vyos-wireguard" -fi + return 0 + fi + + if [ ! -f "packages/vyos-kernel/Makefile" ]; then + status_fail + error_msg "No Makefile found in kernel package" + return 1 + fi + + if ! grep -q "KBUILD_OUTPUT" packages/vyos-kernel/Makefile; then + status_fail + error_msg "Failed to build package vyos-wireguard, no kernel source found\n" + return 1 + fi + + VERSION=$(grep "^VERSION" 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}') + ARCH=$(dpkg --print-architecture) + # Collect kernel information + ( set -e + pushd packages/vyos-wireguard > /dev/null + echo "src/wireguard.ko /lib/modules/$VERSION.$PATCHLEVEL.$SUBLEVEL-$ARCH-vyos/extra" > debian/wireguard-modules.install + bash -c 'KERNELDIR=/vyos/packages/vyos-kernel dpkg-buildpackage -uc -us -tc -b' >$PKGDIR/vyos-wireguard.buildlog 2>&1 + ) + if [ $? -ne 0 ]; then + status_fail + error_msg "Failed to build package vyos-wireguard, look in vyos-wireguard.buildlog to examine the fault\n" + return 2 + fi + status_ok +} +(build_wireguard) # ACCEL-PPP -if [ -d "packages/vyos-accel-ppp/debian" ]; then +build_accel-ppp() { + status_start "Building package: vyos-accel-ppp" + if [ ! -d "packages/vyos-accel-ppp/debian" ]; then + status_skip "No source for: vyos-accel-ppp" + return 0 + fi + if [ -f "packages/vyos-kernel/Makefile" ]; then - status_start "Building package: vyos-accel-ppp" - if grep -q "KBUILD_OUTPUT" packages/vyos-kernel/Makefile; then - VERSION=$(grep "^VERSION" 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}') - ARCH=$(dpkg --print-architecture) - pushd packages/vyos-accel-ppp > /dev/null - #echo "src/wireguard.ko /lib/modules/$VERSION.$PATCHLEVEL.$SUBLEVEL-$ARCH-vyos/extra" > debian/wireguard-modules.install - echo "lib/modules/$VERSION.$PATCHLEVEL.$SUBLEVEL-$ARCH-vyos/extra/*.ko" > debian/vyos-accel-ppp-ipoe-kmod.install - sed -i "s#[0-9].[0-9][0-9].[0-9]-amd64-vyos#$VERSION.$PATCHLEVEL.$SUBLEVEL-$ARCH-vyos#g" debian/rules - KERNELDIR=$PKGDIR/vyos-kernel dpkg-buildpackage -uc -us -tc -b >$PKGDIR/vyos-accel-ppp.buildlog 2>&1 - if [ $? -ne 0 ]; then - status_fail - cat $PKGDIR/vyos-accel-ppp.buildlog - error_msg "Failed to build package vyos-accel-ppp, look in vyos-accel-ppp.buildlog to examine the fault\n" - else - status_ok - fi - popd > /dev/null - else - status_fail - error_msg "Failed to build package vyos-accel-ppp, no kernel source found\n" - fi - else - seeor_msg "Something wrong with the kernel module?" + error_msg "Something wrong with the kernel module?" + return 1 fi -else - status_skip "No source for: vyos-accel-ppp" -fi + + if ! grep -q "KBUILD_OUTPUT" packages/vyos-kernel/Makefile; then + status_fail + error_msg "Failed to build package vyos-accel-ppp, no kernel source found\n" + fi + # Collect kernel information + VERSION=$(grep "^VERSION" 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}') + ARCH=$(dpkg --print-architecture) + + ( set -e + pushd packages/vyos-accel-ppp > /dev/null + #echo "src/wireguard.ko /lib/modules/$VERSION.$PATCHLEVEL.$SUBLEVEL-$ARCH-vyos/extra" > debian/wireguard-modules.install + echo "lib/modules/$VERSION.$PATCHLEVEL.$SUBLEVEL-$ARCH-vyos/extra/*.ko" > debian/vyos-accel-ppp-ipoe-kmod.install + sed -i "s#[0-9].[0-9][0-9].[0-9]-amd64-vyos#$VERSION.$PATCHLEVEL.$SUBLEVEL-$ARCH-vyos#g" debian/rules + KERNELDIR=$PKGDIR/vyos-kernel dpkg-buildpackage -uc -us -tc -b >$PKGDIR/vyos-accel-ppp.buildlog 2>&1 + ) + if [ $? -ne 0 ]; then + status_fail + error_msg "Failed to build package vyos-accel-ppp, look in vyos-accel-ppp.buildlog to examine the fault\n" + return 1 + fi + status_ok +} +build_accel-ppp |