Changeset 1138


Ignore:
Timestamp:
Jan 7, 2011, 2:26:21 AM (9 years ago)
Author:
Bruno Cornec
Message:
  • Change pbgen and pbscript files to unique versions where appropriate to support later on parallelism
File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r1137 r1138  
    941941            pb_mkdir_p("$dest/pbconf");
    942942            # And prepare the pbscript to execute remotely
    943             open(SCRIPT,"> $ENV{'PBDESTDIR'}/pbscript") || die "Unable to create $ENV{'PBDESTDIR'}/pbscript";
     943            open(SCRIPT,"> $ENV{'PBTMP'}/pbscript") || die "Unable to create $ENV{'PBTMP'}/pbscript";
    944944            print SCRIPT "#!/bin/bash\n";
    945945            print SCRIPT "#set -x\n";
     
    14081408
    14091409    if ($cmt =~ /V[EM]build/) {
    1410         $src="$src $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb $ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb $ENV{'PBETC'} $ENV{'PBDESTDIR'}/pbrc $ENV{'PBDESTDIR'}/pbscript";
    1411     } elsif (($cmt =~ /V[EM]Script/) || ($cmt eq "Web")) {
    1412         $src="$src $ENV{'PBDESTDIR'}/pbscript";
     1410        $src="$src $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb $ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb $ENV{'PBETC'} $ENV{'PBDESTDIR'}/pbrc $ENV{'PBDESTDIR'}/pbscript.$$";
     1411    } elsif ($cmt =~ /V[EM]Script/) {
     1412        $src="$src $ENV{'PBDESTDIR'}/pbscript.$$";
    14131413    } elsif ($cmt =~ /V[EM]test/) {
    1414         $src="$src $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb $ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb $ENV{'PBETC'} $ENV{'PBDESTDIR'}/pbrc $ENV{'PBDESTDIR'}/pbscript $ENV{'PBDESTDIR'}/pbtest";
    1415     } elsif ($cmt eq "Announce") {
     1414        $src="$src $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb $ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb $ENV{'PBETC'} $ENV{'PBDESTDIR'}/pbrc $ENV{'PBDESTDIR'}/pbscript.$$ $ENV{'PBDESTDIR'}/pbtest";
     1415    } elsif (($cmt eq "Announce") || ($cmt eq "Web")) {
    14161416        $src="$src $ENV{'PBTMP'}/pbscript";
    14171417    } elsif ($cmt eq "Packages") {
     
    14541454    } else {
    14551455        # VE
    1456         # Overwrite account value if passed as parameter (typically for setup2ve)
     1456        # Overwrite account value if passed as parameter (typically for setup2v)
    14571457        $mac = $sshlogin->{$ENV{'PBPROJ'}};
    14581458        $mac = $pbaccount if (defined $pbaccount);
     
    17211721    if ($cmt =~ /^V[EM]build/) {
    17221722        # Get back info on pkg produced, compute their name and get them from the VM
    1723         pb_system("$cpcmd $cp2target/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'} $ENV{'PBBUILDDIR'} 2> /dev/null","Get package names in $cp2target");
     1723        pb_system("$cpcmd $cp2target/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'} $ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.$$ 2> /dev/null","Get package names in $cp2target");
    17241724        # For VE we need to change the owner manually
    17251725        if ($cmt eq "VEbuild") {
    1726             pb_system("sudo chown $UID $ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}","Adapt owner in $tdir to $UID");
     1726            pb_system("sudo chown $UID $ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.$$","Adapt owner in $tdir to $UID");
    17271727        }
    17281728        # return here to avoid breaking the load on VMs/VEs in case of a bad one
    1729         if (not -f "$ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}") {
    1730             pb_log(0,"Problem with VM $v on $ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}");
     1729        if (not -f "$ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.$$") {
     1730            pb_log(0,"Problem with VM $v on $ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.$$");
    17311731            return;
    17321732        }
    1733         open(KEEP,"$ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}") || die "Unable to read $ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}";
     1733        open(KEEP,"$ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.$$") || die "Unable to read $ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.$$";
    17341734        my $src = <KEEP>;
    17351735        chomp($src);
    17361736        close(KEEP);
     1737        unlink("$ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.$$");
     1738
    17371739        $src =~ s/^ *//;
    17381740        pb_mkdir_p("$ENV{'PBBUILDDIR'}/$odir/$over");
    17391741        # Change pgben to make the next send2target happy
    17401742        my $made = "";
     1743
     1744        # For VM we don't want shell expansion to hapen locally but remotely
     1745        my $delim = '\'';
     1746        if ($cmt =~ /^VEbuild/) {
     1747            # For VE we need to support shell expansion locally
     1748            $delim = "";
     1749        }   
     1750
    17411751        open(KEEP,"> $ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}") || die "Unable to write $ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}";
    17421752        foreach my $p (split(/ +/,$src)) {
    17431753            my $j = basename($p);
    1744             # For VM we don't want shell expansion to hapen locally but remotely
    1745             my $delim = '\'';
    1746             if ($cmt =~ /^VEbuild/) {
    1747                 # For VE we need to support shell expansion locally
    1748                 $delim = "";
    1749             }   
    17501754            pb_system("$cpcmd $cp2target/$delim$p$delim $ENV{'PBBUILDDIR'}/$odir/$over 2> /dev/null","Recovery of package $j in $ENV{'PBBUILDDIR'}/$odir/$over");
    17511755            $made="$made $odir/$over/$j"; # if (($dtype ne "rpm") || ($j !~ /.src.rpm$/));
     
    18081812    my $pbscript=shift;
    18091813    my $vtype=shift;
    1810     my $pbforce=shift || 0; # Force stop of VM. Default not
    1811     my $vm1=shift || undef; # Only that VM to treat
    1812     my $snapme=shift || 0;  # Do we have to create a snapshot
     1814    my $pbforce=shift || 0; # Force stop of VM. Default not.
     1815    my $vm1=shift || undef; # Only that VM to treat. Default all.
     1816    my $snapme=shift || 0;  # Do we have to create a snapshot. Default not.
    18131817    my $vm;
    18141818    my $all;
     
    18161820    pb_log(2,"DEBUG: pb_script2v($pbscript,$vtype,$pbforce,".Dumper($vm1).",$snapme)\n");
    18171821    # Prepare the script to be executed on the VM
    1818     # in $ENV{'PBDESTDIR'}/pbscript
    1819     if ((defined $pbscript ) && ($pbscript ne "$ENV{'PBDESTDIR'}/pbscript")) {
    1820         copy($pbscript,"$ENV{'PBDESTDIR'}/pbscript") || die "Unable to create $ENV{'PBDESTDIR'}/pbscript";
    1821         chmod 0755,"$ENV{'PBDESTDIR'}/pbscript";
     1822    # in $ENV{'PBDESTDIR'}/pbscript.$$
     1823    if ((defined $pbscript ) && ($pbscript ne "$ENV{'PBDESTDIR'}/pbscript.$$")) {
     1824        copy($pbscript,"$ENV{'PBDESTDIR'}/pbscript.$$") || die "Unable to create $ENV{'PBDESTDIR'}/pbscript.$$";
     1825        chmod 0755,"$ENV{'PBDESTDIR'}/pbscript.$$";
    18221826    }
    18231827
     
    19201924        if ($snapme != 0) {
    19211925            if (($vmtype eq "kvm") || ($vmtype eq "qemu")) {
    1922                 # Configure the monitoring to automize the creation of the 'pb' snapshot
     1926                # Configure the monitoring to automate the creation of the 'pb' snapshot
    19231927                $ENV{'PBVMOPT'} .= " -serial mon:telnet::$vmmonport->{$ENV{'PBPROJ'}},server,nowait";
    19241928                # In that case no snapshot call needed
     
    21952199foreach my $v (@$v) {
    21962200    # Prepare the script to be executed on the VM/VE
    2197     # in $ENV{'PBDESTDIR'}/pbscript
    2198     open(SCRIPT,"> $ENV{'PBDESTDIR'}/pbscript") || die "Unable to create $ENV{'PBDESTDIR'}/pbscript";
     2201    # in $ENV{'PBDESTDIR'}/pbscript.$$
     2202    open(SCRIPT,"> $ENV{'PBDESTDIR'}/pbscript.$$") || die "Unable to create $ENV{'PBDESTDIR'}/pbscript.$$";
    21992203    print SCRIPT "#!/bin/bash\n";
    22002204
     
    22892293
    22902294    close(SCRIPT);
    2291     chmod 0755,"$ENV{'PBDESTDIR'}/pbscript";
     2295    chmod 0755,"$ENV{'PBDESTDIR'}/pbscript.$$";
    22922296   
    22932297    # Launch the VM/VE
     
    28262830
    28272831foreach my $v (@$vm) {
    2828     # Get distro context
    2829     my ($name,$ver,$darch) = split(/-/,$v);
    2830     chomp($darch);
    2831     my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf) = pb_distro_init($name,$ver,$darch);
    2832     my ($vepath) = pb_conf_get("vepath");
    2833 
    2834     # Test if an existing snapshot exists and remove it if there is a VE
    2835     if ((-f "$vepath->{$ENV{'PBPROJ'}}/$ddir-$dver-$darch.tar.gz") &&
    2836         (! -d "$vepath->{$ENV{'PBPROJ'}}/$ddir/$dver/$darch")) {
    2837             pb_system("sudo rm -f $vepath->{$ENV{'PBPROJ'}}/$ddir-$dver-$darch.tar.gz","Removing previous snapshot $ddir-$dver-$darch.tar.gz");
     2832    if ($vtype eq "ve") {
     2833        # Get distro context
     2834        my ($name,$ver,$darch) = split(/-/,$v);
     2835        chomp($darch);
     2836        my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf) = pb_distro_init($name,$ver,$darch);
     2837        my ($vepath) = pb_conf_get("vepath");
     2838
     2839        # Test if an existing snapshot exists and remove it if there is a VE
     2840        if ((-f "$vepath->{$ENV{'PBPROJ'}}/$ddir-$dver-$darch.tar.gz") &&
     2841            (! -d "$vepath->{$ENV{'PBPROJ'}}/$ddir/$dver/$darch")) {
     2842                pb_system("sudo rm -f $vepath->{$ENV{'PBPROJ'}}/$ddir-$dver-$darch.tar.gz","Removing previous snapshot $ddir-$dver-$darch.tar.gz");
     2843        }
    28382844    }
    28392845
    28402846    # Prepare the script to be executed on the VM/VE
    2841     # in $ENV{'PBDESTDIR'}/setupv
    28422847    open(SCRIPT,"> $pbscript") || die "Unable to create $pbscript";
    2843    
    28442848    print SCRIPT << 'EOF';
    28452849    #!/bin/bash
Note: See TracChangeset for help on using the changeset viewer.