The branch main has been updated by ivy:

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

commit e64ad2324153dcd77aba0cd42bb8f194b62bb955
Author:     Lexi Winter <i...@freebsd.org>
AuthorDate: 2025-07-07 13:30:13 +0000
Commit:     Lexi Winter <i...@freebsd.org>
CommitDate: 2025-07-15 05:12:44 +0000

    packages: move ucl files to a subdirectory
    
    We want to have a UCL file for every package, to set fields like
    comment, desc, license, etc.; to avoid cluttering release/packages with
    ~200 new files, move these to the ucl/ directory.
    
    Add a better description for the yp package to demonstrate how this will
    work in practice.
    
    Clean up the handling of the package comment suffix for generated
    packages (dev, lib32, etc.) and do the UCL modifications in
    generate-ucl.lua, so we don't overwrite the ucl's comment.
    
    Add a long-form suffix to the description for generated packages to
    explain what they do.
    
    Eventually, we should require the ucl file exists (try=false) to prevent
    people accidentally creating new packages with a typo, but for now, keep
    the ucl optional.
    
    Reviewed by:    kevans, des, bapt, emaste
    Approved by:    kevans (mentor), des (mentor)
    Differential Revision:  https://reviews.freebsd.org/D50160
---
 release/packages/Makefile.package          |  2 -
 release/packages/generate-ucl.lua          | 45 +++++++++++++--
 release/packages/generate-ucl.sh           | 92 ++++++++++++++++++++----------
 release/packages/{ => ucl}/certctl.ucl     |  0
 release/packages/{ => ucl}/clang-all.ucl   |  0
 release/packages/{ => ucl}/clibs.ucl       |  0
 release/packages/{ => ucl}/lld-all.ucl     |  0
 release/packages/{ => ucl}/lldb-all.ucl    |  0
 release/packages/{ => ucl}/runtime.ucl     |  0
 release/packages/{ => ucl}/ssh-all.ucl     |  0
 release/packages/{ => ucl}/unbound-all.ucl |  0
 release/packages/{ => ucl}/utilities.ucl   |  0
 release/packages/ucl/yp-all.ucl            |  7 +++
 13 files changed, 107 insertions(+), 39 deletions(-)

diff --git a/release/packages/Makefile.package 
b/release/packages/Makefile.package
index c2427aa16945..e00efed2af1b 100644
--- a/release/packages/Makefile.package
+++ b/release/packages/Makefile.package
@@ -187,7 +187,5 @@ vt_COMMENT=         VT fonts and keyboard files
 vt_DESC=               VT fonts and keyboard files
 wpa_COMMENT=           802.11 Supplicant
 wpa_DESC=              802.11 Supplicant
-yp_COMMENT=            Yellow Pages programs
-yp_DESC=               Yellow Pages programs
 zfs_COMMENT=           ZFS Libraries and Utilities
 zfs_DESC=              ZFS Libraries and Utilities
diff --git a/release/packages/generate-ucl.lua 
b/release/packages/generate-ucl.lua
index ae6ee58dd84a..0d18e1dc0120 100755
--- a/release/packages/generate-ucl.lua
+++ b/release/packages/generate-ucl.lua
@@ -3,33 +3,66 @@
 --[[ usage:
 generare-ucl.lua [<variablename> <variablevalue>]... <sourceucl> <destucl>
 
-In the <destucl> files the variable <variablename> (in the form ${variablename}
-in the <sourceucl>) will be expanded to <variablevalue>.
+Build a package's UCL configuration by loading the template UCL file
+<sourceucl>, replacing any $VARIABLES in the UCL based on the provided
+variables, then writing the result to <destucl>.
 
-The undefined variables will reamin unmofifier "${variablename}"
+If COMMENT_SUFFIX or DESC_SUFFIX are set, append these to the generated comment
+and desc fields.  We do this here because there's no way to do it in
+template.ucl.
 ]]--
 
 local ucl = require("ucl")
 
