DBRTools - initial version that will diff against a packed release. Also did minor cleanup. Probably caused some regressions.
--- a/dbrtools/dbr/checkenv.py Sat Mar 13 18:56:12 2010 +0000
+++ b/dbrtools/dbr/checkenv.py Mon Mar 15 16:57:00 2010 +0000
@@ -16,7 +16,6 @@
import dbrbaseline
import dbrpatch
import dbrutils
-import glob
import os.path
@@ -34,17 +33,9 @@
dbrpatch.savepatches(patches)
else:
- baseline = createdb()
+ baseline = dbrbaseline.createdb()
dbrbaseline.writedb(baseline,dbfilename)
-def createdb():
- print 'creating db...Move CreateDB into dbrutils!!!'
- env = dbrutils.scanenv()
- hashes = glob.glob(os.path.join(dbrutils.patchpath(),'*.md5'))
- for file in hashes:
- print 'Reading: %s\n' % file
- dbrutils.gethashes(env, file)
- return env
def run(args):
main()
--- a/dbrtools/dbr/cleanenv.py Sat Mar 13 18:56:12 2010 +0000
+++ b/dbrtools/dbr/cleanenv.py Mon Mar 15 16:57:00 2010 +0000
@@ -38,7 +38,7 @@
required.update(results['untestable']) #untestable is going to be a problem...
dbrutils.extractfiles(required, zippath)
for name in sorted(patches):
- dbrutils.extractfromzip(required, re.sub('.txt','.zip',name))
+ dbrutils.extractfromzip(required, re.sub('.txt','.zip',name),'')
env = dbrutils.scanenv()
results2 = dbrpatch.newupdatedb(db,env)
--- a/dbrtools/dbr/dbrbaseline.py Sat Mar 13 18:56:12 2010 +0000
+++ b/dbrtools/dbr/dbrbaseline.py Mon Mar 15 16:57:00 2010 +0000
@@ -18,6 +18,9 @@
import re
import os
import string
+import glob
+import tempfile
+import shutil
from os.path import join, isfile, stat
from stat import *
import dbrutils
@@ -120,3 +123,34 @@
for file in sorted(touched):
print 'Updating timestamp for: ',file
db1[file]['time'] = db2[file]['time']
+
+def createdb():
+ print 'creating db...Move CreateDB into dbrutils!!!'
+ env = dbrutils.scanenv()
+ hashes = glob.glob(os.path.join(dbrutils.patchpath(),'*.md5'))
+ for file in hashes:
+ print 'Reading: %s\n' % file
+ dbrutils.gethashes(env, file, False)
+ return env
+
+
+def readzippeddb(drive):
+ env = dict()
+ #Note that this is really crude. I'm seeing if it'll work before cleaning things up...
+ #see if we have a build_md5.zip file
+ md5zip = os.path.join(drive,'build_md5.zip')
+ temp_dir = tempfile.mkdtemp()
+ print temp_dir
+ if(os.path.exists(md5zip)):
+ files = set();
+ files.add('*')
+ dbrutils.extractfromzip(files,md5zip,temp_dir)
+ globsearch = os.path.join(temp_dir, os.path.join(dbrutils.patch_path_internal(),'*.md5'))
+ print globsearch
+ hashes = glob.glob(globsearch)
+ for file in hashes:
+ print 'Reading: %s\n' % file
+ dbrutils.gethashes(env, file, True)
+ shutil.rmtree(temp_dir)
+ return env
+
--- a/dbrtools/dbr/dbrpatch.py Sat Mar 13 18:56:12 2010 +0000
+++ b/dbrtools/dbr/dbrpatch.py Mon Mar 15 16:57:00 2010 +0000
@@ -145,20 +145,22 @@
envdbroot = dbrutils.defaultdb()
print "MattD: should move this function to a better location..."
print 'Comparing %s with %s' % (drive2,drive1)
- print 'Loading %s' % drive1
- baseline1 = dbrbaseline.readdb('%s%s' %(drive1,envdbroot))
- patches1 = loadpatches('%s/%s' %(drive1,dbrutils.patchpath()))
- db1 = createpatchedbaseline(baseline1,patches1)
- print 'Loading %s' % drive2
- baseline2 = dbrbaseline.readdb('%s%s' %(drive2,envdbroot))
- patches2 = loadpatches('%s/%s' %(drive2,dbrutils.patchpath()))
- db2 = createpatchedbaseline(baseline2,patches2)
-
+ db1 = loadpatcheddb(drive1)
+ db2 = loadpatcheddb(drive2)
+
results = newcompare(db1, db2)
printresults(results)
-
+def loadpatcheddb(drive):
+ envdbroot = dbrutils.defaultdb()
+ print 'Loading %s' % drive
+ baseline = dbrbaseline.readdb('%s%s' %(drive,envdbroot))
+ if(len(baseline) > 0):
+ patches = loadpatches('%s/%s' %(drive,dbrutils.patchpath()))
+ return createpatchedbaseline(baseline,patches)
+ else:
+ return dbrbaseline.readzippeddb(drive)
def createpatchzip(patch, patchname):
patchtext = '%s.txt' % patchname
@@ -192,7 +194,7 @@
if(file in patches[patch]['added']):
mod = 'added'
if(file in patches[patch]['changed']):
- mod = 'changed'
+ mod = 'changed'
if(mod):
if (patches[patch][mod][file]['time'] != db[file]['time']):
patches[patch][mod][file]['time'] = db[file]['time']
--- a/dbrtools/dbr/dbrutils.py Sat Mar 13 18:56:12 2010 +0000
+++ b/dbrtools/dbr/dbrutils.py Mon Mar 15 16:57:00 2010 +0000
@@ -68,13 +68,13 @@
def extractfiles(files, path):
zips = glob.glob(os.path.join(path, '*.zip'))
for name in zips:
- extractfromzip(files, name)
+ extractfromzip(files, name,'')
-def extractfromzip(files, name):
+def extractfromzip(files, name, location):
tmpfilename = os.tmpnam( )
print tmpfilename
- os.chdir(epocroot())
+ os.chdir(os.path.join(epocroot(),location))
f = open(tmpfilename,'w')
for file in sorted(files):
str = '%s%s' % (file,'\n')
@@ -115,13 +115,13 @@
if(exeresult):
sys.exit('Fatal error executing: %s\nReported error: %s' % (exestr,os.strerror(exeresult)))
else:
- db = gethashes(db,outputfile)
+ db = gethashes(db,outputfile, False)
os.unlink(outputfile)
os.unlink(tmpfilename)
return db
# Brittle and nasty!!!
-def gethashes(db,md5filename):
+def gethashes(db, md5filename, create):
os.chdir(epocroot())
# print 'trying to open %s' % md5filename
file = open(md5filename,'r')
@@ -136,9 +136,16 @@
if(res):
filename = "%s%s" % (root,res.group(1))
filename = string.lower(fixpath.sub('/',leadingslash.sub('',filename)))
-# print "found %s" % filename
- if(filename in db):
- db[filename]['md5'] = res.group(3)
+# print "found %s" % filename
+ if(create):
+ entry = dict()
+ entry['time'] = 'xxx'
+ entry['size'] = 'xxx'
+ entry['md5'] = res.group(3)
+ db[filename] = entry
+ else:
+ if(filename in db):
+ db[filename]['md5'] = res.group(3)
else:
res = dirparse.match(line)
--- a/dbrtools/dbr/installpatch.py Sat Mar 13 18:56:12 2010 +0000
+++ b/dbrtools/dbr/installpatch.py Mon Mar 15 16:57:00 2010 +0000
@@ -15,7 +15,7 @@
import sys
import os.path
-#import shutils
+import shutil
import dbrutils
@@ -27,10 +27,10 @@
if(os.path.exists(patch)):
patchname = os.path.basename(patch)
if(not os.path.exists(os.path.join(dbrutils.patchpath(),patchname))):
- shutils.copyfile(patch, os.path.join(dbrutils.patchpath(),patchname))
+ shutil.copyfile(patch, os.path.join(dbrutils.patchpath(),patchname))
files = set();
files.add('*')
- dbrutils.extractfromzip(files,os.path.join(dbrutils.patchpath(),patchname))
+ dbrutils.extractfromzip(files,os.path.join(dbrutils.patchpath(),patchname),'')
print 'Should probably run checkenv now...'
else:
print 'Cannot find patch zip: %s\n' %patch