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 xenial/main armhf Packages 100 /var/lib/dpkg/status 3.3.1-1 500 500 xenial/universe armhf Packages$ grep -r armhf /etc/apt --include="*.list"
# nothing 2 1 Answer
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)