Skip to content

Instantly share code, notes, and snippets.

@dlangille
Last active October 17, 2021 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlangille/924507ce545de8fbbe78b50b752997ce to your computer and use it in GitHub Desktop.
Save dlangille/924507ce545de8fbbe78b50b752997ce to your computer and use it in GitHub Desktop.
Hook for nullfs mounting an extra patches directory in the master jail - see https://dan.langille.org/2019/08/10/poudriere-hooks/
#!/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" ] && [ -d /usr/local/etc/poudriere.d/local-patches ]; 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 -o ro /usr/local/etc/poudriere.d/local-patches "${mntpath}/local-patches"
fi
exit 0
The jail.sh hook can be used on conjunction with an entry in
/usr/local/etc/poudriere.d/make.conf (or similar) such as this
.if ${.CURDIR:M*/net-mgmt/nagios}
EXTRA_PATCHES+= /local-patches/webserver/nagios.patch
.endif
@dlangille
Copy link
Author

This approach was created 2 years ago, before I'd heard of poudriere overlays.

I looked at overlay and could not figure out how to get it work.

Do you see any advantages?

@jlduran
Copy link

jlduran commented Oct 17, 2021

Do you see any advantages?

I see an advantage with this hook, it is closer to having a unionfs-mounted overlay (instead of the current nullfs-mounted one). I have not tested exhaustively, but from my initial tests, you would need to have all the port files + patches, instead of just the diff from the ports tree (local patches).

I looked at overlay and could not figure out how to get it work.

Here is my sample repo: https://github.com/jlduran/test-poudriere-overlay. It basically uses the category/port directory from the overlay instead of the default one. If you're using git, this approach might be a bit excessive for my needs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment