summaryrefslogtreecommitdiff
path: root/scripts/package-build/linux-kernel/build-kernel.sh
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2024-09-06 10:45:27 +0000
committerViacheslav Hletenko <v.gletenko@vyos.io>2024-09-06 11:34:08 +0000
commitc9a5a93834fce33f1e999dd50381cb7ff9e5fabb (patch)
tree26d03e228ca55acc5fc29d4ad18e8331b79e8605 /scripts/package-build/linux-kernel/build-kernel.sh
parent70122746469e930a6775e0c42c4d1fd30bc6d514 (diff)
downloadvyos-build-c9a5a93834fce33f1e999dd50381cb7ff9e5fabb.tar.gz
vyos-build-c9a5a93834fce33f1e999dd50381cb7ff9e5fabb.zip
T6674: Add build-scrips for packages without Jenkins
Add build scripts for .deb packages without Jenkins. To exclude Jenkins we need some place where we can put new builds-scripts to run in parallel (old/new) during meantime. We will deprecate old Jenkins package builds in the future.
Diffstat (limited to 'scripts/package-build/linux-kernel/build-kernel.sh')
-rwxr-xr-xscripts/package-build/linux-kernel/build-kernel.sh56
1 files changed, 56 insertions, 0 deletions
diff --git a/scripts/package-build/linux-kernel/build-kernel.sh b/scripts/package-build/linux-kernel/build-kernel.sh
new file mode 100755
index 00000000..2c02f5c3
--- /dev/null
+++ b/scripts/package-build/linux-kernel/build-kernel.sh
@@ -0,0 +1,56 @@
+#!/bin/bash
+CWD=$(pwd)
+KERNEL_SRC=linux
+
+set -e
+
+if [ ! -d ${KERNEL_SRC} ]; then
+ echo "Linux Kernel source directory does not exists, please 'git clone'"
+ exit 1
+fi
+
+echo "I: Copy Kernel config (x86_64_vyos_defconfig) to Kernel Source"
+cp -rv arch/ ${KERNEL_SRC}/
+
+cd ${KERNEL_SRC}
+
+echo "I: clean modified files"
+git reset --hard HEAD
+
+KERNEL_VERSION=$(make kernelversion)
+KERNEL_SUFFIX=-$(dpkg --print-architecture)-vyos
+
+# VyOS requires some small Kernel Patches - apply them here
+# It's easier to habe them here and make use of the upstream
+# repository instead of maintaining a full Kernel Fork.
+# Saving time/resources is essential :-)
+PATCH_DIR=${CWD}/patches/kernel
+for patch in $(ls ${PATCH_DIR})
+do
+ echo "I: Apply Kernel patch: ${PATCH_DIR}/${patch}"
+ patch -p1 < ${PATCH_DIR}/${patch}
+done
+
+echo "I: make vyos_defconfig"
+# Select Kernel configuration - currently there is only one
+make vyos_defconfig
+
+echo "I: Generate environment file containing Kernel variable"
+cat << EOF >${CWD}/kernel-vars
+#!/bin/sh
+export KERNEL_VERSION=${KERNEL_VERSION}
+export KERNEL_SUFFIX=${KERNEL_SUFFIX}
+export KERNEL_DIR=${CWD}/${KERNEL_SRC}
+EOF
+
+echo "I: Build Debian Kernel package"
+touch .scmversion
+make bindeb-pkg BUILD_TOOLS=1 LOCALVERSION=${KERNEL_SUFFIX} KDEB_PKGVERSION=${KERNEL_VERSION}-1 -j $(getconf _NPROCESSORS_ONLN)
+
+cd $CWD
+if [[ $? == 0 ]]; then
+ for package in $(ls linux-*.deb)
+ do
+ ln -sf linux-kernel/$package ..
+ done
+fi