aboutsummaryrefslogtreecommitdiffstats
path: root/iurt2
diff options
context:
space:
mode:
authorFlorent Villard <warly@mandriva.com>2006-03-31 14:19:02 +0000
committerFlorent Villard <warly@mandriva.com>2006-03-31 14:19:02 +0000
commit275abdcc960d12efb338d298913b25ec7fea85ce (patch)
treef034607fdb365aa2cc4c02faf8b528047ca9f516 /iurt2
parent1677d04c53393c6bb42f20821ff64f8979f73bf9 (diff)
downloadiurt-275abdcc960d12efb338d298913b25ec7fea85ce.tar
iurt-275abdcc960d12efb338d298913b25ec7fea85ce.tar.gz
iurt-275abdcc960d12efb338d298913b25ec7fea85ce.tar.bz2
iurt-275abdcc960d12efb338d298913b25ec7fea85ce.tar.xz
iurt-275abdcc960d12efb338d298913b25ec7fea85ce.zip
try to load an older cache when the latest is corrupted
Diffstat (limited to 'iurt2')
-rwxr-xr-xiurt250
1 files changed, 40 insertions, 10 deletions
diff --git a/iurt2 b/iurt2
index 19314a3..676156a 100755
--- a/iurt2
+++ b/iurt2
@@ -46,7 +46,8 @@ $run{todo} = [ ];
# [ "one letter option", "long name option", "number of args (-X means ´at least X´)", "help text", "function to call", "log info"]
[ "", "$program_name", 0, "[--cache] [--concurrent-run] [--config foo value] [--warn] [--verbose integer]
[--copy_srpm] [--debug] [--distro] [--no_rsync] [--stop {p|c|i|l|b|a|s}]
- [--use-syste)-distrib] [--dir] [--help foo?] [--log filename] [--unionfs]
+ [--use-system-distrib] [--dir] [--help foo?] [--log filename] [--unionfs]
+ [--upload [--markrelease] [--source]] [--dir] [--help foo?] [--log filename] [--unionfs]
{--config_help |
--chroot --arch {i586|x86_64|ppc} --distro {cooker|2006.0|community/2006.0|...} } |
--rebuild {cooker|2006.0|community/2006.0|...} {i586|x86_64|ppc|...} {filename1.src.rpm} {filename2.src.rpm} ... {filenamen.src.rpm} }",
@@ -131,6 +132,9 @@ $run{todo} = [ ];
[ "m", "markrelease", 0, "",
"Mark SVN directory when uploading the packages",
sub { $run{markrelease} = 1 }, "Adding markrelease repsys option" ],
+ [ "s", "source", 0, "",
+ "Upload the source package as wells",
+ sub { $run{source_upload} = 1 }, "Setting source flag for upload" ],
], "[options]",
"Upload the rebuild packages",
sub { $run{upload} = 1 }, "Setting the upload flag" ],
@@ -195,6 +199,7 @@ my %config_usage = (
basesystem_media_root => { desc => 'Name of the media holding basesystem packages', default => sub { my ($config, $run) = @_; "$config->{repository}/$run{distro}/$run{my_arch}/" } },
basesystem_media => { desc => 'Where to find basesystem packages', default => 'main' },
cache_home => { desc => 'Where to store the cache files', default => "$HOME/.bugs" },
+ cache_min_size => { desc => 'Minimal size to consider a cache file valid', default => 1000000 },
distribution => { desc => 'Name of the packages distribution', default => 'Mandriva Linux' },
home => { desc => 'Home dir', default => $HOME },
install_chroot_binary => { desc => 'Tool used to create initial chroot', default => 'install-chroot-tar.sh' },
@@ -256,10 +261,27 @@ if ($run{chroot}) {
my $cachefile = "$config->{cache_home}/iurt.$run{distro_tag}.$run{my_arch}.cache";
$run{cachefile} = $cachefile;
my $cache;
+my $clear_cache = 1;
if (-f $cachefile && $run{use_cache}) {
print {$run{LOG}} "iurt: loading cache file $cachefile\n" if $run{verbose} > 1;
- $cache = do $cachefile or die "FATAL iurt: could not load cache $cachefile ($!)\n"
-} else {
+ $cache = do $cachefile or print "FATAL iurt: could not load cache $cachefile ($!)\n";
+ if (!$cache) {
+ opendir my $cache_dir, $config->{cache_home};
+ my $to_load;
+ foreach my $file (readdir $cache_dir) {
+ (my $date) = $file =~ /iurt\.$run{distro_tag}\.$run{my_arch}\.cache\.tmp\.(\d{8})/ or next;
+ if ($date > $to_load && -s "$config->{cache_home}/$file" > $config->{cache_min_size}) {
+ $to_load = $date;
+ $cachefile = "$config->{cache_home}/$file"
+ }
+ }
+ print "To load: $to_load\n";
+ $cache = do $cachefile or print "FATAL iurt: could not load cache $cachefile ($!)\n"
+ }
+ $clear_cache = 0 if $cache
+}
+
+if ($clear_cache) {
$cache = { rpm_srpm => {}, failure => {}, queue => {}, warning => {}, run => 1, needed => {}, no_unionfs => {} }
}
$run{cache} = $cache;
@@ -280,13 +302,11 @@ print {$run{LOG}} "iurt: will try to compile $to_compile packages\n" if $run{ver
exit if !$run{rebuild};
+my ($fulldate, $daydate) = get_date();
if ($run{use_cache}) {
$run{run} = $cache->{run};
$cache->{run}++
} else {
- my ($sec,$min,$hour,$mday,$mon,$year) = gmtime(time());
- $year += 1900;
- my $fulldate = sprintf "%4d%02d%02d%02d%02d%02d", $year, $mon+1, $mday, $hour, $min, $sec;
$run{run} = "0.$fulldate"
}
print {$run{LOG}} "iurt: using $run{run} as chroot extension\n" if $run{verbose} > 4;
@@ -743,13 +763,16 @@ sub process_queue {
# recheck if the package has not been uploaded in the meantime
my $rpms_dir = "$config->{repository}/$run->{distro}/$run->{my_arch}/media/$run->{media}/";
if (! -f "$rpms_dir/$rpm") {
- my $ok = copy "$dir/$rpm", "$config->{upload}/RPMS/";
+ my $ok = copy "$dir/$rpm", "$config->{upload}/$config->{extra_subdir}/RPMS/";
# try to keep the opportunity to prevent disk full
if (!$ok){
- print {$run{LOG}} "ERROR process_queue: cannot copy $dir/$rpm to $config->{upload}/RPMS/ ($!)\n";
+ print {$run{LOG}} "ERROR process_queue: cannot copy $dir/$rpm to $config->{upload}/$config->{extra_subdir}/RPMS/ ($!)\n";
next
}
}
+ if ($run->{upload_source}) {
+
+ }
unlink "$dir/$rpm";
$cache->{queue}{$srpm} = 1
}
@@ -778,7 +801,7 @@ sub dump_cache {
# 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" or die "FATAL iurt dump_cache: cannot open $filename.tmp";
+ open my $file, ">$filename.tmp.$daydate" or die "FATAL iurt dump_cache: cannot open $filename.tmp";
if (flock($file,LOCK_EX)) {
#seek($file, 0, 2);
if ($run{concurrent_run}) {
@@ -799,7 +822,7 @@ sub dump_cache {
$Data::Dumper::Terse = 1;
print $file Data::Dumper->Dump([ $cache ], [ "cache" ]);
unlink $filename;
- link "$filename.tmp", $filename;
+ link "$filename.tmp.$daydate", $filename;
flock($file,LOCK_UN)
} else {
print {$run{LOG}} "iurt: dumping_cache failed (could not lock cache file $cachefile $!)";
@@ -1161,3 +1184,10 @@ sub search_packages {
$to_compile
}
+sub get_date {
+ my ($sec,$min,$hour,$mday,$mon,$year) = gmtime(time());
+ $year += 1900;
+ my $fulldate = sprintf "%4d%02d%02d%02d%02d%02d", $year, $mon+1, $mday, $hour, $min, $sec;
+ my $daydate = sprintf "%4d%02d%02d", $year, $mon+1, $mday;
+ $fulldate, $daydate
+}