Changeset 1531 in ProjectBuilder


Ignore:
Timestamp:
May 13, 2012, 4:27:42 AM (12 years ago)
Author:
Bruno Cornec
Message:

rpmbootstrap: Add support for stop-on-error. Expand out VE paths. Error out if no packages are defined for the OS version since that indicates something is badly wrong. Track the packages that we install so that we can re-install them with the vendor's tool. Don't mount proc if it is already mounted. Only process repo files under yum.repos.d. In comment for now: Include all the packages installed during bootstrapping in the list of packages to re-install for yum and zypper. If you don't do this for yum, you end up with the generic fedora release file which doesn't match the pattern expected to determine the version. If you don't do this for zypper, then /etc/passwd isn't created, which creates failures later. Remove the zypper repository before adding, just adding fails since it already exists. Hack to fix up the yum.repos.d files again after the yum install since centos 6 mangles them during install. Report on broken packages listed for installation at the end so the warning isn't hidden. (Eric Anderson)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/rpmbootstrap/bin/rpmbootstrap

    r1429 r1531  
    118118at the end of the chroot build.
    119119
     120=item B<--no-stop-on-error>
     121
     122Continue through errors with best effort.
     123
    120124=back
    121125
     
    170174# ---------------------------------------------------------------------------
    171175
     176$Global::pb_stop_on_error = 1;
    172177my ($projectbuilderver,$projectbuilderrev) = pb_version_init();
    173178my $appname = "rpmbootstrap";
     
    191196    "add|a=s" => \$opts{'a'},
    192197    "version|V=s" => \$opts{'V'},
     198    "stop-on-error!" => \$Global::pb_stop_on_error,
    193199) || pb_syntax(-1,0);
    194200
     
    247253if (not defined $vepath) {
    248254    my ($vestdpath) = pb_conf_get("vepath");
    249     $vepath = "$vestdpath->{'default'}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}" if (defined $vestdpath->{'default'});
     255    $vepath = pb_path_expand("$vestdpath->{'default'}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}") if (defined $vestdpath->{'default'});
    250256}
    251257
     
    259265my ($rbscachedir) = pb_conf_get_if("cachedir");
    260266my ($pkgs,$mirror) = pb_distro_get_param($pbos,pb_conf_get("rbsmindep","rbsmirrorsrv"));
     267die "No packages defined for $pbos->{name}-$pbos->{version}-$pbos->{arch}" unless $pkgs =~ /\w/;
    261268
    262269my $cachedir = "/var/cache/rpmbootstrap";
     
    373380my $warning = 0;
    374381my $lwpkg ="";
     382my @installed_packages;
     383
    375384foreach my $p (split(/,/,$pkgs)) {
    376385    pb_log(1,"Processing package $p ...\n");
     
    408417                unlink("$cachedir/$p1");
    409418            }
    410    
     419            push(@installed_packages, $p);
    411420        }
    412421    } else {
     
    452461    pb_mkdir_p("$vepath/usr/lib/python2.4/site-packages/urlgrabber.skx");
    453462    foreach my $i (<$vepath/usr/lib/python2.4/site-packages/urlgrabber/keepalive.*>) {
    454         move($i,"$vepath/usr/lib/python2.4/site-packages/urlgrabber.skx/");
     463        move($i,"$vepath/usr/lib/python2.4/site-packages/urlgrabber.skx/");
    455464    }
    456465}
     
    460469#
    461470pb_mkdir_p("$vepath/proc");
    462 pb_system("mount -o bind /proc $vepath/proc","Mounting /proc");
     471pb_system("mount -o bind /proc $vepath/proc","Mounting /proc") unless (-d "$vepath/proc/$$";);
    463472
    464473#
     
    484493    # $releasever also needs to be filtered
    485494    # yum.conf as well
    486     foreach my $i (<$vepath/etc/yum.repos.d/*>,"$vepath/etc/yum.conf") {
     495    foreach my $i (<$vepath/etc/yum.repos.d/*.repo>,"$vepath/etc/yum.conf") {
    487496        pb_system("sed -i -e 's/\$basearch/$pbos->{'arch'}/g' $i","","quiet");
    488497        pb_system("sed -i -e 's/\$releasever/$pbos->{'version'}/g' $i","","quiet");
     
    492501    }
    493502    $minipkglist = "ldconfig yum passwd vim-minimal dhclient authconfig";
     503    # TODO
     504    # $minipkglist = join(" ", "ldconfig yum passwd vim-minimal dhclient authconfig", @installed_packages);
    494505} elsif ($pbos->{'install'} =~ /zypper/) {
    495506    pb_mkdir_p("$vepath/etc/zypp/repos.d");
     
    500511        pb_system("chroot $vepath /bin/bash -c \"yes | /usr/bin/zypper sa $baseurl $pbos->{'name'}-$pbos->{'version'}\"","Bootstrapping Zypper");
    501512    } else {
     513        pb_system("chroot $vepath /bin/bash -c \"/usr/bin/zypper rr $pbos->{'name'}-$pbos->{'version'}\"","Bootstrapping Zypper",undef,1); # don't care if remove fails if add succeeds.
    502514        pb_system("chroot $vepath /bin/bash -c \"/usr/bin/zypper ar $baseurl $pbos->{'name'}-$pbos->{'version'}\"","Bootstrapping Zypper");
    503515    }
     
    512524    close(REPO);
    513525    $minipkglist = "zypper";
     526    # TODO: Re-installing packages missing and necessary on opensuse 11.4 to get /etc/passwd created.
     527    # $minipkglist = join(" ", "zypper", @installed_packages);
    514528} elsif ($pbos->{'install'} =~ /urpmi/) {
    515529    # Setup the repo
    516530    my $baseurl = dirname(dirname(dirname($mirror)));
    517531    pb_system("chroot $vepath /bin/bash -c \"urpmi.addmedia --distrib $baseurl\"","Bootstrapping URPMI");
     532    # TODO here too ?
    518533    $minipkglist = "ldconfig urpmi passwd vim-minimal dhcp-client";
    519534}
     
    525540$pbos->{'install'} =~ s/sudo//g;
    526541pb_system("chroot $vepath /bin/bash -c \"$pbos->{'install'} $minipkglist \"","Bootstrapping OS by running $pbos->{'install'} $minipkglist");
     542
     543# CentOS6 will replace the yum.repos.d files; oddly it will leave the yum.conf file alone and make the new one ".rpmnew"
     544if (($pbos->{'name'} eq "centos") && ($pbos->{'version'} =~ /^6.*/)) {
     545    pb_log(0,"Fixing $pbos->{'name'} $pbos->{'version'} bug for yum conf files");
     546    foreach my $from (<$vepath/etc/yum.repos.d/*.rpmorig>) {
     547        my $to = $from;
     548        $to =~ s/.rpmorig$//;
     549        pb_system("mv $from $to", "Recover $from");
     550    }
     551}
    527552
    528553#
     
    553578}
    554579
     580if ($warning > 0) {
     581    pb_log(0,"\n\n\n\n$warning WARNINGS found.\nMaybe you should review your package list for $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}\nand remove$lwpkg\n");
     582    pb_log(0,"waiting 60 seconds to give you a chance to notice.\n");
     583    sleep(60);
     584}
     585
    555586# Function for File::Find
    556587sub unlink_old_conf {
Note: See TracChangeset for help on using the changeset viewer.