paru icon indicating copy to clipboard operation
paru copied to clipboard

add PostBuildCommand

Open romanstingler opened this issue 1 year ago • 1 comments

I have implemented the post-build command feature. Here's what I did:

  1. Added post-build command parsing in command_line.rs:

    • Added handling for the --post-build-command argument
    • The argument requires a value which will be stored in config.post_build_command
  2. Created a post_build_command function in install.rs:

    • Similar to pre_build_command, it executes a shell command after successful package build
    • The command has access to PKGBASE and VERSION environment variables
    • The command runs in the package build directory
  3. Added post-build command execution in install.rs:

    • Called post_build_command after a successful package build
    • Only executes if a post-build command is configured
  4. Added post-build command config in config.rs:

    • Added PostBuildCommand option to the config file parser
    • The command can be specified in the config file under the [bin] section

Users can specify a post-build command in these ways:

  1. Via command line: paru --post-build-command "your-command"
  2. OR Via config file:
[bin]
PostBuildCommand = your-command

The command will receive:

  • Current working directory set to the package build directory
  • PKGBASE: The base package name
  • VERSION: The package version

Tested with cargo run -- -S vim-git --post-build-command "/tmp/code/paru/test.sh" and paru.conf

#
# Binary OPTIONS
#
[bin]
PostBuildCommand = "/tmp/code/paru/test.sh"

closes #1300

Waiting for feedback where to place post_build_command(config, dir, base.package_base(), &version)?;

romanstingler avatar Dec 16 '24 23:12 romanstingler

This is useful feature. I noticed that manpage is missing, see https://github.com/Morganamilo/paru/pull/539 for reference.

chovanecadam avatar Feb 06 '25 13:02 chovanecadam