Skip to content

Instantly share code, notes, and snippets.

@memreflect
Created May 10, 2020 20:14
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 memreflect/5229c63060bbbbd59bd2edc4561c74b0 to your computer and use it in GitHub Desktop.
Save memreflect/5229c63060bbbbd59bd2edc4561c74b0 to your computer and use it in GitHub Desktop.
Install devel/ncurses into a Poudriere jail, so ports can be built against it
# Path to packages/xxx/All
PKGS=/usr/local/poudriere/data/packages/12amd64/All
# Name of ZFS pool containing Poudriere jail
ZPOOL=zpool
# Path to jail, without ZPOOL/ prefix
JAIL=poudriere/jails/12amd64
#
# End of customizable variables
#
ZJAIL=$ZPOOL/$JAIL
# Removes the temporary package directory in the jail,
# unmounting it first if necessary.
cleanup() {
if test -n "${PKGDIR}"; then
if test -f "${PKGDIR}"/pkg-*
then umount "${PKGDIR}"
fi
rmdir "${PKGDIR}"
fi
}
# Create and mount the jail's package directory JPKGDIR
if ! PKGDIR="$(mktemp -q -d /usr/local/$JAIL/packages.XXXXXX)"; then
echo 'failed to create temporary directory' >&2
exit 1
elif ! mount -t nullfs $PKGS $JPKGDIR; then
echo 'could not mount package directory' >&2
cleanup
exit 1
fi
# Rollback to the "clean" snapshot and destroy it afterward
if ! zfs rollback $ZJAIL@clean; then
echo 'rollback to snapshot failed' >&2
cleanup
exit 1
elif ! zfs destroy $ZJAIL@clean; then
echo 'failed to destroy snapshot' >&2
cleanup
exit 1
fi
# Start the jail,
# install ports-mgmt/pkg and devel/ncurses,
# and kill the jail.
if ! jail -n $JAIL -c path=/usr/local/$JAIL persist; then
echo 'unable to start jail' >&2
cleanup
exit 1
fi
pkg -j $JAIL add $PKGDIR/pkg-* $PKGDIR/ncurses-*
jail -r $JAIL
# Re-create the ZFS snapshot, so Poudriere will work.
zfs snap $ZJAIL@clean
cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment