From a3fea33120c60ff3e512467c7d9f562a294e6107 Mon Sep 17 00:00:00 2001 From: freesource Date: Sat, 13 Oct 2001 05:28:42 +0000 Subject: [PATCH] This adds the no_rebuilddb Configuration option, because changes in the status are now first diffed, then if a change is found --db --check is ran, and then --rebuilddb (100% stable). This is nice for programs like make-debian-x11. --- SWIM/Conf.pm | 6 +++++- swim | 25 +++++++++++++++++++++++++ swimrc | 13 +++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/SWIM/Conf.pm b/SWIM/Conf.pm index b47a3af..971097d 100644 --- a/SWIM/Conf.pm +++ b/SWIM/Conf.pm @@ -27,7 +27,7 @@ use Exporter; $sort $md5sum $zcat $tar $grep $gzip $fastswim $slowswim $longswim $mount $umount $mke2fs $copy $pager $base $pwd $parent $library $splt $mv $imswim $swim_conf $debug $port $timeout - $firewall $passive $apt_sources $HISTORY $alt); + $firewall $passive $apt_sources $HISTORY $alt $no_rebuilddb); %EXPORT_TAGS = ( Path => [ qw($tmp $parent $base $library $default_directory) ], Deb => [ qw($pwd $dpkg_deb $ar $tar $grep $tmp $md5sum $cat $mv) ], @@ -53,6 +53,10 @@ $my_number = 23; # Just like a shell, you can keep a history of whatever length you want. $HISTORY = 10; +# Set to 1 if you don't want the swim to automatically rebuild its +# databases everytime there is a change. +$no_rebuilddb = 0; + # For not-installed: # This part supplies the default value for --arch. # diff --git a/swim b/swim index a19b3c7..3bca21e 100755 --- a/swim +++ b/swim @@ -784,6 +784,31 @@ sub command { initndb(\%commands); } + # Automatic rebuilding - assuming the first time + if (!-f "$main::home$parent$library/status") { + system "cp -fa $parent$library/status $main::home$parent$library"; + } + else { + if ( $no_rebuilddb == 0 ) { + my $diff = `diff $parent$library/status $main::home$parent$library/status`; + if ( $diff ) { + $commands{"check"} = 1; + require SWIM::DB; + SWIM::DB->import(qw(db)); + db(\%commands); + require SWIM::DB_Init; + + $commands{"rebuilddb"} = 1; + SWIM::DB_Init->import(qw(database)); + database(\%commands); + + system "cp -fa $parent$library/status $main::home$parent$library"; + } + + } + + } + # *deb packages -p querys can be handled separately because they a particular to # *debs. diff --git a/swimrc b/swimrc index f160697..ecf60a2 100644 --- a/swimrc +++ b/swimrc @@ -10,6 +10,19 @@ $package_tool = "/usr/bin/dpkg"; # Do you have apt installed? $apt = "yes"; +# No automatic rebuilding of databases. +# Databases will automatically by rebuilt if any differences are found +# in the status. Although --db could be used to update the changes +# for each particular packages, newer versions of DB_File have introduced +# bugs; --rebuilddb is know to be 100% stable. On some systems +# which are slow, or have massive installations this feature may be +# annoying. If you decide to turn it off, remember to --rebuilddb your +# databases from time to time, or run it as a cron job. Programs like +# make-debian-x11 will then be guaranteed to have correct information about +# your system. + +$no_rebuilddb = 0; + # Pick one. #$architecture = "alpha"; #$architecture = "arm";