From 479bef3b2fb5ba8f7629f9f23dd74e15fe9d004b Mon Sep 17 00:00:00 2001 From: classabbyamp Date: Wed, 4 Jun 2025 20:12:05 -0400 Subject: [PATCH] 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: 62c0c08e182ad56ffa5874cbb105676315e4008c). 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. --- Manual.md | 8 +++----- common/build-style/meta.sh | 9 --------- common/environment/setup-subpkg/subpkg.sh | 2 +- common/hooks/pre-pkg/99-pkglint.sh | 10 +++++++--- common/xbps-src/libexec/xbps-src-doinstall.sh | 12 +++++++++++- common/xbps-src/shutils/common.sh | 6 ++++-- 6 files changed, 26 insertions(+), 21 deletions(-) delete mode 100644 common/build-style/meta.sh diff --git a/Manual.md b/Manual.md index 3635b064ced..c8a891ee0ea 100644 --- a/Manual.md +++ b/Manual.md @@ -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 diff --git a/common/build-style/meta.sh b/common/build-style/meta.sh deleted file mode 100644 index c2dbce1892b..00000000000 --- a/common/build-style/meta.sh +++ /dev/null @@ -1,9 +0,0 @@ -# meta pkg build style; do nothing. - -do_fetch() { - : -} - -do_install() { - : -} diff --git a/common/environment/setup-subpkg/subpkg.sh b/common/environment/setup-subpkg/subpkg.sh index 379ade740fa..7064ab61b8a 100644 --- a/common/environment/setup-subpkg/subpkg.sh +++ b/common/environment/setup-subpkg/subpkg.sh @@ -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 diff --git a/common/hooks/pre-pkg/99-pkglint.sh b/common/hooks/pre-pkg/99-pkglint.sh index 86a6cd64be4..ed543625935 100644 --- a/common/hooks/pre-pkg/99-pkglint.sh +++ b/common/hooks/pre-pkg/99-pkglint.sh @@ -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 diff --git a/common/xbps-src/libexec/xbps-src-doinstall.sh b/common/xbps-src/libexec/xbps-src-doinstall.sh index 690cf8ae0e7..ef958f60f43 100755 --- a/common/xbps-src/libexec/xbps-src-doinstall.sh +++ b/common/xbps-src/libexec/xbps-src-doinstall.sh @@ -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 diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh index 5f4cf7a7e3d..f82db7d98a3 100644 --- a/common/xbps-src/shutils/common.sh +++ b/common/xbps-src/shutils/common.sh @@ -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