Improve `pkgdb_access` API
pkgdb works with multirepo, however, it's API is not aware that we sometimes want to work with some specific repo and not with all of them
The idea of this PR is to allow all pkgdb_* functions to be able to select a set of repos to work with (e.g. that could be overriden from CLI args).
The only option for now is to disable repos in the configuration which might be not convenient for some use cases.
I am puzzled about the usage of va_args here, I both like and dislike it
I am puzzled about the usage of va_args here, I both like and dislike it
I have the same feeling. The alternative is to use a list variable or even const char **. varargs are convenient if it comes to converting of the code, as PKGDB_LOCAL access will remain the same. On the other hand it can lead to potential issues as we hide all type checks. I have no strong opinion on that - it's quite easy to do it in either way. In general, we should allow multiple -r arguments everywhere. This functionality is now merely allowed by playing with enabled flags for repos. However, I think it might be neat to allow better CLI handling of multi-repo.
if we want to allow multiple -r argument (which I like) I think it would be easier to have a const char ** than a va_arg. I fail at seeing an easy way to convert multiple -r into a simple call to pkgdb_access with the current API, but I have only given it a few seconds of thinking.
FYI: The current patch fixes my problem when I specify a custom/alternative repository (+ -U -n combination) :
pkg update -f -r Test-latest (ok)
pkg upgrade -r Test-latest (ok)
pkg upgrade -r Test-latest -n (ok)
pkg upgrade -r Test-latest -U (ok)
pkg upgrade -r Test-latest -U -n (not OK, error):
pkg: Repository FreeBSD missing. 'pkg update' required
Without these changes, pkg also handles the other repository (which may be broken)
I think it would be easier to have a const char ** than a va_arg
However, if we want to reuse the existing const char *reponame that exists in all utilities it will make all calls very ugly. Maybe we should just pass ucl_object_t * to this API representing the set of interesting repos? It will slightly complicate the callers code but not more than char ** transition. However, we will have a set with useful properties. E.g. we can override priorities or do something useful with it without modifying the API. WDYT?
we have pkg_object as an opaque structure to hide ucl_object_t, we could use it to hide libucl.
For the record, I am continuing this work to merge it all at once, as we need to change all the pkgdb_* and not only pkgdb_access. so no this is not stalling, just long work work ongoing to finish this.
I grabbed the commit and convert the remaining pkgdb function while keeping API/ABI compatibility.
That’s right - the whole pkgdb api requires some proper support of multiple repos selection. I was about to continue this project but unfortunately got distracted by other things.Sent from my iPhoneOn 14 Nov 2024, at 14:38, Baptiste Daroussin @.***> wrote: I grabbed the commit and convert the remaining pkgdb function while keeping API/ABI compatibility.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>