From c45c01449e70fbf947c47f213d3ec9e83355e7e3 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Mon, 26 Nov 2018 18:31:19 -0600 Subject: [PATCH] staging: New rebase script. Got tired of finding bugs in the old one and being completely confused by its code, so here is a new one. It doesn't have a fancy progress bar, but at least it actually tells you what patches break. --- staging/newupdate.py | 94 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100755 staging/newupdate.py diff --git a/staging/newupdate.py b/staging/newupdate.py new file mode 100755 index 00000000..103876d7 --- /dev/null +++ b/staging/newupdate.py @@ -0,0 +1,94 @@ +#!/usr/bin/python2 + +import getopt, os, subprocess, sys + +winedir = './staging/wine/' +patchdir = os.path.abspath('./patches/') +applied = [] + +def usage(): + print 'newupdate.py - new script to rebase patches' + print 'usage: ./staging/newupdate.py' + print 'Applies every patch to a Wine tree. On failure, prints the name of' + print 'the patch that failed to apply and cleans up the index. On success,' + print 'leaves every patch applied, and then runs autoreconf -f and' + print 'tools/make_requests to prepare for a build.' + print 'Note: this program must be used on a clean git tree (empty index).' + print 'This program does not update patchinstall.sh; you will need to run' + print './staging/patchupdate.py --skip-bugs --skip-checks' + print 'to do that.' + +# return a patch to be shoved in patchlist below +def parse_def_file(name, path): + deps = [] + if os.path.exists(path): + with open(path) as z: + for l in z.readlines(): + if l.lower().startswith('depends: '): + deps.append(l.split(' ')[1].strip()) + elif l.lower().strip() == 'disabled: true': + return None + return deps + +def apply_set(patchlist, name): + if name in applied: + return True + for dep in patchlist[name]: + if not apply_set(patchlist, dep): + return False + print 'Applying',name + for patch in sorted(os.listdir(patchdir+'/'+name)): + if patch.endswith('.patch') and subprocess.call(['git','-C',winedir,'apply','--index',patchdir+'/'+name+'/'+patch]): + print 'Failed to apply patch %s/%s' %(name, patch) + return False + applied.append(name) + return True + +def main(): + try: + opts, args = getopt.getopt(sys.argv[1:], 'h', ['help']) + except getopt.GetoptError as err: + print str(err) + sys.exit(2) + + for o, a in opts: + if o == '-h': + usage() + sys.exit(0) + + # Build a list of patches + # key is patch name, value is list of deps + # disabled patches are not included + patchlist = {} + + for name in os.listdir(patchdir): + path = patchdir + '/' + name + if not os.path.isdir(path): continue + deps = parse_def_file(name, path + '/definition') + if deps != None: # it's not disabled + patchlist[name] = deps + + # Check that all of our dependencies exist + for p in patchlist: + deps = patchlist[p] + for d in deps: + if d not in patchlist: + print 'Error: unknown or disabled dependency %s of %s.' %(d,p) + + # Now try to apply each patch + for p in sorted(patchlist.keys()): + # Try to apply it + if not apply_set(patchlist, p): + # clean up + subprocess.call(['git','-C',winedir,'reset','--hard','HEAD','--quiet']) + sys.exit(1) + + # we successfully applied everything, autogen some files so we can build + print 'Calling autoreconf -f...' + subprocess.call(['autoreconf','-f'],cwd=winedir) + print 'Calling tools/make_requests...' + subprocess.call(['./tools/make_requests'],cwd=winedir) + sys.exit(0) + +if __name__ == '__main__': + main() \ No newline at end of file