+local comment_suffix = nil
+local desc_suffix = nil
+
+-- This parser is the output UCL we want to build.
+local parser = ucl.parser()
+
+-- Set any $VARIABLES from the command line in the parser.  This causes ucl to
+-- automatically replace them when we load the source ucl.
 if #arg < 2 or #arg % 2 ~= 0 then
        io.stderr:write(arg[0] .. ": expected an even number of arguments, got 
" .. #arg)
        os.exit(1)
 end
 
-local parser = ucl.parser()
 for i = 2, #arg - 2, 2 do
-       parser:register_variable(arg[i - 1], arg[i])
+       local varname = arg[i - 1]
+       local varvalue = arg[i]
+
+       if varname == "COMMENT_SUFFIX" and #varvalue > 0 then
+               comment_suffix = varvalue
+       elseif varname == "DESC_SUFFIX" and #varvalue > 0 then
+               desc_suffix = varvalue
+       end
+
+       parser:register_variable(varname, varvalue)
 end
+
+-- Load the source ucl file.
 local res,err = parser:parse_file(arg[#arg - 1])
 if not res then
        io.stderr:write(arg[0] .. ": fail to parse("..arg[#arg - 1].."): "..err)
        os.exit(1)
 end
+
+local obj = parser:get_object()
+
+-- Add comment and desc suffix.
+if comment_suffix ~= nil then
+       obj["comment"] = obj["comment"] .. comment_suffix
+end
+if desc_suffix ~= nil then
+       obj["desc"] = obj["desc"] .. "\n\n" .. desc_suffix
+end
+
+-- Write the output file.
 local f,err = io.open(arg[#arg], "w")
 if not f then
        io.stderr:write(arg[0] .. ": fail to open("..arg[#arg].."): ".. err)
        os.exit(1)
 end
-local obj = parser:get_object()
+
 f:write(ucl.to_format(obj, 'ucl', true))
 f:close()
diff --git a/release/packages/generate-ucl.sh b/release/packages/generate-ucl.sh
index b7d7bad35023..4dac34cd4753 100755
--- a/release/packages/generate-ucl.sh
+++ b/release/packages/generate-ucl.sh
@@ -2,9 +2,35 @@
 #
 #
 
+mancx=" (manual pages)"
+mandx="This package contains the online manual pages."
+
+lib32cx=" (32-bit libraries)"
+lib32dx="This package contains 32-bit libraries for running 32-bit 
applications on
+a 64-bit host."
+
+devcx=" (development files)"
+devdx="This package contains development files for compiling applications."
+
+dev32cx=" (32-bit development files)"
+dev32dx="This package contains development files for compiling 32-bit 
applications
+on a 64-bit host."
+
+dbgcx=" (debugging symbols)"
+dbgdx="This package contains external debugging symbols for use with a 
source-level
+debugger."
+
+dbg32cx=" (32-bit debugging symbols)"
+dbg32dx="This package contains 32-bit external debugging symbols for use with a
+source-level debugger."
+
 main() {
+       outname=""
+       origname=""
        desc=
+       desc_suffix=""
        comment=
+       comment_suffix=""
        debug=
        uclsource=
        while getopts "do:s:u:" arg; do
@@ -52,51 +78,53 @@ main() {
                # as a dependency.
                libcompat-dev|libcompiler_rt-dev|liby-dev)
                        outname=${outname%%-dev}
-                       _descr="Development Files"
+                       comment_suffix="$devcx"
+                       desc_suffix="$devdx"
                        ;;
-               libcompat-lib32_dev|libcompiler_rt-lib32_dev|liby-lib32_dev)
-                       outname=${outname%%-lib32_dev}
-                       _descr="32-bit Libraries, Development Files"
+               libcompat-dev-lib32|libcompiler_rt-dev-lib32|liby-dev-lib32)
+                       outname=${outname%%-dev-lib32}
+                       comment_suffix="$dev32cx"
+                       desc_suffix="$dev32dx"
                        ;;
                libcompat-man|libelftc-man)
                        outname=${outname%%-man}
-                       _descr="Manual Pages"
-                       ;;
-               utilities)
-                       uclfile="${uclfile}"
-                       ;;
-               runtime)
-                       outname="runtime"
-                       _descr="$(make -C ${srctree}/release/packages -f 
Makefile.package -V ${outname}_DESCR)"
+                       comment_suffix="$mancx"
+                       desc_suffix="$mandx"
                        ;;
-               *-lib32_dev)
-                       outname="${outname%%-lib32_dev}"
-                       _descr="32-bit Libraries, Development Files"
+               *-dev)
+                       outname="${outname%%-dev}"
+                       comment_suffix="$devcx"
+                       desc_suffix="$devdx"
                        pkgdeps="${outname}"
                        ;;
-               *-lib32_dbg)
-                       outname="${outname%%-lib32_dbg}"
-                       _descr="32-bit Libraries, Debugging Symbols"
+               *-dbg)
+                       outname="${outname%%-dbg}"
+                       comment_suffix="$dbgcx"
+                       desc_suffix="$dbgdx"
                        pkgdeps="${outname}"
                        ;;
-               *-lib32)
-                       outname="${outname%%-lib32}"
-                       _descr="32-bit Libraries"
+               *-dev-lib32)
+                       outname="${outname%%-dev-lib32}"
+                       comment_suffix="$dev32cx"
+                       desc_suffix="$dev32dx"
                        pkgdeps="${outname}"
                        ;;
-               *-dev)
-                       outname="${outname%%-dev}"
-                       _descr="Development Files"
+               *-dbg-lib32)
+                       outname="${outname%%-dbg-lib32}"
+                       comment_suffix="$dbg32cx"
+                       desc_suffix="$dbg32dx"
                        pkgdeps="${outname}"
                        ;;
