On Sun, Oct 17, 2021 at 02:49:59PM +0200, BW wrote: > I'm trying retrieve the related repository of a package-version using > python-apt (I hope it make sense, I don't have the full overview of > the apt system yet). > I'll will use this information to decide which package-version to > download and/or install. Sounds like you are reimplementing apt preferences (aka pinning). The job of Policy which you found is to assign a pin value to each version (of a package) and decide based on that which version is considered the candidate for installation. While you can pin specific versions of specific packages it is perhaps more common to assign the pin based on information about the repository (= Release file) containing this version (via Packages). See the manpage for details, perhaps a simple pref file is already solving your problem. You may also want to look at unattended-upgrades, which I think is implemented in python and roughly sounds similar as it tries to download and install security updates while leaving packages from other repositories alone. I would guess it does this iteration dance: > How can I retrieve a list of the subscribed repositories, those > registered in /etc/apt/sources.list? > And how can I mape packages to those repositories? I don't know python-apt, so take my advice with a pint of salt, but in libapt a Package struct [PkgIterator] points to a list of Versions [VerIterator] (for that package) which each have one or more Packages files they refer to (which contain the actual stanzas). Those Packages files belong to a Release file [Ver…, Pkg… & RlsFileIterator]. Those structs live in the binary cache with various data fields containing hopefully all you really need. Packages and Release file can be matched to one or more(!) entries in sources.list by iterating over the sources entries and looking at which contain which files. It probably isn't what you want through. Best regards David Kalnischkies
Attachment:
signature.asc
Description: PGP signature