Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: T3664: improve support for custom build hooks #767

Merged
merged 1 commit into from
Sep 19, 2024

Conversation

dmbaturin
Copy link
Member

@dmbaturin dmbaturin commented Sep 18, 2024

Change Summary

Make build hooks embedded in flavors and improve their flexibility.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes)
  • Migration from an old Vyatta component to vyos-1x, please link to related PR inside obsoleted component
  • Other (please describe):

Component(s) name

Image build scripts.

Proposed changes

I'm taking advantage of the fact that we don't have any official flavors that use that mechanism yet, and I haven't seen anyone using it in the community either. The changes are breaking but I believe necessary to make the custom hook mechanism powerful enough for its intended purpose.

  1. The option is now build_hook rather than post_build_hook — the motivation is that it's a part of the build processes. The hook builds artifacts that built-in functionality cannot build, the fact that it operates on a raw images produced by a built-in function is an implementation detail.

  2. Image version and architecture are passed to the hook as arguments.

  3. There's a way to pass custom arguments to the hook script as well, via --build-hook-opts/build_hook_opts option.

  4. The hook script is now embedded in the flavor file. This solves the problem of how to distribute hook scripts and where to store them and how to put them in $PATH. People in the community can just share single-file flavors, and our CI workflows can also just take single TOML files.

For example, this is how one could re-create building a qcow2 image with a hook:

build_hook = '''
RAW_IMAGE=$1
VERSION=$2
ARCH=$3
OPTS=$4

qemu-img convert -f raw -O qcow2 $OPTS $RAW_IMAGE vyos-$VERSION-$ARCH-qemu.qcow2
'''

$./build-vyos-image --build-hook-opts "-c" my-qcow2
  1. The build script takes the image name from the hook output and adds it to the artifact list in the build manifest.

How to test

Checklist:

  • I have read the CONTRIBUTING document
  • I have linked this PR to one or more Phabricator Task(s)
  • My commit headlines contain a valid Task id
  • My change requires a change to the documentation
  • I have updated the documentation accordingly

Copy link

👍
No issues in PR Title / Commit Title

@dmbaturin dmbaturin merged commit 8274a41 into vyos:current Sep 19, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants