aboutsummaryrefslogtreecommitdiffstats
path: root/iurt2
diff options
context:
space:
mode:
authorFlorent Villard <warly@mandriva.com>2005-12-13 16:19:44 +0000
committerFlorent Villard <warly@mandriva.com>2005-12-13 16:19:44 +0000
commit0ff5bc3e24891ed2055f2694a9885a017b24df09 (patch)
treed99377428684f8d65e13f3984c31d6a5a7d0f894 /iurt2
parentbcbcc436d6464589bb35a7033e6b82a4bb5289e1 (diff)
downloadiurt-0ff5bc3e24891ed2055f2694a9885a017b24df09.tar
iurt-0ff5bc3e24891ed2055f2694a9885a017b24df09.tar.gz
iurt-0ff5bc3e24891ed2055f2694a9885a017b24df09.tar.bz2
iurt-0ff5bc3e24891ed2055f2694a9885a017b24df09.tar.xz
iurt-0ff5bc3e24891ed2055f2694a9885a017b24df09.zip
Use now a config file
Diffstat (limited to 'iurt2')
-rwxr-xr-xiurt2157
1 files changed, 66 insertions, 91 deletions
diff --git a/iurt2 b/iurt2
index 921b81a..1ff2f34 100755
--- a/iurt2
+++ b/iurt2
@@ -28,18 +28,6 @@ use URPM;
use File::NCopy qw(copy);
use MIME::Words qw(encode_mimewords);
use Fcntl ':flock';
-my $home = '/home/mandrake/';
-my $cache_home = "$home/.bugs/";
-my @supported_arch = ('i586', 'x86_64');
-my $upload = "$home/uploads/";
-my $local_home = '/export/home/mandrake';
-my $base_dir = $upload;
-my $check_queue = 0;
-if (@ARGV[0] eq '--check_queue') {
- $check_queue = 1;
- shift @ARGV;
- $base_dir = shift @ARGV;
-}
my $distro_version = shift @ARGV;
my $distro_tag = $distro_version;
@@ -48,25 +36,38 @@ my $my_arch = shift @ARGV;
my $media = shift @ARGV;
my @special_srpm_dir = @ARGV;
-my $unwanted_packages = '^monotone-';
-
$my_arch or usage();
-if ($check_queue) {
- -d $base_dir or usage("$base_dir does not exist");
+
+my $HOME = $ENV{HOME};
+my $configfile = "$HOME/.iurt.$distro_tag.conf";
+print "iurt: loading config file $configfile\n";
+my $config;
+if (-f $configfile) {
+ $config = do $configfile
} else {
- $base_dir .= $distro_version;
- $base_dir =~ s/community//g;
- if ($distro_version ne 'cooker') {
- if ($media ne 'main') {
- $base_dir .= "/$media"
- }
- } elsif ($media eq 'contrib') {
- $base_dir = "$upload/contrib"
+ $config = {}
+}
+
+$config->{home} ||= $HOME;
+$config->{cache_home} ||= "$HOME/.bugs";
+$config->{supported_arch} ||= ['i586', 'x86_64'];
+$config->{upload} ||= "$HOME/uploads/";
+$config->{local_home} ||= "$HOME";
+$config->{base_dir} ||= "$HOME/uploads/";
+
+$config->{base_dir} .= $distro_version;
+$config->{base_dir} =~ s/community//g;
+if ($distro_version ne 'cooker') {
+ if ($media ne 'main') {
+ $config->{base_dir} .= "/$media"
}
- -d $base_dir or usage("$base_dir does not exist")
+} elsif ($media eq 'contrib') {
+ $config->{base_dir} = "$config->{upload}/contrib"
}
-my $pidfile = "$cache_home/iurt.$distro_tag.$my_arch.pid";
+-d $config->{base_dir} or usage("$config->{base_dir} does not exist");
+
+my $pidfile = "$config->{cache_home}/iurt.$distro_tag.$my_arch.pid";
open my $lock, "$pidfile.lock";
flock($lock,LOCK_EX);
if (-f $pidfile) {
@@ -100,19 +101,19 @@ close $PID;
flock($lock,LOCK_UN);
close $lock;
-my $cache = "$cache_home/iurt.$distro_tag.cache";
-print "iurt: loading cache file $cache\n";
-eval { require $cache };
-$::rpm_srpm ||= {};
-$::failure ||= {};
-$::queue ||= {};
-$::warning ||= {};
-$::run ||= {};
+my $cachefile = "$config->{cache_home}/iurt.$distro_tag.cache";
+print "iurt: loading cache file $cachefile\n";
+my $cache;
+if (-f $cachefile) {
+ $cache = do $cachefile
+} else {
+ $cache = { rpm_srpm => {}, failure => {}, queue => {}, warning => {}, run => {} }
+}
my %big;
my %srpm_version;
my @wrong_rpm;
-foreach my $arch (@supported_arch) {
+foreach my $arch (@{$config->{supported_arch}}) {
my $rpms_dir = "/mnt/BIG/dis/$distro_version/$arch/media/$media/";
print "iurt: checking current packages in $rpms_dir\n";
opendir my $rpmdir, $rpms_dir or next;
@@ -120,39 +121,17 @@ foreach my $arch (@supported_arch) {
my ($rarch, $srpm) = update_srpm($rpms_dir, $rpm);
$rarch or next;
$big{$rpm} = 1;
- $::queue->{$srpm}{$arch} = 1;
- $::queue->{$srpm}{$rarch} = 1;
+ $cache->{queue}{$srpm}{$arch} = 1;
+ $cache->{queue}{$srpm}{$rarch} = 1;
check_version($srpm)
}
closedir $rpmdir
}
-if ($check_queue) {
- my $dir = "$base_dir/build/RPMS/";
- opendir my $rpmdir, $dir or next;
-
- print "iurt: checking upload queue in $dir\n";
- foreach my $rpm (readdir $rpmdir) {
- $rpm =~ /\.rpm$/ or next;
- if ($big{$rpm}) {
- print "iurt: cleaning $rpm\n";
- unlink "$dir/$rpm";
- next
- }
- my ($arch, $srpm) = update_srpm($dir, $rpm);
- $arch or next;
- $::queue->{$srpm}{$arch} = 1;
- check_version($srpm)
- }
- closedir $rpmdir;
-
-}
-
my %maint;
my @todo;
--d "$base_dir/build/$my_arch" or mkdir "$base_dir/build/$my_arch";
-push @special_srpm_dir, "$base_dir/build/SRPMS/" if $check_queue;
+-d "$config->{base_dir}/build/$my_arch" or mkdir "$config->{base_dir}/build/$my_arch";
my $clean;
my %rep;
my %done_rpm;
@@ -170,11 +149,11 @@ foreach my $dir ("/mnt/BIG/dis/$distro_version/SRPMS/$media/", @special_srpm_dir
$srpm = $1
}
$srpm =~ /(.*)-[^-]+-[^-]+\.src\.rpm$/ or next;
- if ($srpm =~ /$unwanted_packages/) { next }
+ if ($srpm =~ /$config->{unwanted_packages}/) { next }
my $ok = 1;
if (check_version($srpm)) {
- defined $::failure->{$srpm} && defined $::failure->{$srpm}{$my_arch} and next;
- if (!$::queue->{$srpm}{$my_arch} && !$::queue->{$srpm}{noarch}) {
+ defined $cache->{failure}{$srpm} && defined $cache->{failure}{$srpm}{$my_arch} and next;
+ if (!$cache->{queue}{$srpm}{$my_arch} && !$cache->{queue}{$srpm}{noarch}) {
my $hdr = rpm2header("$dir/$srpm");
check_arch($hdr) and next;
my $changelog = $hdr->queryformat("%{CHANGELOGNAME}");
@@ -183,8 +162,8 @@ foreach my $dir ("/mnt/BIG/dis/$distro_version/SRPMS/$media/", @special_srpm_dir
print "iurt: will try to compile $srpm\n";
push @todo, [ $dir , $srpm ]
}
- foreach my $arch (@supported_arch) {
- $ok &&= $::queue->{$srpm}{$arch} || $::queue->{$srpm}{noarch}
+ foreach my $arch (@{$config->{supported_arch}}) {
+ $ok &&= $cache->{queue}{$srpm}{$arch} || $cache->{queue}{$srpm}{noarch}
}
}
if ($clean && ($rep{$srpm} || $ok)) {
@@ -198,18 +177,20 @@ foreach my $dir ("/mnt/BIG/dis/$distro_version/SRPMS/$media/", @special_srpm_dir
closedir $rpmdir
}
-my $run = $::run->{$distro_tag}{$my_arch}++;
dump_cache();
if (!@todo) {
print "iurt: nothing to do\n";
+ unlink $pidfile;
exit
}
+my $run = $cache->{run}{$distro_tag}{$my_arch}++;
+
print "iurt: checking basesystem tar\n";
-my $chroot = "$local_home/chroot";
+my $chroot = "$config->{local_home}/chroot";
my $chroot_tar = "$chroot-$distro_tag.$my_arch.tar.gz";
perform_command("sudo ~warly/files/cvs//mdk/soft/rpm-rebuilder/install-chroot-tar.sh cooker /mnt/BIG/distrib/$distro_version/$my_arch/media/main/ $chroot_tar $chroot 501 basesystem rpm-build",
mail => 'maintainers@mandriva.com',
@@ -217,9 +198,9 @@ perform_command("sudo ~warly/files/cvs//mdk/soft/rpm-rebuilder/install-chroot-ta
hash => 'chroot_inititialization',
die => 1);
-my $local_spool = "$local_home/iurt/$distro_tag/$my_arch";
-if (!-d "$local_home/iurt/$distro_tag/") {
- mkdir "$local_home/iurt/$distro_tag";
+my $local_spool = "$config->{local_home}/iurt/$distro_tag/$my_arch";
+if (!-d "$config->{local_home}/iurt/$distro_tag/") {
+ mkdir "$config->{local_home}/iurt/$distro_tag";
if (!-d $local_spool) {
mkdir $local_spool;
mkdir "$local_spool/log"
@@ -287,7 +268,7 @@ foreach my $t (@todo) {
log => "$local_spool/log/",
error_regexp => 'rror.*ailed|Bad exit status|RPM build error',
freq => 1) && !glob "$chroot/home/builder/rpm/RPMS/*/*.rpm") {
- $::failure->{$srpm}{$my_arch} = 1;
+ $cache->{failure}{$srpm}{$my_arch} = 1;
next
}
if (!perform_command("sudo urpmi --root $chroot --no-verify-rpm --auto $chroot/home/builder/rpm/RPMS/*/*.rpm",
@@ -298,7 +279,7 @@ foreach my $t (@todo) {
freq => 1,
error_regexp => 'unable to access',
log => "$local_spool/log/")) {
- $::failure->{$srpm}{$my_arch} = 1;
+ $cache->{failure}{$srpm}{$my_arch} = 1;
next
}
system("cp $chroot/home/builder/rpm/RPMS/*/*.rpm $local_spool") and print "ERROR: could not copy rpm files from $chroot/home/builder/rpm/RPMS/ to $local_spool ($!)\n";
@@ -313,7 +294,7 @@ dump_cache();
print "ERROR iurt: RPM with a wrong SRPM name\n" if @wrong_rpm;
if (open my $file, ">$local_spool/log/wrong_srpm_names.log") {
foreach (@wrong_rpm) {
- print $file "$_->[1] -> $_->[0] (", $::rpm_srpm{$_->[1]},")\n";
+ print $file "$_->[1] -> $_->[0] (", $cache->{rpm_srpm}{$_->[1]},")\n";
}
}
@@ -334,30 +315,24 @@ sub usage {
iurt [options] <distro version> <arch> <media>
e.g. iurt community/2006.0 x86_64 main
- options:
- --check_queue <queue base dir>
- e.g iurt --check_queue $home/uploads/contrib/build/ cooker x86_64 contrib
-
-
";
exit
}
sub process_queue {
- my $dir = "$local_home/iurt/$distro_tag/$my_arch";
- #my $dir = "$base_dir/RPMS/";
+ my $dir = "$config->{local_home}/iurt/$distro_tag/$my_arch";
opendir my $rpmdir, $dir or next;
foreach my $rpm (readdir $rpmdir) {
my ($rarch, $srpm) = update_srpm($dir, $rpm);
$rarch or next;
# try to keep the opportunity to prevent disk full
- my $ok = copy "$dir/$rpm", "$base_dir/RPMS/";
+ my $ok = copy "$dir/$rpm", "$config->{base_dir}/RPMS/";
if (!$ok){
- print "ERROR process_queue: cannot copy $dir/$rpm to $base_dir/RPMS/ ($!)\n";
+ print "ERROR process_queue: cannot copy $dir/$rpm to $config->{base_dir}/RPMS/ ($!)\n";
next
}
unlink "$dir/$rpm";
- $::queue->{$srpm}{$rarch} = 1
+ $cache->{queue}{$srpm}{$rarch} = 1
}
closedir $rpmdir;
}
@@ -365,25 +340,25 @@ sub process_queue {
sub update_srpm {
my ($dir, $rpm) = @_;
my ($arch) = $rpm =~ /([^\.]+)\.rpm$/ or return 0;
- my $srpm = $::rpm_srpm->{$rpm};
+ my $srpm = $cache->{rpm_srpm}{$rpm};
if (!$srpm) {
my $hdr = rpm2header("$dir/$rpm");
$hdr or return 0;
$srpm = $hdr->queryformat("%{SOURCERPM}");
- $::rpm_srpm->{$rpm} = $srpm
+ $cache->{rpm_srpm}{$rpm} = $srpm
}
$srpm = fix_srpm_name($srpm, $rpm);
$arch, $srpm
}
sub dump_cache {
- my $filename = $cache;
+ my $filename = $cachefile;
open my $file, ">$filename.tmp" or die "FATAL iurt dump_cache: cannot open $filename.tmp";
flock($file,LOCK_EX);
seek($file, 0, 2);
$Data::Dumper::Indent = 1;
- print $file Data::Dumper->Dump([ $::rpm_srpm, $::failure, $::queue, $::warning, $::run ], [ "::rpm_srpm", "::failure", "::queue", "::warning", "::run" ]);
- print $file "1";
+ $Data::Dumper::Terse = 1;
+ print $file Data::Dumper->Dump([ $cache ], [ "cache" ]);
unlink $filename;
link "$filename.tmp", $filename;
flock($file,LOCK_UN)
@@ -429,7 +404,7 @@ sub fix_srpm_name {
my $old_srpm = $srpm;
if ($srpm =~ s/^lib64/lib/){
push @wrong_rpm, [ $old_srpm, $rpm ];
- $::rpm_srpm->{$rpm} = $srpm
+ $cache->{rpm_srpm}{$rpm} = $srpm
}
$srpm
}
@@ -460,13 +435,13 @@ sub perform_command {
# didn't
if ($? || $opt{error_regexp} && $output =~ /$opt{error_regexp}/) {
if ($opt{mail}) {
- if ($::warning->{$opt{hash}}{$my_arch}{$opt{mail}} % $opt{freq}) {
+ if ($cache->{warning}{$opt{hash}}{$my_arch}{$opt{mail}} % $opt{freq}) {
sendmail($opt{mail}, $opt{cc} , $opt{error} , $output, 0, 0);
} else {
sendmail('warly@mandriva.com', '' , $opt{error}, $output, 0, 0);
}
}
- $::warning->{$opt{hash}}{$my_arch}{$opt{mail}}++;
+ $cache->{warning}{$opt{hash}}{$my_arch}{$opt{mail}}++;
print "\n$output\n";
die "FATAL iurt: $opt{error}." if $opt{die};
return 0