How to tell which repositories provide which packages?

Little Girl littlergirl at gmail.com
Wed Jan 6 15:26:22 UTC 2021


Hey there,

Chris Green wrote:

>Yes, but the whole problem is that I want to know if *any* packages
>are being installed from repository XXXX.  There might be none, in
>which case I can remove the files from /etc/apt/sources.list.d

Yep, I fell over on that one, as Ralf figured out. I'm kind of like a
bull in a china shop when it comes to the command line. I think I get
way too excited about the power I've got and just sort of run around
crashing into everything and then goggling at it all wide-eyed with
wonder instead of scrutinizing it in detail to make sure it's solid.
As a result, my suggestions showed which packages are provided or
offered by repositories, but not necessarily which ones are actually
installed. I should work on refining that bull technique, but old
habits die hard...

Anyway, with Ralf to the rescue, these steps should work for you
(note that each of these is a one-line command, but may wrap on its
way to you, so you'll want to unwrap them to use them):

Get a list of your PPA source names (this is where you'll find the
XXXX to use in the other commands):

apt-cache showpkg "*" | grep repo | grep File | awk -F " " '{print
$2}' | awk -F "." '{print $2}' | sort -u

Get the names of all packages installed by your PPA (replace XXXX in
this command with your source name):

dpkg -l $(awk '$1 == "Package:" { print
$2 }' /var/lib/apt/lists/repo.XXXX*Packages) 2>/dev/null | grep ii |
awk '{print $2}'

Or get the names and versions of all packages installed by XXXX
(replace XXXX in this command with your source name):

apt-cache policy $(awk '$1 == "Package:" { print
$2 }' /var/lib/apt/lists/repo.XXXX*Packages) | grep -v
"Installed: (none)" | grep "Installed: " -B1

-- 
Little Girl

There is no spoon.




More information about the ubuntu-users mailing list