source: ProjectBuilder/devel/pb/bin/pb@ 117

Last change on this file since 117 was 117, checked in by Bruno Cornec, 17 years ago

Better src printing

  • Property svn:executable set to *
File size: 17.6 KB
RevLine 
[5]1#!/usr/bin/perl -w
2#
3# Project Builder main application
4#
5# $Id$
6#
7# Copyright B. Cornec 2007
8# Provided under the GPL v2
9
[22]10# Syntax: see at end
[9]11
[18]12use strict 'vars';
[5]13use Getopt::Std;
[9]14use Data::Dumper;
15use English;
[16]16use AppConfig qw(:argcount :expand);
17use File::Basename;
[26]18use File::Copy;
[13]19use Time::localtime qw(localtime);
20use POSIX qw(strftime);
[5]21
[73]22# Global variables
[17]23use lib qw (lib);
[74]24use ProjectBuilder::Distribution qw (pb_distro_init);
25use ProjectBuilder::Changelog qw (pb_changelog);
26use ProjectBuilder::Version qw (pb_version_init);
[106]27use ProjectBuilder::Base qw (pb_conf_read pb_conf_get pb_cms_init pb_mkdir_p pb_system pb_rm_rf pb_get_filters pb_filter_file pb_filter_file_pb pb_cms_export pb_cms_log);
[5]28
29my %opts; # CLI Options
[9]30my $action; # action to realize
31my $test = "FALSE";
32my $option = "";
33my @pkgs;
[95]34my $pbtag; # Global Tag variable
35my $pbver; # Global Version variable
[77]36my %pbver; # per package
37my %pbtag; # per package
[53]38my $pbrev; # Global REVISION variable
[16]39my @date=(localtime->sec(), localtime->min(), localtime->hour(), localtime->mday(), localtime->mon(), localtime->year(), localtime->wday(), localtime->yday(), localtime->isdst());
40my $pbdate = strftime("%Y-%m-%d", @date);
[112]41my $pbdatecvs = strftime("%Y-%m-%d %H:%M:%S", @date);
[108]42my $debug = 0;
43my $LOG = \*STDOUT;
[5]44
[91]45getopts('hl:m:p:qr:tv',\%opts);
[5]46
[75]47my ($projectbuilderver,$projectbuilderrev) = pb_version_init();
[21]48if (defined $opts{'h'}) {
[74]49 pb_syntax();
[21]50 exit(0);
51}
52if (defined $opts{'v'}) {
53 $debug++;
54}
55if (defined $opts{'q'}) {
56 $debug=-1;
57}
[22]58if (defined $opts{'l'}) {
59 open(LOG,"> $opts{'l'}") || die "Unable to log to $opts{'l'}: $!";
60 $LOG = *LOG;
61 $debug = 0 if ($debug == -1);
62 }
[9]63# Handles test option
64if (defined $opts{'t'}) {
65 $test = "TRUE";
66 # Works only for SVN
67 $option = "-r BASE";
68}
[5]69
[67]70# Handle root of the project if defined
71if (defined $opts{'r'}) {
72 $ENV{'PBROOT'} = $opts{'r'};
73}
[91]74# Handle virtual machines if any
75if (defined $opts{'m'}) {
76 $ENV{'PBVM'} = $opts{'m'};
77}
[108]78
79# Get Action
80$action = shift @ARGV;
81die pb_syntax() if (not defined $action);
82
83my ($pbrc, $filteredfiles, $defpkgdir, $extpkgdir);
84
[59]85# Handles project name if any
[108]86# And get global params
[59]87if (defined $opts{'p'}) {
[107]88 ($ENV{'PBPROJ'},$debug,$LOG, $pbrc, $filteredfiles, $defpkgdir, $extpkgdir)
89 = pb_env_init($opts{'p'});
[59]90} else {
[107]91 ($ENV{'PBPROJ'},$debug,$LOG, $pbrc, $filteredfiles, $defpkgdir, $extpkgdir)
92 = pb_env_init();
[59]93}
94
[108]95print $LOG "Project: $ENV{'PBPROJ'}\n" if ($debug >= 0);
[22]96print $LOG "Action: $action\n" if ($debug >= 0);
[9]97
[91]98# Keep those project values to store them at the end each time
[83]99my $pbprojtag = $ENV{'PBTAG'};
100my $pbprojver = $ENV{'PBVER'};
101
[9]102# Act depending on action
103if ($action =~ /^cms2build$/) {
[77]104 pb_cms2build();
105} elsif ($action =~ /^build2pkg$/) {
106 pb_build2pkg();
107} elsif ($action =~ /^cms2pkg$/) {
108 pb_cms2build();
109 pb_build2pkg();
[88]110} elsif ($action =~ /^build2ssh$/) {
111 pb_build2ssh();
112} elsif ($action =~ /^pkg2ssh$/) {
113 pb_pkg2ssh();
[91]114} elsif ($action =~ /^build2vm$/) {
115 pb_build2vm();
116} elsif ($action =~ /^cms2vm$/) {
117 pb_cms2build();
118 pb_build2vm();
[105]119} elsif ($action =~ /^cms2ssh$/) {
120 pb_cms2build();
121 pb_build2vm();
122 pb_build2ssh();
123 pb_pkg2ssh();
[106]124} elsif ($action =~ /^clean$/) {
[77]125} else {
126 print $LOG "'$action' is not available\n";
127 pb_syntax();
128}
129
130sub pb_cms2build {
131
[112]132 my $ptr = pb_get_pkg($defpkgdir,$extpkgdir);
[22]133 @pkgs = @$ptr;
[112]134 my $cms=pb_cms_init($ENV{'PBPROJ'});
[9]135
[98]136 my ($pkgv, $pkgt) = pb_conf_read("$ENV{'PBCONF'}/$ENV{'PBPROJ'}.pb","pkgver","pkgtag");
[27]137 foreach my $pbpkg (@pkgs) {
[115]138 $ENV{'PBPKG'} = $pbpkg;
[98]139 if ((defined $pkgv) && (defined $pkgv->{$pbpkg})) {
140 $pbver = $pkgv->{$pbpkg};
[115]141 $ENV{'PBVER'} = $pbver;
[9]142 } else {
[16]143 $pbver = $ENV{'PBVER'};
[9]144 }
[98]145 if ((defined $pkgt) && (defined $pkgt->{$pbpkg})) {
146 $pbtag = $pkgt->{$pbpkg};
[115]147 $ENV{'PBTAG'} = $pbtag;
[9]148 } else {
[16]149 $pbtag = $ENV{'PBTAG'};
[9]150 }
[95]151
[16]152 $pbrev = $ENV{'PBREVISION'};
[112]153 print $LOG "\n";
154 print $LOG "Management of $pbpkg $pbver-$pbtag (rev $pbrev)\n";
[9]155 die "Unable to get env var PBDESTDIR" if (not defined $ENV{'PBDESTDIR'});
[16]156 # Clean up dest if necessary. The export will recreate it
[27]157 my $dest = "$ENV{'PBDESTDIR'}/$pbpkg-$pbver";
[74]158 pb_rm_rf($dest) if (-d $dest);
[9]159
160 # Export CMS tree for the concerned package to dest
161 # And generate some additional files
162 $OUTPUT_AUTOFLUSH=1;
[29]163
[9]164 # computes in which dir we have to work
[113]165 my $dir = $defpkgdir->{$pbpkg};
166 $dir = $extpkgdir->{$pbpkg} if (not defined $dir);
[114]167 print "def:".Dumper($defpkgdir)." ext: ".Dumper($extpkgdir)." \n" if ($debug >= 1);
[112]168 pb_cms_export($cms,$pbdatecvs,"$ENV{'PBROOT'}/$dir",$dest);
[9]169
170 # Extract cms log history and store it
[106]171 pb_cms_log($cms,"$ENV{'PBROOT'}/$dir","$dest/$ENV{'PBCMSLOGFILE'}");
[29]172
[21]173 my %build;
[91]174
175 my ($ptr) = pb_conf_get("vmlist");
176 foreach my $d (split(/,/,$ptr->{$ENV{'PBPROJ'}})) {
177 my ($name,$ver) = split(/_/,$d);
[11]178 chomp($ver);
[99]179 my ($ddir, $dver, $dfam, $dtype, $pbsuf) = pb_distro_init($name,$ver);
180 print $LOG "DEBUG: distro tuple: ".Dumper($ddir, $dver, $dfam, $dtype, $pbsuf)."\n" if ($debug >= 1);
[22]181 print $LOG "DEBUG Filtering PBDATE => $pbdate, PBTAG => $pbtag, PBVER => $pbver\n" if ($debug >= 1);
[13]182
[16]183 # Filter build files from the less precise up to the most with overloading
[13]184 # Filter all files found, keeping the name, and generating in dest
[16]185
186 # Find all build files first relatively to PBROOT
187 my %bfiles;
[27]188 print $LOG "DEBUG dir: $ENV{'PBCONF'}/$pbpkg\n" if ($debug >= 1);
[21]189 $build{"$ddir-$dver"} = "yes";
[27]190 if (-d "$ENV{'PBCONF'}/$pbpkg/$dtype") {
191 opendir(BDIR,"$ENV{'PBCONF'}/$pbpkg/$dtype") || die "Unable to open dir $ENV{'PBCONF'}/$pbpkg/$dtype: $!";
[16]192 foreach my $f (readdir(BDIR)) {
193 next if ($f =~ /^\./);
[27]194 $bfiles{$f} = "$ENV{'PBCONF'}/$pbpkg/$dtype/$f";
[16]195 $bfiles{$f} =~ s~$ENV{'PBROOT'}~~;
196 }
[13]197 closedir(BDIR);
[27]198 } elsif (-d "$ENV{'PBCONF'}/$pbpkg/$dfam") {
199 opendir(BDIR,"$ENV{'PBCONF'}/$pbpkg/$dfam") || die "Unable to open dir $ENV{'PBCONF'}/$pbpkg/$dfam: $!";
[16]200 foreach my $f (readdir(BDIR)) {
201 next if ($f =~ /^\./);
[27]202 $bfiles{$f} = "$ENV{'PBCONF'}/$pbpkg/$dfam/$f";
[16]203 $bfiles{$f} =~ s~$ENV{'PBROOT'}~~;
204 }
205 closedir(BDIR);
[27]206 } elsif (-d "$ENV{'PBCONF'}/$pbpkg/$ddir") {
207 opendir(BDIR,"$ENV{'PBCONF'}/$pbpkg/$ddir") || die "Unable to open dir $ENV{'PBCONF'}/$pbpkg/$ddir: $!";
[16]208 foreach my $f (readdir(BDIR)) {
209 next if ($f =~ /^\./);
[27]210 $bfiles{$f} = "$ENV{'PBCONF'}/$pbpkg/$ddir/$f";
[16]211 $bfiles{$f} =~ s~$ENV{'PBROOT'}~~;
212 }
[13]213 closedir(BDIR);
[27]214 } elsif (-d "$ENV{'PBCONF'}/$pbpkg/$ddir-$dver") {
215 opendir(BDIR,"$ENV{'PBCONF'}/$pbpkg/$ddir-$dver") || die "Unable to open dir $ENV{'PBCONF'}/$pbpkg/$ddir-$dver: $!";
[16]216 foreach my $f (readdir(BDIR)) {
217 next if ($f =~ /^\./);
[27]218 $bfiles{$f} = "$ENV{'PBCONF'}/$pbpkg/$ddir-$dver/$f";
[16]219 $bfiles{$f} =~ s~$ENV{'PBROOT'}~~;
220 }
[13]221 closedir(BDIR);
222 } else {
[21]223 $build{"$ddir-$dver"} = "no";
[13]224 next;
225 }
[22]226 print $LOG "DEBUG bfiles: ".Dumper(\%bfiles)."\n" if ($debug >= 1);
[13]227
[15]228 # Get all filters to apply
[77]229 my $ptr = pb_get_filters($pbpkg, $dtype, $dfam, $ddir, $dver);
[15]230
[19]231 # Apply now all the filters on all the files concerned
232 # destination dir depends on the type of file
233 if (defined $ptr) {
234 foreach my $f (values %bfiles) {
[112]235 pb_filter_file_pb("$ENV{'PBROOT'}/$f",$ptr,"$dest/pbconf/$ddir-$dver/".basename($f),$dtype,$pbsuf,$pbpkg,$pbver,$pbtag,$pbrev,$pbdate,$defpkgdir,$extpkgdir);
[16]236 }
[113]237 if (defined $filteredfiles->{$pbpkg}) {
238 foreach my $f (split(/,/,$filteredfiles->{$pbpkg})) {
[99]239 pb_filter_file("$ENV{'PBROOT'}/$dir/$f",$ptr,"$dest/$f",$pbsuf,$pbpkg,$pbver,$pbtag,$pbrev,$pbdate);
[61]240 }
[19]241 }
[15]242 }
[18]243 }
[21]244 if ($debug >= 0) {
245 my @found;
246 my @notfound;
247 foreach my $b (keys %build) {
248 push @found,$b if ($build{$b} =~ /yes/);
249 push @notfound,$b if ($build{$b} =~ /no/);
250 }
[22]251 print $LOG "Build files generated for ".join(',',@found)."\n";
252 print $LOG "No Build files found for ".join(',',@notfound)."\n";
[21]253 }
[18]254 # Prepare the dest directory for archive
[60]255 if (-x "$ENV{'PBCONF'}/$pbpkg/pbinit") {
[108]256 #pb_system("cd $dest ; $ENV{'PBCONF'}/$pbpkg/pbinit","Executing init script $ENV{'PBCONF'}/$pbpkg/pbinit");
257 print $LOG "Executing init script $ENV{'PBCONF'}/$pbpkg/pbinit\n";
258 system("cd $dest ; $ENV{'PBCONF'}/$pbpkg/pbinit");
[11]259 }
[29]260
[18]261 # Archive dest dir
[69]262 chdir "$ENV{'PBDESTDIR'}" || die "Unable to change dir to $ENV{'PBDESTDIR'}";
[25]263 # Possibility to look at PBSRC to guess more the filename
[94]264 pb_system("tar cfz $pbpkg-$pbver.tar.gz $pbpkg-$pbver","Creating $pbpkg tar files compressed");
[31]265 print $LOG "Under $ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz\n" if ($debug >= 0);
[83]266
[70]267 # Keep track of what is generated for default
[113]268 open(LAST,"> $pbrc->{$ENV{'PBPROJ'}}") || die "Unable to create $pbrc->{$ENV{'PBPROJ'}}";
[83]269 print LAST "pbroot $pbprojver-$pbprojtag = $ENV{'PBROOT'}\n";
270 close(LAST);
271
272 # Keep track of per package version
273 if (! -f "$ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb") {
274 open(PKG,">$ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb") || die "Unable to create $ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb";
275 print PKG "# Empty\n";
276 close(PKG);
277 }
[89]278 my ($pkg) = pb_conf_read("$ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb","pbpkg");
[83]279 $pkg = { } if (not defined $pkg);
[88]280 if ((not defined $pkg->{$pbpkg}) || ($pkg->{$pbpkg} ne "$pbver-$pbtag")) {
281 $pkg->{$pbpkg} = "$pbver-$pbtag";
[83]282 }
283
[88]284 print $LOG "DEBUG pkg: ".Dumper($pkg)."\n" if ($debug >= 1);
[83]285 open(PKG,"> $ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb") || die "Unable to create $ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb";
[88]286 foreach my $p (keys %$pkg) {
287 print PKG "pbpkg $p = $pkg->{$p}\n";
[83]288 }
289 close(PKG);
[9]290 }
[77]291}
[22]292
[77]293sub pb_build2pkg {
294
[22]295 # Get list of packages to build
[112]296 my $ptr = pb_get_pkg($defpkgdir,$extpkgdir);
[22]297 @pkgs = @$ptr;
298
299 # Get the running distro to build on
[99]300 my ($ddir, $dver, $dfam, $dtype, $pbsuf) = pb_distro_init();
301 print $LOG "DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf))."\n" if ($debug >= 1);
[22]302
[83]303 # Get content saved in cms2build
[89]304 my ($pkg) = pb_conf_read("$ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb","pbpkg");
[83]305 $pkg = { } if (not defined $pkg);
306
[25]307 chdir "$ENV{'PBBUILDDIR'}";
[27]308 foreach my $pbpkg (@pkgs) {
[88]309 my $vertag = $pkg->{$pbpkg};
[77]310 # get the version of the current package - maybe different
311 ($pbver,$pbtag) = split(/-/,$vertag);
312
[27]313 my $src="$ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz";
[67]314 print $LOG "Source file: $src\n" if ($debug >= 0);
[25]315
316 if ($dtype eq "rpm") {
[28]317 print $LOG "Working under $ENV{'PBBUILDDIR'}\n" if ($debug >= 0);
[25]318 foreach my $d ('RPMS','SRPMS','SPECS','SOURCES','BUILD') {
[28]319 if (! -d "$ENV{'PBBUILDDIR'}/$d") {
[96]320 pb_mkdir_p("$ENV{'PBBUILDDIR'}/$d") || die "Please ensure that you can write into $ENV{'PBBUILDDIR'} to create $d\nchown the $ENV{'PBBUILDDIR'} directory to your uid";
[28]321 }
[25]322 }
323
324 # We need to first extract the spec file
[28]325 symlink "$src","$ENV{'PBBUILDDIR'}/SOURCES/".basename($src) || die "Unable to symlink $src in $ENV{'PBBUILDDIR'}/SOURCES";
326 my @specfile;
[77]327 @specfile = pb_extract_build_files($src,"$pbpkg-$pbver/pbconf/$ddir-$dver/","$ENV{'PBBUILDDIR'}/SPECS");
[25]328
[28]329 print $LOG "specfile: ".Dumper(\@specfile)."\n" if ($debug >= 1);
[25]330 # set LANGUAGE to check for correct log messages
331 $ENV{'LANGUAGE'}="C";
[28]332 #system("ls -R $ENV{'PBBUILDDIR'}") if ($debug >= 1);
333 foreach my $f (@specfile) {
334 if ($f =~ /\.spec$/) {
[97]335 pb_system("rpmbuild --define \"_topdir $ENV{'PBBUILDDIR'}\" -ba $f","Building package with $f under $ENV{'PBBUILDDIR'}");
[28]336 last;
337 }
338 }
[87]339 } elsif ($dtype eq "tgz") {
340 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");
343 } else {
344 }
345 }
346}
347
[88]348sub pb_build2ssh {
[90]349 pb_send2ssh("Sources");
350}
[87]351
[90]352sub pb_pkg2ssh {
353 pb_send2ssh("Packages");
354}
355
[108]356# By default deliver to the the public site hosting the
357# ftp structure (or whatever) or a VM
[90]358sub pb_send2ssh {
359
360 my $cmt = shift;
[108]361 my $host = shift || "sshhost";
362 my $login = shift || "sshlogin";
363 my $dir = shift || "sshdir";
364 my $port = shift || "sshport";
[90]365
[88]366 my @src;
367
[87]368 # Get list of packages to build
[112]369 my $ptr = pb_get_pkg($defpkgdir,$extpkgdir);
[87]370 @pkgs = @$ptr;
371
372 # Get the running distro to build on
[99]373 my ($ddir, $dver, $dfam, $dtype, $pbsuf) = pb_distro_init();
374 print $LOG "DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf))."\n" if ($debug >= 1);
[87]375
376 # Get content saved in cms2build
[89]377 my ($pkg) = pb_conf_read("$ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb","pbpkg");
[87]378 $pkg = { } if (not defined $pkg);
379
380 chdir "$ENV{'PBBUILDDIR'}";
[90]381 my $src;
[87]382 foreach my $pbpkg (@pkgs) {
[88]383 my $vertag = $pkg->{$pbpkg};
[87]384 # get the version of the current package - maybe different
385 ($pbver,$pbtag) = split(/-/,$vertag);
386
[90]387 if ($cmt eq "Sources") {
388 $src="$ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz";
[108]389 } elsif ($cmt eq "VMs") {
390 $src="$ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz $ENV{'PBDESTDIR'}/pbscript $ENV{'PBETC'}";
[90]391 } elsif ($cmt eq "Packages") {
392 if ($dtype eq "rpm") {
[99]393 $src="$ENV{'PBBUILDDIR'}/RPMS/*/$pbpkg-$pbver-$pbtag$pbsuf.*.rpm $ENV{'PBBUILDDIR'}/SRPMS/$pbpkg-$pbver-$pbtag$pbsuf.src.rpm"
[90]394 } elsif ($dtype eq "deb") {
[91]395 my $tmp = "$ENV{'PBBUILDDIR'}/$pbpkg";
396 $src="$tmp"."_*.deb $tmp"."_*.dsc $tmp"."_*.tar.gz"
[90]397 } elsif ($dtype eq "ebuild") {
[96]398 $src="$ENV{'PBBUILDDIR'}/portage/*/$pbpkg/$pbpkg-$pbver.ebuild"
[90]399 } elsif ($dtype eq "slackware") {
[96]400 $src="$ENV{'PBBUILDDIR'}/build-$pbpkg/$pbpkg-$pbver-*-$pbtag.tgz"
[90]401 } else {
402 die "Unknown dtype format $dtype";
403 }
[108]404 # Also make a pbscript to generate yum/urpmi/apt bases
405 # $src = "$src $ENV{'PBDESTDIR'}/pbscript"
[90]406 }
[88]407 push @src, $src;
[87]408 }
[117]409 $src = join(' ',@src);
410 print $LOG "$cmt: $src\n" if ($debug >= 0);
[108]411 my ($sshhost,$sshlogin,$sshdir,$sshport) = pb_conf_get($host,$login,$dir,$port);
[88]412 my $mac = "$sshlogin->{$ENV{'PBPROJ'}}\@$sshhost->{$ENV{'PBPROJ'}}";
[108]413 my $tdir;
[90]414 if ($cmt eq "Sources") {
[108]415 $tdir = "$sshdir->{$ENV{'PBPROJ'}}/src";
416 } elsif ($cmt eq "VMs") {
417 $tdir = "$sshdir->{$ENV{'PBPROJ'}}";
[90]418 } elsif ($cmt eq "Packages") {
[108]419 $tdir = "$sshdir->{$ENV{'PBPROJ'}}/$ddir/$dver";
[90]420 } else {
421 return;
[22]422 }
[111]423 $port = $sshport->{$ENV{'PBPROJ'}};
424 pb_system("ssh -q -p $port $mac \"mkdir -p $tdir ; cd $tdir ; rm -f $src\"","Preparing $tdir on $mac");
425 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");
[108]427 if ($cmt eq "VMs") {
[111]428 pb_system("scp -p -P $port $mac:$tdir/.... ...","Package recovery in $tdir from $mac");
[108]429 }
[9]430}
[16]431
[105]432sub pb_build2vm {
433 my ($vm,$all) = pb_get_vm();
[106]434
[108]435 # Prepare the script to be executed on the VM
436 # 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
[106]441 # Send tar files when we do a global generation
442 pb_build2ssh() if ($all == 1);
[105]443}
444
[77]445sub pb_get_pkg {
[16]446
[22]447my @pkgs;
[108]448my $defpkgdir = shift;
449my $extpkgdir = shift;
[22]450
451# Get packages list
452if (not defined $ARGV[0]) {
[112]453 @pkgs = keys %$defpkgdir;
[22]454} elsif ($ARGV[0] =~ /^all$/) {
[112]455 @pkgs = keys %$defpkgdir;
456 push(@pkgs, keys %$extpkgdir);
[22]457} else {
458 @pkgs = @ARGV;
459}
460print $LOG "Packages: ".join(',',@pkgs)."\n" if ($debug >= 0);
461return(\@pkgs);
462}
463
[105]464#
465# Return the list of VMs we are working on
466# $all is a flag to know if we return all of them
467# or only some (if all we publish also tar files in addition to pkgs
468#
[91]469sub pb_get_vm {
470
471my @vm;
[105]472my $all = 0;
[91]473
474# Get VM list
[105]475if ((not defined $ENV{'PBVM'}) || ($ENV{'PBVM'} =~ /^all$/)) {
[108]476 my ($ptr) = pb_conf_get("vmlist");
[105]477 $ENV{'PBVM'} = $ptr->{$ENV{'PBPROJ'}};
478 $all = 1;
[91]479}
[105]480@vm = split(/,/,$ENV{'PBVM'});
[108]481print $LOG "VMs: ".join(',',@vm)."\n";
[105]482return(\@vm,$all);
[91]483}
484
[77]485sub pb_extract_build_files {
[25]486
487my $src=shift;
488my $dir=shift;
[26]489my $ddir=shift;
[28]490my @files;
[25]491
[106]492pb_system("tar xfpz $src $dir","Extracting build files");
[25]493opendir(DIR,"$dir") || die "Unable to open directory $dir";
494foreach my $f (readdir(DIR)) {
495 next if ($f =~ /^\./);
[26]496 move("$dir/$f","$ddir") || die "Unable to move $dir/$f to $ddir";
[28]497 print $LOG "mv $dir/$f $ddir\n" if ($debug >= 1);
498 push @files,"$ddir/$f";
[25]499}
500closedir(DIR);
[26]501# Not enough but still a first cleanup
[74]502pb_rm_rf("$dir");
[28]503return(@files);
[25]504}
505
[74]506sub pb_syntax {
[21]507
[53]508 print "pb (aka project-builder) Version $projectbuilderver-$projectbuilderrev\n";
509 print "\n";
[105]510 print "Syntax: pb [-vhqt][-r pbroot][-p project][-m \"mach-1[,...]\"] <action> [<pkg1>...]\n";
[21]511 print "\n";
512 print "-h : This help file\n";
513 print "-q : Quiet mode\n";
514 print "-t : Test mode (not done yet)\n";
515 print "-v : Verbose mode\n";
516 print "\n";
[91]517 print "-m machine : Name of the virtual Machines you want\n";
518 print " to build on (space separated) \n";
519 print " (or use the env variable PBVM) \n";
[69]520 print "\n";
[21]521 print "-p project : Name of the project you're working on\n";
522 print " (or use the env variable PBPROJ) \n";
523 print "\n";
[91]524 print "-r pbroot : Path Name of project under the CMS \n";
525 print " (or use the env variable PBROOT) \n";
526 print "\n";
[105]527 print "<params> can be the name of packages\n";
[21]528 print "<action> can be:\n";
529 print "\n";
[105]530 print "\tcms2build: Create tar files for the project under your CMS\n";
[21]531 print "\t CMS supported are SVN and CVS\n";
[22]532 print "\t parameters are packages to build\n";
533 print "\t if not using default list\n";
[21]534 print "\n";
535 print "\tbuild2pkg: Create packages for your running distribution \n";
[22]536 print "\t first parameter is version-tag to build\n";
537 print "\t if not using default version-tag\n";
538 print "\t following parameters are packages to build\n";
539 print "\t if not using default list\n";
[21]540 print "\n";
[105]541 print "\tbuild2ssh: Send the tar files to a SSH host \n";
542 print "\n";
543 print "\tpkg2ssh: Send the packages built to a SSH host \n";
544 print "\n";
[77]545 print "\tcms2pkg: cms2build + build2pkg\n";
[21]546 print "\n";
547}
Note: See TracBrowser for help on using the repository browser.