From c24757c923841de1901501b227d1411eafefc4e4 Mon Sep 17 00:00:00 2001 From: Pascal Terjan Date: Mon, 10 Dec 2012 20:50:42 +0000 Subject: Get rid of cache --- lib/Iurt/Config.pm | 85 ------------------------------------------------------ 1 file changed, 85 deletions(-) (limited to 'lib/Iurt/Config.pm') diff --git a/lib/Iurt/Config.pm b/lib/Iurt/Config.pm index 173ed9e..c793cba 100644 --- a/lib/Iurt/Config.pm +++ b/lib/Iurt/Config.pm @@ -13,8 +13,6 @@ our @EXPORT = qw( config_usage config_init get_date - dump_cache - dump_cache_par get_maint get_date get_prefix @@ -123,89 +121,6 @@ sub get_package_prefix { "$prefix1$prefix2"; } -=head2 dump_cache($run, $config) - -Create a string based on the current date and time -I<%run> is the current running options -Dump the cache - -=cut - -sub dump_cache { - my ($run) = @_; - my $program_name = $run->{program_name}; - my $filename = $run->{cachefile}; - my $cache = $run->{cache}; - my $daydate = $run->{daydate}; - open my $file, ">$filename.tmp.$daydate" or die "FATAL $program_name dump_cache: cannot open $filename.tmp"; - $Data::Dumper::Indent = 1; - $Data::Dumper::Terse = 1; - print $file Data::Dumper->Dump([ $cache ], [ "cache" ]); - # flock does not work on network files and lockf seems to fail too - plog('DEBUG', "locking to dump the cache in $filename"); - if (-f "$filename.lock") { - plog('ERROR', 'ERROR: manual file lock exist, do not save the cache'); - } else { - open my $lock, ">$filename.lock"; - print $lock $$; - close $lock; - unlink $filename; - link "$filename.tmp.$daydate", $filename; - unlink "$filename.lock"; - } -} - -# FIXME need to merge with the simpler dump_cache -sub dump_cache_par { - my ($run) = @_; - my $filename = $run->{cachefile}; - my $cache = $run->{cache}; - my $daydate = $run->{daydate}; - - # Right now there are no mechanism of concurrent access/write to the cache. There is - # on global lock for one iurt session. A finer cache access would allow several iurt running - # but the idea is more to have a global parrallel build than several local ones. - return if $run->{debug} || !$run->{use_cache}; - open my $file, ">$filename.tmp.$daydate" or die "FATAL iurt dump_cache: cannot open $filename.tmp"; - if ($run->{concurrent_run}) { - plog('DEBUG', "merging cache"); - my $old_cache; - if (-f $filename) { - plog('DEBUG', "loading cache file $filename"); - $old_cache = eval(cat_($filename)); - - foreach my $k ('rpm_srpm', 'failure', 'queue', 'needed', 'warning', 'buildrequires') { - foreach my $rpm (%{$old_cache->{$k}}) { - $cache->{$k}{$rpm} ||= $old_cache->{$k}{$rpm}; - } - } - } - # $cache = { rpm_srpm => {}, failure => {}, queue => {}, warning => {}, run => 1, needed => {} } - } - $Data::Dumper::Indent = 1; - $Data::Dumper::Terse = 1; - print $file Data::Dumper->Dump([ $cache ], [ "cache" ]); - # flock does not work on network files and lockf seems to fail too - my $status = 1; #File::lockf::lock($file); - if (!$status) { - unlink $filename; - link "$filename.tmp.$daydate", $filename; - File::lockf::ulock($file); - } else { - plog('WARN', "WARNING: locking the cache file $filename failed (status $status $!), try to lock manually"); - if (-f "$filename.lock") { - plog('ERROR', "ERROR: manual file lock exist, do not save the cache"); - } else { - open my $lock, ">$filename.lock"; - print $lock $$; - close $lock; - unlink $filename; - link "$filename.tmp.$daydate", $filename; - unlink "$filename.lock"; - } - } -} - sub get_maint { my ($run, $srpm) = @_; my ($srpm_name) = $srpm =~ /(.*)-[^-]+-[^-]+\.[^.]+$/; -- cgit v1.2.1