freebsd / pkg

Package management tool for FreeBSD. Help at #pkg on Libera Chat or pkg@FreeBSD.org
Other
748 stars 279 forks source link

Multi repo: add option to include/exclude packages #2089

Open fraenki opened 1 year ago

fraenki commented 1 year ago

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:

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. :)

igalic commented 1 year ago

given that our repo conf is fairly close to UCL, we should probably use arrays instead of single strings here

bapt commented 1 year ago

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.

fraenki commented 1 year ago

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 :)

bapt commented 1 year ago

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

heliosyne commented 1 year ago

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.