[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
|
---|
[74] | 23 | use vars qw (%defpkgdir %extpkgdir %filteredfiles %pbrc $debug $LOG);
|
---|
[73] | 24 |
|
---|
[21] | 25 | $debug = 0; # Debug level
|
---|
[22] | 26 | $LOG = *STDOUT; # Where to log
|
---|
[17] | 27 | use lib qw (lib);
|
---|
[74] | 28 | use ProjectBuilder::Distribution qw (pb_distro_init);
|
---|
| 29 | use ProjectBuilder::Changelog qw (pb_changelog);
|
---|
| 30 | use ProjectBuilder::Version qw (pb_version_init);
|
---|
[77] | 31 | use ProjectBuilder::Base qw (pb_conf_read pb_cms_init pb_mkdir_p pb_system pb_rm_rf pb_get_filters pb_filter_file pb_filter_file_pb);
|
---|
[5] | 32 |
|
---|
| 33 | my %opts; # CLI Options
|
---|
[9] | 34 | my $action; # action to realize
|
---|
| 35 | my $test = "FALSE";
|
---|
| 36 | my $option = "";
|
---|
| 37 | my @pkgs;
|
---|
[16] | 38 | my $pbtag; # Global TAG variable
|
---|
| 39 | my $pbver; # Global VERSION variable
|
---|
[77] | 40 | my %pbver; # per package
|
---|
| 41 | my %pbtag; # per package
|
---|
[53] | 42 | my $pbrev; # Global REVISION variable
|
---|
[16] | 43 | my @date=(localtime->sec(), localtime->min(), localtime->hour(), localtime->mday(), localtime->mon(), localtime->year(), localtime->wday(), localtime->yday(), localtime->isdst());
|
---|
| 44 | my $pbdate = strftime("%Y-%m-%d", @date);
|
---|
[5] | 45 |
|
---|
[67] | 46 | getopts('hl:p:qr: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 |
|
---|
[9] | 71 | # Get Action
|
---|
| 72 | $action = shift @ARGV;
|
---|
[74] | 73 | die pb_syntax() if (not defined $action);
|
---|
[6] | 74 |
|
---|
[67] | 75 | # Handle root of the project if defined
|
---|
| 76 | if (defined $opts{'r'}) {
|
---|
| 77 | $ENV{'PBROOT'} = $opts{'r'};
|
---|
| 78 | }
|
---|
[59] | 79 | # Handles project name if any
|
---|
| 80 | if (defined $opts{'p'}) {
|
---|
[74] | 81 | $ENV{'PBPROJ'} = pb_env_init($opts{'p'});
|
---|
[59] | 82 | } else {
|
---|
[74] | 83 | $ENV{'PBPROJ'} = pb_env_init();
|
---|
[59] | 84 | }
|
---|
| 85 |
|
---|
[22] | 86 | print $LOG "Project $ENV{'PBPROJ'}\n" if ($debug >= 0);
|
---|
| 87 | print $LOG "Action: $action\n" if ($debug >= 0);
|
---|
[9] | 88 |
|
---|
| 89 | # Act depending on action
|
---|
| 90 | if ($action =~ /^cms2build$/) {
|
---|
[77] | 91 | pb_cms2build();
|
---|
| 92 | } elsif ($action =~ /^build2pkg$/) {
|
---|
| 93 | pb_build2pkg();
|
---|
| 94 | } elsif ($action =~ /^cms2pkg$/) {
|
---|
| 95 | pb_cms2build();
|
---|
| 96 | pb_build2pkg();
|
---|
| 97 | } else {
|
---|
| 98 | print $LOG "'$action' is not available\n";
|
---|
| 99 | pb_syntax();
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | sub pb_cms2build {
|
---|
| 103 |
|
---|
| 104 | my $ptr = pb_get_pkg();
|
---|
[22] | 105 | @pkgs = @$ptr;
|
---|
[74] | 106 | pb_cms_init($ENV{'PBPROJ'});
|
---|
[9] | 107 |
|
---|
[27] | 108 | foreach my $pbpkg (@pkgs) {
|
---|
| 109 | if (-f "$ENV{'PBROOT'}/$pbpkg/VERSION") {
|
---|
| 110 | open(V,"$ENV{'PBROOT'}/$pbpkg/VERSION") || die "Unable to open $ENV{'PBROOT'}/$pbpkg/VERSION";
|
---|
[16] | 111 | $pbver = <V>;
|
---|
| 112 | chomp($pbver);
|
---|
[9] | 113 | close(V);
|
---|
| 114 | } else {
|
---|
[16] | 115 | $pbver = $ENV{'PBVER'};
|
---|
[9] | 116 | }
|
---|
| 117 |
|
---|
[27] | 118 | if (-f "$ENV{'PBROOT'}/$pbpkg/TAG") {
|
---|
| 119 | open(T,"$ENV{'PBROOT'}/$pbpkg/TAG") || die "Unable to open $ENV{'PBROOT'}/$pbpkg/TAG";
|
---|
[16] | 120 | $pbtag = <T>;
|
---|
| 121 | chomp($pbtag);
|
---|
[9] | 122 | close(T);
|
---|
| 123 | } else {
|
---|
[16] | 124 | $pbtag = $ENV{'PBTAG'};
|
---|
[9] | 125 | }
|
---|
[16] | 126 | $pbrev = $ENV{'PBREVISION'};
|
---|
[22] | 127 | print $LOG "\n" if ($debug >= 0);
|
---|
[27] | 128 | print $LOG "Management of $pbpkg $pbver-$pbtag (rev $pbrev)\n" if ($debug >= 0);
|
---|
[9] | 129 | die "Unable to get env var PBDESTDIR" if (not defined $ENV{'PBDESTDIR'});
|
---|
[16] | 130 | # Clean up dest if necessary. The export will recreate it
|
---|
[27] | 131 | my $dest = "$ENV{'PBDESTDIR'}/$pbpkg-$pbver";
|
---|
[74] | 132 | pb_rm_rf($dest) if (-d $dest);
|
---|
[9] | 133 |
|
---|
| 134 | # Export CMS tree for the concerned package to dest
|
---|
| 135 | # And generate some additional files
|
---|
| 136 | $OUTPUT_AUTOFLUSH=1;
|
---|
[29] | 137 |
|
---|
[9] | 138 | # computes in which dir we have to work
|
---|
[27] | 139 | my $dir = $defpkgdir{$pbpkg};
|
---|
| 140 | $dir = $extpkgdir{$pbpkg} if (not defined $dir);
|
---|
[74] | 141 | pb_system("$ENV{'PBCMSEXP'} $option $ENV{'PBROOT'}/$dir $dest 1>/dev/null", "Exporting $ENV{'PBROOT'}/$dir");
|
---|
[9] | 142 |
|
---|
| 143 | # Creates a REVISION file
|
---|
| 144 | open(R,"> $dest/REVISION") || die "Unable to create $dest/REVISION";
|
---|
[16] | 145 | print R "$pbrev\n";
|
---|
[9] | 146 | close(R);
|
---|
| 147 |
|
---|
| 148 | # Extract cms log history and store it
|
---|
[74] | 149 | pb_system("$ENV{'PBCMSLOG'} $option $ENV{'PBROOT'}/$dir > $dest/$ENV{'PBCMSLOGFILE'}", "Extracting log info");
|
---|
[29] | 150 |
|
---|
[21] | 151 | my %build;
|
---|
[11] | 152 | open(D,"$ENV{'PBCONF'}/DISTROS") || die "Unable to find $ENV{'PBCONF'}/DISTROS\n";
|
---|
| 153 | while (<D>) {
|
---|
| 154 | my $d = $_;
|
---|
[55] | 155 | my ($ndir,$ver) = split(/_/,$d);
|
---|
[11] | 156 | chomp($ver);
|
---|
[74] | 157 | my ($ddir, $dver, $dfam, $dtype, $dsuf) = pb_distro_init($ndir,$ver);
|
---|
[22] | 158 | print $LOG "DEBUG: distro tuple: ".Dumper($ddir, $dver, $dfam, $dtype, $dsuf)."\n" if ($debug >= 1);
|
---|
| 159 | print $LOG "DEBUG Filtering PBDATE => $pbdate, PBTAG => $pbtag, PBVER => $pbver\n" if ($debug >= 1);
|
---|
[13] | 160 |
|
---|
[16] | 161 | # Filter build files from the less precise up to the most with overloading
|
---|
[13] | 162 | # Filter all files found, keeping the name, and generating in dest
|
---|
[16] | 163 |
|
---|
| 164 | # Find all build files first relatively to PBROOT
|
---|
| 165 | my %bfiles;
|
---|
[27] | 166 | print $LOG "DEBUG dir: $ENV{'PBCONF'}/$pbpkg\n" if ($debug >= 1);
|
---|
[21] | 167 | $build{"$ddir-$dver"} = "yes";
|
---|
[27] | 168 | if (-d "$ENV{'PBCONF'}/$pbpkg/$dtype") {
|
---|
| 169 | opendir(BDIR,"$ENV{'PBCONF'}/$pbpkg/$dtype") || die "Unable to open dir $ENV{'PBCONF'}/$pbpkg/$dtype: $!";
|
---|
[16] | 170 | foreach my $f (readdir(BDIR)) {
|
---|
| 171 | next if ($f =~ /^\./);
|
---|
[27] | 172 | $bfiles{$f} = "$ENV{'PBCONF'}/$pbpkg/$dtype/$f";
|
---|
[16] | 173 | $bfiles{$f} =~ s~$ENV{'PBROOT'}~~;
|
---|
| 174 | }
|
---|
[13] | 175 | closedir(BDIR);
|
---|
[27] | 176 | } elsif (-d "$ENV{'PBCONF'}/$pbpkg/$dfam") {
|
---|
| 177 | opendir(BDIR,"$ENV{'PBCONF'}/$pbpkg/$dfam") || die "Unable to open dir $ENV{'PBCONF'}/$pbpkg/$dfam: $!";
|
---|
[16] | 178 | foreach my $f (readdir(BDIR)) {
|
---|
| 179 | next if ($f =~ /^\./);
|
---|
[27] | 180 | $bfiles{$f} = "$ENV{'PBCONF'}/$pbpkg/$dfam/$f";
|
---|
[16] | 181 | $bfiles{$f} =~ s~$ENV{'PBROOT'}~~;
|
---|
| 182 | }
|
---|
| 183 | closedir(BDIR);
|
---|
[27] | 184 | } elsif (-d "$ENV{'PBCONF'}/$pbpkg/$ddir") {
|
---|
| 185 | opendir(BDIR,"$ENV{'PBCONF'}/$pbpkg/$ddir") || die "Unable to open dir $ENV{'PBCONF'}/$pbpkg/$ddir: $!";
|
---|
[16] | 186 | foreach my $f (readdir(BDIR)) {
|
---|
| 187 | next if ($f =~ /^\./);
|
---|
[27] | 188 | $bfiles{$f} = "$ENV{'PBCONF'}/$pbpkg/$ddir/$f";
|
---|
[16] | 189 | $bfiles{$f} =~ s~$ENV{'PBROOT'}~~;
|
---|
| 190 | }
|
---|
[13] | 191 | closedir(BDIR);
|
---|
[27] | 192 | } elsif (-d "$ENV{'PBCONF'}/$pbpkg/$ddir-$dver") {
|
---|
| 193 | opendir(BDIR,"$ENV{'PBCONF'}/$pbpkg/$ddir-$dver") || die "Unable to open dir $ENV{'PBCONF'}/$pbpkg/$ddir-$dver: $!";
|
---|
[16] | 194 | foreach my $f (readdir(BDIR)) {
|
---|
| 195 | next if ($f =~ /^\./);
|
---|
[27] | 196 | $bfiles{$f} = "$ENV{'PBCONF'}/$pbpkg/$ddir-$dver/$f";
|
---|
[16] | 197 | $bfiles{$f} =~ s~$ENV{'PBROOT'}~~;
|
---|
| 198 | }
|
---|
[13] | 199 | closedir(BDIR);
|
---|
| 200 | } else {
|
---|
[21] | 201 | $build{"$ddir-$dver"} = "no";
|
---|
[13] | 202 | next;
|
---|
| 203 | }
|
---|
[22] | 204 | print $LOG "DEBUG bfiles: ".Dumper(\%bfiles)."\n" if ($debug >= 1);
|
---|
[13] | 205 |
|
---|
[15] | 206 | # Get all filters to apply
|
---|
[77] | 207 | my $ptr = pb_get_filters($pbpkg, $dtype, $dfam, $ddir, $dver);
|
---|
[15] | 208 |
|
---|
[19] | 209 | # Apply now all the filters on all the files concerned
|
---|
| 210 | # destination dir depends on the type of file
|
---|
| 211 | if (defined $ptr) {
|
---|
| 212 | foreach my $f (values %bfiles) {
|
---|
[80] | 213 | pb_filter_file_pb("$ENV{'PBROOT'}/$f",$ptr,"$dest/pbconf/$ddir-$dver/".basename($f),$dtype,$dsuf,$pbpkg,$pbver,$pbtag,$pbrev,$pbdate);
|
---|
[16] | 214 | }
|
---|
[61] | 215 | if (defined $filteredfiles{$dir}) {
|
---|
| 216 | foreach my $f (split(/,/,$filteredfiles{$dir})) {
|
---|
[81] | 217 | pb_filter_file("$ENV{'PBROOT'}/$dir/$f",$ptr,"$dest/$f",$pbpkg,$pbver,$pbtag,$pbrev,$pbdate);
|
---|
[61] | 218 | }
|
---|
[19] | 219 | }
|
---|
[15] | 220 | }
|
---|
[18] | 221 | }
|
---|
[21] | 222 | if ($debug >= 0) {
|
---|
| 223 | my @found;
|
---|
| 224 | my @notfound;
|
---|
| 225 | foreach my $b (keys %build) {
|
---|
| 226 | push @found,$b if ($build{$b} =~ /yes/);
|
---|
| 227 | push @notfound,$b if ($build{$b} =~ /no/);
|
---|
| 228 | }
|
---|
[22] | 229 | print $LOG "Build files generated for ".join(',',@found)."\n";
|
---|
| 230 | print $LOG "No Build files found for ".join(',',@notfound)."\n";
|
---|
[21] | 231 | }
|
---|
[18] | 232 | close(D);
|
---|
| 233 | # Prepare the dest directory for archive
|
---|
[60] | 234 | if (-x "$ENV{'PBCONF'}/$pbpkg/pbinit") {
|
---|
[74] | 235 | pb_system("cd $dest ; $ENV{'PBCONF'}/$pbpkg/pbinit","Executing init script $ENV{'PBCONF'}/$pbpkg/pbinit");
|
---|
[11] | 236 | }
|
---|
[29] | 237 |
|
---|
[18] | 238 | # Archive dest dir
|
---|
[69] | 239 | chdir "$ENV{'PBDESTDIR'}" || die "Unable to change dir to $ENV{'PBDESTDIR'}";
|
---|
[25] | 240 | # Possibility to look at PBSRC to guess more the filename
|
---|
[74] | 241 | pb_system("tar cfpz $pbpkg-$pbver.tar.gz $pbpkg-$pbver","Creating $pbpkg tar files compressed");
|
---|
[31] | 242 | print $LOG "Under $ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz\n" if ($debug >= 0);
|
---|
[70] | 243 | # Keep track of what is generated for default
|
---|
[77] | 244 | $pbver{$pbpkg} = $pbver;
|
---|
| 245 | $pbtag{$pbpkg} = $pbtag;
|
---|
[9] | 246 | }
|
---|
[77] | 247 | open(LAST,"> $pbrc{$ENV{'PBPROJ'}}") || die "Unable to create $pbrc{$ENV{'PBPROJ'}}";
|
---|
| 248 | foreach my $v (keys %pbver) {
|
---|
[79] | 249 | print LAST "pbroot $v-_-$pbver{$v}-$pbtag{$v} = $ENV{'PBROOT'}\n";
|
---|
[22] | 250 | }
|
---|
[77] | 251 | close(LAST);
|
---|
| 252 | }
|
---|
[22] | 253 |
|
---|
[77] | 254 | sub pb_build2pkg {
|
---|
| 255 |
|
---|
[22] | 256 | # Get list of packages to build
|
---|
[77] | 257 | my $ptr = pb_get_pkg();
|
---|
[22] | 258 | @pkgs = @$ptr;
|
---|
| 259 |
|
---|
[77] | 260 | # Check whether we have a specific version to build
|
---|
| 261 | my $vertag = shift @ARGV;
|
---|
| 262 |
|
---|
[22] | 263 | # Get the running distro to build on
|
---|
[74] | 264 | my ($ddir, $dver, $dfam, $dtype, $dsuf) = pb_distro_init();
|
---|
[25] | 265 | print $LOG "DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $dsuf))."\n" if ($debug >= 1);
|
---|
[22] | 266 |
|
---|
[25] | 267 | chdir "$ENV{'PBBUILDDIR'}";
|
---|
[27] | 268 | foreach my $pbpkg (@pkgs) {
|
---|
[77] | 269 | # get the version of the current package - maybe different
|
---|
| 270 | if (not defined $vertag) {
|
---|
| 271 | if (-f $pbrc{$ENV{'PBPROJ'}}) {
|
---|
| 272 | my $pbroot = pb_conf_read($pbrc{$ENV{'PBPROJ'}},"pbroot");
|
---|
| 273 | # All lines should point to the same pbroot so take the first
|
---|
| 274 | $ENV{'PBROOT'} = (values %$pbroot)[0];
|
---|
| 275 | foreach my $k (keys %$pbroot) {
|
---|
| 276 | if ($k =~ /^$pbpkg-_-/) {
|
---|
| 277 | ($ptr,$vertag) = split(/-_-/,$k);
|
---|
| 278 | last;
|
---|
| 279 | }
|
---|
| 280 | }
|
---|
| 281 | die "Unable to find $pbpkg in $pbrc{$ENV{'PBPROJ'}}\nYou may want to precise as parameter version-tag" if (not defined $vertag);
|
---|
| 282 | } else {
|
---|
| 283 | die "Unable to open $pbrc{$ENV{'PBPROJ'}}\nYou may want to precise as parameter version-tag";
|
---|
| 284 | }
|
---|
| 285 | }
|
---|
| 286 | ($pbver,$pbtag) = split(/-/,$vertag);
|
---|
| 287 |
|
---|
[27] | 288 | my $src="$ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz";
|
---|
[67] | 289 | print $LOG "Source file: $src\n" if ($debug >= 0);
|
---|
[25] | 290 |
|
---|
| 291 | if ($dtype eq "rpm") {
|
---|
| 292 | # rpm has its own standard build directory
|
---|
[28] | 293 | my $tmp=`rpmquery --eval '%{_topdir}' 2> /dev/null`;
|
---|
| 294 | chomp($tmp);
|
---|
| 295 | $ENV{'PBBUILDDIR'}=$tmp;
|
---|
| 296 | print $LOG "Working under $ENV{'PBBUILDDIR'}\n" if ($debug >= 0);
|
---|
[25] | 297 | foreach my $d ('RPMS','SRPMS','SPECS','SOURCES','BUILD') {
|
---|
[28] | 298 | if (! -d "$ENV{'PBBUILDDIR'}/$d") {
|
---|
[74] | 299 | 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";
|
---|
[28] | 300 | }
|
---|
[25] | 301 | }
|
---|
| 302 |
|
---|
| 303 | # We need to first extract the spec file
|
---|
[28] | 304 | symlink "$src","$ENV{'PBBUILDDIR'}/SOURCES/".basename($src) || die "Unable to symlink $src in $ENV{'PBBUILDDIR'}/SOURCES";
|
---|
| 305 | my @specfile;
|
---|
[77] | 306 | @specfile = pb_extract_build_files($src,"$pbpkg-$pbver/pbconf/$ddir-$dver/","$ENV{'PBBUILDDIR'}/SPECS");
|
---|
[25] | 307 |
|
---|
[28] | 308 | print $LOG "specfile: ".Dumper(\@specfile)."\n" if ($debug >= 1);
|
---|
[25] | 309 | # set LANGUAGE to check for correct log messages
|
---|
| 310 | $ENV{'LANGUAGE'}="C";
|
---|
[28] | 311 | #system("ls -R $ENV{'PBBUILDDIR'}") if ($debug >= 1);
|
---|
| 312 | foreach my $f (@specfile) {
|
---|
| 313 | if ($f =~ /\.spec$/) {
|
---|
[74] | 314 | pb_system("rpmbuild -ba $f","Building package with $f");
|
---|
[28] | 315 | last;
|
---|
| 316 | }
|
---|
| 317 | }
|
---|
[25] | 318 | } elsif ($dtype eq "tgz") {
|
---|
[74] | 319 | pb_mkdir_p("$ENV{'PBBUILDDIR'}/install") if (! -d "$ENV{'PBBUILDDIR'}/install");
|
---|
[25] | 320 | } elsif ($dtype eq "ebuild") {
|
---|
[74] | 321 | pb_mkdir_p("$ENV{'PBBUILDDIR'}/portage") if (! -d "$ENV{'PBBUILDDIR'}/portage");
|
---|
[25] | 322 | } else {
|
---|
| 323 | }
|
---|
[22] | 324 | }
|
---|
[9] | 325 | }
|
---|
[16] | 326 |
|
---|
[77] | 327 | sub pb_get_pkg {
|
---|
[16] | 328 |
|
---|
[22] | 329 | my @pkgs;
|
---|
| 330 |
|
---|
| 331 | # Get packages list
|
---|
| 332 | if (not defined $ARGV[0]) {
|
---|
| 333 | @pkgs = keys %defpkgdir;
|
---|
| 334 | } elsif ($ARGV[0] =~ /^all$/) {
|
---|
| 335 | @pkgs = keys %defpkgdir;
|
---|
| 336 | if (defined %extpkgdir) {
|
---|
| 337 | my $k = keys %extpkgdir;
|
---|
| 338 | if (defined $k) {
|
---|
| 339 | push(@pkgs, keys %extpkgdir);
|
---|
| 340 | }
|
---|
| 341 | }
|
---|
| 342 | } else {
|
---|
| 343 | @pkgs = @ARGV;
|
---|
| 344 | }
|
---|
| 345 | print $LOG "Packages: ".join(',',@pkgs)."\n" if ($debug >= 0);
|
---|
| 346 | return(\@pkgs);
|
---|
| 347 | }
|
---|
| 348 |
|
---|
[77] | 349 | sub pb_extract_build_files {
|
---|
[25] | 350 |
|
---|
| 351 | my $src=shift;
|
---|
| 352 | my $dir=shift;
|
---|
[26] | 353 | my $ddir=shift;
|
---|
[28] | 354 | my @files;
|
---|
[25] | 355 |
|
---|
[74] | 356 | pb_system("tar xfpz $src $dir >/dev/null","Extracting build files");
|
---|
[25] | 357 | opendir(DIR,"$dir") || die "Unable to open directory $dir";
|
---|
| 358 | foreach my $f (readdir(DIR)) {
|
---|
| 359 | next if ($f =~ /^\./);
|
---|
[26] | 360 | move("$dir/$f","$ddir") || die "Unable to move $dir/$f to $ddir";
|
---|
[28] | 361 | print $LOG "mv $dir/$f $ddir\n" if ($debug >= 1);
|
---|
| 362 | push @files,"$ddir/$f";
|
---|
[25] | 363 | }
|
---|
| 364 | closedir(DIR);
|
---|
[26] | 365 | # Not enough but still a first cleanup
|
---|
[74] | 366 | pb_rm_rf("$dir");
|
---|
[28] | 367 | return(@files);
|
---|
[25] | 368 | }
|
---|
| 369 |
|
---|
[74] | 370 | sub pb_syntax {
|
---|
[21] | 371 |
|
---|
[53] | 372 | print "pb (aka project-builder) Version $projectbuilderver-$projectbuilderrev\n";
|
---|
| 373 | print "\n";
|
---|
[69] | 374 | print "Syntax: pb [-vhqt][-r pbroot][-p project] <action> [<params>...]\n";
|
---|
[21] | 375 | print "\n";
|
---|
| 376 | print "-h : This help file\n";
|
---|
| 377 | print "-q : Quiet mode\n";
|
---|
| 378 | print "-t : Test mode (not done yet)\n";
|
---|
| 379 | print "-v : Verbose mode\n";
|
---|
| 380 | print "\n";
|
---|
[69] | 381 | print "-r pbroot : Path Name of project under the CMS \n";
|
---|
| 382 | print " (or use the env variable PBROOT) \n";
|
---|
| 383 | print "\n";
|
---|
[21] | 384 | print "-p project : Name of the project you're working on\n";
|
---|
| 385 | print " (or use the env variable PBPROJ) \n";
|
---|
| 386 | print "\n";
|
---|
| 387 | print "<action> can be:\n";
|
---|
| 388 | print "\n";
|
---|
| 389 | print "\tcms2build: Create a tar file of the project under your CMS\n";
|
---|
| 390 | print "\t CMS supported are SVN and CVS\n";
|
---|
[22] | 391 | print "\t parameters are packages to build\n";
|
---|
| 392 | print "\t if not using default list\n";
|
---|
[21] | 393 | print "\n";
|
---|
| 394 | print "\tbuild2pkg: Create packages for your running distribution \n";
|
---|
[22] | 395 | print "\t first parameter is version-tag to build\n";
|
---|
| 396 | print "\t if not using default version-tag\n";
|
---|
| 397 | print "\t following parameters are packages to build\n";
|
---|
| 398 | print "\t if not using default list\n";
|
---|
[21] | 399 | print "\n";
|
---|
[77] | 400 | print "\tcms2pkg: cms2build + build2pkg\n";
|
---|
[21] | 401 | print "\n";
|
---|
| 402 | }
|
---|