poudriere hooks

zi0r suggested I use hooks to accomplish my patches-outside-distfiles question.

In this post:

  • FreeBSD 12.0
  • poudriere 3.3.2

I started reading the documentation and played with the supplied sample files in /usr/local/etc/poudriere.d/hooks.

For background, see FreeBSD custom port patches when using poudriere.

Eventually I came up with this solution:

  1. mkdir during the start phase
  2. mount during the mount phase

I put stuff into a gist first, then created this post.

The hook

This is /usr/local/etc/poudriere.d/hooks/jail.sh:

#!/bin/sh
# /usr/local/etc/poudriere.d/hooks/jail.sh

status="$1"

# NOTE: mount is invoked before start: re https://github.com/freebsd/poudriere/wiki/hooks
if [ "$status" = "mount" ]; then
  mntpath="$2"

  # The local-patches directory is created only if it does not already exist.
  # If it does not already exist, it means we are doing this on the master jail
  if [ ! -d "${mntpath}/local-patches" ]; then
    /bin/mkdir "${mntpath}/local-patches"
  fi

  # mount our patches to that location
  /sbin/mount -t nullfs /usr/local/etc/poudriere.d/local-patches "${mntpath}/local-patches"
fi

exit 0

How is EXTRA_PATCHES used?

/usr/local/etc/poudriere.d/local-patches is a directory I created. I use it like this within /usr/local/etc/poudriere.d/make.conf (or similar .conf file):

.if ${.CURDIR:M*/net-mgmt/nagios}
EXTRA_PATCHES+= /local-patches/webserver/nagios.patch
.endif

.if ${.CURDIR:M*/net-mgmt/nagiosql}
EXTRA_PATCHES+= /local-patches/webserver/patch-functions-NagConfigClass.php
.endif

What’s in that directory?

$ ls -l /usr/local/etc/poudriere.d/local-patches
total 1
drwxr-xr-x  2 root  wheel  4 Aug 10 17:09 webserver

$ ls -l /usr/local/etc/poudriere.d/local-patches/webserver/
total 9
-rw-r--r--  1 root  wheel  3678 Nov 26  2017 nagios.patch
-rw-r--r--  1 root  wheel   715 Aug  9 10:39 patch-functions-NagConfigClass.php
Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive

Leave a Comment

Scroll to Top