10

I previously added some external sources to /etc/apt/sources.list.d but I now want to remove one of them. I also want to:

  • remove all packages solely from that source
  • revert all packages to versions in my original source(s)
  • alternatively, make a list of all packages from this source so I can perform this procedure manually

How can I do this?

2 Answers 2

12

Depending on the configuration of the repository you wish to remove, apt list --installed might provide enough information to identify packages you need to uninstall or downgrade. Another option, if the repository defines a unique “Origin”, is to use aptitude search '~i ~Oorigin' (replacing origin as appropriate).

(This is a generic answer; if you edit your question to specify exactly which source you want to remove, I can add a specific answer.)

2
  • this looks promising, could I get a list of origins somehow?
    – lofidevops
    Oct 31, 2017 at 13:43
  • 2
    Yes, apt-cache policy will show you the origins for all your configured repositories (look for o= in the output). Oct 31, 2017 at 13:45
4

Or with dpkg:

dpkg -l | awk '/^.i/ {print $2}' | xargs apt-cache policy | awk '/^[a-z0-9.\-]+:/ {pkg=$1}; /\*\*\*/ {OFS="\t"; ver=$2; getline; print pkg,ver,$2,$3}'|grep -v /var/lib/dpkg/status| sed -e 's/://'|awk '{printf "%-40s %-36s %-36s %-16s \n",$1,$2,$3, $4}' | grep -i yourkeyword

For example

dpkg -l | awk '/^.i/ {print $2}' | xargs apt-cache policy | awk '/^[a-z0-9.\-]+:/ {pkg=$1}; /\*\*\*/ {OFS="\t"; ver=$2; getline; print pkg,ver,$2,$3}'|grep -v /var/lib/dpkg/status| sed -e 's/://'|awk '{printf "%-40s %-36s %-36s %-16s \n",$1,$2,$3, $4}' | grep -i multimedia

returns:

audacious                                1:3.8.2-dmo1                         http://www.deb-multimedia.org        stretch/main     
audacious-plugins                        1:3.8.2-dmo1                         http://www.deb-multimedia.org        stretch/main     
audacious-plugins-data                   1:3.8.2-dmo1                         http://www.deb-multimedia.org        stretch/main    
snipp

This shows me the packages from deb-multimedia.org. Same result with dpkg-query -W -f='${Section}\t\t${Package}\n' | awk '/^.i/ {print $2}' | xargs apt-cache policy | awk '/^[a-z0-9.\-]+:/ {pkg=$1}; /\*\*\*/ {OFS="\t"; ver=$2; getline; print pkg,ver,$2,$3}'|grep -v /var/lib/dpkg/status| sed -e 's/://'|awk '{printf "%-40s %-36s %-36s %-16s \n",$1,$2,$3, $4}' | egrep -i multimedia

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .