dear finkers
in the fink_0.9.12-1 days there was the discussion about a fink cleanup
command, which was then put into fink_0.9.12.cvs on the 9th of june by
max horn (see the corresponding mail to this list). i made then a
suggestion (archive: 10th june) on how i would like a cleanup command to
look like.
now fink_0.10.0-1 is officially released, so i was wondering again how
far fink cleanup was implemented. after doing a fink cleanup i noted the
following:
ODDITIES:
1) some recent (installed) .debs (such as base-files-1.6-1 and a whole
lots of others were deleted)
2) some old .debs (such as less-358-4, fink-0.9.12-1) are still on the
system even though a newer version (in this case less-376-1 and
fink-0.10.0-1) is installed
POSSIBLE EXPLANATIONS:
for 1): (a shot in the blue) all (as far as i checked) these packages
were in unstable. still this does not mean that all my recent, installed
unstable .debs were deleted. can't really find an explanation here.
for 2): i noted the this happens when a .info file (for the same
version!) is present in both stable and unstable. i dare to say that
this is not my fault but due to selfupdate-cvs.
NOTES:
-i'm sorry if the perl script below answers all my questions: i didn't
study it that hard in the hope someone of you can give me an answer. so
the following assumptions might be wrong as well.
-i can't say anything about the sources, as i usually keep my src dir up
to date manually
mathias
################################
sub cmd_cleanup {
my ($pname, $package, $vo, $i, $file);
my (@to_be_deleted);
# TODO - add option that specify whether to clean up source, .debs, or
both
# TODO - add --dry-run option that prints out what actions would be
performed
# TODO - option that steers which file to keep/delete: keep all files
that
# are refered by any .info file; keep only those refered to by
the
# current version of any package; etc.
# Delete all .deb and delete all src? Not really needed, this
can be
# achieved each with single line CLI commands.
# Reset list of non-obsolete debs/source files
%deb_list = ();
%src_list = ();
# Iterate over all packages and collect the deb files, as well
# as all their source files.
foreach $pname (Fink::Package->list_packages()) {
$package = Fink::Package->package_by_name($pname);
foreach $vo ($package->get_all_versions()) {
# Skip dummy packages
next if $vo->{_type} eq "dummy";
# deb file
$file = $vo->get_debfile();
$deb_list{$file} = 1;
# all source files
if (defined $vo->{_sourcecount}) {
# will confuse readdir().
@to_be_deleted = ();
opendir(DIR, "$basepath/src") or die "Can't access $basepath/src: $!";
while (defined($file = readdir(DIR))) {
$file = "$basepath/src/$file";
# Skip all source files that are still used by some package
next if $src_list{$file};
push @to_be_deleted, $file;
}
closedir(DIR);
foreach $file (@to_be_deleted) {
# For now, do *not* remove directories - this could easily kill
# a build running in another process. In the future, we might want
# to add a --dirs switch that will also delete directories.
if (-f $file) {
unlink $file;
}
}
}
sub kill_obsolete_debs {
if (/^.*\.deb\z/s ) {
if (not $deb_list{$File::Find::name}) {
# Obsolete deb
unlink $File::Find::name;
}
}
}
sub kill_broken_links {
if(-l && !-e) {
# Broken link
unlink $File::Find::name;
}
}
################################
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Fink-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/fink-users