summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-06-20 19:42:02 +0200
committerGitHub <noreply@github.com>2023-06-20 19:42:02 +0200
commit14a6e4d848de2eaf899b44762a02d14a5085d724 (patch)
tree27d09e1bd37b8e32ae3524003d4dc6211e3956ef
parentdeb4cb7f4d4b3f5a9b132b7c4528d4b94329a89f (diff)
parentfee69c5c7cafb2959b8b46b22c105b9c1eb82176 (diff)
downloadvyos-build-14a6e4d848de2eaf899b44762a02d14a5085d724.tar.gz
vyos-build-14a6e4d848de2eaf899b44762a02d14a5085d724.zip
Merge pull request #364 from zdc/T1797-sagitta
VPP: T1797: Added build scripts for VPP
-rw-r--r--packages/vpp/Jenkinsfile33
-rwxr-xr-xpackages/vpp/build.py104
-rw-r--r--packages/vpp/build_vpp.json14
-rw-r--r--packages/vpp/patches/vpp/0001-Debian-12-compatible-build.patch54
4 files changed, 205 insertions, 0 deletions
diff --git a/packages/vpp/Jenkinsfile b/packages/vpp/Jenkinsfile
new file mode 100644
index 00000000..097f4da1
--- /dev/null
+++ b/packages/vpp/Jenkinsfile
@@ -0,0 +1,33 @@
+// Copyright (C) 2023 VyOS maintainers and contributors
+//
+// This program is free software; you can redistribute it and/or modify
+// in order to easy exprort images built to "external" world
+// it under the terms of the GNU General Public License version 2 or later as
+// published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+@NonCPS
+
+// Using a version specifier library, use 'current' branch. The underscore (_)
+// is not a typo! You need this underscore if the line immediately after the
+// @Library annotation is not an import statement!
+@Library('vyos-build@current')_
+
+def package_name = 'vpp'
+
+def pkgList = [
+ ['name': 'vpp',
+ 'scmCommit': 'stable/2306',
+ 'scmUrl': 'https://gerrit.fd.io/r/vpp',
+ 'buildCmd': '../build.py --package vpp'],
+]
+
+// Start package build using library function from https://github.com/vyos/vyos-build
+buildPackage("${package_name}", pkgList, null, true, "**/packages/${package_name}/**")
diff --git a/packages/vpp/build.py b/packages/vpp/build.py
new file mode 100755
index 00000000..d1dd54b1
--- /dev/null
+++ b/packages/vpp/build.py
@@ -0,0 +1,104 @@
+#!/usr/bin/env python3
+#
+# Copyright (C) 2023 VyOS maintainers and contributors
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 or later as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+from argparse import ArgumentParser
+from pathlib import Path
+from subprocess import run
+from sys import exit
+from json import load as json_load
+
+
+def check_args(args) -> bool:
+ """Check command arguments
+
+ Args:
+ args (Namespace): Namespace with arguments
+
+ Returns:
+ bool: check result
+ """
+ sources_dir = Path(f'../{args.package}')
+ if not sources_dir.exists():
+ print(f'Sourced directory {sources_dir.as_posix()} does not exist')
+ return False
+ return True
+
+
+# apply patches
+def apply_patches(package_name: str) -> bool:
+ """Apply patches to sources directory
+
+ Args:
+ package_name (str): package name (the same as sources directory)
+ """
+ patches_dir = Path(f'../patches/{package_name}')
+ if patches_dir.exists():
+ for patch_file in patches_dir.iterdir():
+ patch_cmd: list[str] = [
+ 'git', '-c', 'user.email=support@vyos.io', '-c',
+ 'user.name=vyos', 'am',
+ patch_file.as_posix()
+ ]
+ print(f'Applying patch: {patch_file.name}')
+ if run(patch_cmd).returncode != 0:
+ return False
+ return True
+
+
+def build_package(package_name: str) -> bool:
+ """Build a package using commands from external file
+
+ Args:
+ package_name (str): package name
+
+ Returns:
+ bool: build status
+ """
+ build_config_path: str = f'../build_{package_name}.json'
+ with open(build_config_path, 'r') as openfile:
+ try:
+ build_params = json_load(openfile)
+ except Exception as err:
+ print(f'Error parsing config file {build_config_path}: {err}')
+ return False
+
+ for cmd in build_params.get('build_commands', []):
+ print(f'Building: {cmd}')
+ if run(cmd).returncode != 0:
+ return False
+
+ return True
+
+
+# build a package
+if __name__ == '__main__':
+ # prepare argument parser
+ arg_parser = ArgumentParser()
+ arg_parser.add_argument('--package',
+ required=True,
+ help='Package name to build')
+ args = arg_parser.parse_args()
+
+ if not check_args(args):
+ exit(1)
+
+ if not apply_patches(args.package):
+ exit(1)
+
+ if not build_package(args.package):
+ exit(1)
+
+ exit()
diff --git a/packages/vpp/build_vpp.json b/packages/vpp/build_vpp.json
new file mode 100644
index 00000000..8e0fde5b
--- /dev/null
+++ b/packages/vpp/build_vpp.json
@@ -0,0 +1,14 @@
+{
+ "build_commands": [
+ [
+ "sudo",
+ "make",
+ "UNATTENDED=yes",
+ "install-dep"
+ ],
+ [
+ "make",
+ "pkg-deb"
+ ]
+ ]
+} \ No newline at end of file
diff --git a/packages/vpp/patches/vpp/0001-Debian-12-compatible-build.patch b/packages/vpp/patches/vpp/0001-Debian-12-compatible-build.patch
new file mode 100644
index 00000000..786e4556
--- /dev/null
+++ b/packages/vpp/patches/vpp/0001-Debian-12-compatible-build.patch
@@ -0,0 +1,54 @@
+From 3a4e62ad4844e84e93367a19cf1fae0191e677c6 Mon Sep 17 00:00:00 2001
+From: zsdc <taras@vyos.io>
+Date: Mon, 19 Jun 2023 16:39:04 +0300
+Subject: [PATCH] Debian 12 compatible build
+
+---
+ Makefile | 4 ++++
+ build/external/Makefile | 3 +--
+ src/plugins/af_xdp/{CMakeLists.txt => CMakeLists.txt.disable} | 0
+ 3 files changed, 5 insertions(+), 2 deletions(-)
+ rename src/plugins/af_xdp/{CMakeLists.txt => CMakeLists.txt.disable} (100%)
+
+diff --git a/Makefile b/Makefile
+index 88d42dfe4..9c10b62c6 100644
+--- a/Makefile
++++ b/Makefile
+@@ -103,6 +103,10 @@ else ifeq ($(OS_ID)-$(OS_VERSION_ID),debian-11)
+ DEB_DEPENDS += virtualenv
+ DEB_DEPENDS += clang clang-format-11
+ LIBFFI=libffi7
++else ifeq ($(OS_ID)-$(OS_VERSION_ID),debian-12)
++ DEB_DEPENDS += virtualenv
++ DEB_DEPENDS += clang clang-format
++ LIBFFI=libffi8
+ else
+ DEB_DEPENDS += clang-11 clang-format-11
+ LIBFFI=libffi7
+diff --git a/build/external/Makefile b/build/external/Makefile
+index d648f4fa1..8a4d8e115 100644
+--- a/build/external/Makefile
++++ b/build/external/Makefile
+@@ -40,14 +40,13 @@ include packages/ipsec-mb.mk
+ include packages/quicly.mk
+ include packages/rdma-core.mk
+ include packages/dpdk.mk
+-include packages/xdp-tools.mk
+
+ .PHONY: clean
+ clean:
+ @rm -rf $(B) $(I)
+
+ .PHONY: install
+-install: $(if $(ARCH_X86_64), ipsec-mb-install) dpdk-install rdma-core-install quicly-install xdp-tools-install
++install: $(if $(ARCH_X86_64), ipsec-mb-install) dpdk-install rdma-core-install quicly-install
+
+ .PHONY: config
+ config: $(if $(ARCH_X86_64), ipsec-mb-config) dpdk-config rdma-core-config quicly-build
+diff --git a/src/plugins/af_xdp/CMakeLists.txt b/src/plugins/af_xdp/CMakeLists.txt.disable
+similarity index 100%
+rename from src/plugins/af_xdp/CMakeLists.txt
+rename to src/plugins/af_xdp/CMakeLists.txt.disable
+--
+2.34.1
+