587
|
1 |
#============================================================================
|
|
2 |
#Name : idoprep.py
|
|
3 |
#Part of : Helium
|
|
4 |
|
|
5 |
#Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
6 |
#All rights reserved.
|
|
7 |
#This component and the accompanying materials are made available
|
|
8 |
#under the terms of the License "Eclipse Public License v1.0"
|
|
9 |
#which accompanies this distribution, and is available
|
|
10 |
#at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
11 |
#
|
|
12 |
#Initial Contributors:
|
|
13 |
#Nokia Corporation - initial contribution.
|
|
14 |
#
|
|
15 |
#Contributors:
|
|
16 |
#
|
|
17 |
#Description:
|
|
18 |
#===============================================================================
|
|
19 |
|
|
20 |
""" Modules related to ido-prep """
|
|
21 |
|
|
22 |
import re
|
|
23 |
import os
|
|
24 |
import symrec
|
|
25 |
import logging
|
|
26 |
import traceback
|
|
27 |
import ido
|
|
28 |
|
|
29 |
logging.basicConfig(level=logging.INFO)
|
588
|
30 |
_logger = logging.getLogger("check_latest_release")
|
587
|
31 |
|
|
32 |
def validate(grace, service, product, release):
|
|
33 |
""" Validate s60 grace server, s60 grace service, s60 grace product and
|
|
34 |
s60 grace release are set.
|
|
35 |
"""
|
|
36 |
if not grace:
|
628
|
37 |
raise EnvironmentError("Property 's60.grace.server' is not defined.")
|
587
|
38 |
if not service:
|
628
|
39 |
raise EnvironmentError("Property 's60.grace.service' is not defined.")
|
587
|
40 |
if not product:
|
628
|
41 |
raise EnvironmentError("Property 's60.grace.product' is not defined.")
|
587
|
42 |
if not release:
|
628
|
43 |
raise EnvironmentError("Property 's60.grace.release' is not defined.")
|
587
|
44 |
|
|
45 |
def get_s60_env_details(grace, service, product, release, rev, cachefilename, s60gracecheckmd5, s60graceusetickler):
|
|
46 |
""" Return s60 environ details """
|
|
47 |
validate(grace, service, product, release)
|
|
48 |
revision = r'(_\d{3})?'
|
|
49 |
if rev != None:
|
|
50 |
revision = rev
|
|
51 |
|
|
52 |
if cachefilename:
|
588
|
53 |
_logger.info(str("Using cache file: %s" % cachefilename))
|
587
|
54 |
|
|
55 |
checkmd5 = False
|
|
56 |
if s60gracecheckmd5 != None:
|
|
57 |
checkmd5 = str(s60gracecheckmd5).lower()
|
|
58 |
checkmd5 = ((checkmd5 == "true") or (checkmd5 == "1") or (checkmd5 == "on"))
|
|
59 |
|
|
60 |
branch = os.path.join(grace, service, product)
|
|
61 |
if not os.path.exists(branch):
|
628
|
62 |
raise IOError("Error occurred: Could not find directory %s" % branch)
|
587
|
63 |
|
|
64 |
result = []
|
|
65 |
for rel in os.listdir(branch):
|
|
66 |
relpath = os.path.join(branch, rel)
|
588
|
67 |
_logger.info("Checking: %s" % str(relpath))
|
587
|
68 |
res = re.match(r"%s%s$" % (release, revision), rel, re.I)
|
|
69 |
if res != None:
|
588
|
70 |
_logger.info("Found: %s" % str(relpath))
|
587
|
71 |
result.append(relpath)
|
|
72 |
result.sort(reverse=True)
|
|
73 |
use_tickler = False
|
|
74 |
tickler_validation = str(s60graceusetickler).lower()
|
|
75 |
if tickler_validation != None:
|
|
76 |
use_tickler = ((tickler_validation == "true") or (tickler_validation == "1"))
|
|
77 |
validresults = []
|
|
78 |
for rel in result:
|
|
79 |
try:
|
|
80 |
metadata_filename = symrec.find_latest_metadata(str(rel))
|
|
81 |
if metadata_filename is not None and os.path.exists(metadata_filename):
|
588
|
82 |
_logger.info(str("Validating: %s" % metadata_filename))
|
587
|
83 |
if (use_tickler):
|
|
84 |
validator = symrec.ValidateTicklerReleaseMetadata(metadata_filename, cachefilename)
|
|
85 |
else:
|
|
86 |
validator = symrec.ValidateReleaseMetadataCached(metadata_filename, cachefilename)
|
|
87 |
if validator.is_valid(checkmd5):
|
588
|
88 |
_logger.info(str("%s is valid." % rel))
|
587
|
89 |
validresults.append(rel)
|
|
90 |
break
|
|
91 |
else:
|
588
|
92 |
_logger.info(str("%s is not a valid release." % rel))
|
587
|
93 |
elif metadata_filename is None:
|
588
|
94 |
_logger.info(str("Could not find the release metadata file under %s" % rel))
|
628
|
95 |
except IOError, exc:
|
588
|
96 |
_logger.warning(str("WARNING: %s: %s" % (rel , exc)))
|
|
97 |
_logger.warning(("%s is not a valid release." % rel))
|
587
|
98 |
traceback.print_exc()
|
|
99 |
|
|
100 |
result = validresults
|
|
101 |
if len(result) == 0:
|
628
|
102 |
raise EnvironmentError("Error finding GRACE release.")
|
587
|
103 |
print result[0]
|
|
104 |
return result
|
|
105 |
|
|
106 |
def get_version(buiddrive, resultname):
|
|
107 |
""" Return s60 version """
|
|
108 |
vfile = os.path.join(buiddrive + os.sep, 's60_version.txt')
|
|
109 |
version = None
|
|
110 |
if (os.path.exists(vfile)):
|
588
|
111 |
_logger.info("Are we still up-to-date compare to %s" % str(vfile))
|
|
112 |
f_file = open(str(vfile), 'r')
|
|
113 |
version = f_file.readline()
|
|
114 |
_logger.info(str("'%s' == '%s'" % (version, resultname)))
|
|
115 |
f_file.close()
|
587
|
116 |
else:
|
588
|
117 |
_logger.info("Version file not found getting new environment...")
|
587
|
118 |
return version
|
|
119 |
|
|
120 |
def create_ado_mapping(sysdefconfig, adomappingfile, adoqualitymappingfile, builddrive, adoqualitydirs):
|
|
121 |
""" Creates ado mapping and ado quality mapping files """
|
628
|
122 |
input_ = open(sysdefconfig, 'r')
|
587
|
123 |
output = open(adomappingfile, 'w')
|
|
124 |
outputquality = open(adoqualitymappingfile, 'w')
|
628
|
125 |
for sysdef in input_.readlines():
|
587
|
126 |
sysdef = sysdef.strip()
|
|
127 |
if len(sysdef) > 0:
|
|
128 |
print "Checking %s" % sysdef
|
|
129 |
os.path.dirname(sysdef)
|
|
130 |
location = ido.get_sysdef_location(sysdef)
|
|
131 |
if location != None:
|
|
132 |
if os.sep == '\\':
|
|
133 |
sysdef = os.path.dirname(sysdef).replace('\\','/').replace(':','\\:')
|
|
134 |
component = os.path.normpath(os.path.join(builddrive, os.environ['EPOCROOT'], location)).replace('\\','/').replace(':','\\:')
|
|
135 |
else:
|
|
136 |
sysdef = os.path.dirname(sysdef).replace('\\','/')
|
|
137 |
if location.startswith('/'):
|
|
138 |
component = os.path.normpath(os.path.join(builddrive, location.lstrip('/'))).replace('\\','/')
|
|
139 |
else:
|
|
140 |
component = os.path.normpath(os.path.join(builddrive, location)).replace('\\','/')
|
|
141 |
print "%s=%s\n" % (sysdef, component)
|
|
142 |
output.write("%s=%s\n" % (sysdef, component))
|
|
143 |
if adoqualitydirs == None:
|
|
144 |
outputquality.write("%s=%s\n" % (sysdef, component))
|
|
145 |
else:
|
628
|
146 |
for dir_ in adoqualitydirs.split(','):
|
|
147 |
if os.path.normpath(dir_) == os.path.normpath(os.path.join(builddrive, os.environ['EPOCROOT'], location)):
|
587
|
148 |
outputquality.write("%s=%s\n" % (sysdef, component))
|
|
149 |
|
|
150 |
|
|
151 |
outputquality.close()
|
|
152 |
output.close()
|
628
|
153 |
input_.close()
|
587
|
154 |
|
|
155 |
|
|
156 |
|