1 # Copyright (c) 2009 Symbian Foundation Ltd |
1 # Copyright (c) 2009-2010 Symbian Foundation Ltd |
2 # This component and the accompanying materials are made available |
2 # This component and the accompanying materials are made available |
3 # under the terms of the License "Eclipse Public License v1.0" |
3 # under the terms of the License "Eclipse Public License v1.0" |
4 # which accompanies this distribution, and is available |
4 # which accompanies this distribution, and is available |
5 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
5 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 # |
6 # |
11 # mattd <mattd@symbian.org> |
11 # mattd <mattd@symbian.org> |
12 # |
12 # |
13 # Description: |
13 # Description: |
14 # DBR cleanenv - cleans your environment |
14 # DBR cleanenv - cleans your environment |
15 |
15 |
16 import dbrbaseline |
16 |
17 import dbrpatch |
|
18 import dbrutils |
17 import dbrutils |
|
18 import dbrenv |
19 |
19 |
20 import re #temporary for dealing with patches |
20 import re #temporary for dealing with patches |
21 |
21 |
22 def main(args): |
22 def run(args): |
23 zippath = '/' |
23 zippath = '/' |
24 if(len(args)): |
24 if(len(args)): |
25 zippath = args[0] |
25 zippath = args[0] |
26 |
26 #This block is a cut'n'paste from checkenv...we call call that instead... |
27 dbfilename = dbrutils.defaultdb() |
27 |
28 baseline = dbrbaseline.readdb(dbfilename) |
28 location = '/' |
29 if(len(baseline ) > 0): |
29 #needs a fix to scanenv for this to work... |
30 env = dbrutils.scanenv() |
30 # if(len(args)): |
31 patches = dbrpatch.loadpatches(dbrpatch.dbrutils.patchpath()) |
31 # location = args[0] |
32 db = dbrpatch.createpatchedbaseline(baseline,patches) |
32 db = dbrenv.CreateDB(location) |
33 results = dbrpatch.newupdatedb(db,env) |
33 local = dbrenv.DBRLocalEnv(location) |
34 dbrutils.deletefiles(sorted(results['added'])) |
34 results = db.compare(local) |
35 required = set() |
35 local.verify(results.unknown) |
36 required.update(results['removed']) |
36 results2 = db.compare(local) |
37 required.update(results['changed']) |
37 db.update(local, results2.touched) |
38 required.update(results['untestable']) #untestable is going to be a problem... |
38 #cleaning |
39 dbrutils.extractfiles(required, zippath) |
39 dbrutils.deletefiles(sorted(results2.added)) |
40 for name in sorted(patches): |
40 required = results2.changed | results2.removed |
41 dbrutils.extractfromzip(required, re.sub('.txt','.zip',name),'') |
41 dbrutils.extractfiles(required, zippath) |
42 |
42 #do something about the patches here... |
43 env = dbrutils.scanenv() |
43 print 'Need to extract the patches!!!' |
44 results2 = dbrpatch.newupdatedb(db,env) |
44 #scan again...create a new 'local' |
45 |
45 local = dbrenv.DBRLocalEnv(location) |
46 baseline = dbrpatch.updatebaseline(baseline, db) |
46 local.verify(required) |
47 patches = dbrpatch.updatepatches(patches, db) |
47 results3 = db.compare(local) |
48 |
48 db.update(local, results3.touched) |
49 dbrpatch.savepatches(patches) |
49 db.save() |
50 dbrbaseline.writedb(baseline,dbfilename) |
50 results3.printdetail() |
|
51 results3.printsummary() |
51 |
52 |
52 |
53 |
53 |
54 |
54 def run(args): |
|
55 main(args) |
|
56 |
55 |
57 def help(): |
56 def help(): |
58 print "Cleans the current environment" |
57 print "Cleans the current environment" |
59 print "Usage\n\tdbr cleanenv (<baseline_zip_path>)" |
58 print "Usage\n\tdbr cleanenv (<baseline_zip_path>)" |
60 print "\nDefault behaviour presumes baselie zips exist at the root" |
59 print "\nDefault behaviour presumes baselie zips exist at the root" |