Last active
March 14, 2017 14:54
-
-
Save mklooss/c9fca78de4ce4c6758cd94ec45f35d11 to your computer and use it in GitHub Desktop.
find old debian packages after upgrade
This file contains 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
<?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