Changeset 25 for devel/pb/bin/pb.pl


Ignore:
Timestamp:
Aug 1, 2007, 3:30:16 AM (12 years ago)
Author:
bruno
Message:

code of build2pkg done. tests begin

File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb.pl

    r23 r25  
    160160            $build{"$ddir-$dver"} = "yes";
    161161            if (-d "$ENV{'PBCONF'}/$pkg/$dtype") {
    162                 opendir(BDIR,"$ENV{'PBCONF'}/$pkg/$dtype" || die "Unable to open dir $ENV{'PBCONF'}/$pkg/$dtype: $!");
     162                opendir(BDIR,"$ENV{'PBCONF'}/$pkg/$dtype") || die "Unable to open dir $ENV{'PBCONF'}/$pkg/$dtype: $!";
    163163                foreach my $f (readdir(BDIR)) {
    164164                    next if ($f =~ /^\./);
     
    168168                closedir(BDIR);
    169169            } elsif (-d "$ENV{'PBCONF'}/$pkg/$dfam") {
    170                 opendir(BDIR,"$ENV{'PBCONF'}/$pkg/$dfam" || die "Unable to open dir $ENV{'PBCONF'}/$pkg/$dfam: $!");
     170                opendir(BDIR,"$ENV{'PBCONF'}/$pkg/$dfam") || die "Unable to open dir $ENV{'PBCONF'}/$pkg/$dfam: $!";
    171171                foreach my $f (readdir(BDIR)) {
    172172                    next if ($f =~ /^\./);
     
    176176                closedir(BDIR);
    177177            } elsif (-d "$ENV{'PBCONF'}/$pkg/$ddir") {
    178                 opendir(BDIR,"$ENV{'PBCONF'}/$pkg/$ddir" || die "Unable to open dir $ENV{'PBCONF'}/$pkg/$ddir: $!");
     178                opendir(BDIR,"$ENV{'PBCONF'}/$pkg/$ddir") || die "Unable to open dir $ENV{'PBCONF'}/$pkg/$ddir: $!";
    179179                foreach my $f (readdir(BDIR)) {
    180180                    next if ($f =~ /^\./);
     
    184184                closedir(BDIR);
    185185            } elsif (-d "$ENV{'PBCONF'}/$pkg/$ddir-$dver") {
    186                 opendir(BDIR,"$ENV{'PBCONF'}/$pkg/$ddir-$dver" || die "Unable to open dir $ENV{'PBCONF'}/$pkg/$ddir-$dver: $!");
     186                opendir(BDIR,"$ENV{'PBCONF'}/$pkg/$ddir-$dver") || die "Unable to open dir $ENV{'PBCONF'}/$pkg/$ddir-$dver: $!";
    187187                foreach my $f (readdir(BDIR)) {
    188188                    next if ($f =~ /^\./);
     
    269269        chdir "$ENV{'PBDESTDIR'}";
    270270        print $LOG "Creating $pkg tar files (gzip... " if ($debug >= 0);
     271        # Possibility to look at PBSRC to guess more the filename
    271272        system("tar cfphz $pkg-$pbver.tar.gz $pkg-$pbver");
    272273        if ($? == -1) {
     
    300301    # Get the running distro to build on
    301302    my ($ddir, $dver, $dfam, $dtype, $dsuf) = distro_init();
    302     print $LOG "DEBUG: distro tuple: ".Dumper($ddir, $dver, $dfam, $dtype, $dsuf)."\n" if ($debug >= 1);
    303 
     303    print $LOG "DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $dsuf))."\n" if ($debug >= 1);
     304
     305    chdir "$ENV{'PBBUILDDIR'}";
    304306    foreach my $pkg (@pkgs) {
     307        my $src="$ENV{'PBDESTDIR'}/$pkg-$pbver.tar.gz";
     308        print $LOG "Handling source file $src\n" if ($debug >= 0);
     309
     310        if ($dtype eq "rpm") {
     311            # rpm has its own standard build directory
     312            $ENV{'PBBUILDDIR'}=`rpmquery --eval '%{_topdir}' 2> /dev/null`;
     313            chdir "$ENV{'PBBUILDDIR'}";
     314            foreach my $d ('RPMS','SRPMS','SPECS','SOURCES','BUILD') {
     315                pbmkdir_p($d) if (! -d $d) || die "Please ensure that you can write into $ENV{'PBBUILDDIR'}\nSolution: setup _topdir in your ~/.rpmmacros or\nchown the $ENV{'PBBUILDDIR'} directory to your uid";
     316            }
     317
     318            # We need to first extract the spec file
     319            print $LOG "Extracting spec file\n" if ($debug >= 0);
     320            symlink $src,"SOURCES/" || die "Unable to symlink $src in SOURCES";;
     321            chdir "SPECS";
     322            extract_build_files($src,"$pkg-$pbver/pbconf/$ddir-$dver/");
     323
     324            # set LANGUAGE to check for correct log messages
     325            $ENV{'LANGUAGE'}="C";
     326            system("rpmbuild -ba *.spec 2>&1 | tee ");
     327
     328        } elsif ($dtype eq "tgz") {
     329            pbmkdir_p("$ENV{'PBBUILDDIR'}/install") if (! -d "$ENV{'PBBUILDDIR'}/install");
     330        } elsif ($dtype eq "ebuild") {
     331            pbmkdir_p("$ENV{'PBBUILDDIR'}/portage") if (! -d "$ENV{'PBBUILDDIR'}/portage");
     332        } else {
     333        }
    305334    }
    306335} else {
     
    371400}
    372401
     402sub extract_build_files {
     403
     404my $src=shift;
     405my $dir=shift;
     406
     407system("tar xfz $src $dir >/dev/null");
     408if ($? == -1) {
     409    print $LOG "failed to execute: $!\n" if ($debug >= 0);
     410} elsif ($? & 127) {
     411    printf $LOG "child died with signal %d, %s coredump\n", ($? & 127),  ($? & 128) ? 'with' : 'without' if ($debug >= 0);
     412} else {
     413    print $LOG " OK\n" if ($debug >= 0);
     414}
     415opendir(DIR,"$dir") || die "Unable to open directory $dir";
     416foreach my $f (readdir(DIR)) {
     417    next if ($f =~ /^\./);
     418    rename("$dir/$f",".");
     419}
     420closedir(DIR);
     421pbrm_rf("$dir");
     422}
     423
    373424sub syntax {
    374425
Note: See TracChangeset for help on using the changeset viewer.