Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
find old debian packages after upgrade
<?php
/* 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);
unset($__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