Bug 277865 - ports-mgmt/poudriere: builds wrong flavor when default isn't 1st
Summary: ports-mgmt/poudriere: builds wrong flavor when default isn't 1st
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Bryan Drewery
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-03-21 14:53 UTC by Anton Saietskii
Modified: 2024-03-21 16:31 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (bdrewery)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Anton Saietskii 2024-03-21 14:53:43 UTC
[?:0] /usr/ports/net-p2p/tremotesf $ grep ^FLAVOR Makefile
FLAVORS=        qt5 qt6
FLAVOR?=        ${FLAVORS:[2]}
[?:0] /usr/ports/net-p2p/tremotesf $ make -V FLAVOR
qt6
[?:0] /usr/ports/net-p2p/tremotesf $ make -V FLAVORS
qt5 qt6
[?:0] /usr/ports/net-p2p/tremotesf $ sudo poudriere bulk -t -j releng133 -C net-p2p/tremotesf@qt5
[00:00:00] Creating the reference jail... done
[00:00:00] Mounting system devices for releng133-default
[00:00:00] Stashing existing package repository
[00:00:00] Mounting ccache from: /var/cache/ccache/poudriere/
[00:00:00] Mounting ports from: /usr/ports/
[00:00:00] Mounting packages from: /usr/local/poudriere/data/packages/releng133-default
[00:00:00] Mounting distfiles from: /usr/ports/distfiles
[00:00:00] Copying /var/db/ports from: /usr/local/etc/poudriere.d/options
[00:00:00] Appending to make.conf: /usr/local/etc/poudriere.d/make.conf
/etc/resolv.conf -> /usr/local/poudriere/data/.m/releng133-default/ref/etc/resolv.conf
[00:00:00] Starting jail releng133-default
[00:00:00] Creating group pbuild done
[00:00:00] Creating user pbuild done
[00:00:00] Will build as pbuild:pbuild (65529:65529)
[00:00:01] Logs: /usr/local/poudriere/data/logs/bulk/releng133-default/2024-03-21_16h47m54s
[00:00:01] Loading MOVED for /usr/local/poudriere/data/.m/releng133-default/ref/usr/ports
[00:00:01] Ports supports: FLAVORS SUBPACKAGES SELECTED_OPTIONS
[00:00:01] Gathering ports metadata
[00:00:03] Calculating ports order and dependencies
[00:00:03] -C specified, cleaning listed packages
[00:00:03] (-C) Will delete existing package: tremotesf-qt6-2.6.1.pkg
[00:00:03] (-C) Flushing package deletions
[00:00:03] Trimming IGNORED and blacklisted ports
[00:00:04] Sanity checking the repository
[00:00:04] Checking packages for incremental rebuild needs
[00:00:05] Deleting stale symlinks... done
[00:00:05] Deleting empty directories... done
[00:00:05] Unqueueing existing packages
[00:00:05] Unqueueing orphaned build dependencies
[00:00:05] Sanity checking build queue
[00:00:05] Processing PRIORITY_BOOST
[00:00:05] Balancing pool
[releng133-default] [2024-03-21_16h47m54s] [balancing_pool] Queued: 1  Built: 0  Failed: 0  Skipped: 0  Ignored: 0  Fetched: 0  Tobuild: 1   Time: 00:00:04
[00:00:05] Recording filesystem state for prepkg... done
[00:00:05] Building 1 packages using up to 1 builders
[00:00:05] Hit CTRL+t at any time to see build progress and stats
[00:00:05] [01] [00:00:00] Builder starting
[00:00:05] [01] [00:00:00] Builder started
[00:00:05] [01] [00:00:00] Building net-p2p/tremotesf@qt6 | tremotesf-qt6-2.6.1
[00:00:48] [01] [00:00:43] Finished net-p2p/tremotesf@qt6 | tremotesf-qt6-2.6.1: Success
[00:00:48] Stopping 1 builders
[00:00:48] Creating pkg repository
Creating repository in /tmp/packages: 100%
Packing files for repository: 100%
[00:00:52] Committing packages to repository: /usr/local/poudriere/data/packages/releng133-default/.real_1711032553 via .latest symlink
[00:00:52] Removing old packages
[00:00:52] Built ports: net-p2p/tremotesf@qt6
[releng133-default] [2024-03-21_16h47m54s] [committing] Queued: 1  Built: 1  Failed: 0  Skipped: 0  Ignored: 0  Fetched: 0  Tobuild: 0   Time: 00:00:51
[00:00:52] Logs: /usr/local/poudriere/data/logs/bulk/releng133-default/2024-03-21_16h47m54s
Cleaning ccache and recalculating stats... done
[00:00:53] Cleaning up
[00:00:53] Unmounting file systems
[?:0] /usr/ports/net-p2p/tremotesf $

