Re: Rimuovere tutti i pacchetti di un repository
On Sun, Jul 11, 2004 at 05:24:15PM +0200, Daniele Cortesi wrote:
> On Sun, 11 Jul 2004 (17:03), Mattia Dongili wrote:
> > e rimetterci i repository di marillat e ridare `apt-get update` e' tanto
> > brutto? non credo tu abbia molta scelta.
> Si tratta di un sistema che non ho curato io e il repository di Marillat
> era solo un esempio. Oltre a questo ne erano presenti altri che o non
> esistono più o non sono in grado di rintracciare, purtroppo.
mi permetto di riquotare:
[quote]
>
> w32codecs:
> Installed: 1:0.92-2
> Candidate: 1:0.92-2
> Version Table:
> *** 1:0.92-2 0
> 100 /var/lib/dpkg/status
[/quote]
e quindi la discriminante quale dovrebbe essere tra questo e un pacchetto
che vuoi rimanga installato?
se e' il fatto che la versione Installed non ha una url ma /var/lib/dpkg/status puoi provare cosi':
[codice su un'unica riga]
grep -B1 '^Status: install ok installed' /var/lib/dpkg/status | grep Package | cut -d' ' -f 2 | sort | xargs apt-cache policy | perl -e 'while (<>) { if ( m/^\b(.*)?:$/ ) { $p = $1; } if ( $p && m/^.*Installed: (.*)$/) { $v = $1; } if ( $p && $v && m/^.*?\*\*\* \Q${v}\E.*$/ ) { $u=<STDIN>; $u=~s/^.*?\d+[ ]+(.*)/$1/; print $p," ",$v," ",$u if $u=~m/\/var\/lib\/dpkg\/status/; $p=""; $v=""; $u=""; } } '
[/codice]
se la lista da rimuovere ti va bene puoi fare cosi':
[codice su un'unica riga]
sudo apt-get remove `grep -B1 '^Status: install ok installed' /var/lib/dpkg/status | grep Package | cut -d' ' -f 2 | sort | xargs apt-cache policy | perl -e 'while (<>) { if ( m/^\b(.*)?:$/ ) { $p = $1; } if ( $p && m/^.*Installed: (.*)$/) { $v = $1; } if ( $p && $v && m/^.*?\*\*\* \Q${v}\E.*$/ ) { $u=<STDIN>; $u=~s/^.*?\d+[ ]+(.*)/$1/; print $p," " if $u=~m/\/var\/lib\/dpkg\/status/; $p=""; $v=""; $u=""; } } '
[/codice]
se non puoi rintracciare i pacchetti piu' di cosi' non si puo' fare...
praticamente rimuovi tutti i pacchetti che non sono in un repository
on-line.
ATTENZIONE PERO' PUO' ANDARCI IN MEZZO QUALCOSA CHE POTRESTI NON
VOLER INSTALLARE. NON MI RITENGO RESPONSABILE DI COMPORTAMENTI NON
VOLUTI.
saluti
PS: nel frattempo ho fatto uno script che estrae i repository di tutti i
pacchetti installati. Lo appendo qui sotto (o i motori di ricerca trovano
anche negli allegati??)
---- cut here ----
#!/usr/bin/perl -w
#
# extracts the Repository url line where
# an installed package is from.
#
# Usage:
# ./dpkg-url [<perl-regex>] [<perl-regex>] ...
#
# You can filter the Package names with a perl compatible
# regular expression <perl-regex>. If none provided get all
# installed packages.
#
# As the original dpkg it understands the $COLUMNS
# environment variable.
#
# Examples:
# all packages:
# ./dpkg-url
#
# only those containing the string 'alsa':
# ./dpkg-url alsa
#
# match exactely the string 'alsa-base':
# ./dpkg-url ^alsa-base$
#
# all those containing both 'lib' and 'perl':
# ./dpkg-url lib perl
#
# widen the output to 100 columns and select all packages containing
# either the string 'alsa' or 'xfree86'
# COLUMNS=100 ./dpkg-url \(alsa\|xfree86\)
# COLUMNS=100 ./dpkg-url '(alsa|xfree86)'
#
# match case insensitive (you can substitute 'i' with whichever
# modifier perl compatible:
# ./dpkg-url '(?i:ALSA|xfree)'
#
use strict;
my $status_file = '/var/lib/dpkg/status';
my $cols = $ENV{'COLUMNS'} ? $ENV{'COLUMNS'} : 80;
my $re = join '.*', @ARGV;
# Find installed packages
my @inst_packages, my $package_name;
open FH, "<$status_file" or die "$status_file: $!";
while (<FH>) {
if (m/^Package: (.*)$/) {
$package_name = $1;
}
if ($package_name && m/^Status: install ok installed$/) {
push(@inst_packages, $package_name) if !$re || $package_name=~m/.*?${re}.*?/;
}
}
close FH;
die "No packages" unless @inst_packages;
@inst_packages = sort {$a cmp $b} @inst_packages;
# prepare output
use integer;
my $pcols = $cols/4;
my $vcols = ($cols - $pcols)/5;
my $ucols = $cols - $pcols - $vcols;
no integer;
my $package='', my $version='', my $url='';
# Define output format
my $format = "format STDOUT =\n"
. '@' . '<' x $pcols . ' '
. '@' . '<' x $vcols . ' '
. '@' . '<' x $ucols . "\n"
. '$package, $version, $url' . "\n"
. ".\n";
#print $format,"\n";
eval $format;
die $@ if $@;
# print header using the same format as results
$package = 'Package'; $version = 'Version'; $url = 'Repository';
write;
$package = '-' x ($pcols+1); $version = '-' x ($vcols+1); $url = '-' x ($ucols+1);
write;
# ask apt-cache where it got the package from
open APT, "apt-cache policy @inst_packages |" or die $^E;
$package = ''; $version = ''; $url = '';
while (<APT>) {
if (m/^\b(.*)?:$/) {
$package = $1;
}
# got $package, now get installed version
if ($package && m/^.*Installed: (.*)$/) {
$version = $1;
}
# got $package and $version, now get the url (next line to the matched version)
# and print if package name matches the regex
if ($package && $version && m/^.*?\*\*\* \Q${version}\E.*?$/) {
$url = <APT>;
$url =~ s/^.*?\d+ (.*)$/$1/;
write;
$package = ''; $version = ''; $url = '';
}
}
close APT;
exit 0;
---- cut here ----
--
mattia
:wq!
Reply to: