Skip to content

Instantly share code, notes, and snippets.

Last active March 14, 2017 14:54
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
find old debian packages after upgrade
/* yeah i know, php buuuuuh */
exec('apt-cache dumpavail | grep "Package:" | awk \'{print $2}\' > packages.txt');
exec('dpkg -l | awk \'{print $2}\' > installed.txt');
$packages = file_get_contents('packages.txt');
$packages = str_replace("\r", '', $packages);
$packages = array_filter((array) explode("\n", $packages));
$installed = file_get_contents('installed.txt');
$installed = str_replace("\r", '', $installed);
$installed = array_filter((array) explode("\n", $installed));
foreach ($installed as $_pkg)
$__pkg = array_filter((array)explode(':', $_pkg));
$_pkg = array_shift($__pkg);
if (!in_array($_pkg, $packages))
echo $_pkg;
echo "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment