dbrtools/dbr/cleanenv.py
author MattD <mattd@symbian.org>
Wed, 17 Mar 2010 13:34:22 +0000
changeset 206 2fd92922bf5c
parent 203 e274d29c8bc9
child 213 6272bdcb6221
permissions -rw-r--r--
DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
206
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
     1
# Copyright (c) 2009-2010 Symbian Foundation Ltd
179
eab8a264a833 Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff changeset
     2
# This component and the accompanying materials are made available
eab8a264a833 Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff changeset
     3
# under the terms of the License "Eclipse Public License v1.0"
eab8a264a833 Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff changeset
     4
# which accompanies this distribution, and is available
eab8a264a833 Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff changeset
     5
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
eab8a264a833 Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff changeset
     6
#
eab8a264a833 Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff changeset
     7
# Initial Contributors:
eab8a264a833 Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff changeset
     8
# Symbian Foundation Ltd - initial contribution.
eab8a264a833 Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff changeset
     9
#
eab8a264a833 Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff changeset
    10
# Contributors:
eab8a264a833 Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff changeset
    11
# mattd <mattd@symbian.org>
eab8a264a833 Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff changeset
    12
#
eab8a264a833 Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff changeset
    13
# Description:
eab8a264a833 Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff changeset
    14
# DBR cleanenv - cleans your environment
eab8a264a833 Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff changeset
    15
206
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
    16
179
eab8a264a833 Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff changeset
    17
import dbrutils
206
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
    18
import dbrenv
179
eab8a264a833 Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff changeset
    19
eab8a264a833 Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff changeset
    20
import re #temporary for dealing with patches
eab8a264a833 Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff changeset
    21
206
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
    22
def run(args):  
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
    23
  zippath = '/'
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
    24
  if(len(args)):
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
    25
    zippath = args[0]
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
    26
  #This block is a cut'n'paste from checkenv...we call call that instead... 
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
    27
      
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
    28
  location = '/'
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
    29
#needs a fix to scanenv for this to work...  
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
    30
#  if(len(args)):
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
    31
#    location = args[0]
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
    32
  db = dbrenv.CreateDB(location)
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
    33
  local = dbrenv.DBRLocalEnv(location)
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
    34
  results = db.compare(local)
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
    35
  local.verify(results.unknown)
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
    36
  results2 = db.compare(local)
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
    37
  db.update(local, results2.touched)
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
    38
  #cleaning
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
    39
  dbrutils.deletefiles(sorted(results2.added))
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
    40
  required = results2.changed | results2.removed
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
    41
  dbrutils.extractfiles(required, zippath)
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
    42
  #do something about the patches here...
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
    43
  print 'Need to extract the patches!!!'  
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
    44
  #scan again...create a new 'local'   
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
    45
  local = dbrenv.DBRLocalEnv(location)
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
    46
  local.verify(required)
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
    47
  results3 = db.compare(local)
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
    48
  db.update(local, results3.touched)
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
    49
  db.save()
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
    50
  results3.printdetail()
2fd92922bf5c DBRTools - initial version of cleanenv using new structure. Works ok apart from cleaning patches, which isn't in this version.
MattD <mattd@symbian.org>
parents: 203
diff changeset
    51
  results3.printsummary()  
203
e274d29c8bc9 Initial version of code cleanup. Now have classes for the environments. checkenv and diffenv updated to use it (although there are minor changes to the paths).
MattD <mattd@symbian.org>
parents: 200
diff changeset
    52
        
e274d29c8bc9 Initial version of code cleanup. Now have classes for the environments. checkenv and diffenv updated to use it (although there are minor changes to the paths).
MattD <mattd@symbian.org>
parents: 200
diff changeset
    53
    
179
eab8a264a833 Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff changeset
    54
eab8a264a833 Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff changeset
    55
eab8a264a833 Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff changeset
    56
def help():
eab8a264a833 Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff changeset
    57
  print "Cleans the current environment"
eab8a264a833 Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff changeset
    58
  print "Usage\n\tdbr cleanenv (<baseline_zip_path>)"
eab8a264a833 Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff changeset
    59
  print "\nDefault behaviour presumes baselie zips exist at the root"
eab8a264a833 Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff changeset
    60