git: 957875ebcf3d - stable/15 - packages: Add a mandoc package

From: Lexi Winter <ivy_at_FreeBSD.org>
Date: Fri, 19 Sep 2025 01:20:03 UTC
The branch stable/15 has been updated by ivy:

URL: https://cgit.FreeBSD.org/src/commit/?id=957875ebcf3de9e6def0026facb77bdae0cb08b9

commit 957875ebcf3de9e6def0026facb77bdae0cb08b9
Author:     Lexi Winter <ivy@FreeBSD.org>
AuthorDate: 2025-09-18 09:14:45 +0000
Commit:     Lexi Winter <ivy@FreeBSD.org>
CommitDate: 2025-09-19 01:18:41 +0000

    packages: Add a mandoc package
    
    Move mandoc to its own package so users can install it independently of
    -utilities.  Put the package in the minimal set, since we also ship
    manpages in minimal and "man" is a basic Unix utility.
    
    Add a pkg-triggers(5) hook to run makewhatis when new manpages are
    installed, so that apropos(1) works.  This depends on a new pkg(8)
    feature expected to be in in the upcoming 2.3.2 release; in the mean
    time, this is a no-op (i.e., having an older pkg doesn't break anything,
    it just won't run the trigger).
    
    MFC after:      3 seconds
    Reviewed by:    bapt
    Differential Revision:  https://reviews.freebsd.org/D52564
    
    (cherry picked from commit ea5e50c2985bea029e7b30ecee773a59fe22cd68)
---
 UPDATING                            |  5 +++++
 release/packages/ucl/mandoc-all.ucl | 11 +++++++++++
 usr.bin/man/Makefile                |  2 ++
 usr.bin/mandoc/Makefile             |  6 ++++++
 usr.bin/mandoc/mandoc.ucl           | 18 ++++++++++++++++++
 5 files changed, 42 insertions(+)

diff --git a/UPDATING b/UPDATING
index 6756e1ebb936..c58e9afbbcca 100644
--- a/UPDATING
+++ b/UPDATING
@@ -18,6 +18,11 @@ and/or ports.
 	be shipped in the packages they belong to.  If you want to continue
 	building split man packages, set WITH_MANSPLITPKG=1.
 
+20250918:
+	mandoc (including /usr/bin/man) has been moved to a new package,
+	FreeBSD-mandoc.  If you have the minimal set installed, this package
+	will be installed automatically, otherwise you may want to install it.
+
 20250918:
 	Kyua has been moved to the FreeBSD-kyua package, and ATF has been moved
 	to the FreeBSD-atf* packages.  If you have FreeBSD-tests installed,
diff --git a/release/packages/ucl/mandoc-all.ucl b/release/packages/ucl/mandoc-all.ucl
new file mode 100644
index 000000000000..9c43e9f7a46c
--- /dev/null
+++ b/release/packages/ucl/mandoc-all.ucl
@@ -0,0 +1,11 @@
+comment = "Online manual page reader"
+
+desc = <<EOD
+This packages provides man(1), a utility which can format and display system
+manual pages, along with the related utilities apropos(1) and makewhatis(8),
+and the mandoc(1) backend.
+EOD
+
+annotations {
+	set = minimal
+}
diff --git a/usr.bin/man/Makefile b/usr.bin/man/Makefile
index 9c9098270735..9e47006cac0a 100644
--- a/usr.bin/man/Makefile
+++ b/usr.bin/man/Makefile
@@ -1,3 +1,5 @@
+PACKAGE=	mandoc
+
 SCRIPTS= man.sh
 LINKS=	${BINDIR}/man ${BINDIR}/manpath
 
diff --git a/usr.bin/mandoc/Makefile b/usr.bin/mandoc/Makefile
index 0d04aad4e558..2c7c3ed85040 100644
--- a/usr.bin/mandoc/Makefile
+++ b/usr.bin/mandoc/Makefile
@@ -3,6 +3,8 @@
 MANDOCDIR=	${SRCTOP}/contrib/mandoc
 .PATH: ${MANDOCDIR}
 
+PACKAGE=	mandoc
+
 PROG=	mandoc
 MAN=	mandoc.1 mandoc.db.5 eqn.7 mandoc_char.7 tbl.7 man.7 mdoc.7 roff.7
 MLINKS=	mandoc.1 mdocml.1
@@ -16,6 +18,10 @@ LINKS=	${BINDIR}/mandoc ${BINDIR}/whatis \
 .error MK_MAN_UTILS should be set to yes when bootstrapping
 .endif
 
+FILESGROUPS=	TRIGGERS
+TRIGGERS=	mandoc.ucl
+TRIGGERSDIR=	/usr/share/pkg/triggers
+
 LIBMAN_SRCS=	man.c \
 		man_macro.c \
 		man_validate.c
diff --git a/usr.bin/mandoc/mandoc.ucl b/usr.bin/mandoc/mandoc.ucl
new file mode 100644
index 000000000000..f320b6f547fd
--- /dev/null
+++ b/usr.bin/mandoc/mandoc.ucl
@@ -0,0 +1,18 @@
+path_glob: "/usr/share/man/*"
+
+cleanup: {
+	type: lua
+	sandbox: false
+	script: <<EOD
+	os.remove("/usr/share/man/mandoc.db")
+EOD
+}
+
+trigger: {
+	type: lua
+	sandbox: false
+	script: <<EOD
+	print("Generating apropos(1) database...")
+	pkg.exec({"/usr/bin/makewhatis", "/usr/share/man"})
+EOD
+}