Created
March 4, 2015 00:10
-
-
Save ar45/08db412615f2740f1fe9 to your computer and use it in GitHub Desktop.
get a list of all packages installed which are no longer available from the current sources
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# | |
# Generates and prints list of packages that are no longer available on the system from existing apt sources. | |
# | |
# * Ensure your package lists is up-to-date - run apt-get update | |
# | |
# Author: Aron Podrigal <[email protected]> | |
# | |
import os, sys | |
installed = os.popen("dpkg -l |awk '/^i/ {print $2,$3}'").read().split('\n') | |
num_pkgs = len(installed) | |
num_processed = 1 | |
need_remove = [] | |
for p in installed: | |
package = p.split(' ') | |
if len(package) != 2: | |
continue | |
name, version = package | |
sys.stdout.write('\rproccesing %.2f%%: %d/%d packages -- %50s' % (100.0 / num_pkgs * num_processed, num_processed, num_pkgs, name)) | |
sys.stdout.flush() | |
num_processed = num_processed + 1 | |
apt_cache=os.popen("apt-cache madison %s |awk '{print $3}' |uniq" % name).read().split('\n') | |
if version not in apt_cache: | |
need_remove.append((name, version)) | |
pkglist = ' '.join([n[0] for n in need_remove]) | |
sys.stdout.write('+Done. to install thos packages from your existing stable repo do ` apt-get -t <source> install\n') | |
sys.stdout.flush() | |
print pkglist |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment