jmmv / pkg_comp

Automates the build of pkgsrc binary packages in a sandbox
BSD 3-Clause "New" or "Revised" License
15 stars 3 forks source link

Add hook support for post_build_hook routine #14

Open jlmuir opened 7 years ago

jlmuir commented 7 years ago

Add hook support for a post_build_hook routine that is executed right after packages have been built by the pkg_comp build subcommand.

This enables me to, for example, define a post_build_hook function in /usr/local/etc/pkg_comp/default.conf to preserve the pbulk log outside of the sandbox after the build finishes but before the sandbox gets destroyed:

post_build_hook() {
  local logdir bulklog sandbox_bulklog
  logdir=/var/pkg_comp/log
  bulklog=$logdir/bulklog
  sandbox_bulklog=/var/pkg_comp/sandbox/pkg_comp/work/bulklog
  [ ! -e "$sandbox_bulklog" ] && return
  if [ -e "$bulklog" ]; then
    rm -rf "$bulklog.old"
    mv "$bulklog" "$bulklog.old"
  fi
  mkdir -p "$logdir"
  cp -rp "$sandbox_bulklog" "$bulklog"
}