Re: Can `pkg prime-origins` be "trained" to pick up flavors?

From: Tomoaki AOKI <junchoon_at_dec.sakura.ne.jp>
Date: Mon, 01 Jul 2024 21:44:48 UTC
On Mon, 1 Jul 2024 20:42:47 +0200
DutchDaemon - FreeBSD Forums Administrator <DutchDaemon@FreeBSD.org>
wrote:

> On 1-7-2024 19:22, Tomoaki AOKI wrote:
> > On Mon, 1 Jul 2024 15:46:18 +0200
> > DutchDaemon - FreeBSD Forums Administrator<DutchDaemon@FreeBSD.org>
> > wrote:
> >
> >> Hey,
> >>
> >> I use `pkg prime-origins` on my servers to pick up the ports that
> >> Poudriere needs to build for that (cluster of) server(s).
> >>
> >> This doesn't work for flavors, or I'm missing a trick.
> >>
> >> E.g.: I have installed the "guestagent" flavor of emulators/qemu
> >> ("qemu-guest-agent" in pkg terms), which gets built in Poudriere as
> >> "emulators/qemu@guestagent".
> >>
> >> All good and well.
> >>
> >> But `pkg prime-origins` picks it up as "emulators/qemu", which, of
> >> course, triggers Poudriere to build the whole thing,
> >> "emulators/qemu@default".
> >>
> >> Which I don't need.
> >>
> >> So either pkg needs to be amended to be able to recognize and report a
> >> flavor, or I have to put this in the jail's make.conf on Poudriere.
> >>
> >> I'm not sure if there's a place for that in a generic make.conf for all
> >> ports in that specific jail; you know, one that contains
> >> all-encompassing lines like
> >>
> >> DEFAULT_VERSIONS= php=82 apache=2.4 mysql=80 ssl=openssl python=3.9
> >> python3=3.9
> >>
> >> Anyone?
> > Hi.
> > pkg records informations about FLAVORs in annotations only.
> > You should search output from `pkg -A <packagename>` for each pkg.
> >
> > Does the script on brew.bsd.cafe [1] help understanding/usable?
> >
> > [1]
> > https://brew.bsd.cafe/TomAoki/sh_scripts/src/branch/main/poudlist-all
> >
> > Regards.
> 
> That actually put me on a path forward, but I decided to sort of 
> brute-force it, so I could run the script anywhere.
> 
> In fact, Ansible runs it on all servers (grouped by build jail names on 
> Poudriere) and gathers/sorts the output to populate the build lists for 
> Poudriere, which then fires up the jails and builds the associated repos.
> 
> for port in $( /usr/local/sbin/pkg prime-origins )
> do
> flavor=$( /usr/local/sbin/pkg info -A "${port}" | /usr/bin/grep "flavor" 
> | /usr/bin/awk '{print $NF}' | /usr/bin/grep -v "default" )
> [ "x${flavor}" = "x" ] && echo "${port}" || echo "${port}@${flavor}"
> done
> 
> That gives me exactly the output I need.
> 
> Thanks!
> 
> DD

I recommend using pkgname instead of origin for sniffing FLAVORs.
If you have multiple FLAVORs for single origin, for example, has
textproc/fcitx5-qt with FLAVORs qt5 and qt6 are both installed,

     ===== Quot =====

% pkg info -A textproc/fcitx5-qt                       
fcitx5-qt5-5.1.6:
        FreeBSD_version: 1401500
        build_timestamp: 2024-05-20T00:44:42+0000
        built_by       : poudriere-git-3.4.99.20240424
        flavor         : qt5
        port_checkout_unclean: no
        port_git_hash  : 5706c0f18db2
        ports_top_checkout_unclean: yes
        ports_top_git_hash: 92df6b73a07c
fcitx5-qt6-5.1.6:
        FreeBSD_version: 1401500
        build_timestamp: 2024-05-20T00:44:50+0000
        built_by       : poudriere-git-3.4.99.20240424
        flavor         : qt6
        port_checkout_unclean: no
        port_git_hash  : 5706c0f18db2
        ports_top_checkout_unclean: yes
        ports_top_git_hash: 92df6b73a07c
% pkg info -A textproc/fcitx5-qt | /usr/bin/grep "flavor"
| /usr/bin/awk '{print $NF}'
qt5
qt6

     ===== End quot =====

So you would be better using `pkg prime-list` instead of `pkg
prime-origin` or handle the output via `xarg -n 1` for test.

Regards.

-- 
Tomoaki AOKI    <junchoon@dec.sakura.ne.jp>