2 from lilypython
import *
11 self
.to_version
= lilydirs
.version_tuple()
12 self
.from_version
= prev_version(self
.to_version
)
19 'Generate a patch to go to this version.\n'
20 ' --from=FROM, -f FROM old is FROM\n'
21 ' --to=TO, -t TO to version TO\n'
29 sys
.stderr
.write('untarring ' + fn
)
30 os
.system ('tar xzf ' + fn
)
31 sys
.stderr
.write('\n')
35 header
= 'Generated by make-patch, old = %s, new = %s\n\
39 cd lilypond-source-dir; patch -E -p0 < %s\n\
41 Patches do not contain automatically generated files, \n\
42 i.e. you should rerun configure\n\n'
52 def my_find(patterns
, dir = os
.curdir
):
54 names
= os
.listdir(dir)
57 if name
in (os
.curdir
, os
.pardir
):
59 fullname
= os
.path
.join(dir, name
)
61 if fnmatch
.fnmatch(name
, pat
):
63 if os
.path
.isdir(fullname
) and not os
.path
.islink(fullname
):
65 if fnmatch
.fnmatch(name
, p
):
66 if _debug
: print "skip", `fullname`
69 if _debug
: print "descend into", `fullname`
70 found
= my_find(patterns
, fullname
)
75 def multiple_find(pats
, dirnames
):
79 l
= l
+ my_find(pats
, d
)
82 pats
= ['*.lsm', 'configure', '*.text', 'lilypond.spec']
83 def remove_automatic(dirnames
):
85 files
= files
+ multiple_find(pats
, dirnames
)
90 def makepatch(fv
, tv
, patfile_nm
):
92 prev_cwd
= os
.getcwd();
94 untar(released_tarball(fv
))
95 untar(released_tarball(tv
))
96 remove_automatic([dirname(fv
), dirname(tv
)])
101 patfile_nm
= '../patch-%s' % version_tuple_to_str(tv
)
103 f
= open(patfile_nm
, 'w')
105 (version_tuple_to_str(fv
), version_tuple_to_str(tv
), \
106 os
.path
.basename(patfile_nm
)))
109 sys
.stderr
.write('diffing to %s... ' % patfile_nm
)
110 os
.system('diff -urN ../%s . >> %s' % (dirname(fv
), patfile_nm
))
111 #os.system('gzip -9f %s' % patfile_nm)
114 sys
.stderr
.write('cleaning ... ')
115 os
.system('rm -fr %s %s' % (dirname(tv
), dirname(fv
)))
116 sys
.stderr
.write('\n')
120 sys
.stderr
.write('This is make-patch version %s\n' % mp_version
)
121 (cl_options
, files
) = getopt
.getopt(sys
.argv
[1:],
122 'hf:o:t:', ['output=', 'help', 'from=', 'to='])
124 for opt
in cl_options
:
127 if o
== '--from' or o
== '-f':
128 options
.from_version
= version_str_to_tuple(a
)
129 elif o
== '--to' or o
== '-t':
130 options
.to_version
= version_str_to_tuple(a
)
131 elif o
== '--help' or o
== '-h':
133 elif o
== '--output' or o
== '-o':
134 outfn
= os
.path
.join(os
.getcwd(), a
)
139 pn
= 'patch-%s' % version_tuple_to_str(options
.to_version
)
140 outfn
= os
.path
.join(os
.getcwd(), pn
)
142 makepatch(options
.from_version
, options
.to_version
, outfn
)
144 if __name__
== '__main__':