diff options
Diffstat (limited to 'scripts/package-build')
-rwxr-xr-x | scripts/package-build/build.py | 30 | ||||
-rw-r--r-- | scripts/package-build/vpp/.gitignore | 1 | ||||
-rw-r--r-- | scripts/package-build/vpp/package.toml | 11 |
3 files changed, 41 insertions, 1 deletions
diff --git a/scripts/package-build/build.py b/scripts/package-build/build.py index d64a7378..08bda30e 100755 --- a/scripts/package-build/build.py +++ b/scripts/package-build/build.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Copyright (C) 2024 VyOS maintainers and contributors +# Copyright (C) 2024-2025 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 @@ -92,6 +92,34 @@ def build_package(package: list, patch_dir: Path) -> None: # Check out the specific commit run(['git', 'checkout', package['commit_id']], cwd=repo_dir, check=True) + # The `pre_build_hook` is an optional configuration defined in `package.toml`. + # It executes after the repository is checked out and before the build process begins. + # This hook allows you to perform preparatory tasks, such as creating directories, + # copying files, or running custom scripts/commands. + # + # Usage: + # - Single command: + # pre_build_hook = "echo 'Hello Pre-Build-Hook'" + # + # - Multi-line commands: + # pre_build_hook = """ + # mkdir -p ../hello/vyos + # mkdir -p ../vyos + # cp example.txt ../vyos + # """ + # + # - Combination of commands and scripts: + # pre_build_hook = "ls -l; ./script.sh" + pre_build_hook = package.get('pre_build_hook', '') + if pre_build_hook: + try: + print(f'I: execute pre_build_hook for the package "{repo_name}"') + run(pre_build_hook, cwd=repo_dir, check=True, shell=True) + except CalledProcessError as e: + print(e) + print(f"I: pre_build_hook failed for the {repo_name}") + raise + # Apply patches if any if (repo_dir / 'patches'): apply_patches(repo_dir, patch_dir / repo_name) diff --git a/scripts/package-build/vpp/.gitignore b/scripts/package-build/vpp/.gitignore index 100411c4..38768675 100644 --- a/scripts/package-build/vpp/.gitignore +++ b/scripts/package-build/vpp/.gitignore @@ -1 +1,2 @@ /vpp/ +/vyos-vpp-patches/ diff --git a/scripts/package-build/vpp/package.toml b/scripts/package-build/vpp/package.toml index 255c3943..644b36a9 100644 --- a/scripts/package-build/vpp/package.toml +++ b/scripts/package-build/vpp/package.toml @@ -1,8 +1,19 @@ [[packages]] +name = "vyos-vpp-patches" +commit_id = "current" +scm_url = "https://github.com/vyos/vyos-vpp-patches" +build_cmd = "/bin/true" + +[[packages]] name = "vpp" commit_id = "stable/2406" scm_url = "https://github.com/FDio/vpp" +pre_build_hook = """ +mkdir -p ../patches/vpp/ +rsync -av ../vyos-vpp-patches/patches/vpp/ ../patches/vpp/ +""" + build_cmd = """ make UNATTENDED=yes install-dep make pkg-deb |