[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: python-apt, repositories



Perfect! I was able to find the related repository in the Packagefile
for each version

Example:
<apt_pkg.PackageFile
  object:
  filename:'/var/lib/apt/lists/deb.debian.org_debian_dists_bookworm_main_binary-amd64_Packages'
  a=testing,
  c=main,
  v=,
  o=Debian,
  l=Debian
  arch='amd64'
  site='deb.debian.org'
  IndexType='Debian Package Index'
  Size=46045052
  ID:10
>

An additional question:
The package-description for each version is also specified in a
Packagefile + an index,  e.g.
filename: /var/lib/apt/lists/deb.debian.org_debian_dists_buster_main_i18n_Translation-en
(29.375.817 bytes)
Index: 2.604.160
Is the index where the description starts in the file in bytes?



On Sun, Oct 17, 2021 at 6:08 PM David Kalnischkies
<david@kalnischkies.de> wrote:
>
> 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


Reply to: