def newcreatepatch(name, db1, db2):
    results = newcompare(db1, db2)
    printresults(results)
    for file in results['touched']:
      db1[file]['time'] = db2[file]['time']
    
    patch = dict();
    patch['name'] = name
    patch['time'] = 'now!!!'   
    patch['removed'] = results['removed']
    added = results['added'].keys()
    md5sAdded = dbrutils.generateMD5s(added)
    for file in added:
      results['added'][file]['md5'] = md5sAdded[file]['md5']
    patch['added'] = results['added']
    print "Need to add in the untestable stuff here also!!!"
    patch['changed'] = results['changed']
    patchname = "%spatch_%s" %(dbrutils.patchpath(), name)
  
    createpatchzip(patch, patchname)

    #update the ownership 
    for file in patch['changed']:
        db1[file]['name'] = name

    return db1
def newcomparepatcheddbs(drive1, drive2):
    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)

    results = newcompare(db1, db2)
    printresults(results)
Example #3
0
def newcomparepatcheddbs(drive1, drive2):
    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)

    results = newcompare(db1, db2)
    printresults(results)
Example #4
0
def newcreatepatch(name, db1, db2):
    results = newcompare(db1, db2)
    printresults(results)
    for file in results['touched']:
        db1[file]['time'] = db2[file]['time']

    patch = dict()
    patch['name'] = name
    patch['time'] = 'now!!!'
    patch['removed'] = results['removed']
    added = results['added'].keys()
    md5sAdded = dbrutils.generateMD5s(added)
    for file in added:
        results['added'][file]['md5'] = md5sAdded[file]['md5']
    patch['added'] = results['added']
    print "Need to add in the untestable stuff here also!!!"
    patch['changed'] = results['changed']
    patchname = "%spatch_%s" % (dbrutils.patchpath(), name)

    createpatchzip(patch, patchname)

    #update the ownership
    for file in patch['changed']:
        db1[file]['name'] = name

    return db1
Example #5
0
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
Example #6
0
def run(args):
  if(len(args)):
    patch = args[0]
    if(patch):
      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))
        files = set();
        files.add('*')
        dbrutils.extractfromzip(files,os.path.join(dbrutils.patchpath(),patchname))
        print 'Should probably run checkenv now...'
      else:
        print 'Cannot find patch zip: %s\n' %patch
        help()
    else:
        help()
  else:
   help()
def run(args):
    if len(args):
        patch = args[0]
        if patch:
            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))
                files = set()
                files.add("*")
                dbrutils.extractfromzip(files, os.path.join(dbrutils.patchpath(), patchname))
                print "Should probably run checkenv now..."
            else:
                print "Cannot find patch zip: %s\n" % patch
                help()
        else:
            help()
    else:
        help()
def createpatchzip(patch, patchname):
    patchtext = '%s.txt' % patchname
    patchtext = os.path.join(dbrutils.patchpath(),patchtext)
    
    writepatch(patch, patchtext)    
    files = set()
    files.update(patch['added'])
    files.update(patch['changed'])
    files.add(re.sub('\\\\','',patchtext)) #remove leading slash - Nasty - need to fix the whole EPOCROOT thing.
    
    zipname = '%s.zip' % patchname
    dbrutils.createzip(files, zipname)         
Example #9
0
def createpatchzip(patch, patchname):
    patchtext = '%s.txt' % patchname
    patchtext = os.path.join(dbrutils.patchpath(), patchtext)

    writepatch(patch, patchtext)
    files = set()
    files.update(patch['added'])
    files.update(patch['changed'])
    files.add(
        re.sub('\\\\', '', patchtext)
    )  #remove leading slash - Nasty - need to fix the whole EPOCROOT thing.

    zipname = '%s.zip' % patchname
    dbrutils.createzip(files, zipname)
Example #10
0
def removepatch(patch):
    path = dbrutils.patchpath()
    file = '%s%s%s' %(path,patch,'.txt')
    files = set()
    files.add(file)
    dbrutils.deletefiles(files)
Example #11
0
def listpatches():
    path = dbrutils.patchpath()
    patchfiles = glob.glob('%spatch*.txt' % path)
    print 'Installed patches'
    for file in patchfiles:
      print '\t%s' % re.sub('.txt','',os.path.basename(file))
Example #12
0
def removepatch(patch):
    path = dbrutils.patchpath()
    file = '%s%s%s' % (path, patch, '.txt')
    files = set()
    files.add(file)
    dbrutils.deletefiles(files)
Example #13
0
def listpatches():
    path = dbrutils.patchpath()
    patchfiles = glob.glob('%spatch*.txt' % path)
    print 'Installed patches'
    for file in patchfiles:
        print '\t%s' % re.sub('.txt', '', os.path.basename(file))