cvsup to 5.3?
Erik Norgaard
norgaard at locolomo.org
Wed Nov 24 13:50:26 PST 2004
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
-------------- next part --------------
#!/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;
};
};
};
More information about the freebsd-questions
mailing list