Ignore:
Timestamp:
Feb 13, 2008, 6:26:07 PM (12 years ago)
Author:
bruno
Message:
  • Param packager => pbpackager for consistency, and PBPACKAGER is an env var usable
  • Base is now a perl package
  • Multiple fixes all around the place with a correct collectl build from http URL
  • Add build2ve/cms2ve/newve/script2ve and mock support
  • build2vm/launchvm => build2v/launchv and has now a parameter
  • send2ssh => send2target, will be able to evolve later + lots of parameter changes to support VE
  • Add file support
  • Add -f option to force rebuilding the chroot
  • Env var PBVM => PBV
  • Update the concepts doc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/lib/ProjectBuilder/Base.pm

    r319 r320  
    1212use File::Basename;
    1313use File::Path;
     14use File::stat;
    1415use File::Copy;
    1516use File::Temp qw(tempdir);
     
    3132
    3233our @ISA = qw(Exporter);
    33 our @EXPORT = qw(pb_env_init pb_conf_read pb_conf_get pb_conf_get_if pb_cms_init pb_mkdir_p pb_system pb_rm_rf pb_get_filters pb_filter_file pb_filter_file_pb pb_filter_file_inplace pb_cms_export pb_cms_log pb_cms_isdiff pb_cms_copy pb_cms_checkout pb_get_date pb_log pb_log_init pb_get_pkg $debug $LOG);
     34our @EXPORT = qw(pb_env_init pb_conf_read pb_conf_read_if pb_conf_get pb_conf_get_if pb_cms_init pb_mkdir_p pb_system pb_rm_rf pb_get_filters pb_filter_file pb_filter_file_pb pb_filter_file_inplace pb_cms_export pb_cms_log pb_cms_isdiff pb_cms_copy pb_cms_checkout pb_get_date pb_log pb_log_init pb_get_pkg $debug $LOG);
    3435
    3536$ENV{'PBETC'} = "$ENV{'HOME'}/.pbrc";
     
    180181
    181182#
     183# The following part is only useful when in cms2build
     184# In VMs/VEs we want to skip that by providing a good PBCONF env var.
     185# return values in that case are useless
     186#
     187return if (defined $ENV{'PBCONF'});
     188
     189#
    182190# Check pbconf compliance
    183191#
     
    216224        my $maxmtime = 0;
    217225        foreach my $d (readdir(DIR)) {
     226            pb_log(3,"Looking at \'$d\'...");
    218227            next if ($d =~ /^\./);
    219             next if (! -d $d);
    220             my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks)
    221                           = stat($d);
     228            next if (! -d "$ENV{'PBCONF'}/$d");
     229            my $s = stat("$ENV{'PBCONF'}/$d");
     230            next if (not defined $s);
     231            pb_log(3,"KEEP\n");
    222232            # Keep the most recent
    223             pb_log(2,"Looking at $d: $mtime\n");
    224             if ($mtime > $maxmtime) {
     233            pb_log(2," $s->mtime\n");
     234            if ($s->mtime > $maxmtime) {
    225235                $ENV{'PBROOT'} = "$ENV{'PBCONF'}/$d";
    226                 $maxmtime = $mtime;
     236                $maxmtime = $s->mtime;
    227237            }
    228238        }
     
    251261if ((-f "$ENV{'PBROOT'}/$ENV{'PBPROJ'}.pb") and (not defined $pbinit)) {
    252262    # List of pkg to build by default (mandatory)
    253     my ($defpkgdir) = pb_conf_get("defpkgdir");
     263    my ($defpkgdir,$pbpackager) = pb_conf_get("defpkgdir","pbpackager");
    254264    # List of additional pkg to build when all is called (optional)
    255265    # Valid version names (optional)
     
    288298    }
    289299    die "Invalid tag name $ENV{'PBTAG'} in $ENV{'PBROOT'}/$ENV{'PBPROJ'}.pb" if ($ENV{'PBTAG'} !~ /[0-9.]+/);
     300
     301
     302    if (not defined $ENV{'PBPACKAGER'}) {
     303        if ((defined $pbpackager) && (defined $pbpackager->{$ENV{'PBPROJ'}})) {
     304            $ENV{'PBPACKAGER'}=$pbpackager->{$ENV{'PBPROJ'}};
     305        } else {
     306            die "No pbpackager found in $ENV{'PBROOT'}/$ENV{'PBPROJ'}.pb";
     307        }
     308    }
    290309} else {
    291310    if (defined $pbinit) {
     
    317336# Packager label
    318337#
    319 #packager $ENV{'PBPROJ'} = "William Porte <bill\@$ENV{'PBPROJ'}.org>"
     338#pbpackager $ENV{'PBPROJ'} = "William Porte <bill\@$ENV{'PBPROJ'}.org>"
    320339#
    321340
     
    960979    push @ptr,$h{$param};
    961980}
    962 pb_log(2,"DEBUG: h:".Dumper(%h)." param:".Dumper(@param)." ptr:".Dumper(@ptr)."\n");
    963981return(@ptr);
    964982}
     
    10551073    } else {
    10561074        $tmp = $destdir."/".basename($source);
     1075        pb_mkdir_p($destdir);
    10571076    }
    10581077    pb_system("svn export $source $tmp","Exporting $source from SVN to $tmp");
    10591078} elsif ($scheme eq "dir") {
    1060     if (-d $source) {
    1061         $tmp = $destdir;
    1062     } else {
    1063         $tmp = $destdir."/".basename($source);
    1064     }
    1065     pb_system("cp -a $source $tmp","Exporting $source from DIR to $tmp");
     1079    pb_system("cp -a $path $destdir","Copying $uri from DIR to $destdir");
    10661080} elsif (($scheme eq "http") || ($scheme eq "ftp")) {
    10671081    my $f = basename($path);
    10681082    unlink "$ENV{'PBTMP'}/$f";
    10691083    if (-x "/usr/bin/wget") {
    1070         pb_system("/usr/bin/wget -nv -O $ENV{'PBTMP'}/$f $uri","Downloading $uri with wget to $ENV{'PBTMP'}/$f\n");
     1084        pb_system("/usr/bin/wget -nv -O $ENV{'PBTMP'}/$f $uri"," ");
    10711085    } elsif (-x "/usr/bin/curl") {
    10721086        pb_system("/usr/bin/curl $uri -o $ENV{'PBTMP'}/$f","Downloading $uri with curl to $ENV{'PBTMP'}/$f\n");
     
    10791093    my $mm = mimetype($path);
    10801094    pb_log(2,"mimetype: $mm\n");
     1095    pb_mkdir_p($destdir);
    10811096
    10821097    if ($mm =~ /\/x-bzip-compressed-tar$/) {
    10831098        # tar+bzip2
     1099        pb_system("cd $destdir ; tar xfj $path","Extracting $path in $destdir");
    10841100    } elsif ($mm =~ /\/x-lzma-compressed-tar$/) {
    10851101        # tar+lzma
     1102        pb_system("cd $destdir ; tar xfY $path","Extracting $path in $destdir");
    10861103    } elsif ($mm =~ /\/x-compressed-tar$/) {
    10871104        # tar+gzip
     1105        pb_system("cd $destdir ; tar xfz $path","Extracting $path in $destdir");
    10881106    } elsif ($mm =~ /\/x-tar$/) {
    10891107        # tar
     1108        pb_system("cd $destdir ; tar xf $path","Extracting $path in $destdir");
    10901109    } elsif ($mm =~ /\/zip$/) {
    10911110        # zip
    1092     }
    1093     pb_log(0,"scheme file not implemented yet\n");
     1111        pb_system("cd $destdir ; unzip $path","Extracting $path in $destdir");
     1112    }
     1113    # Maybe we created an extra level of dir under destdir
     1114    opendir(DIR,$destdir) || die "Unable to open $destdir";
     1115    my $cnt = 0;
     1116    my $d0;
     1117    foreach my $d (readdir(DIR)) {
     1118        pb_log(3,"Looking at \'$d\'...");
     1119        next if ($d =~ /^\./);
     1120        $cnt++;
     1121        $d0 = $d;
     1122    }
     1123    closedir(DIR);
     1124    # Fix that by moving everything below that extra dir under destdir
     1125    # and remove the extra dir
     1126    if ($cnt == 1) {
     1127        pb_system("cd $destdir/$d0 ; mv * .??* .. 2>/dev/null");
     1128        pb_rm_rf("$destdir/$d0");
     1129    }
    10941130} elsif ($scheme eq "cvs") {
    10951131    my $dir=dirname($destdir);
     
    11211157return if ($authors eq "/dev/null");
    11221158open(SAUTH,$authors) || die "Unable to open $authors";
    1123 open(DAUTH,"> $dest/AUTHORS") || die "Unable to create $dest/AUTHORS";
     1159# Save a potentially existing AUTHORS file and write instead toi AUTHORS.pb
     1160my $ext = "";
     1161if (-f "$dest/AUTHORS") {
     1162    $ext = ".pb";
     1163}
     1164open(DAUTH,"> $dest/AUTHORS$ext") || die "Unable to create $dest/AUTHORS$ext";
    11241165print DAUTH "Authors of the project are:\n";
    11251166print DAUTH "===========================\n";
     
    11291170    print DAUTH "$gcos";
    11301171    if (defined $scheme) {
    1131         print DAUTH " ($nick under $scheme)\n";
     1172        # Do not give a scheme for flat types
     1173        my $endstr="";
     1174        if ("$ENV{'PBREVISION'}" ne "flat") {
     1175            $endstr = " under $scheme";
     1176        }
     1177        print DAUTH " ($nick$endstr)\n";
    11321178    } else {
    11331179        print DAUTH "\n";
     
    11391185
    11401186sub pb_cms_log {
     1187
    11411188my $scheme = shift;
    11421189my $pkgdir = shift;
     
    11471194pb_create_authors($authors,$dest,$scheme);
    11481195
    1149 if ($scheme eq "svn") {
     1196if ($scheme =~ /^svn/) {
    11501197    if (! -f "$dest/ChangeLog") {
    11511198        if (-x "/usr/bin/svn2cl") {
     
    11561203        }
    11571204    }
    1158 } elsif ($scheme eq "flat") {
     1205} elsif (($scheme eq "file") || ($scheme eq "dir") || ($scheme eq "http") || ($scheme eq "ftp")) {
    11591206    if (! -f "$dest/ChangeLog") {
    11601207        pb_system("echo ChangeLog for $pkgdir > $dest/ChangeLog","Empty ChangeLog file created");
     
    12221269
    12231270if ($scheme =~ /^svn/) {
    1224     pb_system("svn co $url $destination","Checking $url to $destination ");
     1271    pb_system("svn co $url $destination","Checking out $url to $destination ");
    12251272} elsif ($scheme eq "flat") {
    12261273} elsif ($scheme eq "cvs") {
Note: See TracChangeset for help on using the changeset viewer.