[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] | 12 | use strict 'vars';
|
---|
[5] | 13 | use Getopt::Std;
|
---|
[9] | 14 | use Data::Dumper;
|
---|
| 15 | use English;
|
---|
[16] | 16 | use AppConfig qw(:argcount :expand);
|
---|
| 17 | use File::Basename;
|
---|
[26] | 18 | use File::Copy;
|
---|
[13] | 19 | use Time::localtime qw(localtime);
|
---|
| 20 | use POSIX qw(strftime);
|
---|
[5] | 21 |
|
---|
[73] | 22 | # Global variables
|
---|
[17] | 23 | use lib qw (lib);
|
---|
[74] | 24 | use ProjectBuilder::Distribution qw (pb_distro_init);
|
---|
| 25 | use ProjectBuilder::Changelog qw (pb_changelog);
|
---|
| 26 | use ProjectBuilder::Version qw (pb_version_init);
|
---|
[106] | 27 | use 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 |
|
---|
| 29 | my %opts; # CLI Options
|
---|
[9] | 30 | my $action; # action to realize
|
---|
| 31 | my $test = "FALSE";
|
---|
| 32 | my $option = "";
|
---|
| 33 | my @pkgs;
|
---|
[95] | 34 | my $pbtag; # Global Tag variable
|
---|
| 35 | my $pbver; # Global Version variable
|
---|
[141] | 36 | my $pbscript; # Name of the script
|
---|
[77] | 37 | my %pbver; # per package
|
---|
| 38 | my %pbtag; # per package
|
---|
[53] | 39 | my $pbrev; # Global REVISION variable
|
---|
[16] | 40 | my @date=(localtime->sec(), localtime->min(), localtime->hour(), localtime->mday(), localtime->mon(), localtime->year(), localtime->wday(), localtime->yday(), localtime->isdst());
|
---|
| 41 | my $pbdate = strftime("%Y-%m-%d", @date);
|
---|
[112] | 42 | my $pbdatecvs = strftime("%Y-%m-%d %H:%M:%S", @date);
|
---|
[108] | 43 | my $debug = 0;
|
---|
| 44 | my $LOG = \*STDOUT;
|
---|
[5] | 45 |
|
---|
[141] | 46 | getopts('hl:m:p:qr:s:tv',\%opts);
|
---|
[5] | 47 |
|
---|
[75] | 48 | my ($projectbuilderver,$projectbuilderrev) = pb_version_init();
|
---|
[21] | 49 | if (defined $opts{'h'}) {
|
---|
[74] | 50 | pb_syntax();
|
---|
[21] | 51 | exit(0);
|
---|
| 52 | }
|
---|
| 53 | if (defined $opts{'v'}) {
|
---|
| 54 | $debug++;
|
---|
| 55 | }
|
---|
| 56 | if (defined $opts{'q'}) {
|
---|
| 57 | $debug=-1;
|
---|
| 58 | }
|
---|
[22] | 59 | if (defined $opts{'l'}) {
|
---|
| 60 | open(LOG,"> $opts{'l'}") || die "Unable to log to $opts{'l'}: $!";
|
---|
| 61 | $LOG = *LOG;
|
---|
| 62 | $debug = 0 if ($debug == -1);
|
---|
| 63 | }
|
---|
[9] | 64 | # Handles test option
|
---|
| 65 | if (defined $opts{'t'}) {
|
---|
| 66 | $test = "TRUE";
|
---|
| 67 | # Works only for SVN
|
---|
| 68 | $option = "-r BASE";
|
---|
| 69 | }
|
---|
[5] | 70 |
|
---|
[67] | 71 | # Handle root of the project if defined
|
---|
| 72 | if (defined $opts{'r'}) {
|
---|
| 73 | $ENV{'PBROOT'} = $opts{'r'};
|
---|
| 74 | }
|
---|
[91] | 75 | # Handle virtual machines if any
|
---|
| 76 | if (defined $opts{'m'}) {
|
---|
| 77 | $ENV{'PBVM'} = $opts{'m'};
|
---|
| 78 | }
|
---|
[141] | 79 | if (defined $opts{'s'}) {
|
---|
| 80 | $pbscript = $opts{'s'};
|
---|
| 81 | }
|
---|
[108] | 82 |
|
---|
| 83 | # Get Action
|
---|
| 84 | $action = shift @ARGV;
|
---|
| 85 | die pb_syntax() if (not defined $action);
|
---|
| 86 |
|
---|
| 87 | my ($pbrc, $filteredfiles, $defpkgdir, $extpkgdir);
|
---|
| 88 |
|
---|
[59] | 89 | # Handles project name if any
|
---|
[108] | 90 | # And get global params
|
---|
[59] | 91 | if (defined $opts{'p'}) {
|
---|
[107] | 92 | ($ENV{'PBPROJ'},$debug,$LOG, $pbrc, $filteredfiles, $defpkgdir, $extpkgdir)
|
---|
| 93 | = pb_env_init($opts{'p'});
|
---|
[59] | 94 | } else {
|
---|
[107] | 95 | ($ENV{'PBPROJ'},$debug,$LOG, $pbrc, $filteredfiles, $defpkgdir, $extpkgdir)
|
---|
| 96 | = pb_env_init();
|
---|
[59] | 97 | }
|
---|
| 98 |
|
---|
[108] | 99 | print $LOG "Project: $ENV{'PBPROJ'}\n" if ($debug >= 0);
|
---|
[22] | 100 | print $LOG "Action: $action\n" if ($debug >= 0);
|
---|
[9] | 101 |
|
---|
[91] | 102 | # Keep those project values to store them at the end each time
|
---|
[83] | 103 | my $pbprojtag = $ENV{'PBTAG'};
|
---|
| 104 | my $pbprojver = $ENV{'PBVER'};
|
---|
| 105 |
|
---|
[9] | 106 | # Act depending on action
|
---|
| 107 | if ($action =~ /^cms2build$/) {
|
---|
[77] | 108 | pb_cms2build();
|
---|
| 109 | } elsif ($action =~ /^build2pkg$/) {
|
---|
| 110 | pb_build2pkg();
|
---|
| 111 | } elsif ($action =~ /^cms2pkg$/) {
|
---|
| 112 | pb_cms2build();
|
---|
| 113 | pb_build2pkg();
|
---|
[88] | 114 | } elsif ($action =~ /^build2ssh$/) {
|
---|
| 115 | pb_build2ssh();
|
---|
| 116 | } elsif ($action =~ /^pkg2ssh$/) {
|
---|
| 117 | pb_pkg2ssh();
|
---|
[91] | 118 | } elsif ($action =~ /^build2vm$/) {
|
---|
| 119 | pb_build2vm();
|
---|
| 120 | } elsif ($action =~ /^cms2vm$/) {
|
---|
| 121 | pb_cms2build();
|
---|
| 122 | pb_build2vm();
|
---|
[141] | 123 | } elsif ($action =~ /^launchvm$/) {
|
---|
[142] | 124 | pb_launchvm($ENV{'PBVM'});
|
---|
| 125 | } elsif ($action =~ /^script2vm$/) {
|
---|
| 126 | pb_script2vm($pbscript);
|
---|
[106] | 127 | } elsif ($action =~ /^clean$/) {
|
---|
[77] | 128 | } else {
|
---|
| 129 | print $LOG "'$action' is not available\n";
|
---|
| 130 | pb_syntax();
|
---|
| 131 | }
|
---|
| 132 |
|
---|
| 133 | sub pb_cms2build {
|
---|
| 134 |
|
---|
[112] | 135 | my $ptr = pb_get_pkg($defpkgdir,$extpkgdir);
|
---|
[22] | 136 | @pkgs = @$ptr;
|
---|
[112] | 137 | my $cms=pb_cms_init($ENV{'PBPROJ'});
|
---|
[9] | 138 |
|
---|
[98] | 139 | my ($pkgv, $pkgt) = pb_conf_read("$ENV{'PBCONF'}/$ENV{'PBPROJ'}.pb","pkgver","pkgtag");
|
---|
[27] | 140 | foreach my $pbpkg (@pkgs) {
|
---|
[115] | 141 | $ENV{'PBPKG'} = $pbpkg;
|
---|
[98] | 142 | if ((defined $pkgv) && (defined $pkgv->{$pbpkg})) {
|
---|
| 143 | $pbver = $pkgv->{$pbpkg};
|
---|
[115] | 144 | $ENV{'PBVER'} = $pbver;
|
---|
[9] | 145 | } else {
|
---|
[16] | 146 | $pbver = $ENV{'PBVER'};
|
---|
[9] | 147 | }
|
---|
[98] | 148 | if ((defined $pkgt) && (defined $pkgt->{$pbpkg})) {
|
---|
| 149 | $pbtag = $pkgt->{$pbpkg};
|
---|
[115] | 150 | $ENV{'PBTAG'} = $pbtag;
|
---|
[9] | 151 | } else {
|
---|
[16] | 152 | $pbtag = $ENV{'PBTAG'};
|
---|
[9] | 153 | }
|
---|
[95] | 154 |
|
---|
[16] | 155 | $pbrev = $ENV{'PBREVISION'};
|
---|
[112] | 156 | print $LOG "\n";
|
---|
| 157 | print $LOG "Management of $pbpkg $pbver-$pbtag (rev $pbrev)\n";
|
---|
[9] | 158 | die "Unable to get env var PBDESTDIR" if (not defined $ENV{'PBDESTDIR'});
|
---|
[16] | 159 | # Clean up dest if necessary. The export will recreate it
|
---|
[27] | 160 | my $dest = "$ENV{'PBDESTDIR'}/$pbpkg-$pbver";
|
---|
[74] | 161 | pb_rm_rf($dest) if (-d $dest);
|
---|
[9] | 162 |
|
---|
| 163 | # Export CMS tree for the concerned package to dest
|
---|
| 164 | # And generate some additional files
|
---|
| 165 | $OUTPUT_AUTOFLUSH=1;
|
---|
[29] | 166 |
|
---|
[9] | 167 | # computes in which dir we have to work
|
---|
[113] | 168 | my $dir = $defpkgdir->{$pbpkg};
|
---|
| 169 | $dir = $extpkgdir->{$pbpkg} if (not defined $dir);
|
---|
[114] | 170 | print "def:".Dumper($defpkgdir)." ext: ".Dumper($extpkgdir)." \n" if ($debug >= 1);
|
---|
[112] | 171 | pb_cms_export($cms,$pbdatecvs,"$ENV{'PBROOT'}/$dir",$dest);
|
---|
[9] | 172 |
|
---|
| 173 | # Extract cms log history and store it
|
---|
[106] | 174 | pb_cms_log($cms,"$ENV{'PBROOT'}/$dir","$dest/$ENV{'PBCMSLOGFILE'}");
|
---|
[29] | 175 |
|
---|
[21] | 176 | my %build;
|
---|
[91] | 177 |
|
---|
| 178 | my ($ptr) = pb_conf_get("vmlist");
|
---|
| 179 | foreach my $d (split(/,/,$ptr->{$ENV{'PBPROJ'}})) {
|
---|
| 180 | my ($name,$ver) = split(/_/,$d);
|
---|
[11] | 181 | chomp($ver);
|
---|
[99] | 182 | my ($ddir, $dver, $dfam, $dtype, $pbsuf) = pb_distro_init($name,$ver);
|
---|
| 183 | print $LOG "DEBUG: distro tuple: ".Dumper($ddir, $dver, $dfam, $dtype, $pbsuf)."\n" if ($debug >= 1);
|
---|
[22] | 184 | print $LOG "DEBUG Filtering PBDATE => $pbdate, PBTAG => $pbtag, PBVER => $pbver\n" if ($debug >= 1);
|
---|
[13] | 185 |
|
---|
[16] | 186 | # Filter build files from the less precise up to the most with overloading
|
---|
[13] | 187 | # Filter all files found, keeping the name, and generating in dest
|
---|
[16] | 188 |
|
---|
| 189 | # Find all build files first relatively to PBROOT
|
---|
| 190 | my %bfiles;
|
---|
[27] | 191 | print $LOG "DEBUG dir: $ENV{'PBCONF'}/$pbpkg\n" if ($debug >= 1);
|
---|
[21] | 192 | $build{"$ddir-$dver"} = "yes";
|
---|
[27] | 193 | if (-d "$ENV{'PBCONF'}/$pbpkg/$dtype") {
|
---|
| 194 | opendir(BDIR,"$ENV{'PBCONF'}/$pbpkg/$dtype") || die "Unable to open dir $ENV{'PBCONF'}/$pbpkg/$dtype: $!";
|
---|
[16] | 195 | foreach my $f (readdir(BDIR)) {
|
---|
| 196 | next if ($f =~ /^\./);
|
---|
[27] | 197 | $bfiles{$f} = "$ENV{'PBCONF'}/$pbpkg/$dtype/$f";
|
---|
[16] | 198 | $bfiles{$f} =~ s~$ENV{'PBROOT'}~~;
|
---|
| 199 | }
|
---|
[13] | 200 | closedir(BDIR);
|
---|
[27] | 201 | } elsif (-d "$ENV{'PBCONF'}/$pbpkg/$dfam") {
|
---|
| 202 | opendir(BDIR,"$ENV{'PBCONF'}/$pbpkg/$dfam") || die "Unable to open dir $ENV{'PBCONF'}/$pbpkg/$dfam: $!";
|
---|
[16] | 203 | foreach my $f (readdir(BDIR)) {
|
---|
| 204 | next if ($f =~ /^\./);
|
---|
[27] | 205 | $bfiles{$f} = "$ENV{'PBCONF'}/$pbpkg/$dfam/$f";
|
---|
[16] | 206 | $bfiles{$f} =~ s~$ENV{'PBROOT'}~~;
|
---|
| 207 | }
|
---|
| 208 | closedir(BDIR);
|
---|
[27] | 209 | } elsif (-d "$ENV{'PBCONF'}/$pbpkg/$ddir") {
|
---|
| 210 | opendir(BDIR,"$ENV{'PBCONF'}/$pbpkg/$ddir") || die "Unable to open dir $ENV{'PBCONF'}/$pbpkg/$ddir: $!";
|
---|
[16] | 211 | foreach my $f (readdir(BDIR)) {
|
---|
| 212 | next if ($f =~ /^\./);
|
---|
[27] | 213 | $bfiles{$f} = "$ENV{'PBCONF'}/$pbpkg/$ddir/$f";
|
---|
[16] | 214 | $bfiles{$f} =~ s~$ENV{'PBROOT'}~~;
|
---|
| 215 | }
|
---|
[13] | 216 | closedir(BDIR);
|
---|
[27] | 217 | } elsif (-d "$ENV{'PBCONF'}/$pbpkg/$ddir-$dver") {
|
---|
| 218 | opendir(BDIR,"$ENV{'PBCONF'}/$pbpkg/$ddir-$dver") || die "Unable to open dir $ENV{'PBCONF'}/$pbpkg/$ddir-$dver: $!";
|
---|
[16] | 219 | foreach my $f (readdir(BDIR)) {
|
---|
| 220 | next if ($f =~ /^\./);
|
---|
[27] | 221 | $bfiles{$f} = "$ENV{'PBCONF'}/$pbpkg/$ddir-$dver/$f";
|
---|
[16] | 222 | $bfiles{$f} =~ s~$ENV{'PBROOT'}~~;
|
---|
| 223 | }
|
---|
[13] | 224 | closedir(BDIR);
|
---|
| 225 | } else {
|
---|
[21] | 226 | $build{"$ddir-$dver"} = "no";
|
---|
[13] | 227 | next;
|
---|
| 228 | }
|
---|
[22] | 229 | print $LOG "DEBUG bfiles: ".Dumper(\%bfiles)."\n" if ($debug >= 1);
|
---|
[13] | 230 |
|
---|
[15] | 231 | # Get all filters to apply
|
---|
[77] | 232 | my $ptr = pb_get_filters($pbpkg, $dtype, $dfam, $ddir, $dver);
|
---|
[15] | 233 |
|
---|
[19] | 234 | # Apply now all the filters on all the files concerned
|
---|
| 235 | # destination dir depends on the type of file
|
---|
| 236 | if (defined $ptr) {
|
---|
| 237 | foreach my $f (values %bfiles) {
|
---|
[112] | 238 | pb_filter_file_pb("$ENV{'PBROOT'}/$f",$ptr,"$dest/pbconf/$ddir-$dver/".basename($f),$dtype,$pbsuf,$pbpkg,$pbver,$pbtag,$pbrev,$pbdate,$defpkgdir,$extpkgdir);
|
---|
[16] | 239 | }
|
---|
[113] | 240 | if (defined $filteredfiles->{$pbpkg}) {
|
---|
| 241 | foreach my $f (split(/,/,$filteredfiles->{$pbpkg})) {
|
---|
[99] | 242 | pb_filter_file("$ENV{'PBROOT'}/$dir/$f",$ptr,"$dest/$f",$pbsuf,$pbpkg,$pbver,$pbtag,$pbrev,$pbdate);
|
---|
[61] | 243 | }
|
---|
[19] | 244 | }
|
---|
[15] | 245 | }
|
---|
[18] | 246 | }
|
---|
[21] | 247 | if ($debug >= 0) {
|
---|
| 248 | my @found;
|
---|
| 249 | my @notfound;
|
---|
| 250 | foreach my $b (keys %build) {
|
---|
| 251 | push @found,$b if ($build{$b} =~ /yes/);
|
---|
| 252 | push @notfound,$b if ($build{$b} =~ /no/);
|
---|
| 253 | }
|
---|
[22] | 254 | print $LOG "Build files generated for ".join(',',@found)."\n";
|
---|
| 255 | print $LOG "No Build files found for ".join(',',@notfound)."\n";
|
---|
[21] | 256 | }
|
---|
[18] | 257 | # Prepare the dest directory for archive
|
---|
[60] | 258 | if (-x "$ENV{'PBCONF'}/$pbpkg/pbinit") {
|
---|
[108] | 259 | #pb_system("cd $dest ; $ENV{'PBCONF'}/$pbpkg/pbinit","Executing init script $ENV{'PBCONF'}/$pbpkg/pbinit");
|
---|
| 260 | print $LOG "Executing init script $ENV{'PBCONF'}/$pbpkg/pbinit\n";
|
---|
| 261 | system("cd $dest ; $ENV{'PBCONF'}/$pbpkg/pbinit");
|
---|
[11] | 262 | }
|
---|
[29] | 263 |
|
---|
[18] | 264 | # Archive dest dir
|
---|
[69] | 265 | chdir "$ENV{'PBDESTDIR'}" || die "Unable to change dir to $ENV{'PBDESTDIR'}";
|
---|
[25] | 266 | # Possibility to look at PBSRC to guess more the filename
|
---|
[94] | 267 | pb_system("tar cfz $pbpkg-$pbver.tar.gz $pbpkg-$pbver","Creating $pbpkg tar files compressed");
|
---|
[31] | 268 | print $LOG "Under $ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz\n" if ($debug >= 0);
|
---|
[83] | 269 |
|
---|
[70] | 270 | # Keep track of what is generated for default
|
---|
[113] | 271 | open(LAST,"> $pbrc->{$ENV{'PBPROJ'}}") || die "Unable to create $pbrc->{$ENV{'PBPROJ'}}";
|
---|
[83] | 272 | print LAST "pbroot $pbprojver-$pbprojtag = $ENV{'PBROOT'}\n";
|
---|
| 273 | close(LAST);
|
---|
| 274 |
|
---|
| 275 | # Keep track of per package version
|
---|
| 276 | if (! -f "$ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb") {
|
---|
| 277 | open(PKG,">$ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb") || die "Unable to create $ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb";
|
---|
| 278 | print PKG "# Empty\n";
|
---|
| 279 | close(PKG);
|
---|
| 280 | }
|
---|
[89] | 281 | my ($pkg) = pb_conf_read("$ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb","pbpkg");
|
---|
[83] | 282 | $pkg = { } if (not defined $pkg);
|
---|
[88] | 283 | if ((not defined $pkg->{$pbpkg}) || ($pkg->{$pbpkg} ne "$pbver-$pbtag")) {
|
---|
| 284 | $pkg->{$pbpkg} = "$pbver-$pbtag";
|
---|
[83] | 285 | }
|
---|
| 286 |
|
---|
[88] | 287 | print $LOG "DEBUG pkg: ".Dumper($pkg)."\n" if ($debug >= 1);
|
---|
[83] | 288 | open(PKG,"> $ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb") || die "Unable to create $ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb";
|
---|
[88] | 289 | foreach my $p (keys %$pkg) {
|
---|
| 290 | print PKG "pbpkg $p = $pkg->{$p}\n";
|
---|
[83] | 291 | }
|
---|
| 292 | close(PKG);
|
---|
[9] | 293 | }
|
---|
[77] | 294 | }
|
---|
[22] | 295 |
|
---|
[77] | 296 | sub pb_build2pkg {
|
---|
| 297 |
|
---|
[22] | 298 | # Get list of packages to build
|
---|
[112] | 299 | my $ptr = pb_get_pkg($defpkgdir,$extpkgdir);
|
---|
[22] | 300 | @pkgs = @$ptr;
|
---|
| 301 |
|
---|
| 302 | # Get the running distro to build on
|
---|
[99] | 303 | my ($ddir, $dver, $dfam, $dtype, $pbsuf) = pb_distro_init();
|
---|
| 304 | print $LOG "DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf))."\n" if ($debug >= 1);
|
---|
[22] | 305 |
|
---|
[83] | 306 | # Get content saved in cms2build
|
---|
[89] | 307 | my ($pkg) = pb_conf_read("$ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb","pbpkg");
|
---|
[83] | 308 | $pkg = { } if (not defined $pkg);
|
---|
| 309 |
|
---|
[25] | 310 | chdir "$ENV{'PBBUILDDIR'}";
|
---|
[126] | 311 | my $made = ""; # pkgs made during build
|
---|
[27] | 312 | foreach my $pbpkg (@pkgs) {
|
---|
[88] | 313 | my $vertag = $pkg->{$pbpkg};
|
---|
[77] | 314 | # get the version of the current package - maybe different
|
---|
| 315 | ($pbver,$pbtag) = split(/-/,$vertag);
|
---|
| 316 |
|
---|
[27] | 317 | my $src="$ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz";
|
---|
[67] | 318 | print $LOG "Source file: $src\n" if ($debug >= 0);
|
---|
[25] | 319 |
|
---|
| 320 | if ($dtype eq "rpm") {
|
---|
[28] | 321 | print $LOG "Working under $ENV{'PBBUILDDIR'}\n" if ($debug >= 0);
|
---|
[25] | 322 | foreach my $d ('RPMS','SRPMS','SPECS','SOURCES','BUILD') {
|
---|
[28] | 323 | if (! -d "$ENV{'PBBUILDDIR'}/$d") {
|
---|
[96] | 324 | 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] | 325 | }
|
---|
[25] | 326 | }
|
---|
| 327 |
|
---|
| 328 | # We need to first extract the spec file
|
---|
[28] | 329 | symlink "$src","$ENV{'PBBUILDDIR'}/SOURCES/".basename($src) || die "Unable to symlink $src in $ENV{'PBBUILDDIR'}/SOURCES";
|
---|
| 330 | my @specfile;
|
---|
[77] | 331 | @specfile = pb_extract_build_files($src,"$pbpkg-$pbver/pbconf/$ddir-$dver/","$ENV{'PBBUILDDIR'}/SPECS");
|
---|
[25] | 332 |
|
---|
[28] | 333 | print $LOG "specfile: ".Dumper(\@specfile)."\n" if ($debug >= 1);
|
---|
[25] | 334 | # set LANGUAGE to check for correct log messages
|
---|
| 335 | $ENV{'LANGUAGE'}="C";
|
---|
[28] | 336 | #system("ls -R $ENV{'PBBUILDDIR'}") if ($debug >= 1);
|
---|
| 337 | foreach my $f (@specfile) {
|
---|
| 338 | if ($f =~ /\.spec$/) {
|
---|
[97] | 339 | pb_system("rpmbuild --define \"_topdir $ENV{'PBBUILDDIR'}\" -ba $f","Building package with $f under $ENV{'PBBUILDDIR'}");
|
---|
[28] | 340 | last;
|
---|
| 341 | }
|
---|
| 342 | }
|
---|
[136] | 343 | $made="$made RPMS/*/$pbpkg-$pbver-$pbtag$pbsuf.*.rpm SRPMS/$pbpkg-$pbver-$pbtag$pbsuf.src.rpm";
|
---|
[118] | 344 | } elsif ($dtype eq "deb") {
|
---|
[136] | 345 | $made="$made $pbpkg"."_*.deb $pbpkg"."_*.dsc $pbpkg"."_*.tar.gz";
|
---|
[87] | 346 | } elsif ($dtype eq "ebuild") {
|
---|
[136] | 347 | $made="$made portage/*/$pbpkg/$pbpkg-$pbver.ebuild";
|
---|
[87] | 348 | pb_mkdir_p("$ENV{'PBBUILDDIR'}/portage") if (! -d "$ENV{'PBBUILDDIR'}/portage");
|
---|
[118] | 349 | } elsif ($dtype eq "slackware") {
|
---|
[136] | 350 | $made="$made build-$pbpkg/$pbpkg-$pbver-*-$pbtag.tgz";
|
---|
[118] | 351 | pb_mkdir_p("$ENV{'PBBUILDDIR'}/install") if (! -d "$ENV{'PBBUILDDIR'}/install");
|
---|
[87] | 352 | } else {
|
---|
[118] | 353 | die "Unknown dtype format $dtype";
|
---|
[87] | 354 | }
|
---|
| 355 | }
|
---|
[118] | 356 | # Keep track of what is generated so that we can get them back from VMs
|
---|
[129] | 357 | open(KEEP,"> $ENV{'PBBUILDDIR'}/pbgen-$pbprojver-$pbprojtag") || die "Unable to create $ENV{'PBBUILDDIR'}/pbgen-$pbprojver-$pbprojtag";
|
---|
[118] | 358 | print KEEP "$made\n";
|
---|
| 359 | close(KEEP);
|
---|
[87] | 360 | }
|
---|
| 361 |
|
---|
[88] | 362 | sub pb_build2ssh {
|
---|
[90] | 363 | pb_send2ssh("Sources");
|
---|
| 364 | }
|
---|
[87] | 365 |
|
---|
[90] | 366 | sub pb_pkg2ssh {
|
---|
| 367 | pb_send2ssh("Packages");
|
---|
| 368 | }
|
---|
| 369 |
|
---|
[108] | 370 | # By default deliver to the the public site hosting the
|
---|
| 371 | # ftp structure (or whatever) or a VM
|
---|
[90] | 372 | sub pb_send2ssh {
|
---|
| 373 |
|
---|
| 374 | my $cmt = shift;
|
---|
[118] | 375 | my $vm = shift || undef;
|
---|
[142] | 376 | my $vmexist = shift || 0; # 0 is FALSE
|
---|
[108] | 377 | my $host = shift || "sshhost";
|
---|
| 378 | my $login = shift || "sshlogin";
|
---|
| 379 | my $dir = shift || "sshdir";
|
---|
| 380 | my $port = shift || "sshport";
|
---|
[90] | 381 |
|
---|
[87] | 382 | # Get list of packages to build
|
---|
[112] | 383 | my $ptr = pb_get_pkg($defpkgdir,$extpkgdir);
|
---|
[87] | 384 | @pkgs = @$ptr;
|
---|
| 385 |
|
---|
[136] | 386 | # Get the running distro to consider
|
---|
[118] | 387 | my ($odir,$over) = (undef, undef);
|
---|
| 388 | if (defined $vm) {
|
---|
| 389 | ($odir,$over) = split(/_/,$vm);
|
---|
| 390 | }
|
---|
| 391 | my ($ddir, $dver, $dfam, $dtype, $pbsuf) = pb_distro_init($odir,$over);
|
---|
[99] | 392 | print $LOG "DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf))."\n" if ($debug >= 1);
|
---|
[87] | 393 |
|
---|
| 394 | # Get content saved in cms2build
|
---|
[89] | 395 | my ($pkg) = pb_conf_read("$ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb","pbpkg");
|
---|
[87] | 396 | $pkg = { } if (not defined $pkg);
|
---|
| 397 |
|
---|
[118] | 398 | my $src = "";
|
---|
[87] | 399 | chdir "$ENV{'PBBUILDDIR'}";
|
---|
| 400 | foreach my $pbpkg (@pkgs) {
|
---|
[88] | 401 | my $vertag = $pkg->{$pbpkg};
|
---|
[87] | 402 | # get the version of the current package - maybe different
|
---|
| 403 | ($pbver,$pbtag) = split(/-/,$vertag);
|
---|
| 404 |
|
---|
[118] | 405 | if (($cmt eq "Sources") || ($cmt eq "VMs")) {
|
---|
| 406 | $src="$src $ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz";
|
---|
| 407 | }
|
---|
| 408 | }
|
---|
| 409 | if ($cmt eq "VMs") {
|
---|
[132] | 410 | $src="$src $ENV{'PBDESTDIR'}/pbscript $ENV{'PBCONF'}/$ENV{'PBPROJ'}.pb $ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb $ENV{'PBETC'}";
|
---|
[142] | 411 | } elsif ($cmt eq "Script") {
|
---|
| 412 | $src="$src $ENV{'PBDESTDIR'}/pbscript";
|
---|
[118] | 413 | } elsif ($cmt eq "Packages") {
|
---|
| 414 | # Get package list from file made during build2pkg
|
---|
[129] | 415 | open(KEEP,"$ENV{'PBBUILDDIR'}/pbgen-$pbprojver-$pbprojtag") || die "Unable to read $ENV{'PBBUILDDIR'}/pbgen-$pbprojver-$pbprojtag";
|
---|
[126] | 416 | $src = <KEEP>;
|
---|
[118] | 417 | chomp($src);
|
---|
| 418 | close(KEEP);
|
---|
| 419 | if ($dtype eq "rpm") {
|
---|
| 420 | # Also make a pbscript to generate yum/urpmi bases
|
---|
[108] | 421 | # $src = "$src $ENV{'PBDESTDIR'}/pbscript"
|
---|
[118] | 422 | } elsif ($dtype eq "deb") {
|
---|
| 423 | # Also make a pbscript to generate apt bases
|
---|
| 424 | # $src = "$src $ENV{'PBDESTDIR'}/pbscript"
|
---|
[90] | 425 | }
|
---|
[87] | 426 | }
|
---|
[132] | 427 | # Remove potential leading spaces (cause pb with basename)
|
---|
| 428 | $src =~ s/^ *//;
|
---|
[129] | 429 | my $basesrc = "";
|
---|
[131] | 430 | foreach my $i (split(/ +/,$src)) {
|
---|
| 431 | $basesrc .= " ".basename($i);
|
---|
[130] | 432 | }
|
---|
[118] | 433 |
|
---|
[128] | 434 | print $LOG "Sources handled ($cmt): $src\n" if ($debug >= 0);
|
---|
[108] | 435 | my ($sshhost,$sshlogin,$sshdir,$sshport) = pb_conf_get($host,$login,$dir,$port);
|
---|
[88] | 436 | my $mac = "$sshlogin->{$ENV{'PBPROJ'}}\@$sshhost->{$ENV{'PBPROJ'}}";
|
---|
[108] | 437 | my $tdir;
|
---|
[136] | 438 | my $bdir;
|
---|
[142] | 439 | if (($cmt eq "Sources") || ($cmt eq "Script")) {
|
---|
[108] | 440 | $tdir = "$sshdir->{$ENV{'PBPROJ'}}/src";
|
---|
| 441 | } elsif ($cmt eq "VMs") {
|
---|
[136] | 442 | $tdir = dirname("$sshdir->{$ENV{'PBPROJ'}}")."/delivery";
|
---|
| 443 | $bdir = dirname("$sshdir->{$ENV{'PBPROJ'}}")."/build";
|
---|
| 444 | # Remove a potential $ENV{'HOME'} as bdir should be relative to pb's home
|
---|
| 445 | $bdir =~ s|\$ENV.+\}/||;
|
---|
[90] | 446 | } elsif ($cmt eq "Packages") {
|
---|
[108] | 447 | $tdir = "$sshdir->{$ENV{'PBPROJ'}}/$ddir/$dver";
|
---|
[90] | 448 | } else {
|
---|
| 449 | return;
|
---|
[22] | 450 | }
|
---|
[136] | 451 | # Remove a potential $ENV{'HOME'} as tdir should be relative to pb's home
|
---|
[132] | 452 | $tdir =~ s|\$ENV.+\}/||;
|
---|
| 453 |
|
---|
[111] | 454 | $port = $sshport->{$ENV{'PBPROJ'}};
|
---|
[144] | 455 | pb_system("ssh -q -p $port $mac \"mkdir -p $tdir ; cd $tdir ; echo \'for i in $basesrc; do if [ -f \$i ]; then rm -f \$i; fi; done\' | bash\"","Preparing $tdir on $mac");
|
---|
[136] | 456 | pb_system("cd $ENV{'PBBUILDDIR'} ; scp -p -P $port $src $mac:$tdir 2> /dev/null","$cmt delivery in $tdir on $mac");
|
---|
| 457 | pb_system("ssh -q -p $port $mac \"echo \'cd $tdir ; if [ -f pbscript ]; then ./pbscript; fi\' | bash\"","Executing pbscript on $mac if needed");
|
---|
[108] | 458 | if ($cmt eq "VMs") {
|
---|
[128] | 459 | # Get back info on pkg produced, compute their name and get them from the VM
|
---|
[136] | 460 | pb_system("scp -p -P $port $mac:$bdir/pbgen-$pbprojver-$pbprojtag $ENV{'PBBUILDDIR'} 2> /dev/null","Get package names in $tdir on $mac");
|
---|
[129] | 461 | open(KEEP,"$ENV{'PBBUILDDIR'}/pbgen-$pbprojver-$pbprojtag") || die "Unable to read $ENV{'PBBUILDDIR'}/pbgen-$pbprojver-$pbprojtag";
|
---|
[118] | 462 | my $src = <KEEP>;
|
---|
| 463 | chomp($src);
|
---|
| 464 | close(KEEP);
|
---|
[131] | 465 | $src =~ s/^ *//;
|
---|
[136] | 466 | pb_mkdir_p("$ENV{'PBBUILDDIR'}/$odir/$over");
|
---|
[139] | 467 | # Change pgben to make the next send2ssh happy
|
---|
[143] | 468 | my $made = "";
|
---|
[139] | 469 | open(KEEP,"> $ENV{'PBBUILDDIR'}/pbgen-$pbprojver-$pbprojtag") || die "Unable to write $ENV{'PBBUILDDIR'}/pbgen-$pbprojver-$pbprojtag";
|
---|
[136] | 470 | foreach my $p (split(/ +/,$src)) {
|
---|
[139] | 471 | my $j = basename($p);
|
---|
| 472 | pb_system("scp -p -P $port $mac:\'$bdir/$p\' $ENV{'PBBUILDDIR'}/$odir/$over 2> /dev/null","Package recovery of $j in $tdir from $mac");
|
---|
[144] | 473 | $made="$made $odir/$over/$j" if (($dtype ne "rpm") || ($j !~ /.src.rpm$/));
|
---|
[136] | 474 | }
|
---|
[143] | 475 | print KEEP "$made\n";
|
---|
[139] | 476 | close(KEEP);
|
---|
[144] | 477 | pb_system("ssh -q -p $port $mac \"rm -rf $tdir\"","VM cleanup on $mac");
|
---|
[142] | 478 | if (! $vmexist) {
|
---|
[145] | 479 | pb_system("ssh -q -p $port $mac \"sudo /usr/bin/poweroff \"; sleep 120 ; echo \'if [ -d /proc/$vmexist ]; then kill $vmexist; fi \' | bash ; sleep 10","VM halt on $mac");
|
---|
[142] | 480 | }
|
---|
[126] | 481 | pb_send2ssh("Packages","$odir"."_"."$over");
|
---|
[141] | 482 | pb_rm_rf("$ENV{'PBBUILDDIR'}/$odir");
|
---|
[108] | 483 | }
|
---|
[9] | 484 | }
|
---|
[16] | 485 |
|
---|
[142] | 486 | sub pb_script2vm {
|
---|
| 487 | my $pbscript=shift;
|
---|
[141] | 488 |
|
---|
| 489 | # Prepare the script to be executed on the VM
|
---|
| 490 | # in $ENV{'PBDESTDIR'}/pbscript
|
---|
[142] | 491 | if ((defined $pbscript ) && ($pbscript ne "$ENV{'PBDESTDIR'}/pbscript")) {
|
---|
| 492 | copy($pbscript,"$ENV{'PBDESTDIR'}/pbscript") || die "Unable to create $ENV{'PBDESTDIR'}/pbscript";
|
---|
| 493 | chmod 0755,"$ENV{'PBDESTDIR'}/pbscript";
|
---|
| 494 | }
|
---|
[141] | 495 |
|
---|
[142] | 496 | my ($vm,$all) = pb_get_vm();
|
---|
| 497 |
|
---|
[141] | 498 | foreach my $v (@$vm) {
|
---|
[142] | 499 | # Launch the VM
|
---|
| 500 | my $vmexist = pb_launchvm($v);
|
---|
| 501 | if (! $vmexist) {
|
---|
| 502 | pb_system("sleep 300","Waiting for it to come up");
|
---|
[141] | 503 | }
|
---|
| 504 |
|
---|
[142] | 505 | # Gather all required files to send them to the VM
|
---|
| 506 | # and launch the build thourgh pbscript
|
---|
| 507 | pb_send2ssh("Script","$v",$vmexist,"vmhost","vmlogin","pbrc","vmport");
|
---|
| 508 | }
|
---|
| 509 | }
|
---|
| 510 |
|
---|
| 511 | sub pb_launchvm {
|
---|
| 512 | my $vm = shift;
|
---|
| 513 |
|
---|
| 514 | die "No VM defined, unable to launch" if (not defined $vm);
|
---|
| 515 | # Keep only the first VM in case many were given
|
---|
| 516 | $vm =~ s/,.*//;
|
---|
| 517 |
|
---|
| 518 | # Launch the VMs
|
---|
| 519 | my ($ptr,$vmopt,$vmport,$vmpath) = pb_conf_get("vmtype","vmopt","vmport","vmpath");
|
---|
| 520 | my $vmtype = $ptr->{$ENV{'PBPROJ'}};
|
---|
| 521 | if (defined $vmopt->{$ENV{'PBPROJ'}}) {
|
---|
| 522 | $ENV{'PBVMOPT'} = $vmopt->{$ENV{'PBPROJ'}};
|
---|
| 523 | } else {
|
---|
| 524 | $ENV{'PBVMOPT'} = "";
|
---|
| 525 | }
|
---|
| 526 |
|
---|
| 527 | my $cmd;
|
---|
| 528 | my $vmcmd; # has to be used for pb_check_ps
|
---|
| 529 | my $vmm; # has to be used for pb_check_ps
|
---|
| 530 | if ($vmtype eq "qemu") {
|
---|
| 531 | my $arch = `uname -m`;
|
---|
| 532 | chomp($arch);
|
---|
| 533 | my $qemucmd32;
|
---|
| 534 | my $qemucmd64;
|
---|
| 535 | if ($arch eq "x86_64") {
|
---|
| 536 | $qemucmd32 = "/usr/bin/qemu-system-i386";
|
---|
| 537 | $qemucmd64 = "/usr/bin/qemu";
|
---|
[141] | 538 | } else {
|
---|
[142] | 539 | $qemucmd32 = "/usr/bin/qemu";
|
---|
| 540 | $qemucmd64 = "/usr/bin/qemu-system-x86_64";
|
---|
[141] | 541 | }
|
---|
[142] | 542 | if ($vm =~ /_64/) {
|
---|
| 543 | $vmcmd = "$qemucmd64 -no-kqemu";
|
---|
| 544 | } else {
|
---|
| 545 | $vmcmd = "$qemucmd32";
|
---|
| 546 | }
|
---|
| 547 | $vmm = "$vmpath->{$ENV{'PBPROJ'}}/$vm.qemu";
|
---|
| 548 | if (! -f "$vmm") {
|
---|
| 549 | print "Unable to find VM $vmm";
|
---|
| 550 | return;
|
---|
| 551 | }
|
---|
| 552 | $cmd = "$vmcmd $ENV{'PBVMOPT'} -redir tcp:$vmport->{$ENV{'PBPROJ'}}:10.0.2.15:22 $vmm"
|
---|
| 553 | } elsif ($vmtype eq "xen") {
|
---|
| 554 | } elsif ($vmtype eq "vmware") {
|
---|
| 555 | } else {
|
---|
| 556 | die "VM of type $vmtype not supported. Report to the dev team";
|
---|
| 557 | }
|
---|
| 558 | my $vmexist = pb_check_ps($vmcmd,$vmm);
|
---|
| 559 | if (! $vmexist) {
|
---|
[141] | 560 | pb_system("$cmd &","Launching the VM");
|
---|
| 561 | }
|
---|
[142] | 562 | return($vmexist);
|
---|
[141] | 563 | }
|
---|
[142] | 564 |
|
---|
[105] | 565 | sub pb_build2vm {
|
---|
[108] | 566 | # Prepare the script to be executed on the VM
|
---|
| 567 | # in $ENV{'PBDESTDIR'}/pbscript
|
---|
[118] | 568 | open(SCRIPT,"> $ENV{'PBDESTDIR'}/pbscript") || die "Unable to create $ENV{'PBDESTDIR'}/pbscript";
|
---|
| 569 | print SCRIPT "#!/bin/bash\n";
|
---|
[126] | 570 | print SCRIPT "echo ... Execution needed\n";
|
---|
[132] | 571 | print SCRIPT "# This is in directory delivery\n";
|
---|
[118] | 572 | print SCRIPT "# Setup the variables required for building\n";
|
---|
| 573 | print SCRIPT "export PBPROJ=$ENV{'PBPROJ'}\n";
|
---|
[132] | 574 | print SCRIPT "# Preparation for pb\n";
|
---|
| 575 | print SCRIPT "mkdir -p ../pbconf\n";
|
---|
| 576 | print SCRIPT "mv $ENV{'PBPROJ'}.pb ../pbconf\n";
|
---|
| 577 | print SCRIPT "mv .pbrc \$HOME\n";
|
---|
| 578 | print SCRIPT "cd ..\n";
|
---|
[118] | 579 | print SCRIPT "export PBROOT=\`pwd\`\n";
|
---|
| 580 | print SCRIPT "# Build\n";
|
---|
[127] | 581 | my $p = "";
|
---|
| 582 | $p = $ARGV[0] if (defined $ARGV[0]);
|
---|
[132] | 583 | print SCRIPT "echo Building packages on VM...\n";
|
---|
[127] | 584 | print SCRIPT "pb build2pkg $p\n";
|
---|
[118] | 585 | close(SCRIPT);
|
---|
| 586 | chmod 0755,"$ENV{'PBDESTDIR'}/pbscript";
|
---|
| 587 |
|
---|
[142] | 588 | my ($vm,$all) = pb_get_vm();
|
---|
| 589 |
|
---|
[106] | 590 | # Send tar files when we do a global generation
|
---|
| 591 | pb_build2ssh() if ($all == 1);
|
---|
[118] | 592 |
|
---|
| 593 | foreach my $v (@$vm) {
|
---|
[142] | 594 | # Launch the VM
|
---|
| 595 | my $vmexist = pb_launchvm($v);
|
---|
| 596 | if (! $vmexist) {
|
---|
| 597 | pb_system("sleep 300","Waiting for it to come up");
|
---|
[127] | 598 | }
|
---|
[118] | 599 |
|
---|
[142] | 600 | # Gather all required files to send them to the VM
|
---|
| 601 | # and launch the build thourgh pbscript
|
---|
| 602 | pb_send2ssh("VMs","$v",$vmexist,"vmhost","vmlogin","pbrc","vmport");
|
---|
[118] | 603 | }
|
---|
[105] | 604 | }
|
---|
| 605 |
|
---|
[77] | 606 | sub pb_get_pkg {
|
---|
[16] | 607 |
|
---|
[22] | 608 | my @pkgs;
|
---|
[108] | 609 | my $defpkgdir = shift;
|
---|
| 610 | my $extpkgdir = shift;
|
---|
[22] | 611 |
|
---|
| 612 | # Get packages list
|
---|
| 613 | if (not defined $ARGV[0]) {
|
---|
[112] | 614 | @pkgs = keys %$defpkgdir;
|
---|
[22] | 615 | } elsif ($ARGV[0] =~ /^all$/) {
|
---|
[112] | 616 | @pkgs = keys %$defpkgdir;
|
---|
| 617 | push(@pkgs, keys %$extpkgdir);
|
---|
[22] | 618 | } else {
|
---|
| 619 | @pkgs = @ARGV;
|
---|
| 620 | }
|
---|
| 621 | print $LOG "Packages: ".join(',',@pkgs)."\n" if ($debug >= 0);
|
---|
| 622 | return(\@pkgs);
|
---|
| 623 | }
|
---|
| 624 |
|
---|
[105] | 625 | #
|
---|
| 626 | # Return the list of VMs we are working on
|
---|
| 627 | # $all is a flag to know if we return all of them
|
---|
| 628 | # or only some (if all we publish also tar files in addition to pkgs
|
---|
| 629 | #
|
---|
[91] | 630 | sub pb_get_vm {
|
---|
| 631 |
|
---|
| 632 | my @vm;
|
---|
[105] | 633 | my $all = 0;
|
---|
[91] | 634 |
|
---|
| 635 | # Get VM list
|
---|
[105] | 636 | if ((not defined $ENV{'PBVM'}) || ($ENV{'PBVM'} =~ /^all$/)) {
|
---|
[108] | 637 | my ($ptr) = pb_conf_get("vmlist");
|
---|
[105] | 638 | $ENV{'PBVM'} = $ptr->{$ENV{'PBPROJ'}};
|
---|
| 639 | $all = 1;
|
---|
[91] | 640 | }
|
---|
[105] | 641 | @vm = split(/,/,$ENV{'PBVM'});
|
---|
[108] | 642 | print $LOG "VMs: ".join(',',@vm)."\n";
|
---|
[105] | 643 | return(\@vm,$all);
|
---|
[91] | 644 | }
|
---|
| 645 |
|
---|
[145] | 646 | # Returns the pid of a running VM command using a specific VM file
|
---|
[142] | 647 | sub pb_check_ps {
|
---|
| 648 | my $vmcmd = shift;
|
---|
| 649 | my $vmm = shift;
|
---|
| 650 | my $vmexist = 0; # FALSE by default
|
---|
| 651 |
|
---|
| 652 | open(PS, "ps auxhww|") || die "Unable to call ps";
|
---|
| 653 | while (<PS>) {
|
---|
| 654 | next if (! /$vmcmd/);
|
---|
| 655 | next if (! /$vmm/);
|
---|
| 656 | my ($void1, $void2);
|
---|
| 657 | ($void1, $vmexist, $void2) = split(/ +/);
|
---|
| 658 | last;
|
---|
| 659 | }
|
---|
| 660 | return($vmexist);
|
---|
| 661 | }
|
---|
| 662 |
|
---|
| 663 |
|
---|
[77] | 664 | sub pb_extract_build_files {
|
---|
[25] | 665 |
|
---|
| 666 | my $src=shift;
|
---|
| 667 | my $dir=shift;
|
---|
[26] | 668 | my $ddir=shift;
|
---|
[28] | 669 | my @files;
|
---|
[25] | 670 |
|
---|
[106] | 671 | pb_system("tar xfpz $src $dir","Extracting build files");
|
---|
[25] | 672 | opendir(DIR,"$dir") || die "Unable to open directory $dir";
|
---|
| 673 | foreach my $f (readdir(DIR)) {
|
---|
| 674 | next if ($f =~ /^\./);
|
---|
[26] | 675 | move("$dir/$f","$ddir") || die "Unable to move $dir/$f to $ddir";
|
---|
[28] | 676 | print $LOG "mv $dir/$f $ddir\n" if ($debug >= 1);
|
---|
| 677 | push @files,"$ddir/$f";
|
---|
[25] | 678 | }
|
---|
| 679 | closedir(DIR);
|
---|
[26] | 680 | # Not enough but still a first cleanup
|
---|
[74] | 681 | pb_rm_rf("$dir");
|
---|
[28] | 682 | return(@files);
|
---|
[25] | 683 | }
|
---|
| 684 |
|
---|
[74] | 685 | sub pb_syntax {
|
---|
[21] | 686 |
|
---|
[53] | 687 | print "pb (aka project-builder) Version $projectbuilderver-$projectbuilderrev\n";
|
---|
| 688 | print "\n";
|
---|
[141] | 689 | print "Syntax: pb [-vhqt][-r pbroot][-p project][[-s script] -m \"mach-1[,...]\"] <action> [<pkg1>...]\n";
|
---|
[21] | 690 | print "\n";
|
---|
| 691 | print "-h : This help file\n";
|
---|
| 692 | print "-q : Quiet mode\n";
|
---|
| 693 | print "-t : Test mode (not done yet)\n";
|
---|
| 694 | print "-v : Verbose mode\n";
|
---|
| 695 | print "\n";
|
---|
[142] | 696 | print "-m machine : Name of the Virtual Machines (VM) you want\n";
|
---|
| 697 | print " to build on (coma separated). All if none precised\n";
|
---|
[91] | 698 | print " (or use the env variable PBVM) \n";
|
---|
[69] | 699 | print "\n";
|
---|
[141] | 700 | print "-s script : Name of the script you want\n";
|
---|
| 701 | print " to execute on the related VMs.\n";
|
---|
| 702 | print "\n";
|
---|
[21] | 703 | print "-p project : Name of the project you're working on\n";
|
---|
| 704 | print " (or use the env variable PBPROJ) \n";
|
---|
| 705 | print "\n";
|
---|
[91] | 706 | print "-r pbroot : Path Name of project under the CMS \n";
|
---|
| 707 | print " (or use the env variable PBROOT) \n";
|
---|
| 708 | print "\n";
|
---|
[21] | 709 | print "<action> can be:\n";
|
---|
| 710 | print "\n";
|
---|
[105] | 711 | print "\tcms2build: Create tar files for the project under your CMS\n";
|
---|
[21] | 712 | print "\t CMS supported are SVN and CVS\n";
|
---|
[22] | 713 | print "\t parameters are packages to build\n";
|
---|
| 714 | print "\t if not using default list\n";
|
---|
[21] | 715 | print "\n";
|
---|
| 716 | print "\tbuild2pkg: Create packages for your running distribution \n";
|
---|
| 717 | print "\n";
|
---|
[105] | 718 | print "\tbuild2ssh: Send the tar files to a SSH host \n";
|
---|
| 719 | print "\n";
|
---|
| 720 | print "\tpkg2ssh: Send the packages built to a SSH host \n";
|
---|
| 721 | print "\n";
|
---|
[77] | 722 | print "\tcms2pkg: cms2build + build2pkg\n";
|
---|
[21] | 723 | print "\n";
|
---|
[142] | 724 | print "\tbuild2vm: Create packages in VMs, launching them if needed\n";
|
---|
| 725 | print "\t and send those packages to a SSH host once built\n";
|
---|
| 726 | print "\t VM type supported are QEMU \n";
|
---|
[136] | 727 | print "\n";
|
---|
[142] | 728 | print "\tlaunchvm: Launch one virtual machine\n";
|
---|
[141] | 729 | print "\n";
|
---|
[142] | 730 | print "\tscript2vm: Launch one virtual machine if needed \n";
|
---|
| 731 | print "\t and executes a script on it \n";
|
---|
| 732 | print "\n";
|
---|
[136] | 733 | print "\tcms2vm: cms2build + build2vm\n";
|
---|
| 734 | print "\n";
|
---|
[21] | 735 | }
|
---|