patchinstall.py: Port to python 3.

This commit is contained in:
Etienne JUVIGNY 2023-02-03 16:07:58 +01:00 committed by Zebediah Figura
parent dde734350d
commit f2f8b949b1

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
# Copyright (C) 2020 Zebediah Figura
#
@ -33,7 +33,7 @@ applied = []
patch_data = ''
def usage():
print '''
print('''
Usage: ./staging/patchinstall.py [options] [patchset ...]
Applies all Wine-Staging patch sets, or each specified patch set plus its
@ -57,10 +57,10 @@ Options:
-r, --rebase-mode alias for --backend=git-am-C1 --no-autoconf
-d, --destdir=<path> install to <path> (defaults to current working directory)
--upstream-commit print the Wine commit hash and exit
'''
''')
def run(*args, **kwargs):
print ' '.join(args[0])
print(' '.join(args[0]))
return subprocess.call(*args, **kwargs)
# return a patch to be shoved in patchlist below
@ -82,7 +82,7 @@ def apply_patch(patch):
return run(['git','-C',winedir,'am','-C1',patch])
elif backend == 'patch':
with open(patch) as f:
print patchdir+'/gitapply.sh <',patch
print(patchdir+'/gitapply.sh <',patch)
return subprocess.call([patchdir+'/gitapply.sh'],stdin=f)
elif backend == 'git-apply':
return run(['git','-C',winedir,'apply','--index',patch])
@ -91,7 +91,7 @@ def run_autoconf(patch):
if not force_autoconf: return
if backend != 'git-am' and backend != 'git-am-C1':
print 'Warning: ignoring --force-autoconf for backend ',backend
print('Warning: ignoring --force-autoconf for backend ',backend)
need_autoreconf = False
need_make_requests = False
@ -138,7 +138,7 @@ def apply_set(patchlist, name):
if patch.endswith('.patch') and patch.startswith('0'):
patch_file = patchdir + '/' + name + '/' + patch
if apply_patch(patch_file):
print 'Failed to apply patch %s/%s' %(name, patch)
print('Failed to apply patch %s/%s' %(name, patch))
return False
run_autoconf(patch_file)
add_patch_data(patch_file)
@ -150,7 +150,7 @@ def add_patchset(patchlist, name):
if os.path.isdir(path):
deps = parse_def_file(name, path + '/definition')
if deps == None:
print 'Error: attempt to apply %s, but it is disabled.' %name
print('Error: attempt to apply %s, but it is disabled.' %name)
sys.exit(1)
patchlist[name] = deps
for dep in deps: add_patchset(patchlist, dep)
@ -174,7 +174,7 @@ def main():
'upstream-commit',
'version'])
except getopt.GetoptError as err:
print str(err)
print(str(err))
sys.exit(2)
for o, a in opts:
@ -183,9 +183,9 @@ def main():
sys.exit(0)
elif o == '-v' or o == '--version':
with open(stagingdir + 'staging/VERSION') as f:
print f.read().rstrip()
print 'wine-staging is distributed under the GNU LGPL 2.1.'
print 'See individual files for copyright information.'
print(f.read().rstrip())
print('wine-staging is distributed under the GNU LGPL 2.1.')
print('See individual files for copyright information.')
sys.exit(0)
elif o == '-r' or o == '--rebase-mode':
no_autoconf = True
@ -211,7 +211,7 @@ def main():
ignore_missing = True
elif o == '--upstream-commit':
with open(stagingdir + 'staging/upstream-commit') as f:
print f.read().rstrip();
print(f.read().rstrip());
sys.exit(0)
for a in args: add_patchset(patchlist, a)
@ -219,11 +219,11 @@ def main():
for p in excluded: del patchlist[p]
if not os.access(winedir + '/tools/make_requests', os.F_OK):
print "Target directory '%s' does not point to a Wine tree." %winedir
print("Target directory '%s' does not point to a Wine tree." %winedir)
sys.exit(1)
if not patchlist:
print 'No patches specified, either use -a or specify one or more patch sets as arguments.'
print('No patches specified, either use -a or specify one or more patch sets as arguments.')
sys.exit(1)
# Check that all of our dependencies exist
@ -232,10 +232,10 @@ def main():
for d in deps:
if d not in patchlist:
if not ignore_missing:
print 'Error: unknown or disabled dependency %s of %s.' %(d,p)
print('Error: unknown or disabled dependency %s of %s.' %(d,p))
sys.exit(1)
else:
print 'Warning: unknown or disabled dependency %s of %s.' %(d,p)
print('Warning: unknown or disabled dependency %s of %s.' %(d,p))
# Now try to apply each patch
for p in sorted(patchlist.keys()):