Monday, July 10, 2017

apt - How to list packages from a ppa/source in command line?



I want to list all the files from a source, say extras.ubuntu.com from the command line. What is the command for that?



dpkg --list lists all files or just the filename.



Find the relevant file in /var/lib/apt/lists/ ending in Packages, and perform this command:



# example for deb http://security.ubuntu.com/ubuntu natty-security multiverse

awk '$1 == "Package:" { print $2 }' /var/lib/apt/lists/security*multiverse*Packages


By the way, my extras.ubuntu.com_ubuntu_dists_natty_main_binary-i386_Packages is empty.



EDIT



You could also parse apt-cache output. This script lists all packages with server and repo information:



#!/bin/bash


apt-cache policy $(dpkg -l | awk 'NR >= 6 { print $2 }') |
awk '/^[^ ]/ { split($1, a, ":"); pkg = a[1] }
nextline == 1 { nextline = 0; printf("%-40s %-50s %s\n", pkg, $2, $3) }
/\*\*\*/ { nextline = 1 }'


Sorting conveniently the output you can get the infos you're looking for.


No comments:

Post a Comment

11.10 - Can't boot from USB after installing Ubuntu

I bought a Samsung series 5 notebook and a very strange thing happened: I installed Ubuntu 11.10 from a usb pen drive but when I restarted (...