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
This commit is contained in:
Baptiste Daroussin 2024-01-31 13:42:16 +01:00
parent 6561c0eceb
commit f8e46fd61e
23 changed files with 104 additions and 282 deletions

View file

@ -2101,22 +2101,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} \
@ -2212,17 +2218,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 } ' \

View file

@ -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

View file

@ -0,0 +1 @@
licenses = [ NCSA ]

View file

@ -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

View file

@ -0,0 +1 @@
vital: true

View file

@ -1,16 +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 = [ BSD2CLAUSE ]
desc = <<EOD
%DESC%
EOD

View file

@ -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()

View file

@ -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
}

View file

@ -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

View file

@ -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
}

View file

@ -0,0 +1 @@
licenses = [ NCSA ]

View file

@ -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

View file

@ -0,0 +1 @@
licenses = [ NCSA ]

View file

@ -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

View file

@ -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: {

View file

@ -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

View file

@ -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

View file

@ -0,0 +1 @@
licenses = [ ISCL ]

View file

@ -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

View file

@ -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"

View file

@ -0,0 +1 @@
licenses = [ BSD4CLAUSE ]

View file

@ -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

View file

@ -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
}