Created
March 10, 2017 06:43
-
-
Save horgh/6a431dea45c2d92e5b84e6fb92520eda to your computer and use it in GitHub Desktop.
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
use strict; | |
use warnings; | |
# Find all installed packages | |
my $out = `dpkg-query -l`; | |
# Lines like: | |
# ii zlib1g-dev:i386 1:1.2.8.dfsg- i386 compression library - development | |
my @lines = split /\n/, $out; | |
foreach my $line (@lines) { | |
my @pieces = split /\s+/, $line; | |
my $status = $pieces[0]; | |
next unless $status eq 'ii'; | |
my $name = $pieces[1]; | |
# Look up its repo | |
# Lines like: | |
# irssi | 0.8.20-2 | http://ftp.ca.debian.org/debian stretch/main i386 Packages | |
# May have multiple lines if have source defined. | |
my $madison = `apt-cache madison $name`; | |
my @madison_lines = split /\n/, $madison; | |
if (@madison_lines == 0) { | |
print "$name MISSING INFO\n"; | |
next; | |
} | |
my @pieces2 = split /\|/, $madison_lines[0]; | |
if (@pieces2 < 3) { | |
print "$name MISSING INFO\n"; | |
next; | |
} | |
my $repo = $pieces2[2]; | |
$repo =~ s/^\s+|\s+$//g; | |
print "$name: $repo\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment