dbrtools/dbr/cleanenv.py
changeset 179 eab8a264a833
child 200 12422144aae1
child 221 f7670db4b513
equal deleted inserted replaced
177:6d3c3db11e72 179:eab8a264a833
       
     1 # Copyright (c) 2009 Symbian Foundation Ltd
       
     2 # This component and the accompanying materials are made available
       
     3 # under the terms of the License "Eclipse Public License v1.0"
       
     4 # which accompanies this distribution, and is available
       
     5 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     6 #
       
     7 # Initial Contributors:
       
     8 # Symbian Foundation Ltd - initial contribution.
       
     9 #
       
    10 # Contributors:
       
    11 # mattd <mattd@symbian.org>
       
    12 #
       
    13 # Description:
       
    14 # DBR cleanenv - cleans your environment
       
    15 
       
    16 import dbrbaseline
       
    17 import dbrpatch
       
    18 import dbrutils
       
    19 
       
    20 import re #temporary for dealing with patches
       
    21 
       
    22 def main(args):
       
    23     zippath = '/'
       
    24     if(len(args)):
       
    25       zippath = args[0] 
       
    26     
       
    27     dbfilename = dbrutils.defaultdb()
       
    28     baseline = dbrbaseline.readdb(dbfilename)
       
    29     if(len(baseline ) > 0):
       
    30         env = dbrutils.scanenv()
       
    31         patches = dbrpatch.loadpatches(dbrpatch.dbrutils.patchpath())
       
    32         db = dbrpatch.createpatchedbaseline(baseline,patches)
       
    33         results = dbrpatch.newupdatedb(db,env)
       
    34         dbrutils.deletefiles(sorted(results['added']))
       
    35         required = set()
       
    36         required.update(results['removed'])
       
    37         required.update(results['changed'])
       
    38         required.update(results['untestable']) #untestable is going to be a problem...
       
    39         dbrutils.extractfiles(required, zippath)
       
    40         for name in sorted(patches):
       
    41           dbrutils.extractfromzip(required, re.sub('.txt','.zip',name))        
       
    42 
       
    43         env = dbrutils.scanenv()
       
    44         results2 = dbrpatch.newupdatedb(db,env)          
       
    45          
       
    46         baseline = dbrpatch.updatebaseline(baseline, db)
       
    47         patches = dbrpatch.updatepatches(patches, db)
       
    48 
       
    49         dbrpatch.savepatches(patches)        
       
    50 
       
    51 
       
    52 def run(args):  
       
    53   main(args)
       
    54 
       
    55 def help():
       
    56   print "Cleans the current environment"
       
    57   print "Usage\n\tdbr cleanenv (<baseline_zip_path>)"
       
    58   print "\nDefault behaviour presumes baselie zips exist at the root"
       
    59