pkg
pkg copied to clipboard
Multi repo: add option to include/exclude packages
It would be very useful if pkg would provide an option to include or exclude certain packages when using multiple repositories. For example:
FreeBSD: {
priority: 0,
excludepkgs: 'apache24,dovecot,haproxy,postfix',
}
3rd-party: {
priority: 1,
includepkgs: 'mysqlwsrep57-server,galera26',
}
OwnRepo: {
priority: 2,
enabled: yes,
}
This example demonstrates my main use-cases:
- I want to use the FreeBSD repository for most packages. But some packages must be excluded, because I need them with different build options. Even if the FreeBSD repository provides newer versions of these packages, they must be ignored.
- I want to use a 3rd-party repo, but only for a small subset of packages. All other packages in this repository must be ignored.
- And I want to use my own repository for packages that are build with custom build options.
This example is derived from the options currently available in DNF/YUM, see YUM.CONF(5):
includepkgs
Include packages of this repository, specified by a name or a glob and separated by a comma, in all
operations. Inverse of excludepkgs, DNF will exclude any package in the repository that doesn't match
this list. This works in conjunction with excludepkgs and doesn't override it, so if you 'excludep‐
kgs=*.i386' and 'includepkgs=python*' then only packages starting with python that do not have an i386
arch will be seen by DNF in this repo. Can be disabled using --disableexcludes command line switch.
Defaults to [].
excludepkgs
Exclude packages of this repository, specified by a name or a glob and separated by a comma, from all
operations. Can be disabled using --disableexcludes command line switch. Defaults to [].
I think adding these options would make the multi-repo feature more usable. Currently my own packages are always replaced with the versions from the FreeBSD repository when there is a newer version available. Having the includepkg and excludepkg options would make this very easy to achieve. On Rocky/Redhat Linux these options make it very easy for a lot repositories from many sources to co-exist without troubles.
On the other hand this may be another challenge for the dependency/conflict resolver, but that's probably a good thing and would allow to further improve it. :)
given that our repo conf is fairly close to UCL, we should probably use arrays instead of single strings here
This feature would be a nice addition if one want to provide it. Not very complicated, I will be low priority in my todo, but would be an "easy" task for new contributors.
Hi @bapt, thanks for chiming in. Could you probably provide a rough outline what components of pkg must be altered to add this feature? Thanks :)
I would exclude the packages at the moment the metadata are sync into the remove db. in libpkg/repos/binary/* and prevent the package in the exclude list to be synced into the db, so the reste of the code is untouched. the drawback being if you append things in the exclude list then you need to rerun pkg update -f, but I think this is a fair limitation
It would be good to make this handle flavors. Perhaps an explicit flavour syntax: portname@flavor with an explicit "at all" to exclude all flavors. The older approach of portname globs isn't fine-grained enough (e.g., postfix* would catch postfixadmin*, postfix-policyd-*, et al). Alternately, make it origin-based: "category/portname" to exclude all pkgs with that origin, "category/portname@flavor" to exclude just that flavor.