Changeset 90


Ignore:
Timestamp:
Sep 3, 2007, 5:27:15 PM (11 years ago)
Author:
bruno
Message:

First version for pkg2ssh

File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r89 r90  
    336336
    337337sub pb_build2ssh {
     338    pb_send2ssh("Sources");
     339}
     340
     341sub pb_pkg2ssh {
     342    pb_send2ssh("Packages");
     343}
     344
     345sub pb_send2ssh {
     346
     347    my $cmt = shift;
    338348
    339349    my @src;
     
    352362
    353363    chdir "$ENV{'PBBUILDDIR'}";
     364    my $src;
    354365    foreach my $pbpkg (@pkgs) {
    355366        my $vertag = $pkg->{$pbpkg};
     
    357368        ($pbver,$pbtag) = split(/-/,$vertag);
    358369
    359         my $src="$ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz";
    360         print $LOG "Source file: $src\n" if ($debug >= 0);
     370        if ($cmt eq "Sources") {
     371            $src="$ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz";
     372        } elsif ($cmt eq "Packages") {
     373            if ($dtype eq "rpm") {
     374                $src="$ENV{'PBBUILDDIR'}/RPMS/*/$pbpkg$pbver-$pbtag$dsuf.*.rpm $ENV{'PBBUILDDIR'}/SRPMS/$pbpkg$pbver-$pbtag$dsuf.src.rpm"
     375            } elsif ($dtype eq "deb") {
     376                $src="$ENV{'PBBUILDDIR'}/$pbpkg_*.deb $ENV{'PBBUILDDIR'}/$pbpkg_*.dsc $ENV{'PBBUILDDIR'}/$pbpkg_*.tag.gz"
     377            } elsif ($dtype eq "ebuild") {
     378                $src="$ENV{'PBBUILDDIR'}/portage/*/$pbpkg/$pbpkg$pbver.ebuild"
     379            } elsif ($dtype eq "slackware") {
     380                $src="$ENV{'PBBUILDDIR'}/build-$pbpkg/$pbpkg$pbver-*-$pbtag.tgz"
     381            } else {
     382                die "Unknown dtype format $dtype";
     383            }
     384        }
     385        print $LOG "$cmt: $src\n" if ($debug >= 0);
    361386        push @src, $src;
    362387    }
     
    364389    my ($sshhost,$sshlogin,$sshdir) = @$pt;
    365390    my $mac = "$sshlogin->{$ENV{'PBPROJ'}}\@$sshhost->{$ENV{'PBPROJ'}}";
    366     my $dir = "$sshdir->{$ENV{'PBPROJ'}}/src";
    367     pb_system("ssh -q $mac \"mkdir -p $dir\"","Preparing $dir on $mac");
    368     pb_system("scp -p ".join(' ',@src)." $mac:$dir","Source delivery in $dir on $mac");
    369 }
    370 
    371 sub pb_pkg2ssh {
    372 
    373     # Get list of packages to build
    374     my $ptr = pb_get_pkg();
    375     @pkgs = @$ptr;
    376 
    377     # Get the running distro to build on
    378     my ($ddir, $dver, $dfam, $dtype, $dsuf) = pb_distro_init();
    379     print $LOG "DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $dsuf))."\n" if ($debug >= 1);
    380 
    381     # Get content saved in cms2build
    382     my ($pkg) = pb_conf_read("$ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb","pbpkg");
    383     $pkg = { } if (not defined $pkg);
    384 
    385     chdir "$ENV{'PBBUILDDIR'}";
    386     foreach my $pbpkg (@pkgs) {
    387         my $vertag = $pkg->{$pbpkg};
    388         # get the version of the current package - maybe different
    389         ($pbver,$pbtag) = split(/-/,$vertag);
    390 
    391         my $src="$ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz";
    392         print $LOG "Source file: $src\n" if ($debug >= 0);
    393 
    394         if ($dtype eq "rpm") {
    395             # rpm has its own standard build directory
    396             my $tmp=`rpmquery --eval '%{_topdir}' 2> /dev/null`;
    397             chomp($tmp);
    398             $ENV{'PBBUILDDIR'}=$tmp;
    399             print $LOG "Working under $ENV{'PBBUILDDIR'}\n" if ($debug >= 0);
    400             foreach my $d ('RPMS','SRPMS','SPECS','SOURCES','BUILD') {
    401                 if (! -d "$ENV{'PBBUILDDIR'}/$d") {
    402                 pb_mkdir_p("$ENV{'PBBUILDDIR'}/$d") || die "Please ensure that you can write into $ENV{'PBBUILDDIR'} to create $d\nSolution: setup _topdir in your ~/.rpmmacros or\nchown the $ENV{'PBBUILDDIR'} directory to your uid";
    403                 }
    404             }
    405 
    406             # We need to first extract the spec file
    407             symlink "$src","$ENV{'PBBUILDDIR'}/SOURCES/".basename($src) || die "Unable to symlink $src in $ENV{'PBBUILDDIR'}/SOURCES";
    408             my @specfile;
    409             @specfile = pb_extract_build_files($src,"$pbpkg-$pbver/pbconf/$ddir-$dver/","$ENV{'PBBUILDDIR'}/SPECS");
    410 
    411             print $LOG "specfile: ".Dumper(\@specfile)."\n" if ($debug >= 1);
    412             # set LANGUAGE to check for correct log messages
    413             $ENV{'LANGUAGE'}="C";
    414             #system("ls -R $ENV{'PBBUILDDIR'}") if ($debug >= 1);
    415             foreach my $f (@specfile) {
    416                 if ($f =~ /\.spec$/) {
    417                     pb_system("rpmbuild -ba $f","Building package with $f");
    418                     last;
    419                 }
    420             }
    421         } elsif ($dtype eq "tgz") {
    422             pb_mkdir_p("$ENV{'PBBUILDDIR'}/install") if (! -d "$ENV{'PBBUILDDIR'}/install");
    423         } elsif ($dtype eq "ebuild") {
    424             pb_mkdir_p("$ENV{'PBBUILDDIR'}/portage") if (! -d "$ENV{'PBBUILDDIR'}/portage");
    425         } else {
    426         }
    427     }
     391    my $dir;
     392    if ($cmt eq "Sources") {
     393        $dir = "$sshdir->{$ENV{'PBPROJ'}}/src";
     394    } elsif ($cmt eq "Packages") {
     395        $dir = "$sshdir->{$ENV{'PBPROJ'}}/$ddir/$dver";
     396    } else {
     397        return;
     398    }
     399    $src = join(' ',@src);
     400    pb_system("ssh -q $mac \"mkdir -p $dir ; cd $dir ; rm -f $src\"","Preparing $dir on $mac");
     401    pb_system("scp -p $src $mac:$dir","$cmt delivery in $dir on $mac");
    428402}
    429403
Note: See TracChangeset for help on using the changeset viewer.