git: 099bd9e6ab8f - stable/14 - pkgbase: rework certctl package to only run rehash on the main package
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 27 Mar 2024 08:35:41 UTC
The branch stable/14 has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=099bd9e6ab8fd563587ccff84f33349a193f208e commit 099bd9e6ab8fd563587ccff84f33349a193f208e Author: Baptiste Daroussin <bapt@FreeBSD.org> AuthorDate: 2024-01-31 12:42:16 +0000 Commit: Baptiste Daroussin <bapt@FreeBSD.org> CommitDate: 2024-03-27 08:31:47 +0000 pkgbase: rework certctl package to only run rehash on the main package Rework how ucl manifest are generated leveraging ucl features and flua now the ucl generation is done via a lua script which uses libucl to ingest the template and use variables as defined in its command line. the template will include only if it exist a ucl file named after the package name which will complement the template or overwrite what was defined in the template if defined in this specific ucl file this allows to overwrite license, but add script only to the packages who actually needs them. As a results the post install scripts are now only added to the right package and not also added to the subpackages like -man or -dev Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D44374 (cherry picked from commit f8e46fd61e055fcc767c2038d867f58c38e43ec3) --- Makefile.inc1 | 60 +++++++++++++++++++++------------------ release/packages/certctl.ucl | 16 ----------- release/packages/clang-all.ucl | 1 + release/packages/clang.ucl | 17 ----------- release/packages/clibs.ucl | 1 + release/packages/generate-ucl.lua | 35 +++++++++++++++++++++++ release/packages/generate-ucl.sh | 36 +++++++++-------------- release/packages/jail.ucl | 18 ------------ release/packages/kernel.ucl | 18 +----------- release/packages/lld-all.ucl | 1 + release/packages/lld.ucl | 17 ----------- release/packages/lldb-all.ucl | 1 + release/packages/lldb.ucl | 17 ----------- release/packages/runtime.ucl | 26 ++++------------- release/packages/src-sys.ucl | 17 ----------- release/packages/src.ucl | 17 ----------- release/packages/ssh-all.ucl | 1 + release/packages/ssh.ucl | 17 ----------- release/packages/template.ucl | 15 +++++----- release/packages/unbound-all.ucl | 1 + release/packages/unbound.ucl | 17 ----------- release/packages/utilities.ucl | 21 ++------------ 22 files changed, 104 insertions(+), 266 deletions(-) diff --git a/Makefile.inc1 b/Makefile.inc1 index 2c3d96360129..0cf5bc1dec6e 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -2098,22 +2098,28 @@ create-source-packages: _pkgbootstrap .PHONY ( echo "@override_prefix /usr/src" ; \ ${GIT_CMD} ls-files --recurse-submodules "sys/" ) \ > ${SSTAGEDIR}/src-sys.plist - sed -e "s/%VERSION%/${PKG_VERSION}/" \ - -e "s/%DESC%/FreeBSD sources/" \ - -e "s/ %VCS_REVISION%/${VCS_REVISION}/" \ - -e "s/%PKG_NAME_PREFIX%/${PKG_NAME_PREFIX}/" \ - -e "s/%PKG_MAINTAINER%/${PKG_MAINTAINER}/" \ - -e "s|%PKG_WWW%|${PKG_WWW}|" \ - ${SRCDIR}/release/packages/src.ucl \ - > ${SSTAGEDIR}/src.ucl - sed -e "s/%VERSION%/${PKG_VERSION}/" \ - -e "s/%DESC%/FreeBSD Kernel sources/" \ - -e "s/ %VCS_REVISION%/${VCS_REVISION}/" \ - -e "s/%PKG_NAME_PREFIX%/${PKG_NAME_PREFIX}/" \ - -e "s/%PKG_MAINTAINER%/${PKG_MAINTAINER}/" \ - -e "s|%PKG_WWW%|${PKG_WWW}|" \ - ${SRCDIR}/release/packages/src-sys.ucl \ - > ${SSTAGEDIR}/src-sys.ucl + ${SRCDIR}/release/packages/generate-ucl.lua \ + PKGNAME "src" \ + PKGGENNAME "src" \ + VERSION "${PKG_VERSION}" \ + DESC "FreeBSD Kernel Sources" \ + COMMENT "FreeBSD Userland Sources" \ + PKG_NAME_PREFIX "${PKG_NAME_PREFIX}" \ + PKG_MAINTAINER "${PKG_MAINTAINER}" \ + PKG_WWW "${PKG_WWW}" \ + ${SRCDIR}/release/packages/template.ucl \ + ${SSTAGEDIR}/src.ucl + ${SRCDIR}/release/packages/generate-ucl.lua \ + PKGNAME "src-sys" \ + PKGGENNAME "src" \ + VERSION "${PKG_VERSION}" \ + DESC "FreeBSD Kernel Sources" \ + COMMENT "FreeBSD Kernel Sources" \ + PKG_NAME_PREFIX "${PKG_NAME_PREFIX}" \ + PKG_MAINTAINER "${PKG_MAINTAINER}" \ + PKG_WWW "${PKG_WWW}" \ + ${SRCDIR}/release/packages/template.ucl \ + ${SSTAGEDIR}/src-sys.ucl ${PKG_CMD} -o ABI=${PKG_ABI} \ -o OSVERSION="${SRCRELDATE}" \ create -f ${PKG_FORMAT} \ @@ -2183,17 +2189,17 @@ create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}: _pkgbootstrap ${METALOG_SORT_CMD} ${KSTAGEDIR}/kernel.meta | \ awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \ -v kernel=yes -v _kernconf=${INSTALLKERNEL} ; \ - sed -e "s/%VERSION%/${PKG_VERSION}/" \ - -e "s/%PKGNAME%/kernel-${INSTALLKERNEL:tl}${flavor}/" \ - -e "s/%KERNELDIR%/kernel/" \ - -e "s/%COMMENT%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \ - -e "s/%DESC%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \ - -e "s/ %VCS_REVISION%/${VCS_REVISION}/" \ - -e "s/%PKG_NAME_PREFIX%/${PKG_NAME_PREFIX}/" \ - -e "s/%PKG_MAINTAINER%/${PKG_MAINTAINER}/" \ - -e "s|%PKG_WWW%|${PKG_WWW}|" \ - ${SRCDIR}/release/packages/kernel.ucl \ - > ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \ + ${SRCDIR}/release/packages/generate-ucl.lua \ + PKGNAME "kernel-${INSTALLKERNEL:tl}${flavor}" \ + VERSION "${PKG_VERSION}" \ + KERNELDIR "kernel" \ + COMMENT "FreeBSD ${INSTALLKERNEL} kernel ${flavor}" \ + DESC "FreeBSD ${INSTALLKERNEL} kernel ${flavor}" \ + PKG_NAME_PREFIX "${PKG_NAME_PREFIX}" \ + PKG_MAINTAINER "${PKG_MAINTAINER}" \ + PKG_WWW "${PKG_WWW}" \ + ${SRCDIR}/release/packages/template.ucl \ + ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \ awk -F\" ' \ /name/ { printf("===> Creating %s-", $$2); next } \ /version/ {print $$2; next } ' \ diff --git a/release/packages/certctl.ucl b/release/packages/certctl.ucl index f6dbb012ce64..664a6d139585 100644 --- a/release/packages/certctl.ucl +++ b/release/packages/certctl.ucl @@ -1,19 +1,3 @@ -# -# - -name = "%PKG_NAME_PREFIX%-%PKGNAME%" -origin = "base" -version = "%VERSION%" -comment = "%COMMENT%" -categories = [ base ] -maintainer = %PKG_MAINTAINER% -www = "%PKG_WWW%" -prefix = "/" -licenselogic = "single" -licenses = [ BSD2CLAUSE ] -desc = <<EOD -%DESC% -EOD scripts: { # XXX If pkg picks up a mechanism to detect in the post-install script # files being added or removed, we should use it instead to gate the diff --git a/release/packages/clang-all.ucl b/release/packages/clang-all.ucl new file mode 100644 index 000000000000..41a697ebe53d --- /dev/null +++ b/release/packages/clang-all.ucl @@ -0,0 +1 @@ +licenses = [ NCSA ] diff --git a/release/packages/clang.ucl b/release/packages/clang.ucl deleted file mode 100644 index 9c164bc18f01..000000000000 --- a/release/packages/clang.ucl +++ /dev/null @@ -1,17 +0,0 @@ -# -# - -name = "%PKG_NAME_PREFIX%-%PKGNAME%" -origin = "base" -version = "%VERSION%" -comment = "%COMMENT%" -categories = [ base ] -maintainer = "%PKG_MAINTAINER%" -www = "%PKG_WWW%" -prefix = "/" -licenselogic = "single" -licenses = [ NCSA ] -desc = <<EOD -%DESC% -EOD - diff --git a/release/packages/clibs.ucl b/release/packages/clibs.ucl new file mode 100644 index 000000000000..093fbb60248a --- /dev/null +++ b/release/packages/clibs.ucl @@ -0,0 +1 @@ +vital: true diff --git a/release/packages/generate-ucl.lua b/release/packages/generate-ucl.lua new file mode 100755 index 000000000000..de52802913f8 --- /dev/null +++ b/release/packages/generate-ucl.lua @@ -0,0 +1,35 @@ +#!/usr/libexec/flua + +--[[ 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>. + +The undefined variables will reamin unmofifier "${variablename}" +]]-- + +local ucl = require("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]) +end +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 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')) +f:close() diff --git a/release/packages/generate-ucl.sh b/release/packages/generate-ucl.sh index e5563c51a4cd..c7147a97a868 100755 --- a/release/packages/generate-ucl.sh +++ b/release/packages/generate-ucl.sh @@ -30,17 +30,10 @@ main() { shift $(( ${OPTIND} - 1 )) - vital="false" - case "${outname}" in bootloader) pkgdeps="" ;; - clibs) - vital="true" - # clibs should not have any dependencies or anything - # else imposed on it. - ;; certctl) pkgdeps="caroot openssl" ;; @@ -68,7 +61,6 @@ main() { runtime) outname="runtime" _descr="$(make -C ${srctree}/release/packages -f Makefile.package -V ${outname}_DESCR)" - vital="true" ;; *-lib32_dev) outname="${outname%%-lib32_dev}" @@ -111,10 +103,7 @@ main() { desc="$(make -C ${srctree}/release/packages -f Makefile.package -V ${outname}_DESC)" comment="$(make -C ${srctree}/release/packages -f Makefile.package -V ${outname}_COMMENT)" - uclsource="${srctree}/release/packages/${outname}.ucl" - if [ ! -e "${uclsource}" ]; then - uclsource="${srctree}/release/packages/template.ucl" - fi + uclsource="${srctree}/release/packages/template.ucl" if [ ! -z "${debug}" ]; then echo "" @@ -153,16 +142,19 @@ EOF echo '}' >> ${uclfile} fi cap_arg="$( make -f ${srctree}/share/mk/bsd.endian.mk -VCAP_MKDB_ENDIAN )" - sed -i '' -e "s/%VERSION%/${PKG_VERSION}/" \ - -e "s/%PKGNAME%/${origname}/" \ - -e "s/%COMMENT%/${comment}/" \ - -e "s/%DESC%/${desc}/" \ - -e "s/%VITAL%/${vital}/" \ - -e "s/%CAP_MKDB_ENDIAN%/${cap_arg}/g" \ - -e "s/%PKG_NAME_PREFIX%/${PKG_NAME_PREFIX}/" \ - -e "s|%PKG_WWW%|${PKG_WWW}|" \ - -e "s/%PKG_MAINTAINER%/${PKG_MAINTAINER}/" \ - ${uclfile} + ${srctree}/release/packages/generate-ucl.lua \ + VERSION "${PKG_VERSION}" \ + PKGNAME "${origname}" \ + PKGGENNAME "${outname}" \ + PKG_NAME_PREFIX "${PKG_NAME_PREFIX}" \ + COMMENT "${comment}" \ + DESC "${desc}" \ + CAP_MKDB_ENDIAN "${cap_arg}" \ + PKG_WWW "${PKG_WWW}" \ + PKG_MAINTAINER "${PKG_MAINTAINER}" \ + UCLFILES "${srctree}/release/packages/" \ + ${uclsource} ${uclfile} + return 0 } diff --git a/release/packages/jail.ucl b/release/packages/jail.ucl deleted file mode 100644 index bc137f009db9..000000000000 --- a/release/packages/jail.ucl +++ /dev/null @@ -1,18 +0,0 @@ -# -# - -name = "%PKG_NAME_PREFIX%-%PKGNAME%" -origin = "base" -version = "%VERSION%" -comment = "%COMMENT%" -categories = [ base ] -maintainer = "%PKG_MAINTAINER%" -www = "%PKG_WWW%" -prefix = "/" -vital = %VITAL% -licenselogic = "single" -licenses = [ BSD2CLAUSE ] -desc = <<EOD -%DESC% -EOD - diff --git a/release/packages/kernel.ucl b/release/packages/kernel.ucl index 799ad046591f..28a360f986a9 100644 --- a/release/packages/kernel.ucl +++ b/release/packages/kernel.ucl @@ -1,21 +1,5 @@ -# -# - -name = "%PKG_NAME_PREFIX%-%PKGNAME%" -origin = "base" -version = "%VERSION%" -comment = "%COMMENT%" -categories = [ base ] -maintainer = "%PKG_MAINTAINER%" -www = "%PKG_WWW%" -prefix = "/" -licenselogic = "single" -licenses = [ BSD2CLAUSE ] -desc = <<EOD -%DESC% -EOD scripts: { post-install = <<EOD - /usr/sbin/kldxref ${PKG_ROOTDIR}/boot/%KERNELDIR% + /usr/sbin/kldxref ${PKG_ROOTDIR}/boot/${KERNELDIR} EOD } diff --git a/release/packages/lld-all.ucl b/release/packages/lld-all.ucl new file mode 100644 index 000000000000..41a697ebe53d --- /dev/null +++ b/release/packages/lld-all.ucl @@ -0,0 +1 @@ +licenses = [ NCSA ] diff --git a/release/packages/lld.ucl b/release/packages/lld.ucl deleted file mode 100644 index 9c164bc18f01..000000000000 --- a/release/packages/lld.ucl +++ /dev/null @@ -1,17 +0,0 @@ -# -# - -name = "%PKG_NAME_PREFIX%-%PKGNAME%" -origin = "base" -version = "%VERSION%" -comment = "%COMMENT%" -categories = [ base ] -maintainer = "%PKG_MAINTAINER%" -www = "%PKG_WWW%" -prefix = "/" -licenselogic = "single" -licenses = [ NCSA ] -desc = <<EOD -%DESC% -EOD - diff --git a/release/packages/lldb-all.ucl b/release/packages/lldb-all.ucl new file mode 100644 index 000000000000..41a697ebe53d --- /dev/null +++ b/release/packages/lldb-all.ucl @@ -0,0 +1 @@ +licenses = [ NCSA ] diff --git a/release/packages/lldb.ucl b/release/packages/lldb.ucl deleted file mode 100644 index 9c164bc18f01..000000000000 --- a/release/packages/lldb.ucl +++ /dev/null @@ -1,17 +0,0 @@ -# -# - -name = "%PKG_NAME_PREFIX%-%PKGNAME%" -origin = "base" -version = "%VERSION%" -comment = "%COMMENT%" -categories = [ base ] -maintainer = "%PKG_MAINTAINER%" -www = "%PKG_WWW%" -prefix = "/" -licenselogic = "single" -licenses = [ NCSA ] -desc = <<EOD -%DESC% -EOD - diff --git a/release/packages/runtime.ucl b/release/packages/runtime.ucl index ee141e059dce..8a337c038fdd 100644 --- a/release/packages/runtime.ucl +++ b/release/packages/runtime.ucl @@ -1,25 +1,9 @@ -# -# - -name = "%PKG_NAME_PREFIX%-%PKGNAME%" -origin = "base" -version = "%VERSION%" -comment = "%COMMENT%" -categories = [ base ] -maintainer = "%PKG_MAINTAINER%" -www = "%PKG_WWW%" -prefix = "/" -vital = %VITAL% -licenselogic = "single" -licenses = [ BSD2CLAUSE ] -desc = <<EOD -%DESC% -EOD +vital: true scripts: { - post-install = <<EOD - pwd_mkdb -i -p -d ${PKG_ROOTDIR}/etc ${PKG_ROOTDIR}/etc/master.passwd - services_mkdb %CAP_MKDB_ENDIAN% -q -o ${PKG_ROOTDIR}/var/db/services.db ${PKG_ROOTDIR}/etc/services - chmod 1777 ${PKG_ROOTDIR}/tmp + post-install = <<EOD + pwd_mkdb -i -p -d ${PKG_ROOTDIR}/etc ${PKG_ROOTDIR}/etc/master.passwd + services_mkdb ${CAP_MKDB_ENDIAN} -q -o ${PKG_ROOTDIR}/var/db/services.db ${PKG_ROOTDIR}/ + chmod 1777 ${PKG_ROOTDIR}/tmp EOD } directories: { diff --git a/release/packages/src-sys.ucl b/release/packages/src-sys.ucl deleted file mode 100644 index ad37f5c5a5f1..000000000000 --- a/release/packages/src-sys.ucl +++ /dev/null @@ -1,17 +0,0 @@ -# -# - -name = "%PKG_NAME_PREFIX%-src-sys" -origin = "base" -version = "%VERSION%" -comment = "FreeBSD Kernel Sources" -categories = [ base ] -maintainer = "%PKG_MAINTAINER%" -www = "%PKG_WWW%" -prefix = "/" -licenselogic = "single" -licenses = [ BSD2CLAUSE ] -desc = <<EOD -%DESC% -EOD - diff --git a/release/packages/src.ucl b/release/packages/src.ucl deleted file mode 100644 index 899193085554..000000000000 --- a/release/packages/src.ucl +++ /dev/null @@ -1,17 +0,0 @@ -# -# - -name = "%PKG_NAME_PREFIX%-src" -origin = "base" -version = "%VERSION%" -comment = "FreeBSD userland sources" -categories = [ base ] -maintainer = "%PKG_MAINTAINER%" -www = "%PKG_WWW%" -prefix = "/" -licenselogic = "single" -licenses = [ BSD2CLAUSE ] -desc = <<EOD -%DESC% -EOD - diff --git a/release/packages/ssh-all.ucl b/release/packages/ssh-all.ucl new file mode 100644 index 000000000000..4f78d80fa68e --- /dev/null +++ b/release/packages/ssh-all.ucl @@ -0,0 +1 @@ +licenses = [ ISCL ] diff --git a/release/packages/ssh.ucl b/release/packages/ssh.ucl deleted file mode 100644 index 86976c0ae99d..000000000000 --- a/release/packages/ssh.ucl +++ /dev/null @@ -1,17 +0,0 @@ -# -# - -name = "%PKG_NAME_PREFIX%-%PKGNAME%" -origin = "base" -version = "%VERSION%" -comment = "%COMMENT%" -categories = [ base ] -maintainer = "%PKG_MAINTAINER%" -www = "%PKG_WWW%" -prefix = "/" -licenselogic = "single" -licenses = [ ISCL ] -desc = <<EOD -%DESC% -EOD - diff --git a/release/packages/template.ucl b/release/packages/template.ucl index f98407c1e83d..2e325e623336 100644 --- a/release/packages/template.ucl +++ b/release/packages/template.ucl @@ -1,17 +1,18 @@ # # -name = "%PKG_NAME_PREFIX%-%PKGNAME%" +name = "${PKG_NAME_PREFIX}-${PKGNAME}" origin = "base" -version = "%VERSION%" -comment = "%COMMENT%" +version = "${VERSION}" +comment = "${COMMENT}" categories = [ base ] -maintainer = "%PKG_MAINTAINER%" -www = "%PKG_WWW%" +maintainer = "${PKG_MAINTAINER}" +www = "${PKG_WWW}" prefix = "/" -vital = %VITAL% licenselogic = "single" licenses = [ BSD2CLAUSE ] desc = <<EOD -%DESC% +${DESC} EOD +.include(try=true,duplicate=rewrite) "${UCLFILES}/${PKGGENNAME}-all.ucl" +.include(try=true,duplicate=rewrite) "${UCLFILES}/${PKGNAME}.ucl" diff --git a/release/packages/unbound-all.ucl b/release/packages/unbound-all.ucl new file mode 100644 index 000000000000..78bb1f284ff2 --- /dev/null +++ b/release/packages/unbound-all.ucl @@ -0,0 +1 @@ +licenses = [ BSD4CLAUSE ] diff --git a/release/packages/unbound.ucl b/release/packages/unbound.ucl deleted file mode 100644 index 966de0a3691b..000000000000 --- a/release/packages/unbound.ucl +++ /dev/null @@ -1,17 +0,0 @@ -# -# - -name = "%PKG_NAME_PREFIX%-%PKGNAME%" -origin = "base" -version = "%VERSION%" -comment = "%COMMENT%" -categories = [ base ] -maintainer = "%PKG_MAINTAINER%" -www = "%PKG_WWW%" -prefix = "/" -licenselogic = "single" -licenses = [ BSD4CLAUSE ] -desc = <<EOD -%DESC% -EOD - diff --git a/release/packages/utilities.ucl b/release/packages/utilities.ucl index b92269cceff7..4eb98cae292a 100644 --- a/release/packages/utilities.ucl +++ b/release/packages/utilities.ucl @@ -1,22 +1,5 @@ -# -# - -name = "%PKG_NAME_PREFIX%-%PKGNAME%" -origin = "base" -version = "%VERSION%" -comment = "%COMMENT%" -categories = [ base ] -maintainer = "%PKG_MAINTAINER%" -www = "%PKG_WWW%" -prefix = "/" -vital = %VITAL% -licenselogic = "single" -licenses = [ BSD2CLAUSE ] -desc = <<EOD -%DESC% -EOD scripts: { - post-install = <<EOD - cap_mkdb %CAP_MKDB_ENDIAN% ${PKG_ROOTDIR}/etc/login.conf + post-install = <<EOD + cap_mkdb ${CAP_MKDB_ENDIAN} ${PKG_ROOTDIR}/etc/login.conf EOD }