File: applypatches.py

package info (click to toggle)
jython 2.7.2%2Brepack1-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 62,676 kB
  • sloc: python: 640,908; java: 306,458; xml: 1,984; sh: 522; ansic: 126; makefile: 76
file content (44 lines) | stat: -rwxr-xr-x 1,356 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
"""
This script copies the relevant files from CPythonLib and applies the patches previously
made with genpatches.py. You will probably need to tweak some patches by hand, or delete
them entirely and do the migration for those modules manually.
"""

import os.path
import sys
import shutil


if not os.path.exists('patches'):
    print >>sys.stderr, 'Run genpatches.py first.'
    sys.exit(1)

succeeded = []
failed = []
for dirpath, dirnames, filenames in os.walk('patches'):
    for filename in filenames:
        realfilename = filename[:-6]
        patchpath = os.path.join(dirpath, filename)
        srcpath = os.path.join('CPythonLib', dirpath[8:], realfilename)
        dstpath = srcpath.replace('CPythonLib', 'Lib')
        print '\nCopying %s -> %s' % (srcpath, dstpath) 
        sys.stdout.flush()
        shutil.copyfile(srcpath, dstpath)

        retcode = os.system('patch -p1 -N <%s' % patchpath)
        if retcode != 0:
            failed.append(dstpath)
        else:
            succeeded.append(dstpath)

if succeeded:
    print '\nThe following files were successfully patched:'
    for path in sorted(succeeded):
        print path

if failed:
    print '\nPatching failed for the following files:'
    for path in sorted(failed):
        print path
    print '\nYou will need to migrate these modules manually.'