Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 24 Nov 2004 22:50:02 +0100
From:      Erik Norgaard <norgaard@locolomo.org>
To:        Damien Hull <dhull@digitaloverload.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: cvsup to 5.3?
Message-ID:  <41A5020A.5020902@locolomo.org>
In-Reply-To: <1101332442.4361.2.camel@tower1.digitaloverload.local>
References:  <1101328720.4244.6.camel@tower1.digitaloverload.local> <41A4F8C3.1090701@locolomo.org> <1101332442.4361.2.camel@tower1.digitaloverload.local>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------040601050009070802090207
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Damien Hull wrote:
> Looks like I didn't do a "make clean" when I installed kde. I know have
> 3.5G in /usr. 
> 
> Is there an easy way to find out which ports need to have "make clean"
> done?
> 

I have a script: cleans up ports with a "work" dir and removes distfiles 
that no port is refering to. Not perfect - it doesn't descend deeply 
into distfiles directories. Also, I'd like to add the posibility of 
removing old packages if you "make package".

But, it works good enough :-)

you can also "make NOCLEANDEPENDS=yes clean" in /usr/ports, but this 
won't remove old distfiles. If you do not use NOCLEANDEPENDS=yes, make 
clean will clean out dependencies for each port which will do multimple 
cleans on a lot of ports. Takes extra time.

Cheers, Erik
-- 
Ph: +34.666334818                                  web: www.locolomo.org
S/MIME Certificate: http://www.locolomo.org/crt/2004071206.crt
Subject ID:  A9:76:7A:ED:06:95:2B:8D:48:97:CE:F2:3F:42:C8:F2:22:DE:4C:B9
Fingerprint: 4A:E8:63:38:46:F6:9A:5D:B4:DC:29:41:3F:62:D3:0A:73:25:67:C2

--------------040601050009070802090207
Content-Type: text/plain;
 name="ports-clean.pl"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="ports-clean.pl"

#!/usr/bin/perl -w
#
# $Id$
#
# This script cleans up the ports tree removing work-directories and
# moving created packages to /var/pkg

use strict;
use warnings;

#
use File::Copy;
#
my $ports_dir = "/usr/ports";               # Ports directory to clean
my $pkg_dir   = "";                         # Directory to store packages

my %distfile;

foreach my $group (glob("$ports_dir/*")) {
  next unless -d $group;                    # Can't descend into a file

  # skip ports special directories
  next if $group =~ /$ports_dir\/(distfiles|Mk|Templates|Tools)/;

  print "Descending into $group:\n";
  foreach my $port (glob("$group/*")) {

    if (-d "$port/work") { # Clean up ports work directory.
      print "   Cleaning up $port\n";
      system("make -C $port NOCLEANDEPENDS=yes clean")
        and warn "   Unable to cleanup $port: $!";
    };

    if (-f "$port/distinfo") { # Read distinfo to clean up distfiles dir
      open(DIST,"<","$port/distinfo")
        or warn "   Failed reading $port/distinfo: $!\n" and next;
      while(my $line = <DIST>) {
        if ($line =~ /MD5 \((.*?)\)\s*=\s*(\w+)/) {
          $distfile{$1} = $2;
        }
      }
      close(DIST);
    };

    if ($pkg_dir) {
      foreach my $pkg (glob("$port/*.tgz"), glob("$port/*.tbz")) {
        print "   Moving package to $pkg_dir:\n";
        # Do stuff
      }
    };
  };
};

# We could recurse deep, but there are no sub-sub directories.
print "Cleaning up distfiles directory: \n";
foreach my $file (glob("$ports_dir/distfiles/*")) {
  if (-d $file) {
    foreach my $subfile (glob("$file/*")) {
      -d $subfile and warn "Found deep directory: $subfile\n" and next;
      my ($base) = $subfile =~ /$ports_dir\/distfiles\/(.*)/;
      if (! defined $distfile{$base} ) {
        print "Removing old distfile: $base\n";
        unlink $subfile;
      };
    }
  }
  else { # Remove unknown source files
    my ($base) = $file =~ /$ports_dir\/distfiles\/(.*)/;
    if (! defined $distfile{$base} ) {
      print "Removing old distfile: $base\n";
      unlink $file;
    };
  };
};

--------------040601050009070802090207--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?41A5020A.5020902>