build_package.pl
author Dario Sestito <darios@symbian.org>
Fri, 09 Oct 2009 12:34:29 +0100
changeset 49 07eb981b2b45
parent 48 5e2200d13067
child 50 e8b76d25d90c
permissions -rw-r--r--
Support for passing -D options to Helium
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15
45ed0efeb8a4 Added copyright header to build_package.pl
darios@symbian.org
parents: 14
diff changeset
     1
# Copyright (c) 2009 Symbian Foundation Ltd
45ed0efeb8a4 Added copyright header to build_package.pl
darios@symbian.org
parents: 14
diff changeset
     2
# This component and the accompanying materials are made available
45ed0efeb8a4 Added copyright header to build_package.pl
darios@symbian.org
parents: 14
diff changeset
     3
# under the terms of the License "Eclipse Public License v1.0"
45ed0efeb8a4 Added copyright header to build_package.pl
darios@symbian.org
parents: 14
diff changeset
     4
# which accompanies this distribution, and is available
45ed0efeb8a4 Added copyright header to build_package.pl
darios@symbian.org
parents: 14
diff changeset
     5
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
45ed0efeb8a4 Added copyright header to build_package.pl
darios@symbian.org
parents: 14
diff changeset
     6
#
45ed0efeb8a4 Added copyright header to build_package.pl
darios@symbian.org
parents: 14
diff changeset
     7
# Initial Contributors:
45ed0efeb8a4 Added copyright header to build_package.pl
darios@symbian.org
parents: 14
diff changeset
     8
# Symbian Foundation Ltd - initial contribution.
45ed0efeb8a4 Added copyright header to build_package.pl
darios@symbian.org
parents: 14
diff changeset
     9
#
45ed0efeb8a4 Added copyright header to build_package.pl
darios@symbian.org
parents: 14
diff changeset
    10
# Contributors:
45ed0efeb8a4 Added copyright header to build_package.pl
darios@symbian.org
parents: 14
diff changeset
    11
#
45ed0efeb8a4 Added copyright header to build_package.pl
darios@symbian.org
parents: 14
diff changeset
    12
# Description:
45ed0efeb8a4 Added copyright header to build_package.pl
darios@symbian.org
parents: 14
diff changeset
    13
# This is a helper script which allocates unique drive letter and build number
45ed0efeb8a4 Added copyright header to build_package.pl
darios@symbian.org
parents: 14
diff changeset
    14
# then starts a package build by running FBF bootstrap and build targets
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
    15
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
    16
use strict;
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
    17
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
    18
use Getopt::Long;
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
    19
use File::Path;
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
    20
16
e1b9f78cef38 Project spec and config to be taken from a dir instead of from a repo
darios@symbian.org
parents: 15
diff changeset
    21
my $sBOOTSTRAP_DIR="C:\\Apps\\FBF\\bootstrap";
32
11821242bc3e Make G: the working drive (unless not ready) and D: the second option
Dario Sestito <darios@symbian.org>
parents: 31
diff changeset
    22
my $sJOB_BASE_DIR="fbf_project";
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
    23
my $nMAX_JOBDIR_AGE_SECONDS = 86400; # max number of seconds after which the letter is forcibly released
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
    24
