Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 1812  / 1 Year ago, sat, may 13, 2023, 3:06:34

How do I get the real full package name (including the version) that would be installed if I ran apt-get install pseudo-package-name?



This is related to this previous question: Get the kernel version from lts package?



Example:



apt-get install linux-image-generic-lts-trusty


would install (as of right now on my 32-bit Trusty server):



linux-image-3.13.0-35-generic


I've tried the following, but none give me the answer. I'm trying to script this so I can just grab the linux-headers.



$ sudo apt-get install -qqs linux-image-generic-lts-trusty
Inst linux-image-generic-lts-trusty (3.13.0.35.42 Ubuntu:14.04/trusty-updates [i386])
Conf linux-image-generic-lts-trusty (3.13.0.35.42 Ubuntu:14.04/trusty-updates [i386])
$ apt-cache depends linux-image-generic-lts-trusty
linux-image-generic-lts-trusty
Depends: linux-image-generic
$ apt-cache depends linux-image-generic
linux-image-generic
Depends: linux-image-3.13.0-35-generic
Depends: linux-image-extra-3.13.0-35-generic
Depends: linux-firmware
$ apt-cache policy linux-image-generic-lts-trusty
linux-image-generic-lts-trusty:
Installed: (none)
Candidate: 3.13.0.35.42
Version table:
3.13.0.35.42 0
500 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main i386 Packages
500 http://security.ubuntu.com/ubuntu/ trusty-security/main i386 Packages
3.13.0.24.28 0
500 http://us.archive.ubuntu.com/ubuntu/ trusty/main i386 Packages


After some exploration of /var/lib/{apt,dpkg}, I relealized that there's not a generic, scriptable answer to this problem. So, similar to the answers below from @mchid and @muru, I did it like this:



#!/bin/bash

metapackage=linux-image-generic-lts-trusty
linux_package_version=$(apt-cache policy $metapackage |
sed -nE '/Candidate:/ s,[^[:digit:]]*([[:digit:].]+).([[:digit:]]+).[[:digit:]]+,1-2,p')

apt-get download linux-headers-${linux_package_version}-generic linux-headers-${linux_package_version})

More From » apt

 Answers
3

First, you must show exactly what package the metapackage provides:



example:



apt-cache show linux-image-generic-lts-trusty | grep Depends:


output:



Depends: linux-image-generic
Depends: linux-image-generic


Now, if you type the specific package of the metapackage you will get your exact result:



apt-cache show linux-image-generic | grep Depends:


output:



Depends: linux-image-3.13.0-35-generic, linux-image-extra-3.13.0-35-generic, linux-firmware
Depends: linux-image-3.13.0-24-generic, linux-image-extra-3.13.0-24-generic, linux-firmware


The newest version is always installed unless otherwise specified like in the following example:



sudo apt-get install linux-image-3.13.0-24-generic


Alternatively, if you just want the version you could type the following command or a variation there of instead:



apt-cache show linux-image-generic-lts-trusty | grep Version:


output:



Version: 3.13.0.35.42
Version: 3.13.0.24.28

[#23181] Saturday, May 13, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
epypian

Total Points: 130
Total Questions: 111
Total Answers: 113

Location: Romania
Member since Mon, Jun 6, 2022
2 Years ago
;