Changeset 118


Ignore:
Timestamp:
Sep 8, 2007, 3:18:32 AM (11 years ago)
Author:
bruno
Message:

Coding of build2vm done. tests not done as it's too late ;-)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r117 r118  
    306306
    307307    chdir "$ENV{'PBBUILDDIR'}";
     308    my $made; # pkgs made during build
    308309    foreach my $pbpkg (@pkgs) {
    309310        my $vertag = $pkg->{$pbpkg};
     
    337338                }
    338339            }
    339         } elsif ($dtype eq "tgz") {
     340            $made="$made $ENV{'PBBUILDDIR'}/RPMS/*/$pbpkg-$pbver-$pbtag$pbsuf.*.rpm $ENV{'PBBUILDDIR'}/SRPMS/$pbpkg-$pbver-$pbtag$pbsuf.src.rpm"
     341        } elsif ($dtype eq "deb") {
     342            my $tmp = "$ENV{'PBBUILDDIR'}/$pbpkg";
     343            $made="$made $tmp"."_*.deb $tmp"."_*.dsc $tmp"."_*.tar.gz"
     344        } elsif ($dtype eq "ebuild") {
     345            $made="$made $ENV{'PBBUILDDIR'}/portage/*/$pbpkg/$pbpkg-$pbver.ebuild"
     346            pb_mkdir_p("$ENV{'PBBUILDDIR'}/portage") if (! -d "$ENV{'PBBUILDDIR'}/portage");
     347        } elsif ($dtype eq "slackware") {
    340348            pb_mkdir_p("$ENV{'PBBUILDDIR'}/install") if (! -d "$ENV{'PBBUILDDIR'}/install");
    341         } elsif ($dtype eq "ebuild") {
    342             pb_mkdir_p("$ENV{'PBBUILDDIR'}/portage") if (! -d "$ENV{'PBBUILDDIR'}/portage");
     349            $made="$made $ENV{'PBBUILDDIR'}/build-$pbpkg/$pbpkg-$pbver-*-$pbtag.tgz"
    343350        } else {
    344         }
    345     }
     351            die "Unknown dtype format $dtype";
     352        }
     353    }
     354    # Keep track of what is generated so that we can get them back from VMs
     355    open(KEEP,"> $ENV{'PBDESTDIR'}/pbgen") || die "Unable to create $ENV{'PBBUILDDIR'}/pbgen";
     356    print KEEP "$made\n";
     357    close(KEEP);
    346358}
    347359
     
    359371
    360372    my $cmt = shift;
     373    my $vm = shift || undef;
    361374    my $host = shift || "sshhost";
    362375    my $login = shift || "sshlogin";
     
    364377    my $port = shift || "sshport";
    365378
    366     my @src;
    367 
    368379    # Get list of packages to build
    369380    my $ptr = pb_get_pkg($defpkgdir,$extpkgdir);
     
    371382
    372383    # Get the running distro to build on
    373     my ($ddir, $dver, $dfam, $dtype, $pbsuf) = pb_distro_init();
     384    my ($odir,$over) = (undef, undef);
     385    if (defined $vm) {
     386        ($odir,$over) = split(/_/,$vm);
     387    }
     388    my ($ddir, $dver, $dfam, $dtype, $pbsuf) = pb_distro_init($odir,$over);
    374389    print $LOG "DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf))."\n" if ($debug >= 1);
    375390
     
    378393    $pkg = { } if (not defined $pkg);
    379394
     395    my $src = "";
    380396    chdir "$ENV{'PBBUILDDIR'}";
    381     my $src;
    382397    foreach my $pbpkg (@pkgs) {
    383398        my $vertag = $pkg->{$pbpkg};
     
    385400        ($pbver,$pbtag) = split(/-/,$vertag);
    386401
    387         if ($cmt eq "Sources") {
    388             $src="$ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz";
    389         } elsif ($cmt eq "VMs") {
    390             $src="$ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz $ENV{'PBDESTDIR'}/pbscript $ENV{'PBETC'}";
    391         } elsif ($cmt eq "Packages") {
    392             if ($dtype eq "rpm") {
    393                 $src="$ENV{'PBBUILDDIR'}/RPMS/*/$pbpkg-$pbver-$pbtag$pbsuf.*.rpm $ENV{'PBBUILDDIR'}/SRPMS/$pbpkg-$pbver-$pbtag$pbsuf.src.rpm"
    394             } elsif ($dtype eq "deb") {
    395                 my $tmp = "$ENV{'PBBUILDDIR'}/$pbpkg";
    396                 $src="$tmp"."_*.deb $tmp"."_*.dsc $tmp"."_*.tar.gz"
    397             } elsif ($dtype eq "ebuild") {
    398                 $src="$ENV{'PBBUILDDIR'}/portage/*/$pbpkg/$pbpkg-$pbver.ebuild"
    399             } elsif ($dtype eq "slackware") {
    400                 $src="$ENV{'PBBUILDDIR'}/build-$pbpkg/$pbpkg-$pbver-*-$pbtag.tgz"
    401             } else {
    402                 die "Unknown dtype format $dtype";
    403             }
    404             # Also make a pbscript to generate yum/urpmi/apt bases
     402        if (($cmt eq "Sources") || ($cmt eq "VMs")) {
     403            $src="$src $ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz";
     404        }
     405    }
     406    if ($cmt eq "VMs") {
     407        $src="$src $ENV{'PBDESTDIR'}/pbscript $ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb $ENV{'PBETC'}";
     408    } elsif ($cmt eq "Packages") {
     409        # Get package list from file made during build2pkg
     410        open(KEEP,"$ENV{'PBBUILDDIR'}/pbgen-$vertag") || die "Unable to read $ENV{'PBBUILDDIR'}/pbgen";
     411        my $src = <KEEP>;
     412        chomp($src);
     413        close(KEEP);
     414        if ($dtype eq "rpm") {
     415            # Also make a pbscript to generate yum/urpmi bases
    405416            # $src = "$src $ENV{'PBDESTDIR'}/pbscript"
    406         }
    407         push @src, $src;
    408     }
    409     $src = join(' ',@src);
     417        } elsif ($dtype eq "deb") {
     418            # Also make a pbscript to generate apt bases
     419            # $src = "$src $ENV{'PBDESTDIR'}/pbscript"
     420        }
     421    }
     422
    410423    print $LOG "$cmt: $src\n" if ($debug >= 0);
    411424    my ($sshhost,$sshlogin,$sshdir,$sshport) = pb_conf_get($host,$login,$dir,$port);
     
    424437    pb_system("ssh -q -p $port $mac \"mkdir -p $tdir ; cd $tdir ; rm -f $src\"","Preparing $tdir on $mac");
    425438    pb_system("scp -p -P $port $src $mac:$tdir","$cmt delivery in $tdir on $mac");
    426     pb_system("ssh -q -p $port $mac \"cd $tdir ; if [ -f pbscript ]; then chmod 755 ./pbscript ; ./pbscript\"","Executing pbscript on $mac");
     439    pb_system("ssh -q -p $port $mac \"cd $tdir ; if [ -f pbscript ]; then ./pbscript\"; fi","Executing pbscript on $mac");
    427440    if ($cmt eq "VMs") {
    428         pb_system("scp -p -P $port $mac:$tdir/.... ...","Package recovery in $tdir from $mac");
     441            # Get back info on pkg produced, compute their name and get them from the VM
     442        pb_system("scp -p -P $port $mac:$tdir/pbgen-$vertag $ENV{'PBBUILDDIR'}","Get package names in $tdir on $mac");
     443        open(KEEP,"$ENV{'PBBUILDDIR'}/pbgen-$vertag") || die "Unable to read $ENV{'PBBUILDDIR'}/pbgen-$vertag";
     444        my $src = <KEEP>;
     445        chomp($src);
     446        close(KEEP);
     447        pb_system("scp -p -P $port $mac:$tdir/{".join(',',$src)."} $ENV{'PBBUILDDIR'}/$odir/$over","Package recovery of in $tdir from $mac");
     448        pb_send2ssh("Packages","$odir_$over");
     449        pb_rm_rf($ENV{'PBBUILDDIR'}/$odir);
    429450    }
    430451}
     
    435456    # Prepare the script to be executed on the VM
    436457    # in $ENV{'PBDESTDIR'}/pbscript
    437     # Launch the VM
    438     # Gather all required files to send them to the VM
    439     pb_send2ssh("VMs","vmhost","vmlogin","vmdir","vmport");
    440    
     458    open(SCRIPT,"> $ENV{'PBDESTDIR'}/pbscript") || die "Unable to create $ENV{'PBDESTDIR'}/pbscript";
     459    print SCRIPT "#!/bin/bash\n";
     460    print SCRIPT "# Move the copied .pbrc to the home dir on the build account\n";
     461    print SCRIPT "mv .pbrc \$ENV{'HOME'}\n";
     462    print SCRIPT "# Setup the variables required for building\n";
     463    print SCRIPT "export PBPROJ=$ENV{'PBPROJ'}\n";
     464    print SCRIPT "export PBROOT=\`pwd\`\n";
     465    print SCRIPT "# Build\n";
     466    print SCRIPT "pb build2pkg $ARGV[0]\n";
     467    close(SCRIPT);
     468    chmod 0755,"$ENV{'PBDESTDIR'}/pbscript";
     469
    441470    # Send tar files when we do a global generation
    442471    pb_build2ssh() if ($all == 1);
     472
     473    foreach my $v (@$vm) {
     474        # Launch the VMs
     475
     476        # Gather all required files to send them to the VM and launch the build thourgh pbscript
     477        pb_send2ssh("VMs","$v","vmhost","vmlogin",dirname($pbrc->{$ENV{'PBPROJ'}}),"vmport");
     478    }
    443479}
    444480
Note: See TracChangeset for help on using the changeset viewer.