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

T7037: Add prebuild hook for the package-build #882

Open
wants to merge 1 commit into
base: current
Choose a base branch
from

Conversation

sever-sever
Copy link
Member

@sever-sever sever-sever commented Jan 10, 2025

Change summary

Add prebuild hook for the package-build

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):

Related Task(s)

Related PR(s)

Details

The pre_build_hook is an optional configuration defined in packages.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"

Example

$ cat package.toml 
[[packages]]
name = "vyos-1x"
commit_id = "current"
scm_url = "https://github.com/vyos/vyos-1x"

pre_build_hook = "echo 'Hello Pre-Build-Cmd'"
build_cmd = "echo 'Hello build-Cmd'"


build

vyos_bld@6bb520f6cf1f:/vyos/work/tmp/T7037/vyos-build/scripts/package-build/vyos-1x$ ./build.py 
Cloning into 'vyos-1x'...
Resolving deltas: 100% (69968/69968), done.
Already on 'current'
Your branch is up to date with 'origin/current'.
I: execute pre_build_hook for the package vyos-1x
Hello Pre-Build-Cmd
I: Patch directory patches/vyos-1x does not exist, skipping patch application
I: Tarball created: vyos-1x_current.tar.gz
dpkg-buildpackage: info: source package vyos-1x-build-deps
...
Hello build-Cmd
I: Cleaned up build dependency packages

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

github-actions bot commented Jan 10, 2025

👍
No issues in PR Title / Commit Title

@github-actions github-actions bot added the current VyOS rolling release label Jan 10, 2025
Copy link
Contributor

@zdc zdc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to have a list of commands here - most likely in places where the build customization will be required, in many cases one command will be not enough.

@sever-sever
Copy link
Member Author

sever-sever commented Jan 10, 2025

I would prefer to have a list of commands here - most likely in places where the build customization will be required, in many cases one command will be not enough.

It works for several commands like this

pre_build_hook = """
mkdir -p ../AA/BB
mkdir -p ../BB
cp example.txt ../BB/
"""

The pre_build_hook is an optional configuration defined in packages.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.
@sever-sever sever-sever changed the title T7037: Add prebuild command for the package-build T7037: Add prebuild hook for the package-build Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
current VyOS rolling release
Development

Successfully merging this pull request may close these issues.

3 participants