aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Iurt
diff options
context:
space:
mode:
authorMarcelo Leitner <mrl@mandriva.com>2007-11-06 12:54:31 +0000
committerMarcelo Leitner <mrl@mandriva.com>2007-11-06 12:54:31 +0000
commit3746f981c3e4aea5342491979cf1d6f8961db7af (patch)
treef60eecbfbe21c1192beb41cb915afe88f2da7694 /lib/Iurt
parenta2c173186705228a9c11370097774b481b1b39fd (diff)
downloadiurt-3746f981c3e4aea5342491979cf1d6f8961db7af.tar
iurt-3746f981c3e4aea5342491979cf1d6f8961db7af.tar.gz
iurt-3746f981c3e4aea5342491979cf1d6f8961db7af.tar.bz2
iurt-3746f981c3e4aea5342491979cf1d6f8961db7af.tar.xz
iurt-3746f981c3e4aea5342491979cf1d6f8961db7af.zip
- Stripped out very hacks at buildreqs/initial packages installation.
URPMI is stable enough nowadays and these hacks seems to be introducing more danger than helping.
Diffstat (limited to 'lib/Iurt')
-rw-r--r--lib/Iurt/Urpmi.pm338
1 files changed, 94 insertions, 244 deletions
diff --git a/lib/Iurt/Urpmi.pm b/lib/Iurt/Urpmi.pm
index 2997704..ed8b996 100644
--- a/lib/Iurt/Urpmi.pm
+++ b/lib/Iurt/Urpmi.pm
@@ -414,48 +414,43 @@ sub install_packages {
mkdir $log_spool;
- my $try_urpmi = 1;
my @rpm = grep { !/\.src\.rpm$/ } @to_install;
- return 1 if ($opt->{check} && -f "$chroot_tmp/bin/rpm" && @rpm && are_installed($chroot_tmp, @to_install));
-
- if ($try_urpmi) {
- foreach my $try (
- [ '', 'using urpmi' ],
- [ '', 'rebuild rpm base and retry', '_retry' ],
- [ ' --allow-nodeps', 'retrying with nodeps' , '_nodeps' ],
- [ ' --no-install', 'using rpm directly', '_rpm' ]
- ) {
- my ($opt, $msg, $suf) = @$try;
-
- plog('INFO', "install dependencies: $msg");
- my $unsatisfied;
-
- if (!perform_command(
- "sudo $self->{urpmi_command} $opt @to_install",
- $run, $config, $cache,
- error => $error,
- logname => "${log}$suf",
- hash => "${log}_$title$suf",
- timeout => 600,
- srpm => $title,
- freq => 1,
- #cc => $cc,
- retry => 3,
- debug_mail => $run->{debug},
- error_regexp => 'cannot be installed',
- wait_regexp => {
- 'database locked' => \&wait_urpmi,
- 'is needed by' => sub {
- plog('WARN', "WARNING: rpm database seems corrupted, retrying");
- system("sudo chroot $chroot_tmp rm -rf /var/lib/rpm/__db* &> /dev/null");
- 1;
- },
- },
- log => $log_spool,
- callback => sub {
- my ($opt, $output) = @_;
- plog('DEBUG', "calling callback for $opt->{hash}");
+ if ($opt->{check}
+ && -f "$chroot_tmp/bin/rpm"
+ && @rpm
+ && are_installed($chroot_tmp, @to_install)) {
+ return 1;
+ }
+
+ plog('INFO', "install dependencies using urpmi");
+ my $unsatisfied;
+
+ if (!perform_command(
+ "sudo $self->{urpmi_command} @to_install",
+ $run, $config, $cache,
+ error => $error,
+ logname => "${log}$suf",
+ hash => "${log}_$title$suf",
+ timeout => 600,
+ srpm => $title,
+ freq => 1,
+ #cc => $cc,
+ retry => 3,
+ debug_mail => $run->{debug},
+ error_regexp => 'cannot be installed',
+ wait_regexp => {
+ 'database locked' => \&wait_urpmi,
+ 'is needed by' => sub {
+ plog('WARN', "WARNING: rpm database seems corrupted, retrying");
+ system("sudo chroot $chroot_tmp rm -rf /var/lib/rpm/__db* &> /dev/null");
+ 1;
+ },
+ },
+ log => $log_spool,
+ callback => sub {
+ my ($opt, $output) = @_;
+ plog('DEBUG', "calling callback for $opt->{hash}");
# 20060614
# it seems the is needed urpmi error is due to something else (likely a
@@ -463,216 +458,71 @@ sub install_packages {
# my @missing_deps = $output =~ /(?:(\S+) is needed by )|(?:\(due to unsatisfied ([^[ ]*)(?: (.*)|\[(.*)\])?\))/g;
#
- my @missing_deps = $output =~ /([^ \n]+) \(due to unsatisfied ([^[ \n]*)(?: ([^\n]*)|\[([^\n]*)\])?\)/g;
-
- # as it seems that rpm db corruption is making urpmi
- # returning false problem on deps installation, try
- # to compile anyway
-
- @missing_deps or return 1;
- $unsatisfied = 1;
-
- while (my $missing_package = shift @missing_deps) {
- my $missing_deps = shift @missing_deps;
- my $version = shift @missing_deps;
- my $version2 = shift @missing_deps;
- $version ||= $version2 || 0;
- my $p = $pack_provide->{$missing_deps} || $missing_deps;
- my ($missing_package_name, $first_maint);
- if ($missing_package !~ /\.src$/) {
- ($first_maint, $missing_package_name) = get_maint($run, $missing_package);
- plog(5, "likely $missing_package_name need to be rebuilt ($first_maint)");
- } else {
- $missing_package = '';
- }
-
- my ($other_maint) = get_maint($run, $p);
- plog('FAIL', "missing dep: $missing_deps ($other_maint) missing_package $missing_package ($first_maint)");
- $run->{status}{$title} = 'missing_dep';
- foreach my $m ($first_maint, $other_maint) { # FIXME: (tv) this loop is useless !!!
- if ($other_maint && $other_maint ne 'NOT_FOUND') {
- $opt->{mail} = $config->{admin};
- #$opt->{mail} .= ", $other_maint";
- }
- }
-
- if (!$opt->{mail}) {
- $opt->{mail} = $config->{admin};
- }
-
- # remember what is needed, and do not try to
- # recompile until it is available
-
- if ($missing_package) {
- $opt->{error} = "[MISSING] $missing_deps, needed by $missing_package to build $title, is not available on $run->{my_arch} (rebuild $missing_package?)";
- $cache->{needed}{$title}{$missing_deps} = { package => $missing_package , version => $version, maint => $first_maint || $other_maint || $maintainer };
- } else {
- $opt->{error} = "[MISSING] $missing_deps, needed to build $title, is not available on $run->{my_arch}";
- $cache->{needed}{$title}{$missing_deps} = { package => $missing_package , version => $version, maint => $maintainer || $other_maint };
- }
- }
- 0;
- },
- )) {
- if (!clean_process($run, "$self->{urpmi_command} $opt @to_install", $run->{verbose})) {
- dump_cache_par($run);
- die "FATAL $program_name: Could not have urpmi working !";
- }
- $unsatisfied and last;
- } else {
- if (!@rpm || are_installed($chroot_tmp, @rpm)) {
- plog("installation successful");
- $ok = 1;
- }
- }
+ my @missing_deps = $output =~ /([^ \n]+) \(due to unsatisfied ([^[ \n]*)(?: ([^\n]*)|\[([^\n]*)\])?\)/g;
+
+ # <mrl> 20071106 FIXME: This should not be needed anymore
+ # as it seems that rpm db corruption is making urpmi
+ # returning false problem on deps installation, try
+ # to compile anyway
+
+ @missing_deps or return 1;
+ $unsatisfied = 1;
+
+ while (my $missing_package = shift @missing_deps) {
+ my $missing_deps = shift @missing_deps;
+ my $version = shift @missing_deps;
+ my $version2 = shift @missing_deps;
+ $version ||= $version2 || 0;
+ my $p = $pack_provide->{$missing_deps} || $missing_deps;
+ my ($missing_package_name, $first_maint);
+ if ($missing_package !~ /\.src$/) {
+ ($first_maint, $missing_package_name) = get_maint($run, $missing_package);
+ plog(5, "likely $missing_package_name need to be rebuilt ($first_maint)");
+ } else {
+ $missing_package = '';
+ }
- if (-f "$chroot_tmp/bin/rpm") {
- if (!$ok && system("sudo chroot $chroot_tmp rm -rf /var/lib/rpm/__db*; sudo chroot $chroot_tmp rpm --rebuilddb")) {
- plog("ERROR: rebuilding rpm db failed, aborting ($!)");
- last;
- }
- if ($suf eq '_rpm') {
- plog(1, "trying to install all the rpms in $chroot_tmp/var/cache/urpmi/rpms/ manually");
- if (!system("sudo chroot $chroot_tmp rpm -Uvh --force --nodeps /var/cache/urpmi/rpms/*.rpm")) {
- $ok = 1;
- last;
+ my ($other_maint) = get_maint($run, $p);
+ plog('FAIL', "missing dep: $missing_deps ($other_maint) missing_package $missing_package ($first_maint)");
+ $run->{status}{$title} = 'missing_dep';
+
+ $opt->{mail} = $config->{admin};
+
+ # remember what is needed, and do not try to
+ # recompile until it is available
+
+ if ($missing_package) {
+ $opt->{error} = "[MISSING] $missing_deps, needed by $missing_package to build $title, is not available on $run->{my_arch} (rebuild $missing_package?)";
+ $cache->{needed}{$title}{$missing_deps} = { package => $missing_package , version => $version, maint => $first_maint || $other_maint || $maintainer };
} else {
- $ok = 0;
+ $opt->{error} = "[MISSING] $missing_deps, needed to build $title, is not available on $run->{my_arch}";
+ $cache->{needed}{$title}{$missing_deps} = { package => $missing_package , version => $version, maint => $maintainer || $other_maint };
}
- }
- }
- last if $ok == 1;
+ }
+ 0;
+ },
+ )) {
+ if (!clean_process($run, "$self->{urpmi_command} $opt @to_install", $run->{verbose})) {
+ dump_cache_par($run);
+ die "FATAL $program_name: Could not have urpmi working !";
}
}
- if (!-f "$chroot_tmp/bin/rpm" || @rpm && !are_installed($chroot_tmp, @to_install)) {
- plog(1, "ERROR: urpmi is not working, doing it manually");
- my $root = "$config->{repository}/$run->{distro}/$run->{my_arch}";
- my $depslist = "$root/media/media_info/depslist.ordered";
- if (-f $depslist) {
- my $distrib = $self->{distrib};
- if (!$distrib) {
- $distrib = MDV::Distribconf::Build->new($root);
- plog(3, "getting media config from $root");
- if (!$distrib->loadtree) {
- plog(1, "ERROR: $root does not seem to be a distribution tree\n");
- return;
- }
- $distrib->parse_mediacfg;
- foreach my $media ($distrib->listmedia) {
- $media =~ /(SRPMS|debug_)/ and next;
- my $path = $distrib->getfullpath($media, 'path');
- opendir my $rpmdh, $path;
- foreach my $rpm (readdir $rpmdh) {
- if ($rpm =~ /^(.*)-([^-]+)-([^-]+)\.([^.]+)\.rpm/) {
- $distrib->{file}{"$1-$2-$3.$4"} = "$path/$rpm";
- }
- }
- }
- }
- $self->{distrib} = $distrib;
- plog(3, "using $depslist to resolve dependencies");
- open my $depsfh, $depslist;
- my %packages;
- my @deps;
- my $i;
- my @install;
- my @pack;
- while (<$depsfh>) {
- my ($pack, $_size, @d) = split ' ';
- $pack =~ s/:\d+$//;
- push @deps, \@d;
- my ($name, $version, $release, $arch) = $pack =~ /(.*)-([^-]+)-([^-]+)\.([^.]+)$/;
- $pack[$i] = $pack;
- $packages{$pack} ||= $i;
- if ($arch ne 'src' && !$packages{$name}) {
- $packages{$name} = $i;
- $packages{"$name-$version"} = $i;
- $packages{"$name-$version-$release"} = $i;
- }
- $i++;
- }
- plog(4, "$i packages found");
- my %done;
- # rpm -root $chroot -qa does not work
- if (-f "$chroot_tmp/bin/rpm") {
- my $qa = `sudo chroot $chroot_tmp rpm -qa --qf "\%{name}-\%{version}-\%{release}.\%{arch}\n"`;
- foreach my $rpm (split "\n", $qa) {
- plog(6, "$rpm already installed");
- $done{$rpm} = 1;
- }
- }
- foreach my $p (@to_install) {
- my $pa = $pack[$packages{$p}];
- $done{$pa} and next;
- my $f = $distrib->{file}{$pa};
- if ($f) {
- push @install, $pa;
- } else {
- plog(1, "ERROR: main package $p is not present in the repository");
- return 0;
- }
- }
- my $dok;
- while (!$dok) {
- $dok = 1;
- foreach my $p (@install) {
- $done{$p} and next;
- $done{$p} = 1;
- plog(5, "adding deps for $p (", join(', ', @{$deps[$packages{$p}]}, ")"));
- foreach my $d (@{$deps[$packages{$p}]}) {
- plog("$d (pack $pack[$d]) done $done{$d} done pack $done{$pack[$d]}");
- $done{$d} and next;
- $done{$pack[$d]} and next;
- $done{$d} = 1;
- if ($d =~ /\d+/) {
- my $f = $distrib->{file}{$pack[$d]};
- if ($f) {
- $dok = 1;
- plog(5, "adding $pack[$d]");
- push @install, $pack[$d];
- } else {
- plog(2, "ERROR: deps for $p, $pack[$d] ($d) is not present in the repository");
- }
- } elsif ($d =~ /\|/) {
- my $done;
- foreach my $a (split '\|', $d) {
- my $f = $distrib->{file}{$pack[$a]};
- if ($f) {
- $done = 1;
- if (!$done{$pack[$a]}) {
- $dok = 1;
- plog(5, "adding $pack[$a]");
- push @install, $pack[$a];
- $done{$pack[$a]} = 1;
- }
- last;
- } else {
- plog(2, "ERROR: alternate deps, $pack[$a] ($d) is not present in the repository, using alternative");
- }
- }
- if (!$done) {
- plog(2, "ERROR: no alternatives present in the repository");
- }
- }
- }
- }
- }
- my $rpms;
- my %install_done;
- # FIXME: (tv) this loop could be simplified with uniq() from MDK::Common:
- # eg: $rpms = join(map { "$distrib->{file}{$_}" } uniq(@install))
- foreach my $rpm (@install) {
- $install_done{$rpm} and next;
- print "$program_name: will install $rpm ($distrib->{file}{$rpm})\n" if $run->{verbose} > 3;
- $install_done{$rpm} = 1;
- $rpms .= "$distrib->{file}{$rpm} ";
- }
- if ($rpms) {
- return !system("sudo rpm --ignoresize --nosignature --root $chroot_tmp -Uvh $rpms");
- }
- $ok = 1;
- }
+
+ # <mrl> URPMI saying ok or not, we check this anyway. So that's why
+ # it's outside the else.
+ if (! -f "$chroot_tmp/bin/rpm") {
+ plog(1, "ERROR: rpm-build is missing!");
+ $ok = 0;
+ }
+ elsif (!@rpm || are_installed($chroot_tmp, @rpm)) {
+ plog("installation successful");
+ $ok = 1;
}
+ else {
+ plog (1, "ERROR: Failed to install initial packages");
+ $ok = 0;
+ }
+
$ok;
}