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'
37 ' --dir=DIR, -d TO directory\n'
44 sys.stderr.write('untarring ' + fn + '\n')
45 os.system ('gzip --quiet -dc ' + fn + '| tar xf - ')
49 header = 'Generated by make-patch, old = %s, new = %s\n\
53 cd lilypond-source-dir; patch -E -p0 < %s\n\
55 Patches do not contain automatically generated files, \n\
56 i.e. you should rerun configure\n\n'
58 # ugh, how to get rid of .tex files generated by lily?
59 pats = ['core', '*.lsm', 'configure', '*.P', '*.txt', 'feta[0-9][0-9]*.ly', 'feta[0-9][0-9]*.tex', '*.orig', '*.rej', '*bla*', 'x', '*.dvi', '*.aux', '*.log', '*.ps', '*.gif', '*.midi', 'lilypond.spec', 'Makefile.am', 'Makefile.in', 'lexer.cc', 'parser.cc', 'patch-*']
61 def remove_automatic(dirnames):
63 files = files + multiple_find(pats, dirnames)
68 def makepatch(fromdir, todir, patfile_nm):
70 remove_automatic([fromdir, todir])
74 f = open(patfile_nm, 'w')
77 os.path.basename(patfile_nm)))
80 sys.stderr.write('diffing to %s... ' % patfile_nm)
82 print ('diff -urN ../%s . >> %s' % (fromdir, patfile_nm))
83 os.system('diff -urN ../%s . >> %s' % (fromdir, patfile_nm))
84 os.system('gzip -9f %s' % patfile_nm)
87 os.environ['GZIP'] = '-q'
88 sys.stderr.write('This is make-patch version %s\n' % mp_version)
89 (cl_options, files) = getopt.getopt(sys.argv[1:],
90 'hf:o:t:', ['output=', 'help', 'from=', 'to='])
95 for opt in cl_options:
98 if o == '--from' or o == '-f':
99 options.from_version = version_str_to_tuple(a)
101 elif o == '--to' or o == '-t':
102 options.to_version = version_str_to_tuple(a)
104 elif o == '--dir' or o == '-d':
106 elif o== '--help' or o == '-h':
109 elif o == '--output' or o == '-o':
110 outfn = os.path.join(os.getcwd(), a)
115 pn = 'patch-%s' % version_tuple_to_str(options.to_version)
116 outfn = os.path.join(os.getcwd(), pn)
119 prev_cwd = os.getcwd();
121 os.system('rm -rf /tmp/make-patch')
123 os.mkdir ('/tmp/make-patch')
127 fromdir = dirname(options.from_version)
128 todir = dirname(options.to_version)
131 # always true, for now
133 diffdir = '/tmp/make-patch/' + 'lilypond-%s'\
134 % version_tuple_to_str(options.to_version)
136 if from_b != 0 or (from_b == 0 and to_b == 0):
137 os.chdir ('/tmp/make-patch')
138 untar(released_tarball(options.from_version))
142 sys.stderr.write('copying ' + srcdir + ' to ' + diffdir + '\n')
143 os.system('cp -pr %s %s' % (srcdir, diffdir))
146 os.chdir ('/tmp/make-patch')
147 untar(released_tarball(options.to_version))
151 sys.stderr.write('copying ' + srcdir + ' to ' + diffdir + '\n')
152 os.system('cp -pr %s %s' % (srcdir, diffdir))
155 os.system('rm -f *.aux *.dvi *.midi *.log *.ps *.tex *.ly')
156 os.chdir ('/tmp/make-patch')
158 makepatch(fromdir, todir, outfn)
160 os.chdir('/tmp/make-patch')
161 sys.stderr.write('cleaning ... ')
162 os.system('rm -fr %s %s' % (fromdir, todir))
163 sys.stderr.write('\n')
166 if __name__ == '__main__':