Andrew Gaffney wrote:
Andrew Gaffney wrote:

I'm writing a Perl program to uninstall a whole package tree, such as KDE or Gnome. Here's my code so far:


#! /usr/bin/perl

my @pkgs1, @pkgs2, $line, $line2, $pkg;

open QUERY, "emerge --nospinner -ep gnome |";
foreach $line (<QUERY>) {
  if($line !~ /^\[.+\]/) {
    next;
  }
  $line =~ s/^\[.+\] (.+)  /$1/;
  chomp $line;
  push (@pkgs1, $line);
}
close QUERY;

PKG:
foreach $pkg (@pkgs1) {
  open QUERY, "qpkg -q -nc $pkg |";
DEP:
  foreach $line (<QUERY>) {
    $line =~ s/\s+//;
    if(($line =~ /\*$/) || ($line =~ /DEPENDED/)) {
      next DEP;
    }
    chomp $line;
    foreach $line2 (reverse @pkgs1) {
      if($line eq $line2) {
        next DEP;
      }
      if($line2 eq $pkg) {
        last;
      }
    }
    foreach my $tmp (@pkgs2) {
      if($tmp eq $line) {
        next PKG;
      }
    }
    push @pkgs2, $line;
    print "$line is safe to unmerge\n";
  }
}


It doesn't yet consult the system or world files, and it seems to still throw in a few things that should stay. Anyone have any ideas?

Okay, it now parses /var/cache/edb/world to filter those out of the list. Where are the packages in the 'system' class stored? Would 'emerge -ep system' be sufficient?


--
Andrew Gaffney


-- [EMAIL PROTECTED] mailing list



Reply via email to