-               *-dbg)
-                       outname="${outname%%-dbg}"
-                       _descr="Debugging Symbols"
+               *-lib32)
+                       outname="${outname%%-lib32}"
+                       comment_suffix="$lib32cx"
+                       desc_suffix="$lib32dx"
                        pkgdeps="${outname}"
                        ;;
                *-man)
                        outname="${outname%%-man}"
-                       _descr="Manual Pages"
+                       comment_suffix="$mancx"
+                       desc_suffix="$mandx"
                        pkgdeps="${outname}"
                        ;;
                ${origname})
@@ -116,13 +144,14 @@ main() {
                echo ""
                echo 
"==============================================================="
                echo "DEBUG:"
-               echo "_descr=${_descr}"
                echo "outname=${outname}"
                echo "origname=${origname}"
                echo "srctree=${srctree}"
                echo "uclfile=${uclfile}"
                echo "desc=${desc}"
+               echo "desc_suffix=${desc_suffix}"
                echo "comment=${comment}"
+               echo "comment_suffix=${comment_suffix}"
                echo "vital=${vital}"
                echo "cp ${uclsource} -> ${uclfile}"
                echo 
"==============================================================="
@@ -132,7 +161,6 @@ main() {
        fi
 
        [ -z "${comment}" ] && comment="${outname} package"
-       [ -n "${_descr}" ] && comment="${comment} (${_descr})"
        [ -z "${desc}" ] && desc="${outname} package"
 
        cp "${uclsource}" "${uclfile}"
@@ -155,11 +183,13 @@ EOF
                PKGGENNAME "${outname}" \
                PKG_NAME_PREFIX "${PKG_NAME_PREFIX}" \
                COMMENT "${comment}" \
+               COMMENT_SUFFIX "${comment_suffix}" \
                DESC "${desc}" \
+               DESC_SUFFIX "$desc_suffix" \
                CAP_MKDB_ENDIAN "${cap_arg}" \
                PKG_WWW "${PKG_WWW}" \
                PKG_MAINTAINER "${PKG_MAINTAINER}" \
-               UCLFILES "${srctree}/release/packages/" \
+               UCLFILES "${srctree}/release/packages/ucl" \
                ${uclfile} ${uclfile}
 
        return 0
diff --git a/release/packages/certctl.ucl b/release/packages/ucl/certctl.ucl
similarity index 100%
rename from release/packages/certctl.ucl
rename to release/packages/ucl/certctl.ucl
diff --git a/release/packages/clang-all.ucl b/release/packages/ucl/clang-all.ucl
similarity index 100%
rename from release/packages/clang-all.ucl
rename to release/packages/ucl/clang-all.ucl
diff --git a/release/packages/clibs.ucl b/release/packages/ucl/clibs.ucl
similarity index 100%
rename from release/packages/clibs.ucl
rename to release/packages/ucl/clibs.ucl
diff --git a/release/packages/lld-all.ucl b/release/packages/ucl/lld-all.ucl
similarity index 100%
rename from release/packages/lld-all.ucl
rename to release/packages/ucl/lld-all.ucl
diff --git a/release/packages/lldb-all.ucl b/release/packages/ucl/lldb-all.ucl
similarity index 100%
rename from release/packages/lldb-all.ucl
rename to release/packages/ucl/lldb-all.ucl
diff --git a/release/packages/runtime.ucl b/release/packages/ucl/runtime.ucl
similarity index 100%
rename from release/packages/runtime.ucl
rename to release/packages/ucl/runtime.ucl
diff --git a/release/packages/ssh-all.ucl b/release/packages/ucl/ssh-all.ucl
similarity index 100%
rename from release/packages/ssh-all.ucl
rename to release/packages/ucl/ssh-all.ucl
diff --git a/release/packages/unbound-all.ucl 
b/release/packages/ucl/unbound-all.ucl
similarity index 100%
rename from release/packages/unbound-all.ucl
rename to release/packages/ucl/unbound-all.ucl
diff --git a/release/packages/utilities.ucl b/release/packages/ucl/utilities.ucl
similarity index 100%
rename from release/packages/utilities.ucl
rename to release/packages/ucl/utilities.ucl
diff --git a/release/packages/ucl/yp-all.ucl b/release/packages/ucl/yp-all.ucl
new file mode 100644
index 000000000000..9e17cd108d84
--- /dev/null
+++ b/release/packages/ucl/yp-all.ucl
@@ -0,0 +1,7 @@
+comment = "Yellow Pages (YP) / Network Information Service (NIS)"
+desc = <<EOD
+YP, also called NIS, is a network protocol for sharing name service
+information across machines on a network.  This packages contains the YP
+server, YP management utilities, the YP-LDAP gateway (ypldap), YP client
+utilities and a sample Makefile for building the YP database.
+EOD

Reply via email to