#!/bin/env python # vi:set tabstop=4 shiftwidth=4 expandtab: # Author: Caolan McNamara # Usage: e.g. ooomapstack backtrace # Takes an ooo-build section name and makes a single patch # from it's contents import sys, os cvsbase = 'cvs -d:pserver:anonymous@anoncvs.gnome.org:/cvs/gnome checkout -p ' def extract(patchpath, patchname): found = False for entry in patchpath: cmd = cvsbase + entry + '/' + patchname file = os.popen(cmd) data = file.read() if len(data) != 0: sys.stdout.write(data) ret = file.close() if ret == None: found = True patchpath.remove(entry) patchpath.insert(0, entry) break; return found if len(sys.argv) < 2: print >> sys.stderr, 'Usage: ooobuildextractsection section [tag]' print >> sys.stderr, 'e.g. ooobuildextractsection VBAObjects ooo-build-2-0-3' else: if len(sys.argv) > 2: cvsbase = cvsbase + "-r" + sys.argv[2] cvsbase = cvsbase + " ooo-build/patches/src680/" file = os.popen(cvsbase + "apply") insection = False patchpath = [] while 1: line = file.readline() if line == '': break line = line[:-1] if line == '': continue if line.split('=')[0] == 'PATCHPATH': patchs = line.split('=')[1] patchpath = patchs.split(':') if line[0] == '[' and line[len(line)-1] == ']': section = line[1:len(line)-1] section = section.strip() if section == sys.argv[1]: insection = True else: insection = False elif insection == True: if line[0] == '#': continue elif line.split()[0] == 'SectionOwner': continue patch = line.split(',')[0] if (extract(patchpath, patch) == False): print >> sys.stderr, "Failure on", patch sys.exit(-1); elif sys.argv[1] == 'VBAObjects' and (line[0:4] == 'vba-' or line[0:6] == 'sc-r1c1'): patch = line.split(',')[0] if (extract(patchpath, patch) == False): print >> sys.stderr, "Failure on", patch sys.exit(-1); file.close()