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 ' -f, --from=FROM old is FROM\n'
36 ' -d, --dir=DIR diff to (or from) directory DIR\n'
37 ' -r, --release diff against latest release\n'
38 ' -t, --to=TO to version TO\n'
43 sys
.stderr
.write('untarring ' + fn
+ '\n')
44 os
.system ('gzip --quiet -dc ' + fn
+ '| tar xf - ')
48 header
= 'Generated by make-patch, old = %s, new = %s\n\
52 cd lilypond-source-dir; patch -E -p1 < %s\n\
54 Patches do not contain automatically generated files, \n\
55 i.e. you should rerun autoconf and configure\n\n'
57 # ugh, how to get rid of .tex files generated by lily?
58 # pats = ['*.lsm', 'configure', '*.txt', '.dstreamrc', 'lilypond.spec']
59 pats
= ['*.lsm', 'configure', '*.txt', '.dstreamrc', 'lilypond.spec',
60 'AUTHORS', 'INSTALL', 'PATCHES']
62 def remove_automatic(dirnames
):
64 files
= files
+ multiple_find(pats
, dirnames
)
69 def makepatch(fromdir
, todir
, patfile_nm
):
71 remove_automatic([fromdir
, todir
])
75 f
= open(patfile_nm
, 'w')
78 os
.path
.basename(patfile_nm
)))
81 sys
.stderr
.write('diffing to %s... ' % patfile_nm
)
83 print ('diff -urN ../%s . >> %s' % (fromdir
, patfile_nm
))
84 os
.system('diff -urN ../%s . >> %s' % (fromdir
, patfile_nm
))
85 os
.system('gzip --quiet -9f %s' % patfile_nm
)
88 os
.environ
['GZIP'] = '-q'
89 sys
.stderr
.write('This is make-patch version %s\n' % mp_version
)
90 (cl_options
, files
) = getopt
.getopt(sys
.argv
[1:],
91 'd:hf:o:rt:', ['output=', 'help', 'from=', 'to='])
95 # on default, we want to diff tar balls, again :-)
98 for opt
in cl_options
:
101 if o
== '--from' or o
== '-f':
102 options
.from_version
= version_str_to_tuple(a
)
104 elif o
== '--to' or o
== '-t':
105 options
.to_version
= version_str_to_tuple(a
)
107 elif o
== '--dir' or o
== '-d':
110 elif o
== '--help' or o
== '-h':
113 elif o
== '--output' or o
== '-o':
114 outfn
= os
.path
.join(os
.getcwd(), a
)
115 elif o
== '--release' or o
== '-r':
117 # if options.from_version[3]:
118 # options.from_version[3] = '';
119 options
.from_version
= (options
.from_version
[0],
120 options
.from_version
[1], options
.from_version
[2], '');
125 pn
= 'patch-%s' % version_tuple_to_str(options
.to_version
)
126 outfn
= os
.path
.join(os
.getcwd(), pn
)
129 prev_cwd
= os
.getcwd();
131 os
.system('rm -rf /tmp/make-patch')
133 os
.mkdir ('/tmp/make-patch')
137 fromdir
= dirname(options
.from_version
)
138 todir
= dirname(options
.to_version
)
142 diffdir
= '/tmp/make-patch/' + 'lilypond-%s'\
143 % version_tuple_to_str(options
.to_version
)
145 if from_b
!= 0 or (from_b
== 0 and to_b
== 0):
146 os
.chdir ('/tmp/make-patch')
147 untar(released_tarball(options
.from_version
))
151 sys
.stderr
.write('copying ' + srcdir
+ ' to ' + diffdir
+ '\n')
152 # os.system('cp -pr %s %s' % (srcdir, diffdir))
153 os
.system('mkdir -p %s '% (diffdir
))
155 os
.system('tar cf - --exclude out . | tar -xf - -C %s'
159 os
.chdir ('/tmp/make-patch')
160 untar(released_tarball(options
.to_version
))
164 sys
.stderr
.write('copying ' + srcdir
+ ' to ' + diffdir
+ '\n')
165 os
.system('mkdir -p %s '% (diffdir
))
166 # os.system('cp -pr %s %s' (srcdir, diffdir))%
168 os
.system('tar -cf - --exclude out . | tar -xf - -C %s '
171 os
.chdir('/tmp/make-patch')
173 # os.system('rm -f *.aux *.dvi *.midi *.log *.ps *.tex *.ly')
174 os
.chdir ('/tmp/make-patch')
176 makepatch(fromdir
, todir
, outfn
)
178 os
.chdir('/tmp/make-patch')
179 sys
.stderr
.write('cleaning ... ')
180 os
.system('rm -fr %s %s' % (fromdir
, todir
))
181 sys
.stderr
.write('\n')
184 if __name__
== '__main__':