But there's should be nothing wrong in '${FLAVORS:[2]}' (isn't it just array index?):
[?:0] /usr/ports/net-p2p/tremotesf $ env FLAVOR=qt5 make -V PKGNAME
tremotesf-2.6.1
[?:0] /usr/ports/net-p2p/tremotesf $ env FLAVOR=qt6 make -V PKGNAME
tremotesf-qt6-2.6.1
[?:0] /usr/ports/net-p2p/tremotesf $
Comment 1 Benjamin Takacs 2024-03-21 15:10:45 UTC
The port is wrong here, the line has to be  FLAVOR?=	${FLAVORS:[1]}  "The first flavor in FLAVORS is the default flavor." [0]. It is a bit unfortunate that poudriere has some troubles in cases were that is violated.

[0]: https://docs.freebsd.org/en/books/porters-handbook/flavors/#flavors-using
Comment 2 Anton Saietskii 2024-03-21 15:33:02 UTC
(In reply to Benjamin Takacs from comment #1)

> The port is wrong here
No it's not. FLAVORS -- just a list of whitespace-separated values, basically an array. ${FLAVORS:[N]} does nothing more than selecting Nth element from that array. That's actually what I demonstrated by running 'env FLAVOR=X make -V PKGNAME'.

BTW, why would we event define default flavor if statement "default can be 1st only" would be true? Actually, there's even a bug #225659 with pretty similar issue, but commit 9823f56764e6cf0b39a6485c3b95a58102b5f2f7 in ports doesn't help for some reason (though I didn't dig into this deeply).
Comment 3 Benjamin Takacs 2024-03-21 16:00:22 UTC
you define FLAVOR yourself, because Mk/bsd.port.mk setting it for you (line 1524) does so to late (I'm suprised that there don't seem to be a <flavor>_USES helper). 9823f56764e6cf0b39a6485c3b95a58102b5f2f7 doesn't help, as it only helps when the port doesn't set FLAVOR, as that makes Mk/bsd.port.mk set _FLAVOR to a non-empty value (line 1043), so the condition is false (not sure how and when it can help, maybe with stuff like python ports)
Comment 4 Anton Saietskii 2024-03-21 16:13:33 UTC
(In reply to Benjamin Takacs from comment #3)

The commit message says _reorder_ flavors, not "set default if no default is set", isn't it? And again: ports tree itself handles this correctly. It's just poudriere can't build 1st flavor _at all_ (take a closer look at the 'bulk' arguments) when default is 2nd.
Comment 5 Benjamin Takacs 2024-03-21 16:31:11 UTC
(In reply to Anton Saietskii from comment #4)

that .if of commit 9823f56764e6cf0b39a6485c3b95a58102b5f2f7 only applies, if FLAVOR isn't set before Mk/bsd.port.mk is included. If it is, then bsd.port.mk will save the requested FLAVOR in _FLAVOR in line 1043, in line 1523 it will skip setting FLAVOR, as FLAVOR is already set, in line 1528 it will skip reordering FLAVORS, as _FLAVOR is set to a non-empty value (and later in 3919 it can't detect that it wasn't the user that requested that FLAVOR, making the clean code a bit incorrect in case FLAVOR was set by the port and not by the user)