my $nLOCK_FILE_MAX_ATTEMPTS = 5;
43
42877cd4d8be Fix REMOTE_LOG_ARCHIVE path string (missing a backslash. Add some debug lines
Dario Sestito <darios@symbian.org>
parents: 42
diff changeset
    25
my $sREMOTE_LOG_ARCHIVE="\\\\bishare\\SF_builds";
31
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    26
my $sNUMBERS_FILE="\\\\bishare\\SF_builds\\numbers2.txt";
32
11821242bc3e Make G: the working drive (unless not ready) and D: the second option
Dario Sestito <darios@symbian.org>
parents: 31
diff changeset
    27
my $sLETTERS_FILE="letters.txt";
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
    28
my $nMAX_LETTER_AGE_SECONDS = 86400; # max number of seconds after which the letter is forcibly released
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
    29
38
6da50515cbeb Fix start package build with no --subproj option, pointed defaults to mercurial_development
Dario Sestito <darios@symbian.org>
parents: 37
diff changeset
    30
my $sFbfProjectRepo = "\\\\bishare\\mercurial_development\\oss\\FCL\\interim\\fbf\\projects\\packages";
16
e1b9f78cef38 Project spec and config to be taken from a dir instead of from a repo
darios@symbian.org
parents: 15
diff changeset
    31
my $sFbfProjectDir = '';
31
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    32
my $sSubProject = '';
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    33
#my $sSourcesFile = '';
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    34
#my $sModelFile = '';
48
5e2200d13067 Location of package build config to fbf/config/default
Dario Sestito <darios@symbian.org>
parents: 47
diff changeset
    35
my $sFbfConfigRepo="\\\\bishare\\mercurial_development\\oss\\FCL\\interim\\fbf\\configs\\default";
16
e1b9f78cef38 Project spec and config to be taken from a dir instead of from a repo
darios@symbian.org
parents: 15
diff changeset
    36
my $sFbfConfigDir = '';
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
    37
my $nCmdLineNumber;
29
b9212509f335 Default to test build: removed --testbuild option and added --production
Dario Sestito <darios@symbian.org>
parents: 28
diff changeset
    38
my $bProduction = 0;
34
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
    39
my $sDiamondsTag = '';
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
    40
my $bHudson = 0;
28
bf45384632b0 Add support for --testbuild and --nopublish options
Dario Sestito <darios@symbian.org>
parents: 27
diff changeset
    41
my $bPublish = 1;
49
07eb981b2b45 Support for passing -D options to Helium
Dario Sestito <darios@symbian.org>
parents: 48
diff changeset
    42
my %hHlmDefines = ();
42
71a252d194e6 Add help option
Dario Sestito <darios@symbian.org>
parents: 41
diff changeset
    43
my $bHelp = 0;
19
472feb69d0c9 Changed location of default config repo, added --testbuild option, extended help
Dario Sestito <darios@symbian.org>
parents: 17
diff changeset
    44
GetOptions((
31
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    45
	'configrepo=s' => \$sFbfConfigRepo,
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    46
	'configdir=s' => \$sFbfConfigDir,
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    47
	'projectrepo=s' => \$sFbfProjectRepo,
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    48
	'projectdir=s' => \$sFbfProjectDir,
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    49
	'subproj=s' => \$sSubProject,
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    50
	#'sources=s' => \$sSourcesFile,
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    51
	#'model=s' => \$sModelFile,
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    52
	'number=s' => \$nCmdLineNumber,
29
b9212509f335 Default to test build: removed --testbuild option and added --production
Dario Sestito <darios@symbian.org>
parents: 28
diff changeset
    53
	'production!' => \$bProduction,
34
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
    54
	'tag=s' => \$sDiamondsTag,
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
    55
	'hudson!' => \$bHudson,
42
71a252d194e6 Add help option
Dario Sestito <darios@symbian.org>
parents: 41
diff changeset
    56
	'publish!' => \$bPublish,
49
07eb981b2b45 Support for passing -D options to Helium
Dario Sestito <darios@symbian.org>
parents: 48
diff changeset
    57
	'define=s' => \%hHlmDefines,
42
71a252d194e6 Add help option
Dario Sestito <darios@symbian.org>
parents: 41
diff changeset
    58
	'help!' => \$bHelp
19
472feb69d0c9 Changed location of default config repo, added --testbuild option, extended help
Dario Sestito <darios@symbian.org>
parents: 17
diff changeset
    59
));
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
    60
42
71a252d194e6 Add help option
Dario Sestito <darios@symbian.org>
parents: 41
diff changeset
    61
if ($bHelp or !($sSubProject or $sFbfProjectRepo or $sFbfProjectDir))
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
    62
{
31
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    63
	print "Usage: build_package.pl --subproj=RELPATH [OPTIONS]\n";
38
6da50515cbeb Fix start package build with no --subproj option, pointed defaults to mercurial_development
Dario Sestito <darios@symbian.org>
parents: 37
diff changeset
    64
	print "       build_package.pl --projectrepo=REPO [OPTIONS]\n";
22
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
    65
	print "where OPTIONS are:\n";
31
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    66
	print "\t--subproj=RELPATH Select subproject located at RELPATH (relative to the root of the project repository)\n";
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    67
	print "\t--projectrepo=REPO[#REV] Use repository REPO at revision REV for the project (instead of \\\\bishare\\mercurial_internal\\fbf\\projects\\packages)\n";
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    68
	print "\t--projectdir=DIR Use DIR location for the project (exclusive with --projectrepo).\n";
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    69
	#print "\t--sources=FILE ...\n";
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    70
	#print "\t--model=FILE ...\n";
48
5e2200d13067 Location of package build config to fbf/config/default
Dario Sestito <darios@symbian.org>
parents: 47
diff changeset
    71
	print "\t--configrepo=REPO[#REV] Use repository REPO at revision REV for the config (instead of \\\\bishare\\mercurial_internal\\fbf\\config\\default)\n";
31
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    72
	print "\t--configdir=DIR Use DIR location for the config (exclusive with --configrepo).\n";
19
472feb69d0c9 Changed location of default config repo, added --testbuild option, extended help
Dario Sestito <darios@symbian.org>
parents: 17
diff changeset
    73
	print "\t--number=N Force build number to N\n";
29
b9212509f335 Default to test build: removed --testbuild option and added --production
Dario Sestito <darios@symbian.org>
parents: 28
diff changeset
    74
	print "\t--production Tag this build as 'production' (default: 'test') and use nnn numbering (default: Tnnn)\n";
34
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
    75
	print "\t--tag=TAG Apply Diamonds tag TAG to this build (exclusive with --production)\n";
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
    76
	print "\t--hudson Checks that there is at least NUMBER_OF_PROCESSORS X 10 GB available on the working drive\n";
45
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
    77
	print "\t--nopublish Use \\numbers_test.txt for numbers and disable publishing\n";
49
07eb981b2b45 Support for passing -D options to Helium
Dario Sestito <darios@symbian.org>
parents: 48
diff changeset
    78
	print "\t--define ATTRIBUTE=VALUE Pass -D statements to the Helium Framework\n";
22
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
    79
	exit(0);
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
    80
}
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
    81
38
6da50515cbeb Fix start package build with no --subproj option, pointed defaults to mercurial_development
Dario Sestito <darios@symbian.org>
parents: 37
diff changeset
    82
if ($sSubProject and $sSubProject !~ m,^([^/]+)/[^/]+/([^/]+)$,)
22
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
    83
{
34
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
    84
	print "ERROR: Option --subproj must be in the format codeline/layer/package (e.g. MCL/os/boardsupport)\n";
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
    85
	exit(0);
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
    86
}
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
    87
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
    88
if ($bProduction and $sDiamondsTag)
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
    89
{
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
    90
	print "ERROR: Options --production and --tag are mutually exclusive.\n";
22
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
    91
	exit(0);
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
    92
}
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
    93
31
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    94
#if (!$sFbfProjectRepo and !$sFbfProjectDir and (!$sSourcesFile or !$sModelFile))
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    95
#{
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    96
#	print "Error: If you don't provide --projectrepo or --projectdir then you have to provide both --sources and --model\n";
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    97
#	exit(0);
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    98
#}
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
    99
45
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   100
my $sWORKING_DRIVE = find_working_drive();
32
11821242bc3e Make G: the working drive (unless not ready) and D: the second option
Dario Sestito <darios@symbian.org>
parents: 31
diff changeset
   101
print "Will use drive $sWORKING_DRIVE as working drive for this build\n";
11821242bc3e Make G: the working drive (unless not ready) and D: the second option
Dario Sestito <darios@symbian.org>
parents: 31
diff changeset
   102
34
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
   103
if ($bHudson)
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
   104
{
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
   105
	my $nProcessors = $ENV{'NUMBER_OF_PROCESSORS'};
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
   106
	my $diroutput = `dir /-C $sWORKING_DRIVE`;
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
   107
	my $nBytesFree = 0;
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
   108
	$nBytesFree = $1 if ($diroutput =~ /(\d+) bytes free/);
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
   109
	my $nNeededSpace = 10*$nProcessors*1073741824;
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
   110
	#print "Needed space is $nNeededSpace\n";
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
   111
	if ($nBytesFree < $nNeededSpace)
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
   112
	{
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
   113
		print "ERROR: Available disk space on working drive ($nBytesFree bytes) is not enough to run a package build with Hudson.\n";
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
   114
		exit(1);
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
   115
	}
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
   116
}
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
   117
24
ed4e68942437 Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents: 22
diff changeset
   118
my $sFbfProjectRev = '';
ed4e68942437 Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents: 22
diff changeset
   119
if ($sFbfProjectRepo =~ m,(.*)#(.*),)
ed4e68942437 Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents: 22
diff changeset
   120
{
ed4e68942437 Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents: 22
diff changeset
   121
	$sFbfProjectRepo = $1;
ed4e68942437 Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents: 22
diff changeset
   122
	$sFbfProjectRev = $2;
ed4e68942437 Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents: 22
diff changeset
   123
}
ed4e68942437 Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents: 22
diff changeset
   124
my $sFbfConfigRev = '';
ed4e68942437 Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents: 22
diff changeset
   125
if ($sFbfConfigRepo =~ m,(.*)#(.*),)
ed4e68942437 Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents: 22
diff changeset
   126
{
ed4e68942437 Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents: 22
diff changeset
   127
	$sFbfConfigRepo = $1;
ed4e68942437 Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents: 22
diff changeset
   128
	$sFbfConfigRev = $2;
ed4e68942437 Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents: 22
diff changeset
   129
}
ed4e68942437 Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents: 22
diff changeset
   130
49
07eb981b2b45 Support for passing -D options to Helium
Dario Sestito <darios@symbian.org>
parents: 48
diff changeset
   131
my $sHlmDefineOpt = '';
07eb981b2b45 Support for passing -D options to Helium
Dario Sestito <darios@symbian.org>
parents: 48
diff changeset
   132
for (keys %hHlmDefines)
07eb981b2b45 Support for passing -D options to Helium
Dario Sestito <darios@symbian.org>
parents: 48
diff changeset
   133
{
07eb981b2b45 Support for passing -D options to Helium
Dario Sestito <darios@symbian.org>
parents: 48
diff changeset
   134
	$sHlmDefineOpt .= "-D$_=$hHlmDefines{$_} ";
07eb981b2b45 Support for passing -D options to Helium
Dario Sestito <darios@symbian.org>
parents: 48
diff changeset
   135
}
07eb981b2b45 Support for passing -D options to Helium
Dario Sestito <darios@symbian.org>
parents: 48
diff changeset
   136
28
bf45384632b0 Add support for --testbuild and --nopublish options
Dario Sestito <darios@symbian.org>
parents: 27
diff changeset
   137
my $sTestBuildOpt = "";
29
b9212509f335 Default to test build: removed --testbuild option and added --production
Dario Sestito <darios@symbian.org>
parents: 28
diff changeset
   138
$sTestBuildOpt = "-Dsf.spec.publish.diamonds.tag=production" if ( $bProduction );
34
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
   139
$sTestBuildOpt = "-Dsf.spec.publish.diamonds.tag=$sDiamondsTag" if ( $sDiamondsTag );
28
bf45384632b0 Add support for --testbuild and --nopublish options
Dario Sestito <darios@symbian.org>
parents: 27
diff changeset
   140
my $sNoPublishOpt = "";
bf45384632b0 Add support for --testbuild and --nopublish options
Dario Sestito <darios@symbian.org>
parents: 27
diff changeset
   141
$sNoPublishOpt = "-Dsf.spec.publish.enable=false" if ( !$bPublish );
45
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   142
$sNUMBERS_FILE = "$sWORKING_DRIVE\\numbers_test.txt" if ( !$bPublish );
19
472feb69d0c9 Changed location of default config repo, added --testbuild option, extended help
Dario Sestito <darios@symbian.org>
parents: 17
diff changeset
   143
31
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   144
my $sJobLabel = 'job';
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   145
if ($sSubProject)
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   146
{
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   147
	$sSubProject =~ m,^([^/]+)/[^/]+/([^/]+)$,;
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   148
	$sJobLabel = $2;
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   149
}
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   150
elsif ($sFbfProjectRepo)
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   151
{
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   152
	$sFbfProjectRepo =~ m,(.*[\\/])?([^\\^/]+),;
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   153
	$sJobLabel = $2;
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   154
}
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   155
elsif ($sFbfProjectDir)
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   156
{
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   157
	$sFbfProjectDir =~ m,(.*[\\/])?([^\\^/]+),;
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   158
	$sJobLabel = $2;
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   159
}
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   160
#elsif ($sSourcesFile)
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   161
#{
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   162
#	$sSourcesFile =~ m,/(adaptation|app|mw|os|ostools|tools)[\\/]([^\\^/]+),i;
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   163
#	$sJobLabel = $2;
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   164
#	$sSourcesFile =~ m,(.*[\\/])?([^\\^/]+),;
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   165
#	$sJobLabel = $2 if (!$sJobLabel);
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   166
#}
32
11821242bc3e Make G: the working drive (unless not ready) and D: the second option
Dario Sestito <darios@symbian.org>
parents: 31
diff changeset
   167
mkdir("$sWORKING_DRIVE\\$sJOB_BASE_DIR") if (!-d "$sWORKING_DRIVE\\$sJOB_BASE_DIR");
11821242bc3e Make G: the working drive (unless not ready) and D: the second option
Dario Sestito <darios@symbian.org>
parents: 31
diff changeset
   168
my $sJobDir = mkdir_unique("$sWORKING_DRIVE\\$sJOB_BASE_DIR\\$sJobLabel");
35
4d500511bf5a Add removal of job directories if build is run from build management system (i.e. --hudson is given)
Dario Sestito <darios@symbian.org>
parents: 34
diff changeset
   169
print "Created project dir $sWORKING_DRIVE\\$sJOB_BASE_DIR\\$sJobDir\n";
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   170
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   171
print("cd $sBOOTSTRAP_DIR\n");
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   172
chdir("$sBOOTSTRAP_DIR");
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   173
print "###### BOOTSTRAP ######\n";
16
e1b9f78cef38 Project spec and config to be taken from a dir instead of from a repo
darios@symbian.org
parents: 15
diff changeset
   174
my $sConfigArg = "-Dsf.config.repo=$sFbfConfigRepo";
24
ed4e68942437 Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents: 22
diff changeset
   175
$sConfigArg .= " -Dsf.config.rev=$sFbfConfigRev" if ($sFbfConfigRev);
16
e1b9f78cef38 Project spec and config to be taken from a dir instead of from a repo
darios@symbian.org
parents: 15
diff changeset
   176
$sConfigArg = "-Dsf.config.dir=$sFbfConfigDir" if ($sFbfConfigDir);
e1b9f78cef38 Project spec and config to be taken from a dir instead of from a repo
darios@symbian.org
parents: 15
diff changeset
   177
my $sProjectArg = "-Dsf.project.repo=$sFbfProjectRepo";
24
ed4e68942437 Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents: 22
diff changeset
   178
$sProjectArg .= " -Dsf.project.rev=$sFbfProjectRev" if ($sFbfProjectRev);
16
e1b9f78cef38 Project spec and config to be taken from a dir instead of from a repo
darios@symbian.org
parents: 15
diff changeset
   179
$sProjectArg = "-Dsf.project.dir=$sFbfProjectDir" if ($sFbfProjectDir);
40
6661369591af Build console output must be redirected to file but must also go to console
Dario Sestito <darios@symbian.org>
parents: 39
diff changeset
   180
my $sBootstrapCmd = "hlm -f bootstrap.xml $sConfigArg $sProjectArg -Dsf.target.dir=$sJobDir";
6661369591af Build console output must be redirected to file but must also go to console
Dario Sestito <darios@symbian.org>
parents: 39
diff changeset
   181
print("$sBootstrapCmd\n");
41
177164b3c155 Fix missing semicolon
Dario Sestito <darios@symbian.org>
parents: 40
diff changeset
   182
open(LOG, ">console_bootstrap_$$.txt");
40
6661369591af Build console output must be redirected to file but must also go to console
Dario Sestito <darios@symbian.org>
parents: 39
diff changeset
   183
open(PIPE, "$sBootstrapCmd 2>&1 |");
6661369591af Build console output must be redirected to file but must also go to console
Dario Sestito <darios@symbian.org>
parents: 39
diff changeset
   184
while(<PIPE>)
6661369591af Build console output must be redirected to file but must also go to console
Dario Sestito <darios@symbian.org>
parents: 39
diff changeset
   185
{
6661369591af Build console output must be redirected to file but must also go to console
Dario Sestito <darios@symbian.org>
parents: 39
diff changeset
   186
	print LOG $_;
6661369591af Build console output must be redirected to file but must also go to console
Dario Sestito <darios@symbian.org>
parents: 39
diff changeset
   187
	print $_;
6661369591af Build console output must be redirected to file but must also go to console
Dario Sestito <darios@symbian.org>
parents: 39
diff changeset
   188
}
6661369591af Build console output must be redirected to file but must also go to console
Dario Sestito <darios@symbian.org>
parents: 39
diff changeset
   189
close(PIPE);
6661369591af Build console output must be redirected to file but must also go to console
Dario Sestito <darios@symbian.org>
parents: 39
diff changeset
   190
close(LOG);
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   191
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   192
# check that $sNUMBERS_FILE exists, otherwise create it
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   193
if (!-f $sNUMBERS_FILE)
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   194
{
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   195
	open FILE, ">$sNUMBERS_FILE";
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   196
	print FILE "\n";
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   197
	close FILE;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   198
}
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   199
35
4d500511bf5a Add removal of job directories if build is run from build management system (i.e. --hudson is given)
Dario Sestito <darios@symbian.org>
parents: 34
diff changeset
   200
my $sJobNumberKey = '';
39
d6975a94a893 Dump console output to files and upload them to \\bishare
Dario Sestito <darios@symbian.org>
parents: 38
diff changeset
   201
my $sPackage = '';
d6975a94a893 Dump console output to files and upload them to \\bishare
Dario Sestito <darios@symbian.org>
parents: 38
diff changeset
   202
my $sPlatform = '';
22
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   203
my $nUnformattedNumber = 0;
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   204
if ($nCmdLineNumber)
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   205
{
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   206
	$nUnformattedNumber = $nCmdLineNumber;
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   207
}
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   208
elsif ($sFbfProjectRepo)
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   209
{
31
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   210
	if ($sSubProject)
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   211
	{
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   212
		# key = <package>_<codeline>, e.g. for subproj=MCL/os/boardsupport -> key=boardsupport_MCL
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   213
		$sSubProject =~ m,^([^/]+)/[^/]+/([^/]+)$,;
39
d6975a94a893 Dump console output to files and upload them to \\bishare
Dario Sestito <darios@symbian.org>
parents: 38
diff changeset
   214
		$sPackage = $2;
d6975a94a893 Dump console output to files and upload them to \\bishare
Dario Sestito <darios@symbian.org>
parents: 38
diff changeset
   215
		$sPlatform = $1;
31
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   216
		$sJobNumberKey = "$2_$1";
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   217
	}
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   218
	else
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   219
	{
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   220
		# key = hash of the rev.0 of the package project repo
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   221
		my $sRevZeroHash = get_rev_zero_hash($sFbfProjectRepo);
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   222
		$sJobNumberKey = $sRevZeroHash;
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   223
	}
29
b9212509f335 Default to test build: removed --testbuild option and added --production
Dario Sestito <darios@symbian.org>
parents: 28
diff changeset
   224
	$sJobNumberKey .= ".T" if (!$bProduction);
28
bf45384632b0 Add support for --testbuild and --nopublish options
Dario Sestito <darios@symbian.org>
parents: 27
diff changeset
   225
	$nUnformattedNumber = get_job_number($sJobNumberKey);
22
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   226
}
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   227
my $nJobNumber = sprintf("%.3d", $nUnformattedNumber);
29
b9212509f335 Default to test build: removed --testbuild option and added --production
Dario Sestito <darios@symbian.org>
parents: 28
diff changeset
   228
$nJobNumber = "T$nJobNumber" if (!$bProduction);
35
4d500511bf5a Add removal of job directories if build is run from build management system (i.e. --hudson is given)
Dario Sestito <darios@symbian.org>
parents: 34
diff changeset
   229
print "For build key $sJobNumberKey got assigned number \"$nJobNumber\"\n";
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   230
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   231
# check that $sLETTERS_FILE exists, otherwise create it
32
11821242bc3e Make G: the working drive (unless not ready) and D: the second option
Dario Sestito <darios@symbian.org>
parents: 31
diff changeset
   232
if (!-f "$sWORKING_DRIVE\\$sLETTERS_FILE")
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   233
{
32
11821242bc3e Make G: the working drive (unless not ready) and D: the second option
Dario Sestito <darios@symbian.org>
parents: 31
diff changeset
   234
	open FILE, ">$sWORKING_DRIVE\\$sLETTERS_FILE";
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   235
	print FILE "\n";
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   236
	close FILE;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   237
}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   238
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   239
# acquire drive letter
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   240
my $sDriveLetter = acquire_drive_letter();
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   241
print "acquired drive letter: $sDriveLetter\n";
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   242
die "Could not acquire drive letter" if (! $sDriveLetter);
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   243
33
4d7642508510 Pass the job rootdir as parameter to helium
Dario Sestito <darios@symbian.org>
parents: 32
diff changeset
   244
my $sJobRootDirArg = "-Dsf.spec.job.rootdir=$sWORKING_DRIVE\\fbf_job";
4d7642508510 Pass the job rootdir as parameter to helium
Dario Sestito <darios@symbian.org>
parents: 32
diff changeset
   245
31
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   246
my $sSubProjArg = '';
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   247
$sSubProjArg = "-Dsf.subproject.path=$sSubProject" if ($sSubProject);
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   248
print("cd $sJobDir\\sf-config\n");
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   249
chdir("$sJobDir\\sf-config");
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   250
print "###### BUILD PREPARATION ######\n";
49
07eb981b2b45 Support for passing -D options to Helium
Dario Sestito <darios@symbian.org>
parents: 48
diff changeset
   251
my $sPreparationCmd = "hlm sf-prep -Dsf.project.type=package $sSubProjArg -Dsf.spec.job.number=$nJobNumber -Dsf.spec.job.drive=$sDriveLetter: $sTestBuildOpt $sNoPublishOpt $sJobRootDirArg $sHlmDefineOpt";
40
6661369591af Build console output must be redirected to file but must also go to console
Dario Sestito <darios@symbian.org>
parents: 39
diff changeset
   252
print("$sPreparationCmd\n");
41
177164b3c155 Fix missing semicolon
Dario Sestito <darios@symbian.org>
parents: 40
diff changeset
   253
open(LOG, ">console_sfprep_$$.txt");
40
6661369591af Build console output must be redirected to file but must also go to console
Dario Sestito <darios@symbian.org>
parents: 39
diff changeset
   254
open(PIPE, "$sPreparationCmd 2>&1 |");
6661369591af Build console output must be redirected to file but must also go to console
Dario Sestito <darios@symbian.org>
parents: 39
diff changeset
   255
while(<PIPE>)
6661369591af Build console output must be redirected to file but must also go to console
Dario Sestito <darios@symbian.org>
parents: 39
diff changeset
   256
{
6661369591af Build console output must be redirected to file but must also go to console
Dario Sestito <darios@symbian.org>
parents: 39
diff changeset
   257
	print LOG $_;
6661369591af Build console output must be redirected to file but must also go to console
Dario Sestito <darios@symbian.org>
parents: 39
diff changeset
   258
	print $_;
6661369591af Build console output must be redirected to file but must also go to console
Dario Sestito <darios@symbian.org>
parents: 39
diff changeset
   259
}
6661369591af Build console output must be redirected to file but must also go to console
Dario Sestito <darios@symbian.org>
parents: 39
diff changeset
   260
close(PIPE);
6661369591af Build console output must be redirected to file but must also go to console
Dario Sestito <darios@symbian.org>
parents: 39
diff changeset
   261
close(LOG);
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   262
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   263
print "###### EXECUTE BUILD ######\n";
49
07eb981b2b45 Support for passing -D options to Helium
Dario Sestito <darios@symbian.org>
parents: 48
diff changeset
   264
my $sBuildallCmd = "hlm sf-build-all -Dsf.project.type=package $sSubProjArg -Dsf.spec.job.number=$nJobNumber -Dsf.spec.job.drive=$sDriveLetter: $sTestBuildOpt $sNoPublishOpt $sJobRootDirArg $sHlmDefineOpt";
40
6661369591af Build console output must be redirected to file but must also go to console
Dario Sestito <darios@symbian.org>
parents: 39
diff changeset
   265
print("$sBuildallCmd\n");
41
177164b3c155 Fix missing semicolon
Dario Sestito <darios@symbian.org>
parents: 40
diff changeset
   266
open(LOG, ">console_sfbuildall_$$.txt");
40
6661369591af Build console output must be redirected to file but must also go to console
Dario Sestito <darios@symbian.org>
parents: 39
diff changeset
   267
open(PIPE, "$sBuildallCmd 2>&1 |");
6661369591af Build console output must be redirected to file but must also go to console
Dario Sestito <darios@symbian.org>
parents: 39
diff changeset
   268
while(<PIPE>)
6661369591af Build console output must be redirected to file but must also go to console
Dario Sestito <darios@symbian.org>
parents: 39
diff changeset
   269
{
6661369591af Build console output must be redirected to file but must also go to console
Dario Sestito <darios@symbian.org>
parents: 39
diff changeset
   270
	print LOG $_;
6661369591af Build console output must be redirected to file but must also go to console
Dario Sestito <darios@symbian.org>
parents: 39
diff changeset
   271
	print $_;
6661369591af Build console output must be redirected to file but must also go to console
Dario Sestito <darios@symbian.org>
parents: 39
diff changeset
   272
}
6661369591af Build console output must be redirected to file but must also go to console
Dario Sestito <darios@symbian.org>
parents: 39
diff changeset
   273
close(PIPE);
6661369591af Build console output must be redirected to file but must also go to console
Dario Sestito <darios@symbian.org>
parents: 39
diff changeset
   274
close(LOG);
39
d6975a94a893 Dump console output to files and upload them to \\bishare
Dario Sestito <darios@symbian.org>
parents: 38
diff changeset
   275
46
4db5e28df888 Add call to sf-summary target
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   276
print "###### GENERATE BUILD SUMMARY ######\n";
49
07eb981b2b45 Support for passing -D options to Helium
Dario Sestito <darios@symbian.org>
parents: 48
diff changeset
   277
my $sSummaryCmd = "hlm sf-summary -Dsf.project.type=package $sSubProjArg -Dsf.spec.job.number=$nJobNumber -Dsf.spec.job.drive=$sDriveLetter: $sTestBuildOpt $sNoPublishOpt $sJobRootDirArg $sHlmDefineOpt";
46
4db5e28df888 Add call to sf-summary target
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   278
print("$sSummaryCmd\n");
4db5e28df888 Add call to sf-summary target
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   279
open(LOG, ">console_sfsummary_$$.txt");
4db5e28df888 Add call to sf-summary target
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   280
open(PIPE, "$sSummaryCmd 2>&1 |");
4db5e28df888 Add call to sf-summary target
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   281
while(<PIPE>)
4db5e28df888 Add call to sf-summary target
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   282
{
4db5e28df888 Add call to sf-summary target
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   283
	print LOG $_;
4db5e28df888 Add call to sf-summary target
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   284
	print $_;
4db5e28df888 Add call to sf-summary target
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   285
}
4db5e28df888 Add call to sf-summary target
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   286
close(PIPE);
4db5e28df888 Add call to sf-summary target
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   287
close(LOG);
4db5e28df888 Add call to sf-summary target
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   288
45
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   289
if ($bPublish)
39
d6975a94a893 Dump console output to files and upload them to \\bishare
Dario Sestito <darios@symbian.org>
parents: 38
diff changeset
   290
{
45
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   291
	# copy console outputs to remote log archive
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   292
	if (-d "$sREMOTE_LOG_ARCHIVE\\$sPackage\\builds\\$sPlatform\\$sPackage\_$sPlatform.$nJobNumber\\logs")
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   293
	{
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   294
		my $sTgtDir = "$sREMOTE_LOG_ARCHIVE\\$sPackage\\builds\\$sPlatform\\$sPackage\_$sPlatform.$nJobNumber\\logs\\console";
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   295
		print "copying console output files to $sTgtDir\n";
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   296
		system("mkdir $sTgtDir");
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   297
		system("copy /Y $sBOOTSTRAP_DIR\\console_bootstrap_$$.txt $sTgtDir");
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   298
		system("del $sBOOTSTRAP_DIR\\console_bootstrap_$$.txt");
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   299
		system("copy $sJobDir\\sf-config\\console_sfprep_$$.txt $sTgtDir");
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   300
		system("copy $sJobDir\\sf-config\\console_sfbuildall_$$.txt $sTgtDir");
47
Dario Sestito <darios@symbian.org>
parents: 46 45
diff changeset
   301
		system("copy $sJobDir\\sf-config\\console_sfsummary_$$.txt $sTgtDir");
45
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   302
	}
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   303
	else
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   304
	{
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   305
		print "directory $sREMOTE_LOG_ARCHIVE\\$sPackage\\builds\\$sPlatform\\$sPackage\_$sPlatform.$nJobNumber\\logs doesn't exist.\n";
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   306
	}
43
42877cd4d8be Fix REMOTE_LOG_ARCHIVE path string (missing a backslash. Add some debug lines
Dario Sestito <darios@symbian.org>
parents: 42
diff changeset
   307
}
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   308
37
2e0ebeeeaf52 Change back to bootstrap dir after the build to allow removal of project dir
Dario Sestito <darios@symbian.org>
parents: 36
diff changeset
   309
print("cd $sBOOTSTRAP_DIR\n");
2e0ebeeeaf52 Change back to bootstrap dir after the build to allow removal of project dir
Dario Sestito <darios@symbian.org>
parents: 36
diff changeset
   310
chdir("$sBOOTSTRAP_DIR");
2e0ebeeeaf52 Change back to bootstrap dir after the build to allow removal of project dir
Dario Sestito <darios@symbian.org>
parents: 36
diff changeset
   311
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   312
# release the drive letter
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   313
release_drive_letter($sDriveLetter);
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   314
system("subst $sDriveLetter: /d"); # this is not required, but it's a good idea to keep things in order
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   315
print "drive letter $sDriveLetter released (and drive unsubsted)\n";
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   316
35
4d500511bf5a Add removal of job directories if build is run from build management system (i.e. --hudson is given)
Dario Sestito <darios@symbian.org>
parents: 34
diff changeset
   317
if ($bHudson)
4d500511bf5a Add removal of job directories if build is run from build management system (i.e. --hudson is given)
Dario Sestito <darios@symbian.org>
parents: 34
diff changeset
   318
{
4d500511bf5a Add removal of job directories if build is run from build management system (i.e. --hudson is given)
Dario Sestito <darios@symbian.org>
parents: 34
diff changeset
   319
	print "cleaning job directories...\n";
4d500511bf5a Add removal of job directories if build is run from build management system (i.e. --hudson is given)
Dario Sestito <darios@symbian.org>
parents: 34
diff changeset
   320
	if (-d "$sWORKING_DRIVE\\$sJOB_BASE_DIR\\$sJobLabel") # project dir
4d500511bf5a Add removal of job directories if build is run from build management system (i.e. --hudson is given)
Dario Sestito <darios@symbian.org>
parents: 34
diff changeset
   321
	{
4d500511bf5a Add removal of job directories if build is run from build management system (i.e. --hudson is given)
Dario Sestito <darios@symbian.org>
parents: 34
diff changeset
   322
		print "rmdir /S $sWORKING_DRIVE\\$sJOB_BASE_DIR\\$sJobLabel\n";
4d500511bf5a Add removal of job directories if build is run from build management system (i.e. --hudson is given)
Dario Sestito <darios@symbian.org>
parents: 34
diff changeset
   323
		system("rmdir /S /Q $sWORKING_DRIVE\\$sJOB_BASE_DIR\\$sJobLabel");
4d500511bf5a Add removal of job directories if build is run from build management system (i.e. --hudson is given)
Dario Sestito <darios@symbian.org>
parents: 34
diff changeset
   324
	}
39
d6975a94a893 Dump console output to files and upload them to \\bishare
Dario Sestito <darios@symbian.org>
parents: 38
diff changeset
   325
	if (-d "$sWORKING_DRIVE\\fbf_job\\$sPackage\_$sPlatform.$nJobNumber") # build drive
35
4d500511bf5a Add removal of job directories if build is run from build management system (i.e. --hudson is given)
Dario Sestito <darios@symbian.org>
parents: 34
diff changeset
   326
	{
39
d6975a94a893 Dump console output to files and upload them to \\bishare
Dario Sestito <darios@symbian.org>
parents: 38
diff changeset
   327
		print "rmdir /S $sWORKING_DRIVE\\fbf_job\\$sPackage\_$sPlatform.$nJobNumber\n";
d6975a94a893 Dump console output to files and upload them to \\bishare
Dario Sestito <darios@symbian.org>
parents: 38
diff changeset
   328
		system("rmdir /S /Q $sWORKING_DRIVE\\fbf_job\\$sPackage\_$sPlatform.$nJobNumber");
35
4d500511bf5a Add removal of job directories if build is run from build management system (i.e. --hudson is given)
Dario Sestito <darios@symbian.org>
parents: 34
diff changeset
   329
	}
4d500511bf5a Add removal of job directories if build is run from build management system (i.e. --hudson is given)
Dario Sestito <darios@symbian.org>
parents: 34
diff changeset
   330
}
4d500511bf5a Add removal of job directories if build is run from build management system (i.e. --hudson is given)
Dario Sestito <darios@symbian.org>
parents: 34
diff changeset
   331
45
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   332
sub find_working_drive
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   333
{
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   334
	my @drive_list = ('E', 'G', 'D', 'C');
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   335
	
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   336
	for my $drive (@drive_list)
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   337
	{
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   338
		return "$drive:" if (-d "$drive:/");
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   339
	}
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   340
	
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   341
	die "Could not find suitable working drive.";
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   342
}
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   343
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   344
sub mkdir_unique
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   345
{
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   346
	my ($sBaseDir) = @_;
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   347
	
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   348
	# check that the path where the new dir must be created exists.
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   349
	$sBaseDir =~ m,(.*[\\/])?(.*),;
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   350
	mkpath($1) if ($1 && !-d $1);
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   351
	
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   352
	my $nI = 0;
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   353
	my $sNewDirName = "$sBaseDir";
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   354
	while(!mkdir($sNewDirName))
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   355
	{
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   356
		$nI++;
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   357
		$sNewDirName = "$sBaseDir.$nI";
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   358
	}
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   359
	
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   360
	return $sNewDirName;
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   361
}
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   362
22
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   363
sub get_rev_zero_hash
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   364
{
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   365
	my ($sFbfProjectRepo) = @_;
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   366
	
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   367
	my $sOutput = `hg -R $sFbfProjectRepo identify -r0`;
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   368
	
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   369
	# remove leading and trailing spaces
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   370
	$sOutput =~ s,^\s+,,;
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   371
	$sOutput =~ s,\s+$,,;
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   372
	
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   373
	# remove tags e.g. "1fc39a7e9d79 tip"
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   374
	$sOutput =~ s,([0-9a-z]+)\s+.*,$1,;
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   375
	
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   376
	return $sOutput;
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   377
}
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   378
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   379
sub get_job_number
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   380
{
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   381
	my ($sKey) = @_;
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   382
	
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   383
	$sKey=lc($sKey);
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   384
	
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   385
	my %hnNumbers = ();
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   386
	
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   387
	my $nAttempts = 0;
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   388
	my $bGotNumber = 0;
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   389
	do
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   390
	{
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   391
		open(FILE, "+<$sNUMBERS_FILE") or die("Can't open $sNUMBERS_FILE");
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   392
		if ( flock(FILE, 6) )
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   393
		{
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   394
			my $sLine;
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   395
			while ($sLine = <FILE>)
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   396
			{
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   397
				$hnNumbers{lc($1)} = $2 if ($sLine =~ m%(.*),(.*)%);
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   398
			}
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   399
			
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   400
			$hnNumbers{$sKey} = 0 if (! $hnNumbers{$sKey} );
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   401
			$hnNumbers{$sKey} = $hnNumbers{$sKey} + 1;
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   402
			
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   403
			seek(FILE, 0, 0);
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   404
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   405
			for my $sStr ( keys(%hnNumbers) )
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   406
			{
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   407
				print FILE "$sStr,$hnNumbers{$sStr}\n";
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   408
			}
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   409
			truncate(FILE,tell(FILE));
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   410
			
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   411
			$bGotNumber = 1;
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   412
		}
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   413
		else
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   414
		{
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   415
			$nAttempts ++;
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   416
			sleep(3);
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   417
		}
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   418
		close(FILE);
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   419
	}
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   420
	until ( $bGotNumber or $nAttempts == $nLOCK_FILE_MAX_ATTEMPTS );
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   421
	
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   422
	return $hnNumbers{$sKey};
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   423
}
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   424
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   425
sub acquire_drive_letter
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   426
{
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   427
	my %hsPidsAndTimestamps = ();
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   428
	
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   429
	my $sLetterToRelease = '';
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   430
	
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   431
	my $nAttempts = 0;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   432
	my $bAcquired = 0;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   433
	do
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   434
	{
32
11821242bc3e Make G: the working drive (unless not ready) and D: the second option
Dario Sestito <darios@symbian.org>
parents: 31
diff changeset
   435
		open(FILE, "+<$sWORKING_DRIVE\\$sLETTERS_FILE") or die("Can't open $sWORKING_DRIVE\\$sLETTERS_FILE");
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   436
		if ( flock(FILE, 6) )
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   437
		{
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   438
			my $sLine;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   439
			while ($sLine = <FILE>)
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   440
			{
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   441
				if ($sLine =~ m%([^,]*),(.*)%)
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   442
				{
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   443
					my $sLetter=$1;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   444
					my $sString=$2;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   445
					
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   446
					$sString=~m%([^,]*),(.*)%;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   447
					my $nPid=$1;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   448
					my $nTimestamp=$2;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   449
					
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   450
					if (time()-$nTimestamp<=$nMAX_LETTER_AGE_SECONDS)
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   451
					{
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   452
						$hsPidsAndTimestamps{$sLetter} = $sString;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   453
					}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   454
					else
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   455
					{
19
472feb69d0c9 Changed location of default config repo, added --testbuild option, extended help
Dario Sestito <darios@symbian.org>
parents: 17
diff changeset
   456
						# lease has expired: unsubst drive letter and don't add to hash
472feb69d0c9 Changed location of default config repo, added --testbuild option, extended help
Dario Sestito <darios@symbian.org>
parents: 17
diff changeset
   457
						system("subst $sLetter: /d");
472feb69d0c9 Changed location of default config repo, added --testbuild option, extended help
Dario Sestito <darios@symbian.org>
parents: 17
diff changeset
   458
						print "forced release of letter: $sLetter (and drive unsubsted)\n";
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   459
					}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   460
				}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   461
			}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   462
			
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   463
			for my $sNewLetter ('H'..'Y')
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   464
			{
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   465
				if (! $hsPidsAndTimestamps{$sNewLetter})
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   466
				{
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   467
					my $sTimestamp = time();
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   468
					$hsPidsAndTimestamps{$sNewLetter} = "$$,$sTimestamp";
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   469
					$sLetterToRelease = $sNewLetter;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   470
					last;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   471
				}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   472
			}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   473
			
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   474
			seek(FILE, 0, 0);
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   475
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   476
			for my $sLetter ( keys(%hsPidsAndTimestamps) )
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   477
			{
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   478
				print FILE "$sLetter,$hsPidsAndTimestamps{$sLetter}\n";
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   479
			}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   480
			truncate(FILE,tell(FILE));
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   481
			
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   482
			$bAcquired = 1;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   483
		}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   484
		else
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   485
		{
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   486
			$nAttempts ++;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   487
			sleep(3);
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   488
		}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   489
		close(FILE);
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   490
	}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   491
	until ( $bAcquired or $nAttempts == $nLOCK_FILE_MAX_ATTEMPTS );
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   492
	
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   493
	return $sLetterToRelease;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   494
}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   495
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   496
sub release_drive_letter
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   497
{
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   498
	my ($sLetterToRelease) = @_;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   499
	
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   500
	my %hsPidsAndTimestamps = ();
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   501
	
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   502
	my $nAttempts = 0;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   503
	my $bAcquired = 0;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   504
	do
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   505
	{
32
11821242bc3e Make G: the working drive (unless not ready) and D: the second option
Dario Sestito <darios@symbian.org>
parents: 31
diff changeset
   506
		open(FILE, "+<$sWORKING_DRIVE\\$sLETTERS_FILE") or die("Can't open $sWORKING_DRIVE\\$sLETTERS_FILE");
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   507
		if ( flock(FILE, 6) )
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   508
		{
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   509
			my $sLine;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   510
			while ($sLine = <FILE>)
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   511
			{
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   512
				$hsPidsAndTimestamps{$1} = $2 if ($sLine =~ m%([^,]*),(.*)%);
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   513
			}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   514
			
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   515
			delete $hsPidsAndTimestamps{$sLetterToRelease};
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   516
			
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   517
			seek(FILE, 0, 0);
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   518
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   519
			for my $sLetter ( keys(%hsPidsAndTimestamps) )
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   520
			{
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   521
				print FILE "$sLetter,$hsPidsAndTimestamps{$sLetter}\n";
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   522
			}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   523
			truncate(FILE,tell(FILE));
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   524
			
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   525
			$bAcquired = 1;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   526
		}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   527
		else
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   528
		{
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   529
			$nAttempts ++;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   530
			sleep(3);
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   531
		}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   532
		close(FILE);
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   533
	}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   534
	until ( $bAcquired or $nAttempts == $nLOCK_FILE_MAX_ATTEMPTS );
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   535
}