buildframework/helium/tools/preparation/bom/bom.ant.xml
changeset 645 b8d81fa19e7d
parent 628 7c4a911dc066
equal deleted inserted replaced
643:27cf35f95864 645:b8d81fa19e7d
    61 import ant
    61 import ant
    62 import sys
    62 import sys
    63 import traceback
    63 import traceback
    64 
    64 
    65 session = None
    65 session = None
    66 try:
    66 
    67     runccm = ant.get_property(r'${ccm.enabled}')
    67 runccm = ant.get_property(r'${ccm.enabled}')
    68     database = ant.get_property(r'${ccm.database}')
    68 database = ant.get_property(r'${ccm.database}')
    69     username = ant.get_property(r'${ccm.user.login}')
    69 username = ant.get_property(r'${ccm.user.login}')
    70     password = ant.get_property(r'${ccm.user.password}')
    70 password = ant.get_property(r'${ccm.user.password}')
    71     engine = ant.get_property(r'${ccm.engine.host}')
    71 engine = ant.get_property(r'${ccm.engine.host}')
    72     dbpath = ant.get_property(r'${ccm.database.path}')
    72 dbpath = ant.get_property(r'${ccm.database.path}')
    73     waroot = ant.get_property(r'${create.bom.workarea.root}')
    73 waroot = ant.get_property(r'${create.bom.workarea.root}')
    74     buildid = ant.get_property(r'${build.id}')
    74 buildid = ant.get_property(r'${build.id}')
    75     buildlogdir = ant.get_property(r'${build.log.dir}')
    75 buildlogdir = ant.get_property(r'${build.log.dir}')
    76     deliveryfile = ant.get_property(r'${prep.delivery.conf.parsed}')
    76 deliveryfile = ant.get_property(r'${prep.delivery.conf.parsed}')
    77     oldbom = ant.get_property(r'${old.bom.log}')
    77 oldbom = ant.get_property(r'${old.bom.log}')
    78     bom = None
    78 bom = None
    79     bomfilename = r"%s/%s_bom.xml" % (buildlogdir, buildid)
    79 bomfilename = r"%s/%s_bom.xml" % (buildlogdir, buildid)
    80     if runccm and deliveryfile:
    80 if deliveryfile and runccm == 'true':
    81         cache = None
    81     cache = None
    82         if ant.get_property(r'${ccm.cache.xml}') is not None:
    82     if ant.get_property(r'${ccm.cache.xml}') is not None:
    83             cache = str(ant.get_property(r'${ccm.cache.xml}'))
    83         cache = str(ant.get_property(r'${ccm.cache.xml}'))
    84         provider = ccm.extra.CachedSessionProvider(opener=nokia.nokiaccm.open_session, cache=cache)
    84     provider = ccm.extra.CachedSessionProvider(opener=nokia.nokiaccm.open_session, cache=cache)
    85             
       
    86         configBuilder = configuration.NestedConfigurationBuilder(open(deliveryfile, 'r'))
       
    87         configSet = configBuilder.getConfiguration()
       
    88         for config in configSet.getConfigurations():
       
    89             waroot = config['dir']
       
    90             print "Found wa for project %s" % waroot
       
    91                         
       
    92         if database != None:
       
    93             session = provider.get(username, password, database=database)
       
    94         else:
       
    95             session = provider.get(username, password, engine, dbpath)
       
    96             
       
    97         ccmproject =  ccm.extra.get_toplevel_project(session, waroot)
       
    98         
    85         
    99         config_data = {'delivery': deliveryfile, 'prep.xml': ant.get_property(r'${prep.config.file.parsed}'), 'build.id': buildid, 'ccm.database': database, 'symbian_rel_week': ant.get_property(r'${symbian.version.week}'), 'symbian_rel_ver': ant.get_property(r'${symbian.version}'), 'symbian_rel_year': ant.get_property(r'${symbian.version.year}'), 's60_version': ant.get_property(r'${s60.version}'), 's60_release': ant.get_property(r'${s60.release}'), 'currentRelease.xml': ant.get_property(r'${build.drive}') + "/currentRelease.xml", 'release_regexp': ant.get_property(r'${bom.release.regex}') }
    86     configBuilder = configuration.NestedConfigurationBuilder(open(deliveryfile, 'r'))
   100         config = configuration.Configuration(config_data)
    87     configSet = configBuilder.getConfiguration()
       
    88     for config in configSet.getConfigurations():
       
    89         waroot = config['dir']
       
    90         print "Found wa for project %s" % waroot
       
    91                     
       
    92     if database != None:
       
    93         session = provider.get(username, password, database=database)
       
    94     else:
       
    95         session = provider.get(username, password, engine, dbpath)
   101         
    96         
   102         # let's only support the new spec model!
    97     ccmproject =  ccm.extra.get_toplevel_project(session, waroot)
   103         bom = build.model.SynergyBOM(config, ccmproject, username=username, password=password, provider=provider)
    98     
   104         
    99     config_data = {'delivery': deliveryfile, 'prep.xml': ant.get_property(r'${prep.config.file.parsed}'), 'build.id': buildid, 'ccm.database': database, 'symbian_rel_week': ant.get_property(r'${symbian.version.week}'), 'symbian_rel_ver': ant.get_property(r'${symbian.version}'), 'symbian_rel_year': ant.get_property(r'${symbian.version.year}'), 's60_version': ant.get_property(r'${s60.version}'), 's60_release': ant.get_property(r'${s60.release}'), 'currentRelease.xml': ant.get_property(r'${build.drive}') + "/currentRelease.xml", 'release_regexp': ant.get_property(r'${bom.release.regex}') }
   105         xml_writer = build.model.BOMXMLWriter(bom)
   100     config = configuration.Configuration(config_data)
   106         xml_writer.write(bomfilename)
   101     
   107     if not bom and os.path.exists(bomfilename):
   102     # let's only support the new spec model!
   108         config_data = {'prep.xml': ant.get_property(r'${prep.config.file.parsed}'), 'build.id': buildid, 'symbian_rel_week': ant.get_property(r'${symbian.version.week}'), 'symbian_rel_ver': ant.get_property(r'${symbian.version}'), 'symbian_rel_year': ant.get_property(r'${symbian.version.year}'), 's60_version': ant.get_property(r'${s60.version}'), 's60_release': ant.get_property(r'${s60.release}'), 'currentRelease.xml': ant.get_property(r'${build.drive}') + "/currentRelease.xml"}
   103     bom = build.model.SynergyBOM(config, ccmproject, username=username, password=password, provider=provider)
   109         config = configuration.Configuration(config_data)
   104     
   110         bom = build.model.SimpleBOM(config, bomfilename)
   105     xml_writer = build.model.BOMXMLWriter(bom)
   111     if os.path.exists(oldbom):
   106     xml_writer.write(bomfilename)
   112         xml_delta_writer = build.model.BOMDeltaXMLWriter(bom, oldbom)
   107 if not bom and os.path.exists(bomfilename):
   113         xml_delta_writer.write(buildlogdir + "/" + buildid + "_bom_delta.xml")
   108     config_data = {'prep.xml': ant.get_property(r'${prep.config.file.parsed}'), 'build.id': buildid, 'symbian_rel_week': ant.get_property(r'${symbian.version.week}'), 'symbian_rel_ver': ant.get_property(r'${symbian.version}'), 'symbian_rel_year': ant.get_property(r'${symbian.version.year}'), 's60_version': ant.get_property(r'${s60.version}'), 's60_release': ant.get_property(r'${s60.release}'), 'currentRelease.xml': ant.get_property(r'${build.drive}') + "/currentRelease.xml"}
   114         delta_bom_content_validity = xml_delta_writer.validate_delta_bom_contents(buildlogdir + "/" + buildid + "_bom_delta.xml", bomfilename, oldbom)
   109     config = configuration.Configuration(config_data)
   115         if((delta_bom_content_validity == False) and (ant.get_property(r'${hlm.enable.asserts}') is not None)):
   110     bom = build.model.SimpleBOM(config, bomfilename)
   116             print 'Bom delta contents are not matching'
   111 if bom and os.path.exists(oldbom):
   117             raise Exception
   112     xml_delta_writer = build.model.BOMDeltaXMLWriter(bom, oldbom)
   118         elif((delta_bom_content_validity == True) or (delta_bom_content_validity == None)):
   113     xml_delta_writer.write(buildlogdir + "/" + buildid + "_bom_delta.xml")
   119             print 'Bom delta contents are matching.'
   114     delta_bom_content_validity = xml_delta_writer.validate_delta_bom_contents(buildlogdir + "/" + buildid + "_bom_delta.xml", bomfilename, oldbom)
   120         elif(delta_bom_content_validity == False):
   115     if((delta_bom_content_validity == False) and (ant.get_property(r'${hlm.enable.asserts}') is not None)):
   121             print 'Bom delta contents are not matching.'
   116         print 'Bom delta contents are not matching'
   122     else:
   117         raise Exception
   123         print 'Old BOM log cannot be found ' + oldbom + ', skipping BOM delta creation.'
   118     elif((delta_bom_content_validity == True) or (delta_bom_content_validity == None)):
   124     if runccm:
   119         print 'Bom delta contents are matching.'
   125         bom.close()
   120     elif(delta_bom_content_validity == False):
   126     if session:
   121         print 'Bom delta contents are not matching.'
   127         session.close()
   122 else:
   128 except Exception, ex:
   123     print 'Old BOM log cannot be found ' + oldbom + ', skipping BOM delta creation.'
   129     print 'Caught exception in BOM: ' + str(ex)
   124 if runccm == 'true':
   130     traceback.print_exc()
   125     bom.close()
       
   126 if session:
       
   127     session.close()
   131         </hlm:python>
   128         </hlm:python>
   132         <if>
   129         <if>
   133             <available file="${build.log.dir}/${build.id}_bom.xml"/>
   130             <available file="${build.log.dir}/${build.id}_bom.xml"/>
   134             <then>
   131             <then>
   135                 <echo>${build.log.dir}</echo>
   132                 <echo>${build.log.dir}</echo>
   136                 <xmltask source="${build.log.dir}/${build.id}_bom.xml" dest="${build.log.dir}/${build.id}_bom.xml" outputter="simple">
   133                 <xmltask source="${build.log.dir}/${build.id}_bom.xml" dest="${build.log.dir}/${build.id}_bom.xml" outputter="simple">
   137                     <replace path="//bom/build/text()" withText="${build.id}"/>
   134                     <replace path="//bom/build/text()" withText="${build.id}"/>
   138                 </xmltask>
   135                 </xmltask>
   139                 <fmpp sourceRoot="${helium.dir}/tools/preparation/bom"
   136                 <fmpp sourceRoot="${helium.dir}/tools/preparation/bom/templates"
   140                       outputRoot="${prep.log.dir}" includes="bom.html.*,bom.txt.*" removeExtensions="ftl">
   137                       outputRoot="${prep.log.dir}" includes="bom.html.*,bom.txt.*" removeExtensions="ftl">
   141                     <freemarkerLinks expandProperties="yes">
   138                     <freemarkerLinks expandProperties="yes">
   142                         macro: ${helium.dir}/tools/common/templates/macro
   139                         macro: ${helium.dir}/tools/common/templates/macro
   143                     </freemarkerLinks>
   140                     </freemarkerLinks>
   144                     <data expandProperties="yes">
   141                     <data expandProperties="yes">
   187                 <echo>WARNING: ${build.log.dir}/${build.id}_bom.xml file not found.</echo>
   184                 <echo>WARNING: ${build.log.dir}/${build.id}_bom.xml file not found.</echo>
   188             </else>
   185             </else>
   189         </if>
   186         </if>
   190         
   187         
   191         <if>
   188         <if>
   192             <available file="${old.bom.log}"/>
   189             <and>
       
   190                 <available file="${old.bom.log}"/>
       
   191                 <available file="${build.log.dir}/${build.id}_bom_delta.xml"/>
       
   192             </and>
   193             <then>
   193             <then>
   194                 <hlm:assertFileExists file="${build.log.dir}/${build.id}_bom_delta.xml"/>
   194                 <hlm:assertFileExists file="${build.log.dir}/${build.id}_bom_delta.xml"/>
   195                 <fmpp sourceRoot="${helium.dir}/tools/preparation/bom"
   195                 <fmpp sourceRoot="${helium.dir}/tools/preparation/bom/templates"
   196                       outputRoot="${prep.log.dir}" includes="bom_delta.*" removeExtensions="ftl">
   196                       outputRoot="${prep.log.dir}" includes="bom_delta.*" removeExtensions="ftl">
   197                     <freemarkerLinks expandProperties="yes">
   197                     <freemarkerLinks expandProperties="yes">
   198                         macro: ${helium.dir}/tools/common/templates/macro
   198                         macro: ${helium.dir}/tools/common/templates/macro
   199                     </freemarkerLinks>
   199                     </freemarkerLinks>
   200                     <data expandProperties="yes">
   200                     <data expandProperties="yes">
   285             <sequential>
   285             <sequential>
   286                 <var name="task.owner" value="@{task.owner}"/>
   286                 <var name="task.owner" value="@{task.owner}"/>
   287                 <if>
   287                 <if>
   288                     <isset property="email.ldap.server"/>
   288                     <isset property="email.ldap.server"/>
   289                     <then>
   289                     <then>
   290                         <hlm:ldap url="${email.ldap.server}" rootdn="${email.ldap.rootdn}" filter="uid=${task.owner}" outputproperty="task.owner.email" key="mail"/>
   290                         <hlm:ldap url="${email.ldap.server}" rootdn="${email.ldap.rootdn}" filter="uid=${task.owner}" outputproperty="task.owner.email" key="mail" failonerror="false"/>
   291                         <if>
   291                         <if>
   292                             <isset property="task.owners.email"/>
   292                             <isset property="task.owners.email"/>
   293                             <then>
   293                             <then>
   294                                 <var name="task.owners.email" value="${task.owners.email},${task.owner.email}"/>
   294                                 <var name="task.owners.email" value="${task.owners.email},${task.owner.email}"/>
   295                             </then>
   295                             </then>