aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2018-06-04 00:31:05 -0400
committerB. Watson <yalhcru@gmail.com>2018-06-04 00:31:05 -0400
commit6d11e9a2f24c1df0b17c67c58ed281b61c5d2259 (patch)
treececf6acac6e2ceb04938ed641c9877dd7ba0dca0
parent2a6daf230e851869abd89675297275261ae498c1 (diff)
downloadsbostuff-6d11e9a2f24c1df0b17c67c58ed281b61c5d2259.tar.gz
sbosrcarch purge_mode fix, wip
-rwxr-xr-xsbosrcarch24
1 files changed, 16 insertions, 8 deletions
diff --git a/sbosrcarch b/sbosrcarch
index c6e3add..a8387dd 100755
--- a/sbosrcarch
+++ b/sbosrcarch
@@ -1228,7 +1228,7 @@ sub purge_mode {
$purgebytes = $purgefiles = 0;
- # pass 1
+ # pass 1; build list of all source files, by parsing all .info files
%keep_filenames = %keep_md5sums = (); # populated by the find():
find({wanted => \&purge_pass_1_wanted, no_chdir => 1}, ".");
@@ -1236,20 +1236,22 @@ sub purge_mode {
# warn "keep $_\n";
# }
- # pass 2
+ # pass 2: find all source files, delete any that aren't mentioned in any
+ # .info files (using list from above)
chdir($archivedir) or die "$archivedir: $!\n";
find({wanted => \&purge_pass_2_wanted, no_chdir => 1}, "by-name");
-# for(keys %keep_filenames) {
-# print "KEEP $_\n";
-# }
-
- # pass 3
if($rebuild) {
+ # pass 3: delete & recreate entire by-md5 tree
rmtree("by-md5");
print "Removed by-md5 tree, rebuilding\n";
find({wanted => \&rebuild_wanted, no_chdir => 1}, "by-name");
} else {
+ # pass 3: find all by-md5 files, delete any whose md5sums aren't found
+ # in any .info file.
+ find({wanted => \&purge_pass_3_wanted, no_chdir => 1}, "by-md5");
+
+ # pass 4: clean out (remove) any empty directories.
trim_post();
}
@@ -1290,6 +1292,12 @@ sub purge_pass_2_wanted {
#unlink $md5path;
}
+# helper for purge_mode, removes all files in by-md5
+# dirs that aren't listed in %keep_md5sums
+sub purge_pass_3_wanted {
+ print "purge_pass_3_wanted $_\n";
+}
+
sub rebuild_wanted {
return unless -f;
@@ -1531,7 +1539,7 @@ sub check_byname_wanted {
my $info = join("/", $sbogitdir, $category, $prgnam, $prgnam . ".info");
if(!-f $info) {
- print "$shortname extraneous: no info file for $prgnam/$category\n";
+ print "$shortname extraneous: no info file for $category/$prgnam\n";
$filecount--;
return;
}