author | Dario Sestito <darios@symbian.org> |
Fri, 17 Jul 2009 14:38:18 +0100 | |
changeset 27 | d12bf27e4e0e |
parent 25 | 234b5eb2dcfe |
child 28 | bf45384632b0 |
permissions | -rw-r--r-- |
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"; |
11
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
22 |
my $sJOB_BASE_DIR="D:\\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; |
21
4b02facbff8f
Changed path to take account of new bishare alias
Dario Sestito <darios@symbian.org>
parents:
19
diff
changeset
|
25 |
my $sNUMBERS_FILE="\\\\bishare\\SF_builds\\numbers.txt"; |
13
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
26 |
my $sLETTERS_FILE="D:\\letters.txt"; |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
27 |
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
|
28 |
|
16
e1b9f78cef38
Project spec and config to be taken from a dir instead of from a repo
darios@symbian.org
parents:
15
diff
changeset
|
29 |
my $sFbfProjectRepo = ''; |
e1b9f78cef38
Project spec and config to be taken from a dir instead of from a repo
darios@symbian.org
parents:
15
diff
changeset
|
30 |
my $sFbfProjectDir = ''; |
21
4b02facbff8f
Changed path to take account of new bishare alias
Dario Sestito <darios@symbian.org>
parents:
19
diff
changeset
|
31 |
my $sFbfConfigRepo="\\\\bishare\\mercurial_internal\\fbf\\configs\\pkgbuild"; |
16
e1b9f78cef38
Project spec and config to be taken from a dir instead of from a repo
darios@symbian.org
parents:
15
diff
changeset
|
32 |
my $sFbfConfigDir = ''; |
11
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
33 |
my $nCmdLineNumber; |
19
472feb69d0c9
Changed location of default config repo, added --testbuild option, extended help
Dario Sestito <darios@symbian.org>
parents:
17
diff
changeset
|
34 |
my $bTestBuild = 0; |
472feb69d0c9
Changed location of default config repo, added --testbuild option, extended help
Dario Sestito <darios@symbian.org>
parents:
17
diff
changeset
|
35 |
GetOptions(( |
472feb69d0c9
Changed location of default config repo, added --testbuild option, extended help
Dario Sestito <darios@symbian.org>
parents:
17
diff
changeset
|
36 |
'configrepo:s' => \$sFbfConfigRepo, |
472feb69d0c9
Changed location of default config repo, added --testbuild option, extended help
Dario Sestito <darios@symbian.org>
parents:
17
diff
changeset
|
37 |
'configdir:s' => \$sFbfConfigDir, |
472feb69d0c9
Changed location of default config repo, added --testbuild option, extended help
Dario Sestito <darios@symbian.org>
parents:
17
diff
changeset
|
38 |
'projectrepo:s' => \$sFbfProjectRepo, |
472feb69d0c9
Changed location of default config repo, added --testbuild option, extended help
Dario Sestito <darios@symbian.org>
parents:
17
diff
changeset
|
39 |
'projectdir:s' => \$sFbfProjectDir, |
472feb69d0c9
Changed location of default config repo, added --testbuild option, extended help
Dario Sestito <darios@symbian.org>
parents:
17
diff
changeset
|
40 |
'number:s' => \$nCmdLineNumber, |
472feb69d0c9
Changed location of default config repo, added --testbuild option, extended help
Dario Sestito <darios@symbian.org>
parents:
17
diff
changeset
|
41 |
'testbuild!' => \$bTestBuild |
472feb69d0c9
Changed location of default config repo, added --testbuild option, extended help
Dario Sestito <darios@symbian.org>
parents:
17
diff
changeset
|
42 |
)); |
11
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
43 |
|
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
|
44 |
if (!$sFbfProjectRepo and !$sFbfProjectDir) |
11
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
45 |
{ |
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
|
46 |
print "Usage: build_package.pl --projectrepo=REPO [OPTIONS]\n"; |
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
|
47 |
print "where OPTIONS are:\n"; |
24
ed4e68942437
Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents:
22
diff
changeset
|
48 |
print "\t--projectrepo=REPO[#REV] Use repository REPO at revision REV for the project.\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
|
49 |
print "\t--projectdir=DIR Use DIR location for the project (exclusive with --projectrepo). Option --testbuild is required.\n"; |
24
ed4e68942437
Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents:
22
diff
changeset
|
50 |
print "\t--configrepo=REPO[#REV] Use repository REPO at revision REV for the config (instead of \\\\bishare\\mercurial_internal\\fbf\\config\\pkgbuild)\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
|
51 |
print "\t--configdir=DIR Use DIR location for the config (exclusive with --configrepo). Option --testbuild is required.\n"; |
19
472feb69d0c9
Changed location of default config repo, added --testbuild option, extended help
Dario Sestito <darios@symbian.org>
parents:
17
diff
changeset
|
52 |
print "\t--number=N Force build number to N\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
|
53 |
print "\t--testbuild Use d:\\numbers_test.txt for numbers and disable publishing\n"; |
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
|
54 |
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
|
55 |
} |
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
|
56 |
|
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
|
57 |
if ($sFbfProjectDir and !$bTestBuild) |
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
|
58 |
{ |
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
|
59 |
print "Error: Option --projectdir requires --testbuild\n"; |
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
|
60 |
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
|
61 |
} |
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
|
62 |
|
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
|
63 |
if ($sFbfConfigDir and !$bTestBuild) |
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
|
64 |
{ |
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 "Error: Option --configdir requires --testbuild\n"; |
11
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
66 |
exit(0); |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
67 |
} |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
68 |
|
24
ed4e68942437
Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents:
22
diff
changeset
|
69 |
my $sFbfProjectRev = ''; |
ed4e68942437
Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents:
22
diff
changeset
|
70 |
if ($sFbfProjectRepo =~ m,(.*)#(.*),) |
ed4e68942437
Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents:
22
diff
changeset
|
71 |
{ |
ed4e68942437
Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents:
22
diff
changeset
|
72 |
$sFbfProjectRepo = $1; |
ed4e68942437
Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents:
22
diff
changeset
|
73 |
$sFbfProjectRev = $2; |
ed4e68942437
Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents:
22
diff
changeset
|
74 |
} |
ed4e68942437
Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents:
22
diff
changeset
|
75 |
my $sFbfConfigRev = ''; |
ed4e68942437
Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents:
22
diff
changeset
|
76 |
if ($sFbfConfigRepo =~ m,(.*)#(.*),) |
ed4e68942437
Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents:
22
diff
changeset
|
77 |
{ |
ed4e68942437
Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents:
22
diff
changeset
|
78 |
$sFbfConfigRepo = $1; |
ed4e68942437
Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents:
22
diff
changeset
|
79 |
$sFbfConfigRev = $2; |
ed4e68942437
Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents:
22
diff
changeset
|
80 |
} |
ed4e68942437
Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents:
22
diff
changeset
|
81 |
|
19
472feb69d0c9
Changed location of default config repo, added --testbuild option, extended help
Dario Sestito <darios@symbian.org>
parents:
17
diff
changeset
|
82 |
my $sTestBuildOpts = ""; |
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 |
$sTestBuildOpts = "-Dsf.spec.publish.enable=false" if ( $bTestBuild ); |
19
472feb69d0c9
Changed location of default config repo, added --testbuild option, extended help
Dario Sestito <darios@symbian.org>
parents:
17
diff
changeset
|
84 |
$sNUMBERS_FILE = "d:\\numbers_test.txt" if ( $bTestBuild ); |
472feb69d0c9
Changed location of default config repo, added --testbuild option, extended help
Dario Sestito <darios@symbian.org>
parents:
17
diff
changeset
|
85 |
|
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
|
86 |
my $sLabelBaseString = $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
|
87 |
$sLabelBaseString = $sFbfProjectDir if ($sFbfProjectDir); |
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
|
88 |
$sLabelBaseString =~ m,.*[\\/]([^\\^/]+),; |
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
|
89 |
my $sJobLabel = $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
|
90 |
$sJobLabel = $sLabelBaseString if (! $1); |
23
435ecee4ea5d
Create sJOB_BASE_DIR if it doesn't exist
royt <tathagatar@symbian.org>
parents:
22
diff
changeset
|
91 |
mkdir($sJOB_BASE_DIR) if (!-d$sJOB_BASE_DIR); |
11
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
92 |
my $sJobDir = mkdir_unique("$sJOB_BASE_DIR\\$sJobLabel"); |
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
|
93 |
print "Created project dir $sJOB_BASE_DIR\\$sJobLabel\n"; |
11
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
94 |
|
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
95 |
print("cd $sBOOTSTRAP_DIR\n"); |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
96 |
chdir("$sBOOTSTRAP_DIR"); |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
97 |
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
|
98 |
my $sConfigArg = "-Dsf.config.repo=$sFbfConfigRepo"; |
24
ed4e68942437
Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents:
22
diff
changeset
|
99 |
$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
|
100 |
$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
|
101 |
my $sProjectArg = "-Dsf.project.repo=$sFbfProjectRepo"; |
24
ed4e68942437
Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents:
22
diff
changeset
|
102 |
$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
|
103 |
$sProjectArg = "-Dsf.project.dir=$sFbfProjectDir" if ($sFbfProjectDir); |
e1b9f78cef38
Project spec and config to be taken from a dir instead of from a repo
darios@symbian.org
parents:
15
diff
changeset
|
104 |
print("hlm -f bootstrap.xml $sConfigArg $sProjectArg -Dsf.target.dir=$sJobDir\n"); |
e1b9f78cef38
Project spec and config to be taken from a dir instead of from a repo
darios@symbian.org
parents:
15
diff
changeset
|
105 |
system("hlm -f bootstrap.xml $sConfigArg $sProjectArg -Dsf.target.dir=$sJobDir"); |
11
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
106 |
|
13
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
107 |
# 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
|
108 |
if (!-f $sNUMBERS_FILE) |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
109 |
{ |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
110 |
open FILE, ">$sNUMBERS_FILE"; |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
111 |
print FILE "\n"; |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
112 |
close FILE; |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
113 |
} |
11
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
114 |
|
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
|
115 |
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
|
116 |
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
|
117 |
{ |
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
|
118 |
$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
|
119 |
} |
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
|
120 |
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
|
121 |
{ |
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
|
122 |
my $sRevZeroHash = get_rev_zero_hash($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
|
123 |
$nUnformattedNumber = get_job_number($sRevZeroHash); |
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
|
124 |
} |
11
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
125 |
my $nJobNumber = sprintf("%.3d", $nUnformattedNumber); |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
126 |
|
13
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
127 |
# check that $sLETTERS_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
|
128 |
if (!-f $sLETTERS_FILE) |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
129 |
{ |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
130 |
open FILE, ">$sLETTERS_FILE"; |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
131 |
print FILE "\n"; |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
132 |
close FILE; |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
133 |
} |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
134 |
|
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
135 |
# acquire drive letter |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
136 |
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
|
137 |
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
|
138 |
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
|
139 |
|
11
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
140 |
print("cd $sJobDir\\sf-config\n"); |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
141 |
chdir("$sJobDir\\sf-config"); |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
142 |
print "###### BUILD PREPARATION ######\n"; |
19
472feb69d0c9
Changed location of default config repo, added --testbuild option, extended help
Dario Sestito <darios@symbian.org>
parents:
17
diff
changeset
|
143 |
print("hlm sf-prep -Dsf.spec.job.number=$nJobNumber -Dsf.spec.job.drive=$sDriveLetter: $sTestBuildOpts\n"); |
472feb69d0c9
Changed location of default config repo, added --testbuild option, extended help
Dario Sestito <darios@symbian.org>
parents:
17
diff
changeset
|
144 |
system("hlm sf-prep -Dsf.spec.job.number=$nJobNumber -Dsf.spec.job.drive=$sDriveLetter: $sTestBuildOpts"); |
11
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
145 |
|
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
146 |
print "###### EXECUTE BUILD ######\n"; |
27
d12bf27e4e0e
Make --testbuild option work also for the sf-build-all target
Dario Sestito <darios@symbian.org>
parents:
25
diff
changeset
|
147 |
print("hlm sf-build-all -Dsf.spec.job.number=$nJobNumber -Dsf.spec.job.drive=$sDriveLetter: $sTestBuildOpts\n"); |
d12bf27e4e0e
Make --testbuild option work also for the sf-build-all target
Dario Sestito <darios@symbian.org>
parents:
25
diff
changeset
|
148 |
system("hlm sf-build-all -Dsf.spec.job.number=$nJobNumber -Dsf.spec.job.drive=$sDriveLetter: $sTestBuildOpts"); |
13
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
149 |
|
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
150 |
# release the drive letter |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
151 |
release_drive_letter($sDriveLetter); |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
152 |
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
|
153 |
print "drive letter $sDriveLetter released (and drive unsubsted)\n"; |
11
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
154 |
|
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
155 |
sub mkdir_unique |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
156 |
{ |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
157 |
my ($sBaseDir) = @_; |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
158 |
|
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
159 |
# 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
|
160 |
$sBaseDir =~ m,(.*[\\/])?(.*),; |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
161 |
mkpath($1) if ($1 && !-d $1); |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
162 |
|
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
163 |
my $nI = 0; |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
164 |
my $sNewDirName = "$sBaseDir"; |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
165 |
while(!mkdir($sNewDirName)) |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
166 |
{ |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
167 |
$nI++; |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
168 |
$sNewDirName = "$sBaseDir.$nI"; |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
169 |
} |
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 |
return $sNewDirName; |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
172 |
} |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
173 |
|
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
|
174 |
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
|
175 |
{ |
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
|
176 |
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
|
177 |
|
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
|
178 |
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
|
179 |
|
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
|
180 |
# 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
|
181 |
$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
|
182 |
$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
|
183 |
|
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
|
184 |
# 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
|
185 |
$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
|
186 |
|
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
|
187 |
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
|
188 |
} |
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
|
189 |
|
11
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
190 |
sub get_job_number |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
191 |
{ |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
192 |
my ($sKey) = @_; |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
193 |
|
13
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
194 |
$sKey=lc($sKey); |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
195 |
|
11
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
196 |
my %hnNumbers = (); |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
197 |
|
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
198 |
my $nAttempts = 0; |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
199 |
my $bGotNumber = 0; |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
200 |
do |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
201 |
{ |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
202 |
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
|
203 |
if ( flock(FILE, 6) ) |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
204 |
{ |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
205 |
my $sLine; |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
206 |
while ($sLine = <FILE>) |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
207 |
{ |
13
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
208 |
$hnNumbers{lc($1)} = $2 if ($sLine =~ m%(.*),(.*)%); |
11
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
209 |
} |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
210 |
|
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
211 |
$hnNumbers{$sKey} = 0 if (! $hnNumbers{$sKey} ); |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
212 |
$hnNumbers{$sKey} = $hnNumbers{$sKey} + 1; |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
213 |
|
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
214 |
seek(FILE, 0, 0); |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
215 |
|
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
216 |
for my $sStr ( keys(%hnNumbers) ) |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
217 |
{ |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
218 |
print FILE "$sStr,$hnNumbers{$sStr}\n"; |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
219 |
} |
13
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
220 |
truncate(FILE,tell(FILE)); |
11
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
221 |
|
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
222 |
$bGotNumber = 1; |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
223 |
} |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
224 |
else |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
225 |
{ |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
226 |
$nAttempts ++; |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
227 |
sleep(3); |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
228 |
} |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
229 |
close(FILE); |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
230 |
} |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
231 |
until ( $bGotNumber or $nAttempts == $nLOCK_FILE_MAX_ATTEMPTS ); |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
232 |
|
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
233 |
return $hnNumbers{$sKey}; |
f3475510d60c
Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff
changeset
|
234 |
} |
13
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
235 |
|
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
236 |
sub acquire_drive_letter |
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 |
my %hsPidsAndTimestamps = (); |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
239 |
|
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
240 |
my $sLetterToRelease = ''; |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
241 |
|
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
242 |
my $nAttempts = 0; |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
243 |
my $bAcquired = 0; |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
244 |
do |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
245 |
{ |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
246 |
open(FILE, "+<$sLETTERS_FILE") or die("Can't open $sLETTERS_FILE"); |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
247 |
if ( flock(FILE, 6) ) |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
248 |
{ |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
249 |
my $sLine; |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
250 |
while ($sLine = <FILE>) |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
251 |
{ |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
252 |
if ($sLine =~ m%([^,]*),(.*)%) |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
253 |
{ |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
254 |
my $sLetter=$1; |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
255 |
my $sString=$2; |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
256 |
|
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
257 |
$sString=~m%([^,]*),(.*)%; |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
258 |
my $nPid=$1; |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
259 |
my $nTimestamp=$2; |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
260 |
|
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
261 |
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
|
262 |
{ |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
263 |
$hsPidsAndTimestamps{$sLetter} = $sString; |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
264 |
} |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
265 |
else |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
266 |
{ |
19
472feb69d0c9
Changed location of default config repo, added --testbuild option, extended help
Dario Sestito <darios@symbian.org>
parents:
17
diff
changeset
|
267 |
# 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
|
268 |
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
|
269 |
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
|
270 |
} |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
271 |
} |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
272 |
} |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
273 |
|
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
274 |
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
|
275 |
{ |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
276 |
if (! $hsPidsAndTimestamps{$sNewLetter}) |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
277 |
{ |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
278 |
my $sTimestamp = time(); |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
279 |
$hsPidsAndTimestamps{$sNewLetter} = "$$,$sTimestamp"; |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
280 |
$sLetterToRelease = $sNewLetter; |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
281 |
last; |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
282 |
} |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
283 |
} |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
284 |
|
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
285 |
seek(FILE, 0, 0); |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
286 |
|
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
287 |
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
|
288 |
{ |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
289 |
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
|
290 |
} |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
291 |
truncate(FILE,tell(FILE)); |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
292 |
|
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
293 |
$bAcquired = 1; |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
294 |
} |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
295 |
else |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
296 |
{ |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
297 |
$nAttempts ++; |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
298 |
sleep(3); |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
299 |
} |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
300 |
close(FILE); |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
301 |
} |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
302 |
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
|
303 |
|
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
304 |
return $sLetterToRelease; |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
305 |
} |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
306 |
|
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
307 |
sub release_drive_letter |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
308 |
{ |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
309 |
my ($sLetterToRelease) = @_; |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
310 |
|
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
311 |
my %hsPidsAndTimestamps = (); |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
312 |
|
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
313 |
my $nAttempts = 0; |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
314 |
my $bAcquired = 0; |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
315 |
do |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
316 |
{ |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
317 |
open(FILE, "+<$sLETTERS_FILE") or die("Can't open $sLETTERS_FILE"); |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
318 |
if ( flock(FILE, 6) ) |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
319 |
{ |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
320 |
my $sLine; |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
321 |
while ($sLine = <FILE>) |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
322 |
{ |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
323 |
$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
|
324 |
} |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
325 |
|
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
326 |
delete $hsPidsAndTimestamps{$sLetterToRelease}; |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
327 |
|
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
328 |
seek(FILE, 0, 0); |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
329 |
|
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
330 |
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
|
331 |
{ |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
332 |
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
|
333 |
} |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
334 |
truncate(FILE,tell(FILE)); |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
335 |
|
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
336 |
$bAcquired = 1; |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
337 |
} |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
338 |
else |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
339 |
{ |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
340 |
$nAttempts ++; |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
341 |
sleep(3); |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
342 |
} |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
343 |
close(FILE); |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
344 |
} |
85202f272e4a
Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents:
12
diff
changeset
|
345 |
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
|
346 |
} |