8 lilypath = os.environ['LILYPOND_SOURCEDIR'] + '/'
10 print 'Please set LILYPOND_SOURCEDIR to the toplevel source, eg LILYPOND_SOURCEDIR=/home/foobar/lilypond-1.2.3/'
13 lilypath = lilypath + '/bin/'
14 sys.path.append(lilypath)
17 from lilypython import *
26 self.to_version = lilydirs.version_tuple()
27 self.from_version = prev_version(self.to_version)
34 'Generate a patch to go to this version.\n'
35 ' --from=FROM, -f FROM old is FROM\n'
36 ' --to=TO, -t TO to version TO\n'
44 sys.stderr.write('untarring ' + fn + '\n')
45 # can't seem to fix errors:
46 # gzip: stdout: Broken pipe
47 # tar: Child returned status 1
48 # os.system ('tar xzf ' + fn)
49 # sys.stderr.write('\n')
50 # ugh, even this does not work, but one error message less :-)
51 os.system ('gzip --quiet -dc ' + fn + '| tar xf - ')
52 # so print soothing message:
53 # sys.stderr.write('make-patch:ugh: Please ignore error: gzip: stdout: Broken pipe\n');
57 header = 'Generated by make-patch, old = %s, new = %s\n\
61 cd lilypond-source-dir; patch -E -p0 < %s\n\
63 Patches do not contain automatically generated files, \n\
64 i.e. you should rerun configure\n\n'
66 pats = ['*.lsm', 'configure', '*.txt', 'lilypond.spec']
67 def remove_automatic(dirnames):
69 files = files + multiple_find(pats, dirnames)
74 def makepatch(fv, tv, patfile_nm):
76 prev_cwd = os.getcwd();
78 os.mkdir ('/tmp/make-patch');
82 os.chdir ('/tmp/make-patch');
83 untar(released_tarball(fv))
84 untar(released_tarball(tv))
85 remove_automatic([dirname(fv), dirname(tv)])
90 patfile_nm = '../patch-%s' % version_tuple_to_str(tv)
92 f = open(patfile_nm, 'w')
94 (version_tuple_to_str(fv), version_tuple_to_str(tv), \
95 os.path.basename(patfile_nm)))
98 sys.stderr.write('diffing to %s... ' % patfile_nm)
99 os.system('diff -urN ../%s . >> %s' % (dirname(fv), patfile_nm))
100 #os.system('gzip -9f %s' % patfile_nm)
101 os.chdir('/tmp/make-patch')
103 sys.stderr.write('cleaning ... ')
104 os.system('rm -fr %s %s' % (dirname(tv), dirname(fv)))
105 sys.stderr.write('\n')
109 os.environ['GZIP'] = '-q'
110 sys.stderr.write('This is make-patch version %s\n' % mp_version)
111 (cl_options, files) = getopt.getopt(sys.argv[1:],
112 'hf:o:t:', ['output=', 'help', 'from=', 'to='])
114 for opt in cl_options:
117 if o == '--from' or o == '-f':
118 options.from_version = version_str_to_tuple(a)
119 elif o == '--to' or o == '-t':
120 options.to_version = version_str_to_tuple(a)
121 elif o== '--help' or o == '-h':
124 elif o == '--output' or o == '-o':
125 outfn = os.path.join(os.getcwd(), a)
130 pn = 'patch-%s' % version_tuple_to_str(options.to_version)
131 outfn = os.path.join(os.getcwd(), pn)
133 makepatch(options.from_version, options.to_version, outfn)
135 if __name__ == '__main__':