aboutsummaryrefslogtreecommitdiffstats
path: root/iurt2
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mandriva.org>2006-11-28 22:30:47 +0000
committerThierry Vignaud <tv@mandriva.org>2006-11-28 22:30:47 +0000
commitc652e4a97a590c9886986f82908acc5758f3c2a2 (patch)
tree1ba79f9f533623c076c16d5a8b3e790e37b014df /iurt2
parentd7e3db7a643cfa90cd21b4c08bce7a55a877b427 (diff)
downloadiurt-c652e4a97a590c9886986f82908acc5758f3c2a2.tar
iurt-c652e4a97a590c9886986f82908acc5758f3c2a2.tar.gz
iurt-c652e4a97a590c9886986f82908acc5758f3c2a2.tar.bz2
iurt-c652e4a97a590c9886986f82908acc5758f3c2a2.tar.xz
iurt-c652e4a97a590c9886986f82908acc5758f3c2a2.zip
(check_media) don't reuse $1, $2, $3 from a previous match if the
regex failled
Diffstat (limited to 'iurt2')
-rwxr-xr-xiurt292
1 files changed, 55 insertions, 37 deletions
diff --git a/iurt2 b/iurt2
index 6fc4102..8c40de2 100755
--- a/iurt2
+++ b/iurt2
@@ -195,7 +195,7 @@ $run{todo} = [ ];
}
if (check_arch($_, $run{my_arch})) {
- plog("force build for $2 (from $1)");
+ plog('DEBUG', "force build for $2 (from $1)");
push @{$run{todo}}, [ $path, $srpm, 1 ]
} else {
plog("ERROR: $_ could not be build on $run{my_arch}, ignored.");
@@ -257,13 +257,14 @@ open(my $LOG, ">&STDERR");
$run{LOG} = $LOG;
print "$program_name version $VERSION\n";
-plog_init($program_name, $LOG, $run{verbose});
+#plog_init($program_name, $LOG, $run{verbose}, 1);
+plog_init($program_name, $LOG, 7, 1); # CM: hardcoded for now, will fix ASAP
my $todo = parseCommandLine($program_name, \@ARGV, \@params);
@ARGV and usage($program_name, \@params, "@ARGV, too many arguments");
foreach my $t (@$todo) {
- plog(6, "$t->[2]");
- &{$t->[0]}(@{$t->[1]}) or plog("ERROR: $t->[2]");
+ plog('DEBUG', "$t->[2]");
+ &{$t->[0]}(@{$t->[1]}) or plog('ERR', "$t->[2]");
}
$run{distro_tag} = $run{distro};
@@ -274,7 +275,7 @@ chomp $real_arch;
my $HOME = $ENV{HOME};
my $configfile = "$HOME/.iurt.$run{distro_tag}.conf";
-plog(2, "loading config file $configfile");
+plog('DEBUG', "load config: $configfile");
my $config;
if (-f $configfile) {
$config = do $configfile
@@ -414,7 +415,8 @@ my %config_usage = (
desc => 'Name of the packages vendor',
default => 'Mandriva'
},
- );
+);
+
config_usage() if $run{config_usage};
$run{my_arch} or usage($program_name, \@params, "no architecture given (media $run{media}, run{my_arch} $run{my_arch}, todo @{$run{todo}})");
if (!$arch_comp{$real_arch}{$run{my_arch}}) {
@@ -463,21 +465,26 @@ if ($config->{local_spool}) {
$local_spool = "$config->{local_upload}/iurt/$run{distro_tag}/$run{my_arch}/$run{media}/"
}
-plog(5, "using $local_spool as local spooler");
+plog('INFO', "local spool: $local_spool");
if (!-d "$local_spool/log") {
- plog(5, "creating local spool $local_spool");
- mkpath("$local_spool/log") or die "FATAL $program_name: could not create local spool dir $local_spool ($!)"
+ plog('DEBUG', "creating local spool $local_spool");
+ mkpath("$local_spool/log")
+ or die "FATAL: could not create local spool dir $local_spool ($!)"
}
$run{local_spool} = $local_spool;
my $cache;
my $clear_cache = 1;
if (-f $cachefile && $run{use_cache}) {
- plog(2, "loading cache file $cachefile");
- $cache = do $cachefile or print "FATAL $program_name: could not load cache $cachefile ($!)\n";
+ plog('INFO', "loading cache file $cachefile");
+
+ $cache = do $cachefile
+ or plog('ERR', "FATAL: could not load cache $cachefile ($!)");
+
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}\.$run{media}\.cache\.tmp\.(\d{8})/ or next;
if ($date > $to_load && -s "$config->{cache_home}/$file" > $config->{cache_min_size}) {
@@ -485,8 +492,10 @@ if (-f $cachefile && $run{use_cache}) {
$cachefile = "$config->{cache_home}/$file"
}
}
- plog("loading alternate cache file $cachefile");
- $cache = do $cachefile or print "FATAL $program_name: could not load cache $cachefile ($!)\n"
+
+ plog('NOTIFY', "loading alternate cache file $cachefile");
+ $cache = do $cachefile
+ or plog('ERR', "FATAL: could not load cache $cachefile ($!)");
}
$clear_cache = 0 if $cache
}
@@ -520,7 +529,7 @@ $run{to_compile} = $to_compile;
dump_cache_par(\%run);
-plog(2, "will try to compile $to_compile packages");
+plog("Packages to build: $to_compile");
my ($fulldate, $daydate) = get_date();
if ($run{use_cache}) {
@@ -531,14 +540,15 @@ if ($run{use_cache}) {
$run{run} = "0.$fulldate"
}
$run{daydate} = $daydate;
-plog(5, "using $run{run} as chroot extension");
+plog('DEBUG', "using $run{run} as chroot extension");
$run{user} = $ENV{SUDO_USER} || $ENV{USER};
$run{uid} = getpwnam $run{user};
-plog(3, "using local user $run{user}, id $run{uid}");
+plog('DEBUG', "using local user $run{user}, id $run{uid}");
my $luser = $run{user} || 'builder';
-check_sudo_access() or die "FATAL $program_name: you need to have sudo access to run $program_name";
+check_sudo_access()
+ or die "FATAL: you need to have sudo access to run $program_name";
my $debug_tag = '_debug' if $run{debug};
$run{debug_tag} = $debug_tag;
@@ -560,11 +570,13 @@ my $union_id = 1;
$run{unionfs_tmp} = $run{unionfs};
my $chroot_name = "chroot_$run{distro_tag}$debug_tag";
my $chroot_tmp = "$config->{local_home}/chroot_tmp";
+
if (!-d $chroot_tmp) {
mkdir $chroot_tmp
} else {
remove_chroot(\%run, $chroot_tmp, \&clean_all_chroot_tmp, $chroot_name);
}
+
$chroot_tmp = "$config->{local_home}/chroot_tmp/$run{user}";
if (!-d $chroot_tmp) {
mkdir $chroot_tmp
@@ -588,12 +600,12 @@ if ($run{no_compile} || !@{$run{todo}} && !$run{debug} && !$run{shell} && !$run{
exit
}
-plog("running with pid $$");
+plog('DEBUG', "running with pid $$");
$run{prefix} = get_prefix($luser);
my $df = df $home;
if ($df->{per} >= 99) {
- die "FATAL $program_name: not enough space on the filesystem, only $df->{bavail} KB on $home, full at $df->{per}%"
+ die "FATAL: not enough space on the filesystem, only $df->{bavail} KB on $home, full at $df->{per}%"
}
if ($run{shell}) {
@@ -609,7 +621,7 @@ if ($run{shell}) {
$urpmi->install_packages('chroot', $chroot_tmp, $local_spool,\%pack_provide, 'configure', "[ADMIN] installation of urpmi and sudo failed in the chroot $run{my_arch}", { check => 1, maintainer => $config->{admin} }, 'urpmi', 'sudo') or die "FATAL $program_name: could not add urpmi and sudo in the chroot";
add_sudoers(\%run, $chroot_tmp, $luser);
if ($run{shell}) {
- plog("dumping to a chrooted shell into $chroot_tmp");
+ plog('NOTIFY', "dumping to a chrooted shell into $chroot_tmp");
exec "$sudo chroot $chroot_tmp /bin/su $luser -c \"PS1='[\[\033[01;33m\]iurt $run{distro} \[\033[00m\]\u@\h \W]\$ ' bash\"";
die "FATAL $program_name: could not exec chroot to $chroot_tmp ($!)"
}
@@ -634,13 +646,13 @@ my $s = sub {
dump_cache_par(\%run);
$Data::Dumper::Indent = 0;
$Data::Dumper::Terse = 1;
- plog(6, "Running environment:\n", Data::Dumper->Dump([\%run]), "\n");
- plog(0, "Configuration:\n", Data::Dumper->Dump([$config]),"\n");
+ plog("Running environment:\n", Data::Dumper->Dump([\%run]), "\n");
+ plog("Configuration:\n", Data::Dumper->Dump([$config]),"\n");
}
exit
};
-$SIG{TERM} = $s;
-$SIG{INT} = $s;
+#$SIG{TERM} = $s;
+#$SIG{INT} = $s;
$run{main} = 1;
my $rebuild;
@@ -672,7 +684,7 @@ do {
check_version($srpm, \%srpm_version) or next;
if ($run{debug}) { $run{debug}++ == 2 and exit }
$done++;
- plog("packages $srpm [$done/$to_compile]");
+ plog('NOTIFY', "Build package $srpm [$done/$to_compile]");
# FIXME unfortunately urpmi stalls quite often
my $retry = 0;
@@ -702,7 +714,7 @@ retry:
}
#($maintainer, $cc) = ($config->{admin},'');
- plog(1, "adding local user $luser into $chroot_tmp...");
+ plog('DEBUG', "creating user $luser in chroot");
add_local_user($chroot_tmp, \%run, $config, $luser, $run{uid}) or next;
my $old_srpm = $srpm;
@@ -725,7 +737,7 @@ retry:
# only create the log dir for the new srpm
mkdir "$local_spool/log/$srpm";
- plog(1, "installing build dependencies of $srpm...");
+ plog("installing build dependencies");
my $path_srpm = "$chroot_tmp/home/$luser/rpm/SRPMS/";
# on x86_64 the rpm database is getting corrupted and sometimes
@@ -738,6 +750,11 @@ retry:
next;
}
+ # CM: Hack to allow resolution of localhost inside the chroot (for
+ # e.g. libneon). This will be properly done elsewhere later
+ #
+ system("$sudo sh -c \"echo 127.0.0.1 localhost > $chroot_tmp/etc/hosts\"");
+
# try to workarround the rpm -qa db4 error(2) from dbcursor->c_get:
# No such file or directory
# system("sudo chroot $chroot_tmp rm -rf /var/lib/rpm/__db* &> /dev/null");
@@ -748,7 +765,7 @@ retry:
timeout => 60,
debug_mail => $run{debug},
log => "$local_spool/log/$srpm/"); # or next; As this failed quite often, do not stop
- plog(1, "Compiling $srpm");
+ plog('NOTIFY', "Building $srpm");
my $command = "rpm --rebuild /home/$luser/rpm/SRPMS/$srpm";
if ($run{stop}) {
$urpmi->install_packages('chroot', $chroot_tmp, $local_spool, \%pack_provide, 'configure', "[ADMIN] installation of urpmi and sudo failed in the chroot $run{my_arch}", { check => 1, maintainer => $config->{admin} }, 'urpmi', 'sudo');
@@ -774,13 +791,13 @@ retry:
system("$sudo chroot $chroot_tmp /bin/su $luser -c \"PS1='[\[\033[01;33m\]iurt $run{distro} \[\033[00m\]\u@\h \W]\$ ' bash\"");
exit
}
- plog(5, "calling callback for $opt->{hash}");
+ plog('DEBUG', "calling callback for $opt->{hash}");
if ($run{unionfs_tmp} && $output =~ /no space left on device/i) {
- plog("ERROR: running out of space to compile $srpm in unionfs mode, will recompile it in normal mode");
+ plog('ERROR', "ERROR: running out of space to compile $srpm in unionfs mode, will recompile it in normal mode");
$cache->{no_unionfs}{$srpm} = 1;
return 1
} elsif ($run{unionfs_tmp} && $output =~ m,$home,) {
- plog("ERROR: seems like building $srpm needs to access /proc/self/exe, which is broken with unionfs, will try to recompile it in non unionfs mode");
+ plog('ERROR', "ERROR: seems like building $srpm needs to access /proc/self/exe, which is broken with unionfs, will try to recompile it in non unionfs mode");
$cache->{no_unionfs}{$srpm} = 1;
return 1
} elsif ($output =~ /bin\/ld: cannot find -l(\S*)|configure.*error.* (?:-l([^\s]+)|([^\s]+) includes)/) {
@@ -901,12 +918,12 @@ if (!$run{debug}) {
clean_chroot($chroot_tmp, $chroot_tar, \%run, $config, 1)
}
}
-plog(1, "reprocess generated packages queue");
+plog("reprocess generated packages queue");
process_queue($config, \%run, \@wrong_rpm);
dump_cache_par(\%run);
-plog("ERROR: RPM with a wrong SRPM name") if @wrong_rpm;
+plog('FAIL', "ERROR: RPM with a wrong SRPM name") if @wrong_rpm;
if (@wrong_rpm && open my $file, ">$local_spool/log/wrong_srpm_names.log") {
foreach (@wrong_rpm) {
print $file "$_->[1] -> $_->[0] (", $cache->{rpm_srpm}{$_->[1]},")\n";
@@ -925,7 +942,7 @@ if ($config->{rsync_to} && !$run{no_rsync}) {
}
# one last try to clean
-plog(1, "try to clean remaining unionfs");
+plog('DEBUG', "clean remaining unionfs");
if ($run{unionfs}) {
remove_chroot(\%run, $unionfs_dir, \&clean_all_unionfs)
}
@@ -1140,9 +1157,10 @@ sub check_media {
while (<$syn>) {
if (/^\@provides@(.*)/) {
foreach my $p (split '@', $1) {
- $p =~ /([^[]+)(?:\[(.*)\])?/g;
- push @prov, $1;
- $provides->{$1} = $2 || 1
+ if ($p =~ /([^[]+)(?:\[(.*)\])?/g) {
+ push @prov, $1;
+ $provides->{$1} = $2 || 1
+ }
}
} elsif (/\@info\@([^@]+)@/) {
$nb++;