[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';
|
---|
[331] | 13 | use Getopt::Long qw(:config auto_abbrev no_ignore_case);
|
---|
[9] | 14 | use Data::Dumper;
|
---|
| 15 | use English;
|
---|
[16] | 16 | use File::Basename;
|
---|
[26] | 17 | use File::Copy;
|
---|
[395] | 18 | use File::stat;
|
---|
| 19 | use File::Temp qw(tempdir);
|
---|
[13] | 20 | use POSIX qw(strftime);
|
---|
[17] | 21 | use lib qw (lib);
|
---|
[329] | 22 | use ProjectBuilder::Version;
|
---|
[318] | 23 | use ProjectBuilder::Base;
|
---|
[405] | 24 | use ProjectBuilder::Conf;
|
---|
| 25 | use ProjectBuilder::Distribution;
|
---|
| 26 | use ProjectBuilder::CMS;
|
---|
[416] | 27 | use ProjectBuilder::Env;
|
---|
[405] | 28 | use ProjectBuilder::Filter;
|
---|
[5] | 29 |
|
---|
[397] | 30 | # Global variables
|
---|
[5] | 31 | my %opts; # CLI Options
|
---|
[9] | 32 | my $action; # action to realize
|
---|
[320] | 33 | my $test = "FALSE"; # Not used
|
---|
| 34 | my $force = 0; # Force VE/VM rebuild
|
---|
| 35 | my $option = ""; # Not used
|
---|
| 36 | my @pkgs; # list of packages
|
---|
[95] | 37 | my $pbtag; # Global Tag variable
|
---|
| 38 | my $pbver; # Global Version variable
|
---|
[141] | 39 | my $pbscript; # Name of the script
|
---|
[77] | 40 | my %pbver; # per package
|
---|
| 41 | my %pbtag; # per package
|
---|
[53] | 42 | my $pbrev; # Global REVISION variable
|
---|
[152] | 43 | my $pbaccount; # Login to use to connect to the VM
|
---|
[162] | 44 | my $pbport; # Port to use to connect to the VM
|
---|
[199] | 45 | my $newver; # New version to create
|
---|
[331] | 46 | my $iso; # ISO image for the VM to create
|
---|
[5] | 47 |
|
---|
[320] | 48 | my @date = pb_get_date();
|
---|
| 49 | my $pbdate = strftime("%Y-%m-%d", @date);
|
---|
[5] | 50 |
|
---|
[331] | 51 | =pod
|
---|
| 52 |
|
---|
| 53 | =head1 NAME
|
---|
| 54 |
|
---|
| 55 | pb, aka project-builder.org - builds packages for your projects
|
---|
| 56 |
|
---|
| 57 | =head1 DESCRIPTION
|
---|
| 58 |
|
---|
| 59 | pb helps you build various packages directly from your project sources.
|
---|
| 60 | Those sources could be handled by a CMS (Configuration Management System)
|
---|
| 61 | such as Subversion, CVS, ... or being a simple reference to a compressed tar file.
|
---|
| 62 | It's based on a set of configuration files, a set of provided macros to help
|
---|
| 63 | you keeping build files as generic as possible. For example, a single .spec
|
---|
| 64 | file should be required to generate for all rpm based distributions, even
|
---|
| 65 | if you could also have multiple .spec files if required.
|
---|
| 66 |
|
---|
| 67 | =head1 SYNOPSIS
|
---|
| 68 |
|
---|
[332] | 69 | pb [-vhq][-r pbroot][-p project][[-s script -a account -P port][-m mach-1[,...]]][-i iso] <action> [<pkg1> ...]
|
---|
[331] | 70 |
|
---|
[332] | 71 | pb [--verbose][--help][--man][--quiet][--revision pbroot][--project project][[--script script --account account --port port][--machine mach-1[,...]]][--iso iso] <action> [<pkg1> ...]
|
---|
[331] | 72 |
|
---|
| 73 | =head1 OPTIONS
|
---|
| 74 |
|
---|
| 75 | =over 4
|
---|
| 76 |
|
---|
| 77 | =item B<-v|--verbose>
|
---|
| 78 |
|
---|
| 79 | Print a brief help message and exits.
|
---|
| 80 |
|
---|
| 81 | =item B<-q|--quiet>
|
---|
| 82 |
|
---|
| 83 | Do not print any output.
|
---|
| 84 |
|
---|
| 85 | =item B<-h|--help>
|
---|
| 86 |
|
---|
| 87 | Print a brief help message and exits.
|
---|
| 88 |
|
---|
| 89 | =item B<--man>
|
---|
| 90 |
|
---|
| 91 | Prints the manual page and exits.
|
---|
| 92 |
|
---|
| 93 | =item B<-m|--machine machine1[,machine2,...]>
|
---|
| 94 |
|
---|
| 95 | Name of the Virtual Machines (VM) or Virtual Environments (VE) you want to build on (coma separated).
|
---|
| 96 | All if none precised (or use the env variable PBV).
|
---|
| 97 |
|
---|
| 98 | =item B<-s|--script script>
|
---|
| 99 |
|
---|
| 100 | Name of the script you want to execute on the related VMs or VEs.
|
---|
| 101 |
|
---|
| 102 | =item B<-i|--iso iso_image>
|
---|
| 103 |
|
---|
| 104 | Name of the ISO image of the distribution you want to install on the related VMs.
|
---|
| 105 |
|
---|
| 106 | =item B<-a|--account account>
|
---|
| 107 |
|
---|
| 108 | Name of the account to use to connect on the related VMs.
|
---|
| 109 |
|
---|
| 110 | =item B<-P|--port port_number>
|
---|
| 111 |
|
---|
| 112 | Port number to use to connect on the related VMs.\n";
|
---|
| 113 |
|
---|
| 114 | =item B<-p|--project project_name>
|
---|
| 115 |
|
---|
| 116 | Name of the project you're working on (or use the env variable PBPROJ)
|
---|
| 117 |
|
---|
| 118 | =item B<-r|--revision revision>
|
---|
| 119 |
|
---|
| 120 | Path Name of the project revision under the CMS (or use the env variable PBROOT)
|
---|
| 121 |
|
---|
| 122 | =item B<-V|--version new_version>
|
---|
| 123 |
|
---|
| 124 | New version of the project to create based on the current one.
|
---|
| 125 |
|
---|
| 126 | =back
|
---|
| 127 |
|
---|
| 128 | =head1 ARGUMENTS
|
---|
| 129 |
|
---|
| 130 | <action> can be:
|
---|
| 131 |
|
---|
| 132 | =over 4
|
---|
| 133 |
|
---|
| 134 | =item B<cms2build>
|
---|
| 135 |
|
---|
| 136 | Create tar files for the project under your CMS.
|
---|
| 137 | CMS supported are SVN and CVS
|
---|
| 138 | parameters are packages to build
|
---|
| 139 | if not using default list
|
---|
| 140 |
|
---|
| 141 | =item B<build2pkg>
|
---|
| 142 |
|
---|
| 143 | Create packages for your running distribution
|
---|
| 144 |
|
---|
| 145 | =item B<cms2pkg>
|
---|
| 146 |
|
---|
| 147 | cms2build + build2pkg
|
---|
| 148 |
|
---|
| 149 | =item B<build2ssh>
|
---|
| 150 |
|
---|
| 151 | Send the tar files to a SSH host
|
---|
| 152 |
|
---|
| 153 | =item B<cms2ssh>
|
---|
| 154 |
|
---|
| 155 | cms2build + build2ssh
|
---|
| 156 |
|
---|
| 157 | =item B<pkg2ssh>
|
---|
| 158 |
|
---|
| 159 | Send the packages built to a SSH host
|
---|
| 160 |
|
---|
| 161 | =item B<build2vm>
|
---|
| 162 |
|
---|
| 163 | Create packages in VMs, launching them if needed
|
---|
| 164 | and send those packages to a SSH host once built
|
---|
| 165 | VM type supported are QEMU
|
---|
| 166 |
|
---|
| 167 | =item B<build2ve>
|
---|
| 168 |
|
---|
| 169 | Create packages in VEs, creating it if needed
|
---|
| 170 | and send those packages to a SSH host once built
|
---|
| 171 |
|
---|
| 172 | =item B<cms2vm>
|
---|
| 173 |
|
---|
| 174 | cms2build + build2vm
|
---|
| 175 |
|
---|
| 176 | =item B<cms2ve>
|
---|
| 177 |
|
---|
| 178 | cms2build + build2ve
|
---|
| 179 |
|
---|
| 180 | =item B<launchvm>
|
---|
| 181 |
|
---|
| 182 | Launch one virtual machine
|
---|
| 183 |
|
---|
| 184 | =item B<launchve>
|
---|
| 185 |
|
---|
| 186 | Launch one virtual environment
|
---|
| 187 |
|
---|
| 188 | =item B<script2vm>
|
---|
| 189 |
|
---|
| 190 | Launch one virtual machine if needed
|
---|
| 191 | and executes a script on it
|
---|
| 192 |
|
---|
| 193 | =item B<script2ve>
|
---|
| 194 |
|
---|
| 195 | Execute a script in a virtual environment
|
---|
| 196 |
|
---|
| 197 | =item B<newvm>
|
---|
| 198 |
|
---|
| 199 | Create a new virtual machine
|
---|
| 200 |
|
---|
| 201 | =item B<newve>
|
---|
| 202 |
|
---|
| 203 | Create a new virtual environment
|
---|
| 204 |
|
---|
[346] | 205 | =item B<setupvm>
|
---|
| 206 |
|
---|
| 207 | Setup a virtual machine for pb usage
|
---|
| 208 |
|
---|
| 209 | =item B<setupve>
|
---|
| 210 |
|
---|
| 211 | Setup a virtual environment for pb usage
|
---|
| 212 |
|
---|
[331] | 213 | =item B<newver>
|
---|
| 214 |
|
---|
| 215 | Create a new version of the project derived
|
---|
| 216 | from the current one
|
---|
| 217 |
|
---|
| 218 | =item B<newproj>
|
---|
| 219 |
|
---|
| 220 | Create a new project and a template set of
|
---|
| 221 | configuration files under pbconf
|
---|
| 222 |
|
---|
| 223 | =back
|
---|
| 224 |
|
---|
| 225 | <pkgs> can be a list of packages, the keyword 'all' or nothing, in which case the default list of packages is taken (corresponding to the defpkgdir list of arguments in the configuration file).
|
---|
| 226 |
|
---|
| 227 | =head1 WEB SITES
|
---|
| 228 |
|
---|
| 229 | The main Web site of the project is available at L<http://www.project-builder.org/>. Bug reports should be filled using the trac instance of the project at L<http://trac.project-builder.org/>.
|
---|
| 230 |
|
---|
| 231 | =head1 USER MAILING LIST
|
---|
| 232 |
|
---|
| 233 | None exists for the moment.
|
---|
| 234 |
|
---|
| 235 | =head1 CONFIGURATION FILES
|
---|
| 236 |
|
---|
| 237 | Each pb user may have a configuration in F<$HOME/.pbrc>. The values in this file may overwrite any other configuration file value.
|
---|
| 238 |
|
---|
| 239 | Here is an example of such a configuration file:
|
---|
| 240 |
|
---|
| 241 | #
|
---|
| 242 | # Define for each project the URL of its pbconf repository
|
---|
| 243 | # No default option allowed here as they need to be all different
|
---|
| 244 | #
|
---|
| 245 | # URL of the pbconf content
|
---|
| 246 | # This is the format of a classical URL with the extension of additional schema such as
|
---|
| 247 | # svn+ssh, cvs+ssh, ...
|
---|
| 248 | #
|
---|
| 249 | pbconfurl linuxcoe = cvs+ssh://:ext:bcornec@linuxcoe.cvs.sourceforge.net:/cvsroot/linuxcoe/pbconf
|
---|
| 250 |
|
---|
| 251 | # This is normaly defined in the project's configuration file
|
---|
| 252 | # Url of the project
|
---|
| 253 | #
|
---|
| 254 | pburl linuxcoe = cvs+ssh://:ext:bcornec@linuxcoe.cvs.sourceforge.net:/cvsroot/linuxcoe
|
---|
| 255 |
|
---|
| 256 | # All these URLs needs to be defined here as the are the entry point
|
---|
| 257 | # for how to build packages for the project
|
---|
| 258 | #
|
---|
| 259 | pbconfurl pb = svn+ssh://svn.project-builder.org/mondo/svn/pb/pbconf
|
---|
| 260 | pbconfurl mondorescue = svn+ssh://svn.project-builder.org/mondo/svn/project-builder/mondorescue/pbconf
|
---|
| 261 | pbconfurl collectl = svn+ssh://bruno@svn.mondorescue.org/mondo/svn/project-builder/collectl/pbconf
|
---|
| 262 | pbconfurl netperf = svn+ssh://svn.mondorescue.org/mondo/svn/project-builder/netperf/pbconf
|
---|
| 263 |
|
---|
| 264 | # Under that dir will take place everything related to pb
|
---|
| 265 | # If you want to use VMs/chroot/..., then use $ENV{'HOME'} to make it portable
|
---|
| 266 | # to your VMs/chroot/...
|
---|
| 267 | # if not defined then /var/cache
|
---|
| 268 | pbdefdir default = $ENV{'HOME'}/project-builder
|
---|
| 269 | pbdefdir pb = $ENV{'HOME'}
|
---|
| 270 | pbdefdir linuxcoe = $ENV{'HOME'}/LinuxCOE/cvs
|
---|
| 271 | pbdefdir mondorescue = $ENV{'HOME'}/mondo/svn
|
---|
| 272 |
|
---|
| 273 | # pbconfdir points to the directory where the CMS content of the pbconfurl is checked out
|
---|
| 274 | # If not defined, pbconfdir is under pbdefdir/pbproj/pbconf
|
---|
| 275 | pbconfdir linuxcoe = $ENV{'HOME'}/LinuxCOE/cvs/pbconf
|
---|
| 276 | pbconfdir mondorescue = $ENV{'HOME'}/mondo/svn/pbconf
|
---|
| 277 |
|
---|
| 278 | # pbdir points to the directory where the CMS content of the pburl is checked out
|
---|
| 279 | # If not defined, pbdir is under pbdefdir/pbproj
|
---|
| 280 | # Only defined if we have access to the dev of the project
|
---|
| 281 | pbdir linuxcoe = $ENV{'HOME'}/LinuxCOE/cvs
|
---|
| 282 | pbdir mondorescue = $ENV{'HOME'}/mondo/svn
|
---|
| 283 |
|
---|
| 284 | # -daemonize doesn't work with qemu 0.8.2
|
---|
| 285 | vmopt default = -m 384
|
---|
| 286 |
|
---|
| 287 | =head1 AUTHORS
|
---|
| 288 |
|
---|
| 289 | The Project-Builder.org team L<http://trac.project-builder.org/> lead by Bruno Cornec L<mailto:bruno@project-builder.org>.
|
---|
| 290 |
|
---|
| 291 | =head1 COPYRIGHT
|
---|
| 292 |
|
---|
| 293 | Project-Builder.org is distributed under the GPL v2.0 license
|
---|
| 294 | described in the file C<COPYING> included with the distribution.
|
---|
| 295 |
|
---|
| 296 | =cut
|
---|
| 297 |
|
---|
| 298 | # ---------------------------------------------------------------------------
|
---|
| 299 |
|
---|
| 300 | # Old syntax
|
---|
| 301 | #getopts('a:fhi:l:m:P:p:qr:s:vV:',\%opts);
|
---|
| 302 |
|
---|
[75] | 303 | my ($projectbuilderver,$projectbuilderrev) = pb_version_init();
|
---|
[331] | 304 |
|
---|
[397] | 305 | # Initialize the syntax string
|
---|
| 306 |
|
---|
| 307 | pb_syntax_init("pb (aka project-builder.org) Version $projectbuilderver-$projectbuilderrev\n");
|
---|
| 308 |
|
---|
[331] | 309 | GetOptions("help|?|h" => \$opts{'h'},
|
---|
| 310 | "man" => \$opts{'man'},
|
---|
| 311 | "verbose|v+" => \$opts{'v'},
|
---|
| 312 | "quiet|q" => \$opts{'q'},
|
---|
| 313 | "log-files|l=s" => \$opts{'l'},
|
---|
| 314 | "force|f" => \$opts{'f'},
|
---|
| 315 | "account|a=s" => \$opts{'a'},
|
---|
| 316 | "revision|r=s" => \$opts{'r'},
|
---|
| 317 | "script|s=s" => \$opts{'s'},
|
---|
| 318 | "machines|mock|m=s" => \$opts{'m'},
|
---|
| 319 | "port|P=i" => \$opts{'P'},
|
---|
| 320 | "project|p=s" => \$opts{'p'},
|
---|
| 321 | "iso|i=s" => \$opts{'i'},
|
---|
| 322 | "version|V=s" => \$opts{'V'},
|
---|
| 323 | ) || pb_syntax(-1,0);
|
---|
| 324 |
|
---|
[21] | 325 | if (defined $opts{'h'}) {
|
---|
[331] | 326 | pb_syntax(0,1);
|
---|
[21] | 327 | }
|
---|
[331] | 328 | if (defined $opts{'man'}) {
|
---|
| 329 | pb_syntax(0,2);
|
---|
| 330 | }
|
---|
[21] | 331 | if (defined $opts{'v'}) {
|
---|
[331] | 332 | $debug = $opts{'v'};
|
---|
[21] | 333 | }
|
---|
[320] | 334 | if (defined $opts{'f'}) {
|
---|
| 335 | $force=1;
|
---|
| 336 | }
|
---|
[21] | 337 | if (defined $opts{'q'}) {
|
---|
| 338 | $debug=-1;
|
---|
| 339 | }
|
---|
[22] | 340 | if (defined $opts{'l'}) {
|
---|
| 341 | open(LOG,"> $opts{'l'}") || die "Unable to log to $opts{'l'}: $!";
|
---|
[348] | 342 | $LOG = \*LOG;
|
---|
[22] | 343 | $debug = 0 if ($debug == -1);
|
---|
| 344 | }
|
---|
[315] | 345 | pb_log_init($debug, $LOG);
|
---|
| 346 |
|
---|
[67] | 347 | # Handle root of the project if defined
|
---|
| 348 | if (defined $opts{'r'}) {
|
---|
[340] | 349 | $ENV{'PBROOTDIR'} = $opts{'r'};
|
---|
[67] | 350 | }
|
---|
[91] | 351 | # Handle virtual machines if any
|
---|
| 352 | if (defined $opts{'m'}) {
|
---|
[320] | 353 | $ENV{'PBV'} = $opts{'m'};
|
---|
[91] | 354 | }
|
---|
[141] | 355 | if (defined $opts{'s'}) {
|
---|
| 356 | $pbscript = $opts{'s'};
|
---|
| 357 | }
|
---|
[152] | 358 | if (defined $opts{'a'}) {
|
---|
| 359 | $pbaccount = $opts{'a'};
|
---|
[347] | 360 | die "option -a requires a -s script option" if (not defined $pbscript);
|
---|
[152] | 361 | }
|
---|
[162] | 362 | if (defined $opts{'P'}) {
|
---|
| 363 | $pbport = $opts{'P'};
|
---|
| 364 | }
|
---|
[199] | 365 | if (defined $opts{'V'}) {
|
---|
| 366 | $newver = $opts{'V'};
|
---|
| 367 | }
|
---|
[262] | 368 | if (defined $opts{'i'}) {
|
---|
| 369 | $iso = $opts{'i'};
|
---|
| 370 | }
|
---|
[108] | 371 |
|
---|
| 372 | # Get Action
|
---|
| 373 | $action = shift @ARGV;
|
---|
[331] | 374 | die pb_syntax(-1,1) if (not defined $action);
|
---|
[108] | 375 |
|
---|
[314] | 376 | my ($filteredfiles, $supfiles, $defpkgdir, $extpkgdir);
|
---|
[273] | 377 | my $pbinit = undef;
|
---|
| 378 | $pbinit = 1 if ($action =~ /^newproj$/);
|
---|
[108] | 379 |
|
---|
[59] | 380 | # Handles project name if any
|
---|
[108] | 381 | # And get global params
|
---|
[353] | 382 | ($filteredfiles, $supfiles, $defpkgdir, $extpkgdir) = pb_env_init($opts{'p'},$pbinit,$action);
|
---|
[59] | 383 |
|
---|
[315] | 384 | pb_log(0,"Project: $ENV{'PBPROJ'}\n");
|
---|
| 385 | pb_log(0,"Action: $action\n");
|
---|
[9] | 386 |
|
---|
| 387 | # Act depending on action
|
---|
| 388 | if ($action =~ /^cms2build$/) {
|
---|
[77] | 389 | pb_cms2build();
|
---|
| 390 | } elsif ($action =~ /^build2pkg$/) {
|
---|
| 391 | pb_build2pkg();
|
---|
| 392 | } elsif ($action =~ /^cms2pkg$/) {
|
---|
| 393 | pb_cms2build();
|
---|
| 394 | pb_build2pkg();
|
---|
[88] | 395 | } elsif ($action =~ /^build2ssh$/) {
|
---|
| 396 | pb_build2ssh();
|
---|
[220] | 397 | } elsif ($action =~ /^cms2ssh$/) {
|
---|
| 398 | pb_cms2build();
|
---|
| 399 | pb_build2ssh();
|
---|
[88] | 400 | } elsif ($action =~ /^pkg2ssh$/) {
|
---|
| 401 | pb_pkg2ssh();
|
---|
[320] | 402 | } elsif ($action =~ /^build2ve$/) {
|
---|
| 403 | pb_build2v("ve");
|
---|
[91] | 404 | } elsif ($action =~ /^build2vm$/) {
|
---|
[320] | 405 | pb_build2v("vm");
|
---|
| 406 | } elsif ($action =~ /^cms2ve$/) {
|
---|
| 407 | pb_cms2build();
|
---|
| 408 | pb_build2v("ve");
|
---|
[91] | 409 | } elsif ($action =~ /^cms2vm$/) {
|
---|
| 410 | pb_cms2build();
|
---|
[320] | 411 | pb_build2v("vm");
|
---|
[141] | 412 | } elsif ($action =~ /^launchvm$/) {
|
---|
[320] | 413 | pb_launchv("vm",$ENV{'PBV'},0);
|
---|
| 414 | } elsif ($action =~ /^launchve$/) {
|
---|
| 415 | pb_launchv("ve",$ENV{'PBV'},0);
|
---|
[142] | 416 | } elsif ($action =~ /^script2vm$/) {
|
---|
[320] | 417 | pb_script2v($pbscript,"vm");
|
---|
| 418 | } elsif ($action =~ /^script2ve$/) {
|
---|
| 419 | pb_script2v($pbscript,"ve");
|
---|
[199] | 420 | } elsif ($action =~ /^newver$/) {
|
---|
| 421 | pb_newver();
|
---|
[320] | 422 | } elsif ($action =~ /^newve$/) {
|
---|
| 423 | pb_launchv("ve",$ENV{'PBV'},1);
|
---|
[262] | 424 | } elsif ($action =~ /^newvm$/) {
|
---|
[320] | 425 | pb_launchv("vm",$ENV{'PBV'},1);
|
---|
[346] | 426 | } elsif ($action =~ /^setupve$/) {
|
---|
[353] | 427 | pb_setup_v("ve");
|
---|
[346] | 428 | } elsif ($action =~ /^setupvm$/) {
|
---|
[353] | 429 | pb_setup_v("vm");
|
---|
[273] | 430 | } elsif ($action =~ /^newproj$/) {
|
---|
| 431 | # Nothing to do - already done in pb_env_init
|
---|
[106] | 432 | } elsif ($action =~ /^clean$/) {
|
---|
[77] | 433 | } else {
|
---|
[315] | 434 | pb_log(0,"\'$action\' is not available\n");
|
---|
[331] | 435 | pb_syntax(-2,1);
|
---|
[77] | 436 | }
|
---|
| 437 |
|
---|
| 438 | sub pb_cms2build {
|
---|
| 439 |
|
---|
[357] | 440 | my $pkg = pb_cms_get_pkg($defpkgdir,$extpkgdir);
|
---|
| 441 | my @pkgs = @$pkg;
|
---|
| 442 | my %pkgs;
|
---|
[9] | 443 |
|
---|
[341] | 444 | my ($scheme, $uri) = pb_cms_init($pbinit);
|
---|
[331] | 445 |
|
---|
[313] | 446 | my ($pkgv, $pkgt) = pb_conf_get_if("pkgver","pkgtag");
|
---|
[174] | 447 |
|
---|
[429] | 448 | # declare packager and repo for filtering
|
---|
| 449 | my ($tmp1, $tmp2) = pb_conf_get("pbpackager","pbrepo");
|
---|
| 450 | $ENV{'PBPACKAGER'} = $tmp1->{$ENV{'PBPROJ'}};
|
---|
| 451 | $ENV{'PBREPO'} = $tmp2->{$ENV{'PBPROJ'}};
|
---|
[174] | 452 |
|
---|
[27] | 453 | foreach my $pbpkg (@pkgs) {
|
---|
[115] | 454 | $ENV{'PBPKG'} = $pbpkg;
|
---|
[98] | 455 | if ((defined $pkgv) && (defined $pkgv->{$pbpkg})) {
|
---|
| 456 | $pbver = $pkgv->{$pbpkg};
|
---|
[9] | 457 | } else {
|
---|
[353] | 458 | $pbver = $ENV{'PBPROJVER'};
|
---|
[9] | 459 | }
|
---|
[98] | 460 | if ((defined $pkgt) && (defined $pkgt->{$pbpkg})) {
|
---|
| 461 | $pbtag = $pkgt->{$pbpkg};
|
---|
[9] | 462 | } else {
|
---|
[353] | 463 | $pbtag = $ENV{'PBPROJTAG'};
|
---|
[9] | 464 | }
|
---|
[95] | 465 |
|
---|
[16] | 466 | $pbrev = $ENV{'PBREVISION'};
|
---|
[319] | 467 | pb_log(0,"\n");
|
---|
| 468 | pb_log(0,"Management of $pbpkg $pbver-$pbtag (rev $pbrev)\n");
|
---|
[9] | 469 | die "Unable to get env var PBDESTDIR" if (not defined $ENV{'PBDESTDIR'});
|
---|
[16] | 470 | # Clean up dest if necessary. The export will recreate it
|
---|
[27] | 471 | my $dest = "$ENV{'PBDESTDIR'}/$pbpkg-$pbver";
|
---|
[74] | 472 | pb_rm_rf($dest) if (-d $dest);
|
---|
[9] | 473 |
|
---|
| 474 | # Export CMS tree for the concerned package to dest
|
---|
| 475 | # And generate some additional files
|
---|
| 476 | $OUTPUT_AUTOFLUSH=1;
|
---|
[29] | 477 |
|
---|
[9] | 478 | # computes in which dir we have to work
|
---|
[113] | 479 | my $dir = $defpkgdir->{$pbpkg};
|
---|
| 480 | $dir = $extpkgdir->{$pbpkg} if (not defined $dir);
|
---|
[315] | 481 | pb_log(2,"def:".Dumper($defpkgdir)." ext: ".Dumper($extpkgdir)." \n");
|
---|
[9] | 482 |
|
---|
[340] | 483 | # Exporting from CMS
|
---|
| 484 | pb_cms_export($uri,"$ENV{'PBDIR'}/$dir",$dest);
|
---|
[315] | 485 |
|
---|
[435] | 486 | # Generated fake content for test versions to speed up stuff
|
---|
| 487 | my ($testver) = pb_conf_get_if("testver");
|
---|
| 488 | my $chglog;
|
---|
[285] | 489 |
|
---|
[435] | 490 | if ((defined $testver) && (defined $testver->{$ENV{'PBPROJ'}}) && ($testver->{$ENV{'PBPROJ'}} =~ /true/i)) {
|
---|
| 491 | if (! -f "$dest/NEWS") {
|
---|
| 492 | open(NEWS,"> $dest/NEWS") || die "Unable to create $dest/NEWS";
|
---|
| 493 | close(NEWS);
|
---|
| 494 | }
|
---|
| 495 | open(CL,"> $dest/ChangeLog") || die "Unable to create $dest/ChangeLog";
|
---|
| 496 | close(CL);
|
---|
| 497 | open(CL,"> $dest/$ENV{'PBCMSLOGFILE'}") || die "Unable to create $dest/$ENV{'PBCMSLOGFILE'}";
|
---|
| 498 | close(CL);
|
---|
| 499 | $chglog = undef;
|
---|
| 500 | } else {
|
---|
[285] | 501 |
|
---|
[435] | 502 | # Get project info on authors and log file
|
---|
| 503 | $chglog = "$ENV{'PBROOTDIR'}/$pbpkg/pbcl";
|
---|
| 504 | $chglog = "$ENV{'PBROOTDIR'}/pbcl" if (! -f $chglog);
|
---|
| 505 | $chglog = undef if (! -f $chglog);
|
---|
| 506 |
|
---|
| 507 | my $authors = "$ENV{'PBROOTDIR'}/$pbpkg/pbauthors";
|
---|
| 508 | $authors = "$ENV{'PBROOTDIR'}/pbauthors" if (! -f $authors);
|
---|
| 509 | $authors = "/dev/null" if (! -f $authors);
|
---|
| 510 |
|
---|
| 511 | # Extract cms log history and store it
|
---|
| 512 | if ((defined $chglog) && (! -f "$dest/NEWS")) {
|
---|
| 513 | pb_log(2,"Generating NEWS file from $chglog\n");
|
---|
| 514 | copy($chglog,"$dest/NEWS") || die "Unable to create $dest/NEWS";
|
---|
| 515 | }
|
---|
| 516 | pb_cms_log($scheme,"$ENV{'PBDIR'}/$dir",$dest,$chglog,$authors);
|
---|
[285] | 517 | }
|
---|
[29] | 518 |
|
---|
[21] | 519 | my %build;
|
---|
[435] | 520 | my @pt;
|
---|
| 521 | my $tmpl = "";
|
---|
[91] | 522 |
|
---|
[328] | 523 | @pt = pb_conf_get_if("vmlist","velist");
|
---|
[340] | 524 | if (defined $pt[0]->{$ENV{'PBPROJ'}}) {
|
---|
| 525 | $tmpl .= $pt[0]->{$ENV{'PBPROJ'}};
|
---|
| 526 | }
|
---|
| 527 | if (defined $pt[1]->{$ENV{'PBPROJ'}}) {
|
---|
| 528 | # the 2 lists needs to be grouped with a ',' separated them
|
---|
| 529 | if ($tmpl ne "") {
|
---|
| 530 | $tmpl .= ",";
|
---|
| 531 | }
|
---|
| 532 | $tmpl .= $pt[1]->{$ENV{'PBPROJ'}}
|
---|
| 533 | }
|
---|
| 534 | foreach my $d (split(/,/,$tmpl)) {
|
---|
[315] | 535 | my ($name,$ver,$arch) = split(/-/,$d);
|
---|
| 536 | chomp($arch);
|
---|
[99] | 537 | my ($ddir, $dver, $dfam, $dtype, $pbsuf) = pb_distro_init($name,$ver);
|
---|
[315] | 538 | pb_log(2,"DEBUG: distro tuple: ".Dumper($ddir, $dver, $dfam, $dtype, $pbsuf)."\n");
|
---|
| 539 | pb_log(2,"DEBUG Filtering PBDATE => $pbdate, PBTAG => $pbtag, PBVER => $pbver\n");
|
---|
[13] | 540 |
|
---|
[16] | 541 | # Filter build files from the less precise up to the most with overloading
|
---|
[13] | 542 | # Filter all files found, keeping the name, and generating in dest
|
---|
[16] | 543 |
|
---|
[340] | 544 | # Find all build files first relatively to PBROOTDIR
|
---|
[300] | 545 | # Find also all specific files referenced in the .pb conf file
|
---|
[320] | 546 | my %bfiles = ();
|
---|
| 547 | my %pkgfiles = ();
|
---|
[21] | 548 | $build{"$ddir-$dver"} = "yes";
|
---|
[315] | 549 |
|
---|
[340] | 550 | if (-d "$ENV{'PBROOTDIR'}/$pbpkg/$dtype") {
|
---|
| 551 | pb_list_bfiles("$ENV{'PBROOTDIR'}/$pbpkg/$dtype",$pbpkg,\%bfiles,\%pkgfiles,$supfiles);
|
---|
| 552 | } elsif (-d "$ENV{'PBROOTDIR'}/$pbpkg/$dfam") {
|
---|
| 553 | pb_list_bfiles("$ENV{'PBROOTDIR'}/$pbpkg/$dfam",$pbpkg,\%bfiles,\%pkgfiles,$supfiles);
|
---|
| 554 | } elsif (-d "$ENV{'PBROOTDIR'}/$pbpkg/$ddir") {
|
---|
| 555 | pb_list_bfiles("$ENV{'PBROOTDIR'}/$pbpkg/$ddir",$pbpkg,\%bfiles,\%pkgfiles,$supfiles);
|
---|
| 556 | } elsif (-d "$ENV{'PBROOTDIR'}/$pbpkg/$ddir-$dver") {
|
---|
| 557 | pb_list_bfiles("$ENV{'PBROOTDIR'}/$pbpkg/$ddir-$dver",$pbpkg,\%bfiles,\%pkgfiles,$supfiles);
|
---|
[13] | 558 | } else {
|
---|
[21] | 559 | $build{"$ddir-$dver"} = "no";
|
---|
[13] | 560 | next;
|
---|
| 561 | }
|
---|
[315] | 562 | pb_log(2,"DEBUG bfiles: ".Dumper(\%bfiles)."\n");
|
---|
[13] | 563 |
|
---|
[15] | 564 | # Get all filters to apply
|
---|
[77] | 565 | my $ptr = pb_get_filters($pbpkg, $dtype, $dfam, $ddir, $dver);
|
---|
[15] | 566 |
|
---|
[19] | 567 | # Apply now all the filters on all the files concerned
|
---|
| 568 | # destination dir depends on the type of file
|
---|
| 569 | if (defined $ptr) {
|
---|
[300] | 570 | foreach my $f (values %bfiles,values %pkgfiles) {
|
---|
[429] | 571 | pb_filter_file_pb("$ENV{'PBROOTDIR'}/$f",$ptr,"$dest/pbconf/$ddir-$dver/".basename($f),$dtype,$pbsuf,$pbpkg,$pbver,$pbtag,$pbrev,$pbdate,$defpkgdir,$extpkgdir,$ENV{'PBPACKAGER'},$chglog,$ENV{'PBPROJ'},$ENV{'PBREPO'});
|
---|
[16] | 572 | }
|
---|
[15] | 573 | }
|
---|
[18] | 574 | }
|
---|
[315] | 575 | my @found;
|
---|
| 576 | my @notfound;
|
---|
| 577 | foreach my $b (keys %build) {
|
---|
| 578 | push @found,$b if ($build{$b} =~ /yes/);
|
---|
| 579 | push @notfound,$b if ($build{$b} =~ /no/);
|
---|
[21] | 580 | }
|
---|
[315] | 581 | pb_log(0,"Build files generated for ".join(',',@found)."\n");
|
---|
| 582 | pb_log(0,"No Build files found for ".join(',',@notfound)."\n") if (@notfound);
|
---|
[236] | 583 | # Get the generic filter (all.pbf) and
|
---|
| 584 | # apply those to the non-build files including those
|
---|
| 585 | # generated by pbinit if applicable
|
---|
| 586 |
|
---|
| 587 | # Get only all.pbf filter
|
---|
[357] | 588 | my $ptr = pb_get_filters($pbpkg);
|
---|
[236] | 589 |
|
---|
| 590 | my $liste ="";
|
---|
| 591 | if (defined $filteredfiles->{$pbpkg}) {
|
---|
| 592 | foreach my $f (split(/,/,$filteredfiles->{$pbpkg})) {
|
---|
[429] | 593 | pb_filter_file_inplace($ptr,"$dest/$f",$pbpkg,$pbver,$pbtag,$pbrev,$pbdate,$ENV{'PBPACKAGER'},$ENV{'PBPROJ'},$ENV{'PBREPO'});
|
---|
[238] | 594 | $liste = "$f $liste";
|
---|
[236] | 595 | }
|
---|
| 596 | }
|
---|
[315] | 597 | pb_log(2,"Files ".$liste."have been filtered\n");
|
---|
[236] | 598 |
|
---|
[265] | 599 | # Prepare the dest directory for archive
|
---|
[340] | 600 | if (-x "$ENV{'PBROOTDIR'}/$pbpkg/pbinit") {
|
---|
[429] | 601 | pb_filter_file("$ENV{'PBROOTDIR'}/$pbpkg/pbinit",$ptr,"$ENV{'PBTMP'}/pbinit",$pbpkg,$pbver,$pbtag,$pbrev,$pbdate,$ENV{'PBPACKAGER'},$ENV{'PBPROJ'},$ENV{'PBREPO'});
|
---|
[266] | 602 | chmod 0755,"$ENV{'PBTMP'}/pbinit";
|
---|
[340] | 603 | pb_system("cd $dest ; $ENV{'PBTMP'}/pbinit","Executing init script from $ENV{'PBROOTDIR'}/$pbpkg/pbinit");
|
---|
[265] | 604 | }
|
---|
| 605 |
|
---|
[18] | 606 | # Archive dest dir
|
---|
[69] | 607 | chdir "$ENV{'PBDESTDIR'}" || die "Unable to change dir to $ENV{'PBDESTDIR'}";
|
---|
[25] | 608 | # Possibility to look at PBSRC to guess more the filename
|
---|
[94] | 609 | pb_system("tar cfz $pbpkg-$pbver.tar.gz $pbpkg-$pbver","Creating $pbpkg tar files compressed");
|
---|
[344] | 610 | pb_log(0,"Under $ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz\n");
|
---|
[83] | 611 |
|
---|
[357] | 612 | # Keep track of version-tag per pkg
|
---|
| 613 | $pkgs{$pbpkg} = "$pbver-$pbtag";
|
---|
[83] | 614 |
|
---|
[288] | 615 | # Final cleanup
|
---|
| 616 | pb_rm_rf($dest) if (-d $dest);
|
---|
[9] | 617 | }
|
---|
[357] | 618 |
|
---|
| 619 | # Keep track of per package version
|
---|
| 620 | pb_log(2,"DEBUG pkgs: ".Dumper(%pkgs)."\n");
|
---|
| 621 | open(PKG,"> $ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb") || die "Unable to create $ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb";
|
---|
| 622 | foreach my $pbpkg (@pkgs) {
|
---|
| 623 | print PKG "pbpkg $pbpkg = $pkgs{$pbpkg}\n";
|
---|
| 624 | }
|
---|
| 625 | close(PKG);
|
---|
| 626 |
|
---|
| 627 | # Keep track of what is generated by default
|
---|
| 628 | # We need to store the dir and info on version-tag
|
---|
| 629 | # Base our content on the existing .pb file
|
---|
| 630 | copy("$ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb","$ENV{'PBDESTDIR'}/pbrc");
|
---|
| 631 | open(LAST,">> $ENV{'PBDESTDIR'}/pbrc") || die "Unable to create $ENV{'PBDESTDIR'}/pbrc";
|
---|
| 632 | print LAST "pbroot $ENV{'PBPROJ'} = $ENV{'PBROOTDIR'}\n";
|
---|
| 633 | print LAST "pbprojver $ENV{'PBPROJ'} = $ENV{'PBPROJVER'}\n";
|
---|
| 634 | print LAST "pbprojtag $ENV{'PBPROJ'} = $ENV{'PBPROJTAG'}\n";
|
---|
| 635 | print LAST "pbpackager $ENV{'PBPROJ'} = $ENV{'PBPACKAGER'}\n";
|
---|
| 636 | close(LAST);
|
---|
[77] | 637 | }
|
---|
[22] | 638 |
|
---|
[77] | 639 | sub pb_build2pkg {
|
---|
| 640 |
|
---|
[22] | 641 | # Get the running distro to build on
|
---|
[99] | 642 | my ($ddir, $dver, $dfam, $dtype, $pbsuf) = pb_distro_init();
|
---|
[315] | 643 | pb_log(2,"DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf))."\n");
|
---|
[22] | 644 |
|
---|
[353] | 645 | # Get list of packages to build
|
---|
[83] | 646 | # Get content saved in cms2build
|
---|
[353] | 647 | my $ptr = pb_get_pkg();
|
---|
| 648 | @pkgs = @$ptr;
|
---|
| 649 |
|
---|
| 650 | my ($pkg) = pb_conf_read("$ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb","pbpkg");
|
---|
[83] | 651 | $pkg = { } if (not defined $pkg);
|
---|
| 652 |
|
---|
[25] | 653 | chdir "$ENV{'PBBUILDDIR'}";
|
---|
[126] | 654 | my $made = ""; # pkgs made during build
|
---|
[27] | 655 | foreach my $pbpkg (@pkgs) {
|
---|
[88] | 656 | my $vertag = $pkg->{$pbpkg};
|
---|
[77] | 657 | # get the version of the current package - maybe different
|
---|
| 658 | ($pbver,$pbtag) = split(/-/,$vertag);
|
---|
| 659 |
|
---|
[27] | 660 | my $src="$ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz";
|
---|
[315] | 661 | pb_log(2,"Source file: $src\n");
|
---|
[25] | 662 |
|
---|
[315] | 663 | pb_log(2,"Working directory: $ENV{'PBBUILDDIR'}\n");
|
---|
[25] | 664 | if ($dtype eq "rpm") {
|
---|
| 665 | foreach my $d ('RPMS','SRPMS','SPECS','SOURCES','BUILD') {
|
---|
[28] | 666 | if (! -d "$ENV{'PBBUILDDIR'}/$d") {
|
---|
[96] | 667 | 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] | 668 | }
|
---|
[25] | 669 | }
|
---|
| 670 |
|
---|
[315] | 671 | # Remove in case a previous link/file was there
|
---|
[301] | 672 | unlink "$ENV{'PBBUILDDIR'}/SOURCES/".basename($src);
|
---|
[188] | 673 | symlink "$src","$ENV{'PBBUILDDIR'}/SOURCES/".basename($src) || die "Unable to symlink $src in $ENV{'PBBUILDDIR'}/SOURCES";
|
---|
[25] | 674 | # We need to first extract the spec file
|
---|
[28] | 675 | my @specfile;
|
---|
[77] | 676 | @specfile = pb_extract_build_files($src,"$pbpkg-$pbver/pbconf/$ddir-$dver/","$ENV{'PBBUILDDIR'}/SPECS");
|
---|
[25] | 677 |
|
---|
[315] | 678 | pb_log(2,"specfile: ".Dumper(\@specfile)."\n");
|
---|
[25] | 679 | # set LANGUAGE to check for correct log messages
|
---|
| 680 | $ENV{'LANGUAGE'}="C";
|
---|
[28] | 681 | foreach my $f (@specfile) {
|
---|
| 682 | if ($f =~ /\.spec$/) {
|
---|
[353] | 683 | pb_system("rpmbuild --define \'packager $ENV{'PBPACKAGER'}\' --define \"_topdir $ENV{'PBBUILDDIR'}\" -ba $f","Building package with $f under $ENV{'PBBUILDDIR'}");
|
---|
[28] | 684 | last;
|
---|
| 685 | }
|
---|
| 686 | }
|
---|
[136] | 687 | $made="$made RPMS/*/$pbpkg-$pbver-$pbtag$pbsuf.*.rpm SRPMS/$pbpkg-$pbver-$pbtag$pbsuf.src.rpm";
|
---|
[149] | 688 | if (-f "/usr/bin/rpmlint") {
|
---|
| 689 | pb_system("rpmlint $made","Checking validity of rpms with rpmlint");
|
---|
[150] | 690 | }
|
---|
[118] | 691 | } elsif ($dtype eq "deb") {
|
---|
[149] | 692 | chdir "$ENV{'PBBUILDDIR'}" || die "Unable to chdir to $ENV{'PBBUILDDIR'}";
|
---|
[274] | 693 | pb_system("tar xfz $src","Extracting sources");
|
---|
[149] | 694 |
|
---|
| 695 | chdir "$pbpkg-$pbver" || die "Unable to chdir to $pbpkg-$pbver";
|
---|
[310] | 696 | pb_rm_rf("debian");
|
---|
[149] | 697 | symlink "pbconf/$ddir-$dver","debian" || die "Unable to symlink to pbconf/$ddir-$dver";
|
---|
[199] | 698 | chmod 0755,"debian/rules";
|
---|
[149] | 699 | pb_system("dpkg-buildpackage -us -uc -rfakeroot","Building package");
|
---|
[136] | 700 | $made="$made $pbpkg"."_*.deb $pbpkg"."_*.dsc $pbpkg"."_*.tar.gz";
|
---|
[315] | 701 | if (-f "/usr/bin/lintian") {
|
---|
| 702 | pb_system("lintian $made","Checking validity of debs with lintian");
|
---|
| 703 | }
|
---|
[87] | 704 | } elsif ($dtype eq "ebuild") {
|
---|
[149] | 705 | my @ebuildfile;
|
---|
| 706 | # For gentoo we need to take pb as subsystem name
|
---|
[295] | 707 | # We put every apps here under sys-apps. hope it's correct
|
---|
[435] | 708 | # We use pb's home dir in order to have a single OVERLAY line
|
---|
[295] | 709 | my $tmpd = "$ENV{'HOME'}/portage/pb/sys-apps/$pbpkg";
|
---|
| 710 | pb_mkdir_p($tmpd) if (! -d "$tmpd");
|
---|
| 711 | pb_mkdir_p("$ENV{'HOME'}/portage/distfiles") if (! -d "$ENV{'HOME'}/portage/distfiles");
|
---|
[149] | 712 |
|
---|
[295] | 713 | # We need to first extract the ebuild file
|
---|
| 714 | @ebuildfile = pb_extract_build_files($src,"$pbpkg-$pbver/pbconf/$ddir-$dver/","$tmpd");
|
---|
[149] | 715 |
|
---|
| 716 | # Prepare the build env for gentoo
|
---|
| 717 | my $found = 0;
|
---|
[295] | 718 | my $pbbd = $ENV{'HOME'};
|
---|
[150] | 719 | $pbbd =~ s|/|\\/|g;
|
---|
[295] | 720 | if (-r "/etc/make.conf") {
|
---|
| 721 | open(MAKE,"/etc/make.conf");
|
---|
| 722 | while (<MAKE>) {
|
---|
| 723 | $found = 1 if (/$pbbd\/portage/);
|
---|
| 724 | }
|
---|
| 725 | close(MAKE);
|
---|
[149] | 726 | }
|
---|
| 727 | if ($found == 0) {
|
---|
[295] | 728 | pb_system("sudo sh -c 'echo PORTDIR_OVERLAY=\"$ENV{'HOME'}/portage\" >> /etc/make.conf'");
|
---|
[149] | 729 | }
|
---|
[295] | 730 | #$found = 0;
|
---|
| 731 | #if (-r "/etc/portage/package.keywords") {
|
---|
| 732 | #open(KEYW,"/etc/portage/package.keywords");
|
---|
| 733 | #while (<KEYW>) {
|
---|
| 734 | #$found = 1 if (/portage\/pb/);
|
---|
| 735 | #}
|
---|
| 736 | #close(KEYW);
|
---|
| 737 | #}
|
---|
| 738 | #if ($found == 0) {
|
---|
| 739 | #pb_system("sudo sh -c \"echo portage/pb >> /etc/portage/package.keywords\"");
|
---|
| 740 | #}
|
---|
[149] | 741 |
|
---|
| 742 | # Build
|
---|
| 743 | foreach my $f (@ebuildfile) {
|
---|
| 744 | if ($f =~ /\.ebuild$/) {
|
---|
[295] | 745 | move($f,"$tmpd/$pbpkg-$pbver.ebuild");
|
---|
| 746 | pb_system("cd $tmpd ; ebuild $pbpkg-$pbver.ebuild clean ; ebuild $pbpkg-$pbver.ebuild digest ; ebuild $pbpkg-$pbver.ebuild package");
|
---|
| 747 | # Now move it where pb expects it
|
---|
| 748 | pb_mkdir_p("$ENV{'PBBUILDDIR'}/portage/pb/sys-apps/$pbpkg");
|
---|
| 749 | move("$tmpd/$pbpkg-$pbver.ebuild","$ENV{'PBBUILDDIR'}/portage/pb/sys-apps/$pbpkg");
|
---|
[149] | 750 | }
|
---|
| 751 | }
|
---|
| 752 |
|
---|
[295] | 753 | $made="$made portage/pb/sys-apps/$pbpkg/$pbpkg-$pbver.ebuild";
|
---|
[437] | 754 | } elsif ($dtype eq "tgz") {
|
---|
| 755 | # Slackware family
|
---|
[435] | 756 | $made="$made $pbpkg/$pbpkg-$pbver-*-$pbtag.tgz";
|
---|
| 757 |
|
---|
| 758 | chdir "$ENV{'PBBUILDDIR'}" || die "Unable to chdir to $ENV{'PBBUILDDIR'}";
|
---|
| 759 | pb_system("tar xfz $src","Extracting sources");
|
---|
| 760 | chdir "$pbpkg-$pbver" || die "Unable to chdir to $pbpkg-$pbver";
|
---|
| 761 | symlink "pbconf/$ddir-$dver","install" || die "Unable to symlink to pbconf/$ddir-$dver";
|
---|
| 762 | if (-x "install/pbslack") {
|
---|
| 763 | pb_system("./install/pbslack","Building package");
|
---|
| 764 | pb_system("sudo /sbin/makepkg -p -l y -c y $pbpkg","Packaging $pbpkg");
|
---|
| 765 | }
|
---|
[87] | 766 | } else {
|
---|
[118] | 767 | die "Unknown dtype format $dtype";
|
---|
[87] | 768 | }
|
---|
| 769 | }
|
---|
[118] | 770 | # Keep track of what is generated so that we can get them back from VMs
|
---|
[353] | 771 | open(KEEP,"> $ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}") || die "Unable to create $ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}";
|
---|
[118] | 772 | print KEEP "$made\n";
|
---|
| 773 | close(KEEP);
|
---|
[87] | 774 | }
|
---|
| 775 |
|
---|
[88] | 776 | sub pb_build2ssh {
|
---|
[320] | 777 | pb_send2target("Sources");
|
---|
[90] | 778 | }
|
---|
[87] | 779 |
|
---|
[90] | 780 | sub pb_pkg2ssh {
|
---|
[320] | 781 | pb_send2target("Packages");
|
---|
[90] | 782 | }
|
---|
| 783 |
|
---|
[108] | 784 | # By default deliver to the the public site hosting the
|
---|
[320] | 785 | # ftp structure (or whatever) or a VM/VE
|
---|
| 786 | sub pb_send2target {
|
---|
[90] | 787 |
|
---|
| 788 | my $cmt = shift;
|
---|
[320] | 789 | my $v = shift || undef;
|
---|
[142] | 790 | my $vmexist = shift || 0; # 0 is FALSE
|
---|
[200] | 791 | my $vmpid = shift || 0; # 0 is FALSE
|
---|
[320] | 792 |
|
---|
| 793 | my $host = "sshhost";
|
---|
| 794 | my $login = "sshlogin";
|
---|
| 795 | my $dir = "sshdir";
|
---|
| 796 | my $port = "sshport";
|
---|
| 797 | my $conf = "sshconf";
|
---|
| 798 | my $rebuild = "sshrebuild";
|
---|
[415] | 799 | my $tmout = "vmtmout";
|
---|
| 800 | my $path = "vmpath";
|
---|
[348] | 801 | if (($cmt eq "vm") || ($cmt eq "Script")) {
|
---|
[320] | 802 | $login = "vmlogin";
|
---|
[322] | 803 | $dir = "pbdefdir";
|
---|
[320] | 804 | $tmout = "vmtmout";
|
---|
| 805 | $rebuild = "vmrebuild";
|
---|
| 806 | # Specific VM
|
---|
| 807 | $host = "vmhost";
|
---|
| 808 | $port = "vmport";
|
---|
| 809 | } elsif ($cmt eq "ve") {
|
---|
| 810 | $login = "velogin";
|
---|
[322] | 811 | $dir = "pbdefdir";
|
---|
[320] | 812 | $tmout = "vetmout";
|
---|
| 813 | # Specific VE
|
---|
| 814 | $path = "vepath";
|
---|
| 815 | $conf = "veconf";
|
---|
| 816 | $rebuild = "verebuild";
|
---|
| 817 | }
|
---|
[158] | 818 | my $cmd = "";
|
---|
[90] | 819 |
|
---|
[353] | 820 | my $ptr = pb_get_pkg();
|
---|
[87] | 821 | @pkgs = @$ptr;
|
---|
| 822 |
|
---|
[136] | 823 | # Get the running distro to consider
|
---|
[347] | 824 | my ($odir,$over,$oarch) = (undef, undef, undef);
|
---|
[320] | 825 | if (defined $v) {
|
---|
| 826 | ($odir,$over,$oarch) = split(/-/,$v);
|
---|
[118] | 827 | }
|
---|
| 828 | my ($ddir, $dver, $dfam, $dtype, $pbsuf) = pb_distro_init($odir,$over);
|
---|
[315] | 829 | pb_log(2,"DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf))."\n");
|
---|
[87] | 830 |
|
---|
[353] | 831 | # Get list of packages to build
|
---|
[87] | 832 | # Get content saved in cms2build
|
---|
[353] | 833 | my ($pkg) = pb_conf_read("$ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb","pbpkg");
|
---|
[87] | 834 | $pkg = { } if (not defined $pkg);
|
---|
| 835 |
|
---|
[118] | 836 | my $src = "";
|
---|
[87] | 837 | chdir "$ENV{'PBBUILDDIR'}";
|
---|
| 838 | foreach my $pbpkg (@pkgs) {
|
---|
[88] | 839 | my $vertag = $pkg->{$pbpkg};
|
---|
[87] | 840 | # get the version of the current package - maybe different
|
---|
| 841 | ($pbver,$pbtag) = split(/-/,$vertag);
|
---|
| 842 |
|
---|
[320] | 843 | if (($cmt eq "Sources") || ($cmt eq "vm") || ($cmt eq "ve")) {
|
---|
[158] | 844 | $src = "$src $ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz";
|
---|
[166] | 845 | if ($cmd eq "") {
|
---|
| 846 | $cmd = "ln -sf $pbpkg-$pbver.tar.gz $pbpkg-latest.tar.gz";
|
---|
| 847 | } else {
|
---|
| 848 | $cmd = "$cmd ; ln -sf $pbpkg-$pbver.tar.gz $pbpkg-latest.tar.gz";
|
---|
| 849 | }
|
---|
[118] | 850 | }
|
---|
| 851 | }
|
---|
[429] | 852 | # Adds conf file for availability of conf elements
|
---|
[417] | 853 | pb_conf_add("$ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb");
|
---|
| 854 |
|
---|
[320] | 855 | if (($cmt eq "vm") || ($cmt eq "ve")) {
|
---|
[429] | 856 | $src="$src $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb $ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb $ENV{'PBETC'} $ENV{'PBDESTDIR'}/pbrc";
|
---|
[142] | 857 | } elsif ($cmt eq "Script") {
|
---|
[429] | 858 | # Nothing special to do
|
---|
[118] | 859 | } elsif ($cmt eq "Packages") {
|
---|
| 860 | # Get package list from file made during build2pkg
|
---|
[353] | 861 | open(KEEP,"$ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}") || die "Unable to read $ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}";
|
---|
[126] | 862 | $src = <KEEP>;
|
---|
[118] | 863 | chomp($src);
|
---|
| 864 | close(KEEP);
|
---|
[429] | 865 |
|
---|
[87] | 866 | }
|
---|
[429] | 867 | # Systematically adds the pbscript
|
---|
| 868 | $src="$src $ENV{'PBDESTDIR'}/pbscript";
|
---|
[320] | 869 | # Remove potential leading spaces (cause problem with basename)
|
---|
[132] | 870 | $src =~ s/^ *//;
|
---|
[129] | 871 | my $basesrc = "";
|
---|
[131] | 872 | foreach my $i (split(/ +/,$src)) {
|
---|
| 873 | $basesrc .= " ".basename($i);
|
---|
[130] | 874 | }
|
---|
[118] | 875 |
|
---|
[320] | 876 | pb_log(0,"Sources handled ($cmt): $src\n");
|
---|
[355] | 877 | pb_log(2,"values: ".Dumper(($host,$login,$dir,$port,$tmout,$rebuild,$path,$conf))."\n");
|
---|
[415] | 878 | my ($sshhost,$sshlogin,$sshdir,$sshport,$vtmout,$vepath) = pb_conf_get($host,$login,$dir,$port,$tmout,$path);
|
---|
| 879 | my ($vrebuild,$veconf) = pb_conf_get_if($rebuild,$conf);
|
---|
[320] | 880 | pb_log(2,"ssh: ".Dumper(($sshhost,$sshlogin,$sshdir,$sshport,$vtmout,$vrebuild,$vepath,$veconf))."\n");
|
---|
| 881 | # Not mandatory
|
---|
| 882 | my ($testver) = pb_conf_get_if("testver");
|
---|
| 883 |
|
---|
| 884 | my $mac;
|
---|
| 885 | # Useless for VE
|
---|
| 886 | if ($cmt ne "ve") {
|
---|
| 887 | $mac = "$sshlogin->{$ENV{'PBPROJ'}}\@$sshhost->{$ENV{'PBPROJ'}}";
|
---|
| 888 | # Overwrite account value if passed as parameter
|
---|
| 889 | $mac = "$pbaccount\@$sshhost->{$ENV{'PBPROJ'}}" if (defined $pbaccount);
|
---|
[355] | 890 | pb_log(2, "DEBUG: pbaccount: $pbaccount => mac: $mac\n") if (defined $pbaccount);
|
---|
[320] | 891 | }
|
---|
| 892 |
|
---|
[108] | 893 | my $tdir;
|
---|
[136] | 894 | my $bdir;
|
---|
[142] | 895 | if (($cmt eq "Sources") || ($cmt eq "Script")) {
|
---|
[108] | 896 | $tdir = "$sshdir->{$ENV{'PBPROJ'}}/src";
|
---|
[435] | 897 | if ((defined $testver) && (defined $testver->{$ENV{'PBPROJ'}}) && ($testver->{$ENV{'PBPROJ'}} =~ /true/i)) {
|
---|
| 898 | # This is a test pkg => target dir is under test
|
---|
| 899 | $tdir = "$sshdir->{$ENV{'PBPROJ'}}/test/src";
|
---|
| 900 | }
|
---|
[320] | 901 | } elsif (($cmt eq "vm") || ($cmt eq "ve")) {
|
---|
| 902 | $tdir = $sshdir->{$ENV{'PBPROJ'}}."/$ENV{'PBPROJ'}/delivery";
|
---|
| 903 | $bdir = $sshdir->{$ENV{'PBPROJ'}}."/$ENV{'PBPROJ'}/build";
|
---|
[136] | 904 | # Remove a potential $ENV{'HOME'} as bdir should be relative to pb's home
|
---|
| 905 | $bdir =~ s|\$ENV.+\}/||;
|
---|
[90] | 906 | } elsif ($cmt eq "Packages") {
|
---|
[108] | 907 | $tdir = "$sshdir->{$ENV{'PBPROJ'}}/$ddir/$dver";
|
---|
[429] | 908 |
|
---|
[337] | 909 | if ((defined $testver) && (defined $testver->{$ENV{'PBPROJ'}}) && ($testver->{$ENV{'PBPROJ'}} =~ /true/i)) {
|
---|
[289] | 910 | # This is a test pkg => target dir is under test
|
---|
[428] | 911 | $tdir = "$sshdir->{$ENV{'PBPROJ'}}/test/$ddir/$dver";
|
---|
[291] | 912 | }
|
---|
[429] | 913 |
|
---|
| 914 | my $repodir = $tdir;
|
---|
| 915 | $repodir =~ s|^$sshdir->{$ENV{'PBPROJ'}}/||;
|
---|
| 916 |
|
---|
| 917 | my ($pbrepo) = pb_conf_get("pbrepo");
|
---|
| 918 |
|
---|
| 919 | # Repository management
|
---|
| 920 | open(PBS,"> $ENV{'PBDESTDIR'}/pbscript") || die "Unable to create $ENV{'PBDESTDIR'}/pbscript";
|
---|
| 921 | if ($dtype eq "rpm") {
|
---|
| 922 | # Also make a pbscript to generate yum/urpmi bases
|
---|
| 923 | print PBS << "EOF";
|
---|
[433] | 924 | #!/bin/bash
|
---|
[429] | 925 | # Prepare a script to ease yum setup
|
---|
| 926 | cat > $ENV{'PBPROJ'}.repo << EOT
|
---|
| 927 | [$ENV{'PBPROJ'}]
|
---|
| 928 | name=$ddir $dver - $ENV{'PBPROJ'} Vanilla Packages
|
---|
[433] | 929 | baseurl=$pbrepo->{$ENV{'PBPROJ'}}/$repodir
|
---|
[429] | 930 | enabled=1
|
---|
| 931 | gpgcheck=0
|
---|
| 932 | EOT
|
---|
| 933 | chmod 644 $ENV{'PBPROJ'}.repo
|
---|
| 934 |
|
---|
| 935 | # Clean up old repo content
|
---|
| 936 | rm -rf headers/ repodata/
|
---|
| 937 | # Create yum repo
|
---|
| 938 | yum-arch .
|
---|
| 939 | # Create repodata
|
---|
| 940 | createrepo .
|
---|
| 941 | EOF
|
---|
| 942 | if ($dfam eq "md") {
|
---|
| 943 | # For Mandriva add urpmi management
|
---|
| 944 | print PBS << "EOF";
|
---|
| 945 | # Prepare a script to ease urpmi setup
|
---|
| 946 | cat > $ENV{'PBPROJ'}.addmedia << EOT
|
---|
[433] | 947 | urpmi.addmedia $ENV{'PBPROJ'} $pbrepo->{$ENV{'PBPROJ'}}/$repodir with hdlist.cz
|
---|
[429] | 948 | EOT
|
---|
| 949 | chmod 755 $ENV{'PBPROJ'}.addmedia
|
---|
| 950 |
|
---|
| 951 | # Clean up old repo content
|
---|
[437] | 952 | rm -f hdlist.cz synthesis.hdlist.cz
|
---|
[429] | 953 | # Create urpmi repo
|
---|
| 954 | genhdlist .
|
---|
| 955 | EOF
|
---|
| 956 | }
|
---|
| 957 | } elsif ($dtype eq "deb") {
|
---|
| 958 | # Also make a pbscript to generate apt bases
|
---|
| 959 | }
|
---|
| 960 | close(PBS);
|
---|
| 961 |
|
---|
[90] | 962 | } else {
|
---|
| 963 | return;
|
---|
[22] | 964 | }
|
---|
[239] | 965 |
|
---|
[320] | 966 | # Useless for VE
|
---|
| 967 | my $nport;
|
---|
| 968 | if ($cmt ne "ve") {
|
---|
| 969 | $nport = $sshport->{$ENV{'PBPROJ'}};
|
---|
| 970 | $nport = "$pbport" if (defined $pbport);
|
---|
| 971 | }
|
---|
| 972 |
|
---|
[136] | 973 | # Remove a potential $ENV{'HOME'} as tdir should be relative to pb's home
|
---|
[132] | 974 | $tdir =~ s|\$ENV.+\}/||;
|
---|
| 975 |
|
---|
[320] | 976 | my $tm = $vtmout->{$ENV{'PBPROJ'}};
|
---|
| 977 |
|
---|
| 978 | # ssh communication if not VE
|
---|
[349] | 979 | # should use a hash instead...
|
---|
[320] | 980 | my ($shcmd,$cpcmd,$cptarget,$cp2target);
|
---|
| 981 | if ($cmt ne "ve") {
|
---|
[347] | 982 | my $keyfile = pb_ssh_get(0);
|
---|
[435] | 983 | $shcmd = "ssh -i $keyfile -q -o UserKnownHostsFile=/dev/null -p $nport $mac";
|
---|
| 984 | $cpcmd = "scp -i $keyfile -p -o UserKnownHostsFile=/dev/null -P $nport";
|
---|
[320] | 985 | $cptarget = "$mac:$tdir";
|
---|
[351] | 986 | if ($cmt eq "vm") {
|
---|
| 987 | $cp2target = "$mac:$bdir";
|
---|
| 988 | }
|
---|
[320] | 989 | } else {
|
---|
| 990 | my $tp = $vepath->{$ENV{'PBPROJ'}};
|
---|
| 991 | $shcmd = "sudo chroot $tp/$v /bin/su - $sshlogin->{$ENV{'PBPROJ'}} -c ";
|
---|
| 992 | $cpcmd = "cp -a ";
|
---|
| 993 | $cptarget = "$tp/$tdir";
|
---|
| 994 | $cp2target = "$tp/$bdir";
|
---|
| 995 | }
|
---|
| 996 |
|
---|
| 997 | pb_system("$shcmd \"mkdir -p $tdir ; cd $tdir ; echo \'for i in $basesrc; do if [ -f \$i ]; then rm -f \$i; fi; done\ ; $cmd' | bash\"","Preparing $tdir on $cptarget");
|
---|
| 998 | pb_system("cd $ENV{'PBBUILDDIR'} ; $cpcmd $src $cptarget 2> /dev/null","$cmt delivery in $cptarget");
|
---|
| 999 | # For VE we need to change the owner manually - To be tested if needed
|
---|
| 1000 | #if ($cmt eq "ve") {
|
---|
| 1001 | #pb_system("cd $cptarget ; sudo chown -R $sshlogin->{$ENV{'PBPROJ'}} .","$cmt chown in $cptarget to $sshlogin->{$ENV{'PBPROJ'}}");
|
---|
| 1002 | #}
|
---|
[434] | 1003 | pb_system("$shcmd \"echo \'cd $tdir ; if [ -f pbscript ]; then ./pbscript; fi ; rm -f ./pbscript\' | bash\"","Executing pbscript on $cptarget if needed");
|
---|
[320] | 1004 | if (($cmt eq "vm") || ($cmt eq "ve")) {
|
---|
[128] | 1005 | # Get back info on pkg produced, compute their name and get them from the VM
|
---|
[353] | 1006 | pb_system("$cpcmd $cp2target/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'} $ENV{'PBBUILDDIR'} 2> /dev/null","Get package names in $cp2target");
|
---|
| 1007 | open(KEEP,"$ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}") || die "Unable to read $ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}";
|
---|
[118] | 1008 | my $src = <KEEP>;
|
---|
| 1009 | chomp($src);
|
---|
| 1010 | close(KEEP);
|
---|
[131] | 1011 | $src =~ s/^ *//;
|
---|
[136] | 1012 | pb_mkdir_p("$ENV{'PBBUILDDIR'}/$odir/$over");
|
---|
[320] | 1013 | # Change pgben to make the next send2target happy
|
---|
[143] | 1014 | my $made = "";
|
---|
[353] | 1015 | open(KEEP,"> $ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}") || die "Unable to write $ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}";
|
---|
[136] | 1016 | foreach my $p (split(/ +/,$src)) {
|
---|
[139] | 1017 | my $j = basename($p);
|
---|
[320] | 1018 | pb_system("$cpcmd $cp2target/\'$p\' $ENV{'PBBUILDDIR'}/$odir/$over 2> /dev/null","Package recovery of $j in $cp2target");
|
---|
[144] | 1019 | $made="$made $odir/$over/$j" if (($dtype ne "rpm") || ($j !~ /.src.rpm$/));
|
---|
[136] | 1020 | }
|
---|
[143] | 1021 | print KEEP "$made\n";
|
---|
[139] | 1022 | close(KEEP);
|
---|
[320] | 1023 | pb_system("$shcmd \"rm -rf $tdir $bdir\"","$cmt cleanup");
|
---|
[355] | 1024 |
|
---|
| 1025 | # We want to send them to the ssh account so overwrite what has been done before
|
---|
| 1026 | undef $pbaccount;
|
---|
[357] | 1027 | pb_log(2,"Before sending pkgs, vmexist: $vmexist, vmpid: $vmpid\n");
|
---|
[355] | 1028 | pb_send2target("Packages",$odir."-".$over."-".$oarch,$vmexist,$vmpid);
|
---|
[320] | 1029 | if ((! $vmexist) && ($cmt eq "vm")) {
|
---|
| 1030 | pb_system("$shcmd \"sudo /sbin/halt -p \"; sleep $tm ; echo \'if [ -d /proc/$vmpid ]; then kill -9 $vmpid; fi \' | bash ; sleep 10","VM $v halt (pid $vmpid)");
|
---|
[142] | 1031 | }
|
---|
[141] | 1032 | pb_rm_rf("$ENV{'PBBUILDDIR'}/$odir");
|
---|
[108] | 1033 | }
|
---|
[9] | 1034 | }
|
---|
[16] | 1035 |
|
---|
[320] | 1036 | sub pb_script2v {
|
---|
[142] | 1037 | my $pbscript=shift;
|
---|
[320] | 1038 | my $vtype=shift;
|
---|
[141] | 1039 |
|
---|
| 1040 | # Prepare the script to be executed on the VM
|
---|
| 1041 | # in $ENV{'PBDESTDIR'}/pbscript
|
---|
[142] | 1042 | if ((defined $pbscript ) && ($pbscript ne "$ENV{'PBDESTDIR'}/pbscript")) {
|
---|
| 1043 | copy($pbscript,"$ENV{'PBDESTDIR'}/pbscript") || die "Unable to create $ENV{'PBDESTDIR'}/pbscript";
|
---|
| 1044 | chmod 0755,"$ENV{'PBDESTDIR'}/pbscript";
|
---|
| 1045 | }
|
---|
[141] | 1046 |
|
---|
[320] | 1047 | my ($vm,$all) = pb_get_v($vtype);
|
---|
| 1048 | my ($vmexist,$vmpid) = (undef,undef);
|
---|
[142] | 1049 |
|
---|
[141] | 1050 | foreach my $v (@$vm) {
|
---|
[320] | 1051 | # Launch the VM/VE
|
---|
| 1052 | if ($vtype eq "vm") {
|
---|
| 1053 | ($vmexist,$vmpid) = pb_launchv($vtype,$v,0);
|
---|
[141] | 1054 |
|
---|
[320] | 1055 | # Skip that VM if something went wrong
|
---|
| 1056 | next if (($vmpid == 0) && ($vmexist ==0));
|
---|
| 1057 | }
|
---|
[274] | 1058 |
|
---|
[142] | 1059 | # Gather all required files to send them to the VM
|
---|
[320] | 1060 | # and launch the build through pbscript
|
---|
| 1061 | pb_send2target("Script","$v",$vmexist,$vmpid);
|
---|
[169] | 1062 |
|
---|
[142] | 1063 | }
|
---|
| 1064 | }
|
---|
| 1065 |
|
---|
[320] | 1066 | sub pb_launchv {
|
---|
| 1067 | my $vtype = shift;
|
---|
| 1068 | my $v = shift;
|
---|
| 1069 | my $create = shift || 0; # By default do not create a VM
|
---|
[310] | 1070 |
|
---|
[320] | 1071 | die "No VM/VE defined, unable to launch" if (not defined $v);
|
---|
| 1072 | # Keep only the first VM in case many were given
|
---|
| 1073 | $v =~ s/,.*//;
|
---|
[310] | 1074 |
|
---|
[320] | 1075 | # Which is our local arch ? (standardize on i386 for those platforms)
|
---|
| 1076 | my $arch = `uname -m`;
|
---|
| 1077 | chomp($arch);
|
---|
| 1078 | $arch =~ s/i.86/i386/;
|
---|
[310] | 1079 |
|
---|
[320] | 1080 | # Launch the VMs/VEs
|
---|
| 1081 | if ($vtype eq "vm") {
|
---|
| 1082 | die "-i iso parameter needed" if (((not defined $iso) || ($iso eq "")) && ($create != 0));
|
---|
[310] | 1083 |
|
---|
[415] | 1084 | my ($ptr,$vmopt,$vmpath,$vmport,$vmtmout,$vmsize) = pb_conf_get("vmtype","vmopt","vmpath","vmport","vmtmout","vmsize");
|
---|
[320] | 1085 |
|
---|
| 1086 | my $vmtype = $ptr->{$ENV{'PBPROJ'}};
|
---|
| 1087 | if (not defined $ENV{'PBVMOPT'}) {
|
---|
| 1088 | $ENV{'PBVMOPT'} = "";
|
---|
[310] | 1089 | }
|
---|
[320] | 1090 | if (defined $vmopt->{$ENV{'PBPROJ'}}) {
|
---|
| 1091 | $ENV{'PBVMOPT'} .= " $vmopt->{$ENV{'PBPROJ'}}" if ($ENV{'PBVMOPT'} !~ / $vmopt->{$ENV{'PBPROJ'}}/);
|
---|
| 1092 | }
|
---|
| 1093 | my $nport = $vmport->{$ENV{'PBPROJ'}};
|
---|
| 1094 | $nport = "$pbport" if (defined $pbport);
|
---|
| 1095 |
|
---|
| 1096 | my $cmd;
|
---|
| 1097 | my $vmcmd; # has to be used for pb_check_ps
|
---|
| 1098 | my $vmm; # has to be used for pb_check_ps
|
---|
| 1099 | if ($vmtype eq "qemu") {
|
---|
| 1100 | my $qemucmd32;
|
---|
| 1101 | my $qemucmd64;
|
---|
| 1102 | if ($arch eq "x86_64") {
|
---|
| 1103 | $qemucmd32 = "/usr/bin/qemu-system-i386";
|
---|
| 1104 | $qemucmd64 = "/usr/bin/qemu";
|
---|
| 1105 | } else {
|
---|
| 1106 | $qemucmd32 = "/usr/bin/qemu";
|
---|
| 1107 | $qemucmd64 = "/usr/bin/qemu-system-x86_64";
|
---|
| 1108 | }
|
---|
| 1109 | if ($v =~ /x86_64/) {
|
---|
| 1110 | $vmcmd = "$qemucmd64 -no-kqemu";
|
---|
| 1111 | } else {
|
---|
| 1112 | $vmcmd = "$qemucmd32";
|
---|
| 1113 | }
|
---|
| 1114 | $vmm = "$vmpath->{$ENV{'PBPROJ'}}/$v.qemu";
|
---|
| 1115 | if ($create != 0) {
|
---|
| 1116 | $ENV{'PBVMOPT'} .= " -cdrom $iso -boot d";
|
---|
| 1117 | }
|
---|
| 1118 | $cmd = "$vmcmd $ENV{'PBVMOPT'} -redir tcp:$nport:10.0.2.15:22 $vmm"
|
---|
| 1119 | } elsif ($vmtype eq "xen") {
|
---|
| 1120 | } elsif ($vmtype eq "vmware") {
|
---|
[310] | 1121 | } else {
|
---|
[320] | 1122 | die "VM of type $vmtype not supported. Report to the dev team";
|
---|
[310] | 1123 | }
|
---|
[320] | 1124 | my ($tmpcmd,$void) = split(/ +/,$cmd);
|
---|
| 1125 | my $vmexist = pb_check_ps($tmpcmd,$vmm);
|
---|
| 1126 | my $vmpid = 0;
|
---|
| 1127 | if (! $vmexist) {
|
---|
| 1128 | if ($create != 0) {
|
---|
| 1129 | if (($vmtype eq "qemu") || ($vmtype eq "xen")) {
|
---|
| 1130 | pb_system("/usr/bin/qemu-img create -f qcow2 $vmm $vmsize->{$ENV{'PBPROJ'}}","Creating the QEMU VM");
|
---|
| 1131 | } elsif ($vmtype eq "vmware") {
|
---|
| 1132 | } else {
|
---|
| 1133 | }
|
---|
| 1134 | }
|
---|
| 1135 | if (! -f "$vmm") {
|
---|
| 1136 | pb_log(0,"Unable to find VM $vmm\n");
|
---|
| 1137 | } else {
|
---|
| 1138 | pb_system("$cmd &","Launching the VM $vmm");
|
---|
| 1139 | pb_system("sleep $vmtmout->{$ENV{'PBPROJ'}}","Waiting for VM $v to come up");
|
---|
| 1140 | $vmpid = pb_check_ps($tmpcmd,$vmm);
|
---|
[357] | 1141 | pb_log(0,"VM $vmm launched (pid $vmpid)\n");
|
---|
[320] | 1142 | }
|
---|
[310] | 1143 | } else {
|
---|
[320] | 1144 | pb_log(0,"Found an existing VM $vmm (pid $vmexist)\n");
|
---|
[310] | 1145 | }
|
---|
[320] | 1146 | return($vmexist,$vmpid);
|
---|
| 1147 | # VE here
|
---|
[310] | 1148 | } else {
|
---|
[320] | 1149 | # Get VE context
|
---|
[415] | 1150 | my ($ptr,$vetmout,$vepath,$verebuild,$veconf) = pb_conf_get("vetype","vetmout","vepath","verebuild","veconf");
|
---|
[320] | 1151 | my $vetype = $ptr->{$ENV{'PBPROJ'}};
|
---|
[310] | 1152 |
|
---|
[320] | 1153 | # Get distro context
|
---|
| 1154 | my ($name,$ver,$darch) = split(/-/,$v);
|
---|
| 1155 | chomp($darch);
|
---|
| 1156 | my ($ddir, $dver, $dfam, $dtype, $pbsuf) = pb_distro_init($name,$ver);
|
---|
[142] | 1157 |
|
---|
[320] | 1158 | if ($vetype eq "chroot") {
|
---|
| 1159 | # Architecture consistency
|
---|
| 1160 | if ($arch ne $darch) {
|
---|
| 1161 | die "Unable to launch a VE of architecture $darch on a $arch platform" if (not (($darch eq "x86_64") && ($arch =~ /i?86/)));
|
---|
| 1162 | }
|
---|
[142] | 1163 |
|
---|
[320] | 1164 | if (($create != 0) || ($verebuild->{$ENV{'PBPROJ'}} eq "true") || ($force == 1)) {
|
---|
| 1165 | # We have to rebuild the chroot
|
---|
| 1166 | if ($dtype eq "rpm") {
|
---|
| 1167 | pb_system("sudo /usr/sbin/mock --init --resultdir=\"/tmp\" --configdir=\"$veconf->{$ENV{'PBPROJ'}}\" -r $v","Creating the mock VE");
|
---|
| 1168 | # Once setup we need to install some packages, the pb account, ...
|
---|
| 1169 | pb_system("sudo /usr/sbin/mock --install --configdir=\"$veconf->{$ENV{'PBPROJ'}}\" -r $v su","Configuring the mock VE");
|
---|
| 1170 | #pb_system("sudo /usr/sbin/mock --init --resultdir=\"/tmp\" --configdir=\"$veconf->{$ENV{'PBPROJ'}}\" --basedir=\"$vepath->{$ENV{'PBPROJ'}}\" -r $v","Creating the mock VE");
|
---|
| 1171 | } elsif ($dtype eq "deb") {
|
---|
| 1172 | pb_system("","Creating the pbuilder VE");
|
---|
| 1173 | } elsif ($dtype eq "ebuild") {
|
---|
| 1174 | die "Please teach the dev team how to build gentoo chroot";
|
---|
| 1175 | } else {
|
---|
| 1176 | die "Unknown distribution type $dtype. Report to dev team";
|
---|
| 1177 | }
|
---|
[310] | 1178 | }
|
---|
[320] | 1179 | # Nothing more to do for VE. No real launch
|
---|
[274] | 1180 | } else {
|
---|
[320] | 1181 | die "VE of type $vetype not supported. Report to the dev team";
|
---|
[262] | 1182 | }
|
---|
[141] | 1183 | }
|
---|
| 1184 | }
|
---|
[142] | 1185 |
|
---|
[320] | 1186 | sub pb_build2v {
|
---|
[118] | 1187 |
|
---|
[320] | 1188 | my $vtype = shift;
|
---|
[142] | 1189 |
|
---|
[320] | 1190 | # Prepare the script to be executed on the VM/VE
|
---|
| 1191 | # in $ENV{'PBDESTDIR'}/pbscript
|
---|
[353] | 1192 | #my ($ntp) = pb_conf_get($vtype."ntp");
|
---|
| 1193 | #my $vntp = $ntp->{$ENV{'PBPROJ'}};
|
---|
[118] | 1194 |
|
---|
[320] | 1195 | open(SCRIPT,"> $ENV{'PBDESTDIR'}/pbscript") || die "Unable to create $ENV{'PBDESTDIR'}/pbscript";
|
---|
| 1196 | print SCRIPT "#!/bin/bash\n";
|
---|
| 1197 | print SCRIPT "echo ... Execution needed\n";
|
---|
| 1198 | print SCRIPT "# This is in directory delivery\n";
|
---|
| 1199 | print SCRIPT "# Setup the variables required for building\n";
|
---|
| 1200 | print SCRIPT "export PBPROJ=$ENV{'PBPROJ'}\n";
|
---|
| 1201 | print SCRIPT "# Preparation for pb\n";
|
---|
| 1202 | print SCRIPT "mv .pbrc \$HOME\n";
|
---|
| 1203 | print SCRIPT "cd ..\n";
|
---|
| 1204 | # Force new date to be in the future compared to the date of the tar file by adding 1 minute
|
---|
| 1205 | my @date=pb_get_date();
|
---|
| 1206 | $date[1]++;
|
---|
| 1207 | my $upddate = strftime("%m%d%H%M%Y", @date);
|
---|
[353] | 1208 | #print SCRIPT "echo Setting up date on $vntp...\n";
|
---|
[320] | 1209 | # Or use ntpdate if available TBC
|
---|
| 1210 | print SCRIPT "sudo date $upddate\n";
|
---|
[353] | 1211 | # Get list of packages to build and get some ENV vars as well
|
---|
| 1212 | my $ptr = pb_get_pkg();
|
---|
| 1213 | @pkgs = @$ptr;
|
---|
| 1214 | my $p = join(' ',@pkgs) if (@pkgs);
|
---|
| 1215 | print SCRIPT "export PBPROJVER=$ENV{'PBPROJVER'}\n";
|
---|
| 1216 | print SCRIPT "export PBPROJTAG=$ENV{'PBPROJTAG'}\n";
|
---|
[320] | 1217 | print SCRIPT "export PBPACKAGER=\"$ENV{'PBPACKAGER'}\"\n";
|
---|
| 1218 | print SCRIPT "# Build\n";
|
---|
| 1219 | print SCRIPT "echo Building packages on $vtype...\n";
|
---|
| 1220 | print SCRIPT "pb -p $ENV{'PBPROJ'} build2pkg $p\n";
|
---|
| 1221 | close(SCRIPT);
|
---|
| 1222 | chmod 0755,"$ENV{'PBDESTDIR'}/pbscript";
|
---|
| 1223 |
|
---|
| 1224 | my ($v,$all) = pb_get_v($vtype);
|
---|
| 1225 |
|
---|
| 1226 | # Send tar files when we do a global generation
|
---|
| 1227 | pb_build2ssh() if ($all == 1);
|
---|
| 1228 |
|
---|
| 1229 | my ($vmexist,$vmpid) = (undef,undef);
|
---|
| 1230 |
|
---|
| 1231 | foreach my $v (@$v) {
|
---|
| 1232 | if ($vtype eq "vm") {
|
---|
[142] | 1233 | # Launch the VM
|
---|
[357] | 1234 | ($vmexist,$vmpid) = pb_launchv($vtype,$v,0);
|
---|
[118] | 1235 |
|
---|
[274] | 1236 | # Skip that VM if it something went wrong
|
---|
| 1237 | next if (($vmpid == 0) && ($vmexist == 0));
|
---|
[118] | 1238 | }
|
---|
[320] | 1239 | # Gather all required files to send them to the VM/VE
|
---|
[347] | 1240 | # and launch the build through pbscript
|
---|
[357] | 1241 | pb_log(2,"Calling send2target $vtype,$v,$vmexist,$vmpid\n");
|
---|
[320] | 1242 | pb_send2target($vtype,"$v",$vmexist,$vmpid);
|
---|
[105] | 1243 | }
|
---|
[320] | 1244 | }
|
---|
[105] | 1245 |
|
---|
[262] | 1246 |
|
---|
[199] | 1247 | sub pb_newver {
|
---|
| 1248 |
|
---|
[204] | 1249 | die "-V Version parameter needed" if ((not defined $newver) || ($newver eq ""));
|
---|
[340] | 1250 |
|
---|
[366] | 1251 | # Need this call for PBDIR
|
---|
| 1252 | my ($scheme2,$uri) = pb_cms_init($pbinit);
|
---|
[361] | 1253 |
|
---|
[415] | 1254 | my ($pbconf) = pb_conf_get("pbconfurl");
|
---|
[366] | 1255 | $uri = $pbconf->{$ENV{'PBPROJ'}};
|
---|
| 1256 | my ($scheme, $account, $host, $port, $path) = pb_get_uri($uri);
|
---|
| 1257 |
|
---|
[361] | 1258 | # Checking CMS repositories status
|
---|
[358] | 1259 | my ($pburl) = pb_conf_get("pburl");
|
---|
[366] | 1260 | ($scheme2, $account, $host, $port, $path) = pb_get_uri($pburl->{$ENV{'PBPROJ'}});
|
---|
[340] | 1261 |
|
---|
| 1262 | if ($scheme !~ /^svn/) {
|
---|
[199] | 1263 | die "Only SVN is supported at the moment";
|
---|
| 1264 | }
|
---|
[358] | 1265 | my $res = pb_cms_isdiff($scheme,$ENV{'PBROOTDIR'});
|
---|
[361] | 1266 | die "ERROR: No differences accepted in CMS for $ENV{'PBROOTDIR'} before creating a new version" if ($res != 0);
|
---|
[358] | 1267 |
|
---|
| 1268 | $res = pb_cms_isdiff($scheme2,$ENV{'PBDIR'});
|
---|
[361] | 1269 | die "ERROR: No differences accepted in CMS for $ENV{'PBDIR'} before creating a new version" if ($res != 0);
|
---|
[358] | 1270 |
|
---|
| 1271 | # Tree identical between PBCONFDIR and PBROOTDIR. The delta is what
|
---|
| 1272 | # we want to get for the root of the new URL
|
---|
| 1273 |
|
---|
| 1274 | my $tmp = $ENV{'PBROOTDIR'};
|
---|
| 1275 | $tmp =~ s|^$ENV{'PBCONFDIR'}||;
|
---|
| 1276 |
|
---|
| 1277 | my $newurl = "$uri/".dirname($tmp)."/$newver";
|
---|
[366] | 1278 | # Should probably use projver in the old file
|
---|
| 1279 | my $oldver= basename($tmp);
|
---|
[361] | 1280 |
|
---|
| 1281 | # Checking pbcl files
|
---|
[366] | 1282 | foreach my $f (<$ENV{'PBROOTDIR'}/*/pbcl>) {
|
---|
[361] | 1283 | open(PBCL,$f) || die "Unable to open $f";
|
---|
| 1284 | my $foundnew = 0;
|
---|
| 1285 | while (<PBCL>) {
|
---|
[363] | 1286 | $foundnew = 1 if (/^$newver \(/);
|
---|
[361] | 1287 | }
|
---|
| 1288 | close(PBCL);
|
---|
[362] | 1289 | die "ERROR: version $newver not found in $f" if ($foundnew == 0);
|
---|
[361] | 1290 | }
|
---|
| 1291 |
|
---|
[366] | 1292 | # Duplicate and extract project-builder part
|
---|
[361] | 1293 | pb_log(2,"Copying $uri/$tmp to $newurl\n");
|
---|
[366] | 1294 | pb_cms_copy($scheme,"$uri/$tmp",$newurl);
|
---|
| 1295 | pb_log(2,"Checkout $newurl to $ENV{'PBROOTDIR'}/../$newver\n");
|
---|
[383] | 1296 | pb_cms_up($scheme,"$ENV{'PBCONFDIR'}/..");
|
---|
[361] | 1297 |
|
---|
[366] | 1298 | # Duplicate and extract project
|
---|
| 1299 | my $newurl2 = "$pburl->{$ENV{'PBPROJ'}}/".dirname($tmp)."/$newver";
|
---|
| 1300 |
|
---|
| 1301 | pb_log(2,"Copying $pburl->{$ENV{'PBPROJ'}}/$tmp to $newurl2\n");
|
---|
| 1302 | pb_cms_copy($scheme,"$pburl->{$ENV{'PBPROJ'}}/$tmp",$newurl2);
|
---|
| 1303 | pb_log(2,"Checkout $newurl2 to $ENV{'PBDIR'}/../$newver\n");
|
---|
[383] | 1304 | pb_cms_up($scheme,"$ENV{'PBDIR'}/..");
|
---|
[366] | 1305 |
|
---|
[361] | 1306 | # Update the .pb file
|
---|
[358] | 1307 | open(FILE,"$ENV{'PBROOTDIR'}/../$newver/$ENV{'PBPROJ'}.pb") || die "Unable to open $ENV{'PBROOTDIR'}/../$newver/$ENV{'PBPROJ'}.pb";
|
---|
| 1308 | open(OUT,"> $ENV{'PBROOTDIR'}/../$newver/$ENV{'PBPROJ'}.pb.new") || die "Unable to write to $ENV{'PBROOTDIR'}/../$newver/$ENV{'PBPROJ'}.pb.new";
|
---|
[208] | 1309 | while(<FILE>) {
|
---|
[361] | 1310 | s/^projver\s+$ENV{'PBPROJ'}\s*=\s*$oldver/projver $ENV{'PBPROJ'} = $newver/;
|
---|
| 1311 | pb_log(0,"Changing projver from $oldver to $newver in $ENV{'PBROOTDIR'}/../$newver/$ENV{'PBPROJ'}.pb\n") if (/^projver\s+$ENV{'PBPROJ'}\s*=\s*$oldver/);
|
---|
| 1312 | s/^testver/#testver/;
|
---|
| 1313 | pb_log(0,"Commenting testver in $ENV{'PBROOTDIR'}/../$newver/$ENV{'PBPROJ'}.pb\n") if (/^testver/);
|
---|
[211] | 1314 | print OUT $_;
|
---|
[208] | 1315 | }
|
---|
| 1316 | close(FILE);
|
---|
[211] | 1317 | close(OUT);
|
---|
[358] | 1318 | rename("$ENV{'PBROOTDIR'}/../$newver/$ENV{'PBPROJ'}.pb.new","$ENV{'PBROOTDIR'}/../$newver/$ENV{'PBPROJ'}.pb");
|
---|
[363] | 1319 |
|
---|
[358] | 1320 | pb_log(2,"Checkin $ENV{'PBROOTDIR'}/../$newver\n");
|
---|
[363] | 1321 | pb_cms_checkin($scheme,"$ENV{'PBROOTDIR'}/../$newver");
|
---|
[199] | 1322 | }
|
---|
| 1323 |
|
---|
[293] | 1324 | #
|
---|
[320] | 1325 | # Return the list of VMs/VEs we are working on
|
---|
[105] | 1326 | # $all is a flag to know if we return all of them
|
---|
| 1327 | # or only some (if all we publish also tar files in addition to pkgs
|
---|
| 1328 | #
|
---|
[320] | 1329 | sub pb_get_v {
|
---|
[91] | 1330 |
|
---|
[320] | 1331 | my $vtype = shift;
|
---|
| 1332 | my @v;
|
---|
[105] | 1333 | my $all = 0;
|
---|
[320] | 1334 | my $vlist;
|
---|
| 1335 | my $pbv = 'PBV';
|
---|
[91] | 1336 |
|
---|
[320] | 1337 | if ($vtype eq "vm") {
|
---|
| 1338 | $vlist = "vmlist";
|
---|
| 1339 | } elsif ($vtype eq "ve") {
|
---|
| 1340 | $vlist = "velist";
|
---|
| 1341 | }
|
---|
| 1342 | # Get VM/VE list
|
---|
| 1343 | if ((not defined $ENV{$pbv}) || ($ENV{$pbv} =~ /^all$/)) {
|
---|
| 1344 | my ($ptr) = pb_conf_get($vlist);
|
---|
| 1345 | $ENV{$pbv} = $ptr->{$ENV{'PBPROJ'}};
|
---|
[105] | 1346 | $all = 1;
|
---|
[91] | 1347 | }
|
---|
[320] | 1348 | pb_log(2,"$vtype: $ENV{$pbv}\n");
|
---|
| 1349 | @v = split(/,/,$ENV{$pbv});
|
---|
| 1350 | return(\@v,$all);
|
---|
[91] | 1351 | }
|
---|
| 1352 |
|
---|
[320] | 1353 | # Function to create a potentialy missing pb account on the VM/VE, and adds it to sudo
|
---|
| 1354 | # Needs to use root account to connect to the VM/VE
|
---|
| 1355 | # pb will take your local public SSH key to access
|
---|
[346] | 1356 | # the pb account in the VM later on if needed
|
---|
| 1357 | sub pb_setup_v {
|
---|
[320] | 1358 |
|
---|
| 1359 | my $vtype = shift;
|
---|
| 1360 |
|
---|
[353] | 1361 | my ($vm,$all) = pb_get_v($vtype);
|
---|
| 1362 |
|
---|
[346] | 1363 | # Script generated
|
---|
| 1364 | my $pbscript = "$ENV{'PBDESTDIR'}/setupv";
|
---|
[320] | 1365 |
|
---|
[353] | 1366 | foreach my $v (@$vm) {
|
---|
| 1367 | # Name of the account to deal with for VM/VE
|
---|
| 1368 | # Do not use the one passed potentially with -a
|
---|
| 1369 | my ($pbac) = pb_conf_get($vtype."login");
|
---|
[354] | 1370 | my ($key,$zero0,$zero1,$zero2);
|
---|
[357] | 1371 | my ($vmexist,$vmpid);
|
---|
[346] | 1372 |
|
---|
[353] | 1373 | if ($vtype eq "vm") {
|
---|
| 1374 | # Prepare the key to be used and transfered remotely
|
---|
| 1375 | my $keyfile = pb_ssh_get(1);
|
---|
| 1376 |
|
---|
| 1377 | my ($vmhost,$vmport) = pb_conf_get("vmhost","vmport");
|
---|
| 1378 | my $nport = $vmport->{$ENV{'PBPROJ'}};
|
---|
| 1379 | $nport = "$pbport" if (defined $pbport);
|
---|
[347] | 1380 |
|
---|
[353] | 1381 | # Launch the VM
|
---|
[357] | 1382 | ($vmexist,$vmpid) = pb_launchv($vtype,$v,0);
|
---|
[347] | 1383 |
|
---|
[353] | 1384 | # Skip that VM if something went wrong
|
---|
| 1385 | return if (($vmpid == 0) && ($vmexist == 0));
|
---|
| 1386 |
|
---|
[354] | 1387 | # Store the pub key part in a variable
|
---|
| 1388 | open(FILE,"$keyfile.pub") || die "Unable to open $keyfile.pub";
|
---|
| 1389 | ($zero0,$zero1,$zero2) = split(/ /,<FILE>);
|
---|
| 1390 | close(FILE);
|
---|
| 1391 |
|
---|
| 1392 | $key = "\Q$zero1";
|
---|
| 1393 |
|
---|
[435] | 1394 | pb_system("cat $keyfile.pub | ssh -q -o UserKnownHostsFile=/dev/null -p $nport -i $keyfile root\@$vmhost->{$ENV{'PBPROJ'}} \"mkdir -p .ssh ; chmod 700 .ssh ; cat >> .ssh/authorized_keys ; chmod 600 .ssh/authorized_keys\"","Copying local keys to $vtype. This will require the root password");
|
---|
[353] | 1395 | # once this is done, we can do what we want on the VM remotely
|
---|
| 1396 | }
|
---|
| 1397 |
|
---|
| 1398 | # Prepare the script to be executed on the VM/VE
|
---|
| 1399 | # in $ENV{'PBDESTDIR'}/setupv
|
---|
| 1400 |
|
---|
| 1401 | open(SCRIPT,"> $pbscript") || die "Unable to create $pbscript";
|
---|
| 1402 | print SCRIPT << 'EOF';
|
---|
[320] | 1403 | #!/usr/bin/perl -w
|
---|
| 1404 |
|
---|
[346] | 1405 | use strict;
|
---|
| 1406 | use File::Copy;
|
---|
| 1407 |
|
---|
[427] | 1408 | our $debug;
|
---|
| 1409 | our $LOG;
|
---|
| 1410 | our $synmsg = "pbscript";
|
---|
| 1411 | pb_log_init($debug, $LOG);
|
---|
| 1412 | pb_temp_init();
|
---|
| 1413 |
|
---|
[354] | 1414 | EOF
|
---|
| 1415 | if ($vtype eq "vm") {
|
---|
| 1416 | print SCRIPT << 'EOF';
|
---|
| 1417 | # Removes duplicate in .ssh/authorized_keys of our key if needed
|
---|
| 1418 | #
|
---|
| 1419 | my $file1="$ENV{'HOME'}/.ssh/authorized_keys";
|
---|
| 1420 | open(PBFILE,$file1) || die "Unable to open $file1";
|
---|
| 1421 | open(PBOUT,"> $file1.new") || die "Unable to open $file1.new";
|
---|
| 1422 | my $count = 0;
|
---|
| 1423 | while (<PBFILE>) {
|
---|
| 1424 | EOF
|
---|
| 1425 | print SCRIPT << "EOF";
|
---|
| 1426 | if (/ $key /) {
|
---|
| 1427 | \$count++;
|
---|
| 1428 | }
|
---|
| 1429 | print PBOUT \$_ if ((\$count <= 1) || (\$_ !~ / $key /));
|
---|
| 1430 | }
|
---|
| 1431 | close(PBFILE);
|
---|
| 1432 | close(PBOUT);
|
---|
| 1433 | rename("\$file1.new",\$file1);
|
---|
| 1434 | chmod 0600,\$file1;
|
---|
| 1435 | EOF
|
---|
| 1436 | }
|
---|
| 1437 | print SCRIPT << 'EOF';
|
---|
| 1438 |
|
---|
| 1439 | # Adds $pbac->{$ENV{'PBPROJ'}} as an account if needed
|
---|
| 1440 | #
|
---|
[346] | 1441 | my $file="/etc/passwd";
|
---|
[320] | 1442 | open(PBFILE,$file) || die "Unable to open $file";
|
---|
| 1443 | my $found = 0;
|
---|
| 1444 | while (<PBFILE>) {
|
---|
[346] | 1445 | EOF
|
---|
[353] | 1446 | print SCRIPT << "EOF";
|
---|
| 1447 | \$found = 1 if (/^$pbac->{$ENV{'PBPROJ'}}:/);
|
---|
[346] | 1448 | EOF
|
---|
[353] | 1449 | print SCRIPT << 'EOF';
|
---|
[320] | 1450 | }
|
---|
| 1451 | close(PBFILE);
|
---|
| 1452 |
|
---|
| 1453 | if ( $found == 0 ) {
|
---|
| 1454 | if ( ! -d "/home" ) {
|
---|
[427] | 1455 | pb_mkdir("/home");
|
---|
[320] | 1456 | }
|
---|
[346] | 1457 | EOF
|
---|
[353] | 1458 | print SCRIPT << "EOF";
|
---|
[427] | 1459 | pb_system("groupadd $pbac->{$ENV{'PBPROJ'}}","Adding group $pbac->{$ENV{'PBPROJ'}}");
|
---|
| 1460 | pb_system("useradd $pbac->{$ENV{'PBPROJ'}} -g $pbac->{$ENV{'PBPROJ'}} -m -d /home/$pbac->{$ENV{'PBPROJ'}}","Adding user $pbac->{$ENV{'PBPROJ'}} (group $pbac->{$ENV{'PBPROJ'}} - home /home/$pbac->{$ENV{'PBPROJ'}}");
|
---|
| 1461 | }
|
---|
[320] | 1462 |
|
---|
[354] | 1463 | # allow ssh entry to build
|
---|
| 1464 | #
|
---|
[427] | 1465 | mkdir "/home/$pbac->{$ENV{'PBPROJ'}}/.ssh",0700;
|
---|
[347] | 1466 | # Allow those accessing root to access the build account
|
---|
[427] | 1467 | copy("\$ENV{'HOME'}/.ssh/authorized_keys","/home/$pbac->{$ENV{'PBPROJ'}}/.ssh/authorized_keys");
|
---|
[320] | 1468 | chmod 0600,".ssh/authorized_keys";
|
---|
[427] | 1469 | pb_system("chown -R $pbac->{$ENV{'PBPROJ'}}:$pbac->{$ENV{'PBPROJ'}} /home/$pbac->{$ENV{'PBPROJ'}}/.ssh","Finish setting up the SSH env for $pbac->{$ENV{'PBPROJ'}}");
|
---|
[320] | 1470 |
|
---|
[346] | 1471 | EOF
|
---|
[353] | 1472 | print SCRIPT << 'EOF';
|
---|
[347] | 1473 | # No passwd for build account only keys
|
---|
[320] | 1474 | $file="/etc/shadow";
|
---|
| 1475 | open(PBFILE,$file) || die "Unable to open $file";
|
---|
| 1476 | open(PBOUT,"> $file.new") || die "Unable to open $file.new";
|
---|
| 1477 | while (<PBFILE>) {
|
---|
[346] | 1478 | EOF
|
---|
[353] | 1479 | print SCRIPT << "EOF";
|
---|
| 1480 | s/^$pbac->{$ENV{'PBPROJ'}}:\!\!:/$pbac->{$ENV{'PBPROJ'}}:*:/;
|
---|
| 1481 | s/^$pbac->{$ENV{'PBPROJ'}}:\!:/$pbac->{$ENV{'PBPROJ'}}:*:/; #SLES 9 e.g.
|
---|
[346] | 1482 | EOF
|
---|
[353] | 1483 | print SCRIPT << 'EOF';
|
---|
[320] | 1484 | print PBOUT $_;
|
---|
| 1485 | }
|
---|
| 1486 | close(PBFILE);
|
---|
| 1487 | close(PBOUT);
|
---|
| 1488 | rename("$file.new",$file);
|
---|
| 1489 | chmod 0640,$file;
|
---|
| 1490 |
|
---|
| 1491 | # pb has to be added to portage group on gentoo
|
---|
| 1492 |
|
---|
[346] | 1493 | # Adapt sudoers
|
---|
| 1494 | $file="/etc/sudoers";
|
---|
| 1495 | open(PBFILE,$file) || die "Unable to open $file";
|
---|
| 1496 | open(PBOUT,"> $file.new") || die "Unable to open $file.new";
|
---|
| 1497 | while (<PBFILE>) {
|
---|
| 1498 | EOF
|
---|
[353] | 1499 | print SCRIPT << "EOF";
|
---|
| 1500 | next if (/^$pbac->{$ENV{'PBPROJ'}} /);
|
---|
[346] | 1501 | EOF
|
---|
[353] | 1502 | print SCRIPT << 'EOF';
|
---|
[346] | 1503 | s/Defaults[ \t]+requiretty//;
|
---|
| 1504 | print PBOUT $_;
|
---|
| 1505 | }
|
---|
| 1506 | close(PBFILE);
|
---|
| 1507 | EOF
|
---|
[353] | 1508 | print SCRIPT << "EOF";
|
---|
| 1509 | # This is needed in order to be able to halt the machine from the $pbac->{$ENV{'PBPROJ'}} account at least
|
---|
| 1510 | print PBOUT "$pbac->{$ENV{'PBPROJ'}} ALL=(ALL) NOPASSWD:ALL\n";
|
---|
[346] | 1511 | EOF
|
---|
[353] | 1512 | print SCRIPT << 'EOF';
|
---|
[346] | 1513 | close(PBOUT);
|
---|
| 1514 | rename("$file.new",$file);
|
---|
| 1515 | chmod 0440,$file;
|
---|
| 1516 |
|
---|
| 1517 | EOF
|
---|
[353] | 1518 |
|
---|
| 1519 | my $SCRIPT = \*SCRIPT;
|
---|
| 1520 |
|
---|
| 1521 | pb_install_deps($SCRIPT);
|
---|
| 1522 |
|
---|
| 1523 | print SCRIPT << 'EOF';
|
---|
[346] | 1524 | # Suse wants sudoers as 640
|
---|
| 1525 | if (($ddir eq "sles") || (($ddir eq "suse")) && ($dver ne "10.3")) {
|
---|
| 1526 | chmod 0640,$file;
|
---|
| 1527 | }
|
---|
| 1528 |
|
---|
| 1529 | # Sync date
|
---|
[353] | 1530 | #system "/usr/sbin/ntpdate ntp.pool.org";
|
---|
[346] | 1531 |
|
---|
[427] | 1532 | pb_system("rm -rf perl-ProjectBuilder-* ; wget --passive-ftp ftp://ftp.mondorescue.org/src/perl-ProjectBuilder-latest.tar.gz ; tar xvfz perl-ProjectBuilder-latest.tar.gz ; cd perl-ProjectBuilder-* ; perl Makefile.PL ; make ; make install ; cd .. ; rm -rf perl-ProjectBuilder-* ; rm -rf project-builder-* ; wget --passive-ftp ftp://ftp.mondorescue.org/src/project-builder-latest.tar.gz ; tar xvfz project-builder-latest.tar.gz ; cd project-builder-* ; perl Makefile.PL ; make ; make install ; cd .. ; rm -rf project-builder-* ;","Building Project-Builder");
|
---|
[358] | 1533 | system "pb 2>&1 | head -5";
|
---|
[357] | 1534 | EOF
|
---|
| 1535 | if ((! $vmexist) && ($vtype eq "vm")) {
|
---|
| 1536 | print SCRIPT << 'EOF';
|
---|
[437] | 1537 | pb_system("sudo /sbin/halt -p","Halting the VM");
|
---|
[346] | 1538 | EOF
|
---|
[357] | 1539 | }
|
---|
[353] | 1540 |
|
---|
| 1541 | # Adds pb_distro_init from ProjectBuilder::Distribution
|
---|
| 1542 | foreach my $d (@INC) {
|
---|
[405] | 1543 | my @f = ("$d/ProjectBuilder/Base.pm","$d/ProjectBuilder/Distribution.pm");
|
---|
| 1544 | foreach my $f (@f) {
|
---|
| 1545 | if (-f "$f") {
|
---|
| 1546 | open(PBD,"$f") || die "Unable to open $f";
|
---|
| 1547 | while (<PBD>) {
|
---|
[427] | 1548 | next if (/^package/);
|
---|
| 1549 | next if (/^use Exporter/);
|
---|
| 1550 | next if (/^use ProjectBuilder::/);
|
---|
| 1551 | next if (/^our /);
|
---|
[405] | 1552 | print SCRIPT $_;
|
---|
| 1553 | }
|
---|
| 1554 | close(PBD);
|
---|
[353] | 1555 | }
|
---|
[347] | 1556 | }
|
---|
| 1557 | }
|
---|
[353] | 1558 | close(SCRIPT);
|
---|
| 1559 | chmod 0755,"$pbscript";
|
---|
| 1560 |
|
---|
| 1561 | # That build script needs to be run as root
|
---|
| 1562 | $pbaccount = "root";
|
---|
| 1563 | pb_script2v($pbscript,$vtype);
|
---|
[347] | 1564 | }
|
---|
[353] | 1565 | return;
|
---|
[346] | 1566 | }
|
---|
| 1567 |
|
---|
[347] | 1568 | sub pb_install_deps {
|
---|
[346] | 1569 |
|
---|
[348] | 1570 | my $SCRIPT = shift;
|
---|
[346] | 1571 |
|
---|
[348] | 1572 | print {$SCRIPT} << 'EOF';
|
---|
[346] | 1573 | # We need to have that pb_distro_init function
|
---|
[347] | 1574 | # Get it from Project-Builder::Distribution
|
---|
[320] | 1575 | my ($ddir, $dver, $dfam, $dtype, $pbsuf) = pb_distro_init();
|
---|
| 1576 | print "distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf))."\n";
|
---|
| 1577 |
|
---|
| 1578 | # Get and install pb
|
---|
[437] | 1579 | my $insdm = "rm -rf Date-Manip* ; wget http://search.cpan.org/CPAN/authors/id/S/SB/SBECK/Date-Manip-5.54.tar.gz ; tar xvfz Date-Manip-5.54.tar.gz ; cd Date-Manip* ; perl Makefile.PL ; make ; make install ; cd .. ; rm -rf Date-Manip*";
|
---|
[357] | 1580 | my $insmb = "rm -rf Module-Build* ; wget http://search.cpan.org/CPAN/authors/id/K/KW/KWILLIAMS/Module-Build-0.2808.tar.gz ; tar xvfz Module-Build-0.2808.tar.gz ; cd Module-Build* ; perl Makefile.PL ; make ; make install ; cd .. ; rm -rf Module-Build*";
|
---|
| 1581 | my $insfm = "rm -rf File-MimeInfo* ; wget http://search.cpan.org/CPAN/authors/id/P/PA/PARDUS/File-MimeInfo/File-MimeInfo-0.15.tar.gz ; tar xvfz File-MimeInfo-0.15.tar.gz ; cd File-MimeInfo* ; perl Makefile.PL ; make ; make install ; cd .. ; rm -rf File-MimeInfo*";
|
---|
| 1582 | my $insfb = "rm -rf File-Basedir* ; wget http://search.cpan.org/CPAN/authors/id/P/PA/PARDUS/File-BaseDir-0.03.tar.gz ; tar xvfz File-BaseDir-0.03.tar.gz ; cd File-BaseDir* ; perl Makefile.PL ; make ; make install ; cd .. ; rm -rf File-BaseDir*";
|
---|
[427] | 1583 | my $cmtdm = "Installing Date-Manip perl module";
|
---|
| 1584 | my $cmtmb = "Installing Module-Build perl module";
|
---|
| 1585 | my $cmtfm = "Installing File-MimeInfo perl module";
|
---|
| 1586 | my $cmtfb = "Installing File-Basedir perl module";
|
---|
| 1587 | my $cmtall = "Installing required modules";
|
---|
[357] | 1588 |
|
---|
[320] | 1589 | if ( $ddir eq "fedora" ) {
|
---|
[427] | 1590 | pb_system("yum clean all","Cleaning yum env");
|
---|
[346] | 1591 | #system "yum update -y";
|
---|
[320] | 1592 | my $arch=`uname -m`;
|
---|
| 1593 | my $opt = "";
|
---|
| 1594 | chomp($arch);
|
---|
| 1595 | if ($arch eq "x86_64") {
|
---|
| 1596 | $opt="--exclude=*.i?86";
|
---|
| 1597 | }
|
---|
| 1598 |
|
---|
[427] | 1599 | pb_system("yum -y $opt install rpm-build wget patch ntp sudo perl-DateManip perl-File-MimeInfo perl-ExtUtils-MakeMaker",$cmtall);
|
---|
[357] | 1600 | if ($dver eq 4) {
|
---|
[427] | 1601 | pb_system("$insmb","$cmtmb");
|
---|
| 1602 | pb_system("$insfm","$cmtfm");
|
---|
| 1603 | pb_system("$insfb","$cmtfb");
|
---|
[357] | 1604 | }
|
---|
| 1605 | } elsif (( $dfam eq "rh" ) || ($ddir eq "sles") || (($ddir eq "suse") && (($dver eq "10.1") || ($dver eq "10.0"))) || ($ddir eq "slackware")) {
|
---|
[358] | 1606 | # Suppose pkg are installed already as no online mirror available
|
---|
[427] | 1607 | pb_system("rpm -e lsb 2>&1 > /dev/null","Removing lsb package");
|
---|
| 1608 | pb_system("$insdm","$cmtdm");
|
---|
| 1609 | pb_system("$insmb","$cmtmb");
|
---|
| 1610 | pb_system("$insfm","$cmtfm");
|
---|
| 1611 | pb_system("$insfb","$cmtfb");
|
---|
[320] | 1612 | } elsif ($ddir eq "suse") {
|
---|
| 1613 | # New OpenSuSE
|
---|
[427] | 1614 | pb_system("$insmb","$cmtmb");
|
---|
| 1615 | pb_system("$insfm","$cmtfm");
|
---|
| 1616 | pb_system("$insfb","$cmtfb");
|
---|
| 1617 | pb_system("export TERM=linux ; liste=\"\" ; for i in make wget patch sudo perl-DateManip perl-File-HomeDir xntp; do rpm -q \$i 1> /dev/null 2> /dev/null ; if [ \$\? != 0 ]; then liste=\"\$liste \$i\"; fi; done; echo \"Liste: \$liste\" ; if [ \"\$liste\" != \"\" ]; then yast2 -i \$liste ; fi","$cmtall");
|
---|
[320] | 1618 | } elsif ( $dfam eq "md" ) {
|
---|
[427] | 1619 | pb_system("urpmi.update -a ; urpmi --auto rpm-build wget sudo patch ntp-client perl-File-MimeInfo","$cmtall");
|
---|
[357] | 1620 | if (($ddir eq "mandrake") && ($dver eq "10.1")) {
|
---|
[427] | 1621 | pb_system("$insdm","$cmtdm");
|
---|
[357] | 1622 | } else {
|
---|
[427] | 1623 | pb_system("urpmi --auto perl-DateManip","$cmtdm");
|
---|
[357] | 1624 | }
|
---|
[320] | 1625 | } elsif ( $dfam eq "du" ) {
|
---|
| 1626 | if (( $dver eq "3.1" ) && ($ddir eq "debian")) {
|
---|
[346] | 1627 | #system "apt-get update";
|
---|
[427] | 1628 | pb_system("$insfb","$cmtfb");
|
---|
| 1629 | pb_system("$insfm","$cmtfm");
|
---|
| 1630 | pb_system("apt-get -y install wget patch ssh sudo debian-builder dh-make fakeroot ntpdate libmodule-build-perl libdate-manip-perl","$cmtall");
|
---|
[320] | 1631 | } else {
|
---|
[427] | 1632 | pb_system("apt-get update; apt-get -y install wget patch openssh-server dpkg-dev sudo debian-builder dh-make fakeroot ntpdate libfile-mimeinfo-perl libmodule-build-perl libdate-manip-perl","$cmtall");
|
---|
[320] | 1633 | }
|
---|
| 1634 | } elsif ( $dfam eq "gen" ) {
|
---|
[427] | 1635 | #system "emerge -u system";
|
---|
| 1636 | pb_system("emerge wget sudo ntp DateManip File-MimeInfo","$cmtall");
|
---|
[320] | 1637 | } else {
|
---|
| 1638 | print "No pkg to install\n";
|
---|
| 1639 | }
|
---|
| 1640 | EOF
|
---|
| 1641 | }
|
---|
| 1642 |
|
---|
[347] | 1643 | # Return the SSH key file to use
|
---|
| 1644 | # Potentially create it if needed
|
---|
| 1645 |
|
---|
| 1646 | sub pb_ssh_get {
|
---|
| 1647 |
|
---|
| 1648 | my $create = shift || 0; # Do not create keys by default
|
---|
| 1649 |
|
---|
| 1650 | # Check the SSH environment
|
---|
| 1651 | my $keyfile = undef;
|
---|
| 1652 |
|
---|
| 1653 | # We have specific keys by default
|
---|
| 1654 | $keyfile = "$ENV{'HOME'}/.ssh/pb_dsa";
|
---|
[348] | 1655 | if (!(-e $keyfile) && ($create eq 1)) {
|
---|
[347] | 1656 | pb_system("ssh-keygen -q -b 1024 -N '' -f $keyfile -t dsa","Generating SSH keys for pb");
|
---|
| 1657 | }
|
---|
| 1658 |
|
---|
| 1659 | $keyfile = "$ENV{'HOME'}/.ssh/id_rsa" if (-s "$ENV{'HOME'}/.ssh/id_rsa");
|
---|
| 1660 | $keyfile = "$ENV{'HOME'}/.ssh/id_dsa" if (-s "$ENV{'HOME'}/.ssh/id_dsa");
|
---|
| 1661 | $keyfile = "$ENV{'HOME'}/.ssh/pb_dsa" if (-s "$ENV{'HOME'}/.ssh/pb_dsa");
|
---|
| 1662 | die "Unable to find your public ssh key under $keyfile" if (not defined $keyfile);
|
---|
| 1663 | return($keyfile);
|
---|
| 1664 | }
|
---|
| 1665 |
|
---|
| 1666 |
|
---|
[145] | 1667 | # Returns the pid of a running VM command using a specific VM file
|
---|
[142] | 1668 | sub pb_check_ps {
|
---|
| 1669 | my $vmcmd = shift;
|
---|
| 1670 | my $vmm = shift;
|
---|
| 1671 | my $vmexist = 0; # FALSE by default
|
---|
| 1672 |
|
---|
| 1673 | open(PS, "ps auxhww|") || die "Unable to call ps";
|
---|
| 1674 | while (<PS>) {
|
---|
| 1675 | next if (! /$vmcmd/);
|
---|
| 1676 | next if (! /$vmm/);
|
---|
| 1677 | my ($void1, $void2);
|
---|
| 1678 | ($void1, $vmexist, $void2) = split(/ +/);
|
---|
| 1679 | last;
|
---|
| 1680 | }
|
---|
| 1681 | return($vmexist);
|
---|
| 1682 | }
|
---|
| 1683 |
|
---|
| 1684 |
|
---|
[77] | 1685 | sub pb_extract_build_files {
|
---|
[25] | 1686 |
|
---|
| 1687 | my $src=shift;
|
---|
| 1688 | my $dir=shift;
|
---|
[26] | 1689 | my $ddir=shift;
|
---|
[28] | 1690 | my @files;
|
---|
[25] | 1691 |
|
---|
[188] | 1692 | if ($src =~ /tar\.gz$/) {
|
---|
| 1693 | pb_system("tar xfpz $src $dir","Extracting build files");
|
---|
| 1694 | } elsif ($src =~ /tar\.bz2$/) {
|
---|
| 1695 | pb_system("tar xfpj $src $dir","Extracting build files");
|
---|
| 1696 | } else {
|
---|
| 1697 | die "Unknown compression algorithm for $src";
|
---|
| 1698 | }
|
---|
[25] | 1699 | opendir(DIR,"$dir") || die "Unable to open directory $dir";
|
---|
| 1700 | foreach my $f (readdir(DIR)) {
|
---|
| 1701 | next if ($f =~ /^\./);
|
---|
[26] | 1702 | move("$dir/$f","$ddir") || die "Unable to move $dir/$f to $ddir";
|
---|
[315] | 1703 | pb_log(2,"mv $dir/$f $ddir\n");
|
---|
[28] | 1704 | push @files,"$ddir/$f";
|
---|
[25] | 1705 | }
|
---|
| 1706 | closedir(DIR);
|
---|
[26] | 1707 | # Not enough but still a first cleanup
|
---|
[74] | 1708 | pb_rm_rf("$dir");
|
---|
[28] | 1709 | return(@files);
|
---|
[25] | 1710 | }
|
---|
| 1711 |
|
---|
[315] | 1712 | sub pb_list_bfiles {
|
---|
| 1713 |
|
---|
| 1714 | my $dir = shift;
|
---|
| 1715 | my $pbpkg = shift;
|
---|
| 1716 | my $bfiles = shift;
|
---|
| 1717 | my $pkgfiles = shift;
|
---|
| 1718 | my $supfiles = shift;
|
---|
| 1719 |
|
---|
| 1720 | opendir(BDIR,"$dir") || die "Unable to open dir $dir: $!";
|
---|
| 1721 | foreach my $f (readdir(BDIR)) {
|
---|
| 1722 | next if ($f =~ /^\./);
|
---|
| 1723 | $bfiles->{$f} = "$dir/$f";
|
---|
[340] | 1724 | $bfiles->{$f} =~ s~$ENV{'PBROOTDIR'}~~;
|
---|
[315] | 1725 | if (defined $supfiles->{$pbpkg}) {
|
---|
| 1726 | $pkgfiles->{$f} = "$dir/$f" if ($f =~ /$supfiles->{$pbpkg}/);
|
---|
| 1727 | }
|
---|
| 1728 | }
|
---|
| 1729 | closedir(BDIR);
|
---|
| 1730 | }
|
---|
| 1731 |
|
---|
[395] | 1732 |
|
---|
| 1733 | #
|
---|
| 1734 | # Return the list of packages we are working on in a non CMS action
|
---|
| 1735 | #
|
---|
| 1736 | sub pb_get_pkg {
|
---|
| 1737 |
|
---|
| 1738 | my @pkgs = ();
|
---|
| 1739 |
|
---|
| 1740 | my ($var) = pb_conf_read("$ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb","pbpkg");
|
---|
| 1741 | @pkgs = keys %$var;
|
---|
| 1742 |
|
---|
| 1743 | pb_log(0,"Packages: ".join(',',@pkgs)."\n");
|
---|
| 1744 | return(\@pkgs);
|
---|
| 1745 | }
|
---|
| 1746 |
|
---|
| 1747 | 1;
|
---|