sabato 25 giugno 2005, alle 14:34, Christian Barbato scrive: > Amen. Speravo si potesse con apt. Questo script, perl, che non ricordo bene dove ho trovato, dovrebbe fare al caso tuo. Si lancia senza argomenti. Gabriele :-) -- http://poisson.phc.unipi.it/~stilli/ ICQ UIN: 159169930 [HT] Lothlorien F.C. (51042, V.202) #156 Club dei Mille Meglio essere ottimisti e avere torto, che pessimisti e avere ragione [Albert Einstein]
#!/usr/bin/perl # Author: Marcel Meckel # Contact: debian [at] thermoman [dot] de ########################################### sub usage { print 'Usage: apt-listrepository Lists all installed packages and the corresponding repository it was installed from. --help - this usage message '; } unless ($#ARGV ne 0) { &usage(); exit 1; } # all installed packages open(DATA, 'dpkg --get-selections|') or die "Can not execute dpkg\n"; @tmp = <DATA>; close DATA; chomp(@tmp); $tmp2 = join("\n", @tmp)."\n"; $packages_nl = $tmp2; $packages_nl =~ s/([^\s]+)\s+([^\n]+)/\1/g; $packages = $packages_nl; $packages =~ s/\n/ /g; # get policy of all installed packages open(DATA, "apt-cache policy $packages|") or die "Can not execute apt-cache\n"; @tmp = <DATA>; close DATA; chomp(@tmp); $tmp2 = join("\n", @tmp)."\n"; $tmp2 =~ s/^ (Candidate|Installed|Version Table):.*\n//mg; $tmp2 =~ s/([^:\s\n]+):\n[^\*]+\*\*\* ([^\s\n]+)[^\n]+\n\s+-?[0-9]+ ([^\n]+)\n(\s+[^\n]+\n)*/\1|\2|\3\n/g; # all packages with version nr. and repository per line @packages = split(/\n/, $tmp2); foreach my $line (@packages) { my ($name, $version, $repository) = split (/\|/, $line); $repository =~ s/ Packages$//; printf("%-35s %s\n", $name, $repository) } exit 0;
Attachment:
signature.asc
Description: Digital signature