0

I need to programmatically gather the apt Origin and Suite information for a certain package, in order to configure unattended-upgrades.

I can manually find the corresponding apt state information file, then process it, however, I need to automated the process.

For example, if I:

  • add the PPA ppa:qbittorrent-team/qbittorrent-stable
  • install qbittorrent-nox

among the other files, apt will create /var/lib/apt/lists/ppa.launchpad.net_qbittorrent-team_qbittorrent-stable_ubuntu_dists_xenial_InRelease, which is the file I'm looking for.

I've tried with apt-cache showpkg:

$ apt-cache showpkg qbittorrent-nox
Package: qbittorrent-nox
Versions:
4.1.7.99~201908140017-6718-e98f44a~ubuntu16.04.1 (/var/lib/apt/lists/ppa.launchpad.net_qbittorrent-team_qbittorrent-stable_ubuntu_dists_xenial_main_binary-armhf_Packages) (/var/lib/dpkg/status)
[...]

which doesn't include the _InRelease file.

Is there an exact programmatic way to find the *Release file name, starting from the package, or even better, there Origin and Suite values?

Edit: extra output follows:

$ apt-cache policy qbittorrent-nox  
qbittorrent-nox:
  Installed: 4.1.7.99~201908140017-6718-e98f44a~ubuntu16.04.1
  Candidate: 4.1.7.99~201908140017-6718-e98f44a~ubuntu16.04.1
  Version table:
 *** 4.1.7.99~201908140017-6718-e98f44a~ubuntu16.04.1 500
        500 http://ppa.launchpad.net/qbittorrent-team/qbittorrent-stable/ubuntu xenial/main armhf Packages
        100 /var/lib/dpkg/status
     3.3.1-1 500
        500 http://ports.ubuntu.com/ubuntu-ports xenial/universe armhf Packages
$ grep -r armhf /etc/apt --include="*.list"
# nothing
  • 1
    Please add output of apt-cache policy qbittorrent-nox and grep -r armhf /etc/apt --include="*.list" to the question. Having armhf on amd64 (desktop or laptop machine) will mean that you have wrong line in your sources.list. – N0rbert Sep 7 at 13:09
  • Ubuntu also has arm distributions :-) The output comes from an armv7l host. I've added the requested commands' output, thanks! – Marcus Sep 8 at 14:07
0

Based on the research I've done, there is no direct way to solve this problem.

However, according to the Debian repository format document, the naming of the state information files has precise rules, that can be used.

Therefore, one can find a package's _Packages corresponding filename via apt-cache showpkg, then process it according to the repository format rules:

  • if the respository has a component, the name will have a suffix _<component>_binary-<arch>_Packages
  • otherwise, the suffix will be just _Packages

then:

  • replace the suffix with _InRelease, and test the resulting filename
  • if the file exists, all done
  • if not, replace the suffix with Release (which is an alternative naming for state files with an external signature)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.