Add support for -r ${REPOSITORY} flag for 'pkg info' command
Hi.
After the migration to the upcoming PKGBASE solution it will not be possible to list just the third party packages - or just the PKGBASE packages.
% pkg info -r FreeBSD
pkg: No package(s) matching FreeBSD
% pkg -r FreeBSD info
pkg: Invalid rootdir: No such file or directory
One of the needed features would be to add support for -r ${REPOSITORY} flag for pkg info command.
Regards, vermaden
I believe the same 'upgrade' to support -r ${REPOSITORY} flag would be useful for pkg delete command.
upgrade and install have a -r because it means upgrade only seeking for new sources in the repositories, for info and delete it does not really make sense you query the local db containing packages which could have come from any of the repository you have configured, yes we keep the information about the name of the repository if installed from a repo, but the name may have changed since or not have been installed at all from a repo (when installing from usb stick or dvd)
see my reply here
https://github.com/freebsd/pkg/issues/2494#issuecomment-3224574659 for a request which is similar
I just try to make FreeBSD better - and to bo honest - in all my experience with pkg(8) in the PKGBASE world its real PITA that all these Base System packages are listed every time. For 99% of the time when I execute pkg(8) - especially pkg info - I just want to 'mess' with third party packages and not anything else.
Yes - I will manage on my own - I will probably create some alias in /usr/local/etc/pkg.conf file ... but having to do that in all managed systems is the same PITA as adding a pipe to grep -v '^FreeBSD' at each pkg info execution.
That is why I am trying to find some solution for this that will work for all.
I have better idea - lets add two additional aliases to /usr/local/etc/pkg.conf file:
info-base- that will list only PKGBASE packages.info-ports- that will list only NOT PKGBASE packages (which will include bothFreeBSD-portsandFreeBSD-ports-kmodsrepos).
That would be a good compromise and easy/fast to implement I think.
I understand what you are trying to do, and the will behind, I am just saying that I have no idea how to make it happen in pkg in a non fragile way as the notion of pkgbase or anything other thing does not exist in pkg, it is just another repository with a name than can change, if we what to achieve such things, we need a metadata in the packages which pkg could recognize, the easiest would be to add a switch to info to tell it to only match origin, this way we could pkg info -O base or something like this
https://github.com/freebsd/pkg/issues/2507#issue-3388384030
… it will not be possible to list just the third party packages …
To list non-base packages, with their origins:
pkg prime-origins | grep -v base | sort -u
An example, with FreeBSD 14.3-RELEASE-p2 using pkgbase
Script started on Sat Sep 6 09:15:17 2025
root@pkg:~ # pkg prime-origins | grep -v base | sort -u
compat/libraries
devel/uclcmd
editors/nano
editors/turbo
emulators/virtualbox-ose-additions
net/gitup
ports-mgmt/pkg
sysutils/htop
sysutils/lsblk
x11/xsel-conrad
root@pkg:~ # pkg prime-origins | grep base | wc -l
525
root@pkg:~ # freebsd-version -kru ; uname -mvKU
14.3-RELEASE-p2
14.3-RELEASE-p2
14.3-RELEASE-p2
FreeBSD 14.3-RELEASE-p2 releng/14.3-n271439-5982521fe3dd GENERIC amd64 1403000 1403000
root@pkg:~ # exit
exit
Script done on Sat Sep 6 09:16:17 2025
#2507 (comment) To list non-base packages, with their origins:
Its even shorter as I wrote earlier:
# pkg info | grep -v ^FreeBSD
https://github.com/freebsd/pkg/issues/2507#issuecomment-3261071811
… origin, this way we could pkg info -O base or something like this …
-O is --by-origin in pkg-info(8).
For other readers to understand origin (distinct from repository), here's a pkg-version(8) example:
root@zfs:~ # pkg query '%o %v %At:%Av' lsblk | grep repository
sysutils/lsblk 4.0 repository:FreeBSD
root@zfs:~ # pkg version -Uv -O FreeBSD
root@zfs:~ # pkg version -Uv -O sysutils
root@zfs:~ # pkg version -Uv -O sysutils/lsblk
lsblk-4.0 > succeeds port (port has 3.9)
root@zfs:~ #
https://github.com/freebsd/pkg/issues/2507#issuecomment-3259525216
… I will probably create some alias in
/usr/local/etc/pkg.conf…
https://github.com/freebsd/pkg/issues/2507#issuecomment-3261652811
# pkg info | grep -v ^FreeBSD
For that, an alias might not work.
- https://github.com/freebsd/pkg/issues/2509
I understand what you are trying to do, and the will behind, I am just saying that I have no idea how to make it happen in pkg in a non fragile way as the notion of pkgbase or anything other thing does not exist in pkg, it is just another repository with a name than can change, if we what to achieve such things, we need a metadata in the packages which pkg could recognize, the easiest would be to add a switch to info to tell it to only match origin, this way we could pkg info -O base or something like this
The pkg documentation may need to be explicit about -r ${REPOSITORY} not generally being a way to specify a limited namespace for name matching in general --and not being intended for such in the future. I expect that these sorts of requests to create examples of namespace control (matching repository scope) are going to be an ongoing support-request issue.