git: e621530321e3 - main - ports-mgmt/pkg-be-plugin: new port

From: Michael Osipov <michaelo_at_FreeBSD.org>
Date: Mon, 28 Sep 2026 09:12:23 UTC
The branch main has been updated by michaelo:

URL: https://cgit.FreeBSD.org/ports/commit/?id=e621530321e30058df691df2d35b7655d15e71ef

commit e621530321e30058df691df2d35b7655d15e71ef
Author:     Sasha Karcz <sasha@starnix.net>
AuthorDate: 2026-09-27 05:53:00 +0000
Commit:     Michael Osipov <michaelo@FreeBSD.org>
CommitDate: 2026-09-28 09:12:11 +0000

    ports-mgmt/pkg-be-plugin: new port
    
    pkg-be-plugin is a pkg(8) plugin that automatically creates a ZFS
    boot environment before each install, upgrade, or deinstall
    transaction. If a transaction leaves the system in a broken state,
    the pre-transaction BE provides a clean rollback point.
    
    The plugin uses libbe(3) directly with no subprocess invocations of
    bectl(8) or zfs(8). Boot environments are pruned automatically based
    on a configurable keep count and minimum age.
    
    Co-authored-by: Michael Osipov <michaelo@FreeBSD.org>
    PR:             295305
---
 ports-mgmt/Makefile                           |  1 +
 ports-mgmt/pkg-be-plugin/Makefile             | 46 +++++++++++++++++++++++++++
 ports-mgmt/pkg-be-plugin/distinfo             |  3 ++
 ports-mgmt/pkg-be-plugin/files/pkg-message.in | 15 +++++++++
 ports-mgmt/pkg-be-plugin/pkg-descr            |  8 +++++
 5 files changed, 73 insertions(+)

diff --git a/ports-mgmt/Makefile b/ports-mgmt/Makefile
index 66f5ca6d7af0..2dea67dfa703 100644
--- a/ports-mgmt/Makefile
+++ b/ports-mgmt/Makefile
@@ -25,6 +25,7 @@
     SUBDIR += pchecker
     SUBDIR += pkg
     SUBDIR += pkg-appstream
+    SUBDIR += pkg-be-plugin
     SUBDIR += pkg-devel
     SUBDIR += pkg-graph
     SUBDIR += pkg-provides
diff --git a/ports-mgmt/pkg-be-plugin/Makefile b/ports-mgmt/pkg-be-plugin/Makefile
new file mode 100644
index 000000000000..18eeb50e150c
--- /dev/null
+++ b/ports-mgmt/pkg-be-plugin/Makefile
@@ -0,0 +1,46 @@
+PORTNAME=	pkg-be-plugin
+DISTVERSION=	1.0.1
+CATEGORIES=	ports-mgmt sysutils
+
+MAINTAINER=	sasha@starnix.net
+COMMENT=	Plugin for pkg(8) to auto-create ZFS boot environments
+WWW=		https://github.com/usenix17/pkg-be-plugin
+
+LICENSE=	BSD2CLAUSE
+LICENSE_FILE=	${WRKSRC}/LICENSE
+
+LIB_DEPENDS=	libpkg.so:ports-mgmt/pkg
+
+USES=		uidfix
+USE_GITHUB=	yes
+GH_ACCOUNT=	usenix17
+
+NO_TEST=	yes
+SUB_FILES=	pkg-message
+
+PLIST_FILES=	lib/pkg/be.so \
+		"@sample etc/pkg/be.conf.sample" \
+		share/man/man8/pkg-be-plugin.8.gz
+PORTDOCS=	README.md RELEASE-NOTES.md
+
+OPTIONS_DEFINE=	DOCS
+
+post-patch:
+	${REINPLACE_CMD} -e 's#/usr/local#${PREFIX}#' ${WRKSRC}/pkg-be-plugin.8
+
+pre-install:
+	@${MKDIR} ${STAGEDIR}${PREFIX}/lib/pkg
+	@${MKDIR} ${STAGEDIR}${PREFIX}/etc/pkg
+	@${MKDIR} ${STAGEDIR}${PREFIX}/share/man/man8
+
+post-install:
+	${INSTALL_DATA} ${WRKSRC}/be.conf \
+		${STAGEDIR}${PREFIX}/etc/pkg/be.conf.sample
+	${STRIP_CMD} ${STAGEDIR}${PREFIX}/lib/pkg/be.so
+
+post-install-DOCS-on:
+	@${MKDIR} ${STAGEDIR}${DOCSDIR}
+	${INSTALL_DATA} ${WRKSRC}/README.md ${STAGEDIR}${DOCSDIR}
+	${INSTALL_DATA} ${WRKSRC}/RELEASE-NOTES.md ${STAGEDIR}${DOCSDIR}
+
+.include <bsd.port.mk>
diff --git a/ports-mgmt/pkg-be-plugin/distinfo b/ports-mgmt/pkg-be-plugin/distinfo
new file mode 100644
index 000000000000..7e738ba02918
--- /dev/null
+++ b/ports-mgmt/pkg-be-plugin/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1790585970
+SHA256 (usenix17-pkg-be-plugin-1.0.1_GH0.tar.gz) = 1582cddbd1f3bce9352d92945722c522ba0b542e86f8df10d6d49dde5d735fa9
+SIZE (usenix17-pkg-be-plugin-1.0.1_GH0.tar.gz) = 33702
diff --git a/ports-mgmt/pkg-be-plugin/files/pkg-message.in b/ports-mgmt/pkg-be-plugin/files/pkg-message.in
new file mode 100644
index 000000000000..ad029f287959
--- /dev/null
+++ b/ports-mgmt/pkg-be-plugin/files/pkg-message.in
@@ -0,0 +1,15 @@
+[
+{ type: install
+  message: <<EOM
+pkg(8) loads only plugins that are explicitly enabled.  To activate
+pkg-be-plugin, add the following line to %%PREFIX%%/etc/pkg.conf:
+
+	PLUGINS [ "be" ];
+
+The plugin works without a configuration file; all keys have built-in
+defaults.  To customize, edit %%PREFIX%%/etc/pkg/be.conf.
+
+See pkg-be-plugin(8) for details.
+EOM
+}
+]
diff --git a/ports-mgmt/pkg-be-plugin/pkg-descr b/ports-mgmt/pkg-be-plugin/pkg-descr
new file mode 100644
index 000000000000..12a696421b47
--- /dev/null
+++ b/ports-mgmt/pkg-be-plugin/pkg-descr
@@ -0,0 +1,8 @@
+pkg-be-plugin is a pkg(8) plugin that automatically creates a ZFS
+boot environment before each install, upgrade, or deinstall
+transaction. If a transaction leaves the system in a broken state,
+the pre-transaction BE provides a clean rollback point.
+
+The plugin uses libbe(3) directly with no subprocess invocations of
+bectl(8) or zfs(8). Boot environments are pruned automatically based
+on a configurable keep count and minimum age.