common: define meta-packages with metapackage=yes

Overloading `build_style` for meta-packages has always felt very hacky,
and it prevents having the main package be a meta-package (with non-meta
subpackages) and using a `build_style` at the same time (example of
trying to hack around that: 62c0c08e18).
It also can create confusion about how subpackages work if you can
define a `build_style` there (but only `meta`).

This makes using `build_style=meta` an error at the package and subpackage
level, and replaces it with a new variable (`metapackage=yes`).

A pkglint for non-empty meta-packages is also added.
This commit is contained in:
classabbyamp 2025-06-04 20:12:05 -04:00 committed by classabbyamp
parent 2aff0bd5a5
commit 479bef3b2f
6 changed files with 26 additions and 21 deletions

View file

@ -691,6 +691,9 @@ redistribution.
to override the guessed list. Only use this if a specific order of subpackages is required,
otherwise the default would work in most cases.
- `metapackage` If set to `yes`, the package must be an empty meta-package, i.e. a package that
only depends on other packages.
- `broken` If set, building the package won't be allowed because its state is currently broken.
This should be set to a string describing why it is broken, or a link to a buildlog demonstrating the failure.
@ -1011,11 +1014,6 @@ information can be found in the `go.mod` file for modern Go projects.
It's expected that the distfile contains the package, but dependencies
will be downloaded with `go get`.
- `meta` For `meta-packages`, i.e packages that only install local files or simply
depend on additional packages. This build style does not install
dependencies to the root directory, and only checks if a binary package is
available in repositories.
- `R-cran` For packages that are available on The Comprehensive R Archive
Network (CRAN). The build style requires the `pkgname` to start with
`R-cran-` and any dashes (`-`) in the CRAN-given version to be replaced

View file

@ -1,9 +0,0 @@
# meta pkg build style; do nothing.
do_fetch() {
:
}
do_install() {
:
}

View file

@ -3,7 +3,7 @@
## VARIABLES
unset -v conf_files mutable_files preserve triggers alternatives
unset -v depends run_depends replaces provides conflicts tags
unset -v depends run_depends replaces provides conflicts tags metapackage
# hooks/post-install/03-strip-and-debug-pkgs
unset -v nostrip nostrip_files

View file

@ -63,9 +63,13 @@ hook() {
esac
done
# Forbid empty packages unless build_style=meta or it is 32bit devel package
if [ "$build_style" != meta ] && [ "$emptypkg" != no ] && [[ ${pkgname} != *-devel-32bit ]]; then
msg_red "${pkgver}: PKGDESTDIR is empty and build_style != meta\n"
# Forbid empty packages unless metapackage=yes or it is 32bit devel package
if [ "$metapackage" != yes ] && [ "$emptypkg" != no ] && [[ ${pkgname} != *-devel-32bit ]]; then
msg_red "${pkgver}: PKGDESTDIR is empty and metapackage != yes\n"
error=1
fi
if [ "$metapackage" = yes ] && [ "$emptypkg" = no ]; then
msg_red "${pkgver}: PKGDESTDIR of meta package is not empty\n"
error=1
fi

View file

@ -34,7 +34,13 @@ if [ "$SUBPKG_MODE" = "no" ]; then
if [ ! -f $XBPS_INSTALL_DONE ] || [ -f $XBPS_INSTALL_DONE -a -n "$XBPS_BUILD_FORCEMODE" ]; then
mkdir -p $XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/$pkgname-$version
run_step install "" skip
if [ "$metapackage" = yes ]; then
optional="optional"
else
optional=""
fi
run_step install "$optional" skip
touch -f $XBPS_INSTALL_DONE
fi
@ -54,6 +60,10 @@ if [ ! -f $XBPS_SUBPKG_INSTALL_DONE -o -n "$XBPS_BUILD_FORCEMODE" ]; then
${PKGNAME}_package
pkgname=$PKGNAME
if [ "$build_style" = meta ]; then
msg_error "$pkgver: build_style=meta is deprecated, replace with metapackage=yes\n"
fi
source_file $XBPS_COMMONDIR/environment/build-style/${build_style}.sh
install -d $PKGDESTDIR

View file

@ -523,12 +523,14 @@ setup_pkg() {
pkgver="${pkg}-${version}_${revision}"
# If build_style() unset, a do_install() function must be defined.
# If build_style is unset, a do_install() function must be defined.
if [ -z "$build_style" ]; then
# Check that at least do_install() is defined.
if ! declare -f do_install >/dev/null; then
if [ "$metapackage" != yes ] && ! declare -f do_install >/dev/null; then
msg_error "$pkgver: missing do_install() function!\n"
fi
elif [ "$build_style" = meta ]; then
msg_error "$pkgver: build_style=meta is deprecated, replace with metapackage=yes\n"
fi
for x in ${hostmakedepends} ${makedepends} ${checkdepends}; do