# source file of the GNU LilyPond music typesetter
#
# download and rebuild latest lilypond or from specified url
-#
+#
+
'''
TODO:
import sys
import __main__
+package_name = 'lilypond'
+program_name = 'build-lily'
+program_version = '@TOPLEVEL_VERSION@'
+
+original_dir = os.getcwd ()
+temp_dir = os.path.join (original_dir, '%s.dir' % program_name)
+errorport = sys.stderr
+keep_temp_dir_p = 0
+verbose_p = 0
+remove_previous_p = 0
+
+url = 'file:/home/ftp/pub/gnu/LilyPond/development/lilypond-*.tar.gz'
+url = 'ftp://appel.lilypond.org/pub/gnu/LilyPond/development/lilypond-*.tar.gz'
+url = 'ftp://ftp.cs.uu.nl/pub/GNU/LilyPond/development/lilypond-*.tar.gz'
+
+
+build_root = os.path.join (os.environ ['HOME'], 'usr', 'src')
+release_dir = build_root + '/releases'
+patch_dir = build_root + '/patches'
+
+
+
try:
import gettext
gettext.bindtextdomain ('lilypond', '@localedir@')
- gettext.textdomain('lilypond')
+ gettext.textdomain ('lilypond')
_ = gettext.gettext
except:
def _ (s):
return s
-sys.path.append ('@datadir@/python')
-import gettext
-gettext.bindtextdomain ('lilypond', '@localedir@')
-gettext.textdomain('lilypond')
-_ = gettext.gettext
-
-
-program_name = 'build-lily'
-package_name = 'lilypond'
-help_summary = _("Fetch and rebuild from latest source package")
-build_root = os.path.join (os.environ ['HOME'], 'usr', 'src')
-release_dir = build_root + '/releases'
-patch_dir = build_root + '/patches'
-notify = 0
-
-build_command = '''
-set -x
-cd %b &&
-[ -d %n-%v ] && exit 1 || true;
-mkdir -p %n-%v
-(
-tar xzf %r/%t &&
-rm -f building &&
-ln -s %n-%v building &&
-cd %n-%v &&
-./configure --prefix=$HOME/usr && make all web
-) >> %n-%v/log.txt 2>&1 &&
-rm -f %n &&
-ln -s %n-%v %n
-'''
+# Attempt to fix problems with limited stack size set by Python!
+# Sets unlimited stack size. Note that the resource module only
+# is available on UNIX.
+try:
+ import resource
+ resource.setrlimit (resource.RLIMIT_STACK, (-1, -1))
+except:
+ pass
-url = 'file:/home/ftp/pub/gnu/LilyPond/development/lilypond-*.tar.gz'
-url = 'ftp://appel.lilypond.org/pub/gnu/LilyPond/development/lilypond-*.tar.gz'
-url = 'ftp://ftp.cs.uu.nl/pub/GNU/LilyPond/development/lilypond-*.tar.gz'
-#arg
-url = 'ftp://ftp.cs.uu.nl/pub/GNU/LilyPond/v1.3/lilypond-*.tar.gz'
+help_summary = _ ("Fetch and rebuild from latest source package")
-remove_previous_p = 0
+option_definitions = [
+ ('DIR', 'b', 'build-root', _ ("unpack and build in DIR [%s]") % build_root),
+ ('COMMAND', 'c', 'command', _ ("execute COMMAND, subtitute:") \
+ + '\n ' + _ ("%b: build root") \
+ + '\n ' + _ ("%n: package name") \
+ + '\n ' + _ ("%r: release directory") \
+ + '\n ' + _ ("%t: tarball") \
+ + '\n ' + _ ("%v: package version") \
+ ),
+ ('', 'h', 'help', _ ("this help")),
+ ('', 'k', 'keep', _ ("keep all output, and name the directory %s") % temp_dir),
+ ('EMAIL', 'n', 'notify', _ ("upon failure notify EMAIL[,EMAIL]")),
+ ('', 'r', 'remove-previous', _ ("remove previous build")),
+ ('', 'V', 'verbose', _ ("verbose")),
+ ('', 'v', 'version', _ ("print version number")),
+ ('URL', 'u', 'url', _ ("fetch and build URL [%s]") % url),
+ ('', 'w', 'warranty', _ ("show warranty and copyright")),
+ ]
-# lily_py.py -- options and stuff
+################################################################
+# lilylib.py -- options and stuff
#
# source file of the GNU LilyPond music typesetter
-# BEGIN Library for these?
-# cut-n-paste from ly2dvi
-
-program_version = '@TOPLEVEL_VERSION@'
-if program_version == '@' + 'TOPLEVEL_VERSION' + '@':
- program_version = '1.3.142'
+import os
+try:
+ import gettext
+ gettext.bindtextdomain ('lilypond', localedir)
+ gettext.textdomain ('lilypond')
+ _ = gettext.gettext
+except:
+ def _ (s):
+ return s
-original_dir = os.getcwd ()
-temp_dir = '%s.dir' % program_name
-keep_temp_dir_p = 0
-verbose_p = 0
+if program_version == '@' + 'TOPLEVEL_VERSION' + '@':
+ program_version = '1.5.17'
def identify ():
sys.stdout.write ('%s (GNU LilyPond) %s\n' % (program_name, program_version))
def warranty ():
identify ()
sys.stdout.write ('\n')
- sys.stdout.write (_ ('Copyright (c) %s by' % ' 2001'))
+ sys.stdout.write (_ ('Copyright (c) %s by' % ' 2001--2002'))
sys.stdout.write ('\n')
sys.stdout.write (' Han-Wen Nienhuys')
sys.stdout.write (' Jan Nieuwenhuizen')
sys.stdout.write ('\n')
def progress (s):
- sys.stderr.write (s + '\n')
+ errorport.write (s + '\n')
def warning (s):
- sys.stderr.write (_ ("warning: ") + s)
- sys.stderr.write ('\n')
-
+ progress (_ ("warning: ") + s)
def error (s):
- sys.stderr.write (_ ("error: ") + s)
- sys.stderr.write ('\n')
+
+
+ '''Report the error S. Exit by raising an exception. Please
+ do not abuse by trying to catch this error. If you do not want
+ a stack trace, write to the output directly.
+
+ RETURN VALUE
+
+ None
+
+ '''
+
+ progress (_ ("error: ") + s)
raise _ ("Exiting ... ")
def getopt_args (opts):
return str
def help ():
- sys.stdout.write (_ ("Usage: %s [OPTION]... FILE") % program_name)
- sys.stdout.write ('\n\n')
- sys.stdout.write (help_summary)
- sys.stdout.write ('\n\n')
- sys.stdout.write (_ ("Options:"))
- sys.stdout.write ('\n')
- sys.stdout.write (options_help_str (option_definitions))
- sys.stdout.write ('\n\n')
- sys.stdout.write (_ ("Report bugs to %s") % 'bug-gnu-music@gnu.org')
- sys.stdout.write ('\n')
- sys.exit (0)
-
-
+ ls = [(_ ("Usage: %s [OPTION]... FILE") % program_name),
+ ('\n\n'),
+ (help_summary),
+ ('\n\n'),
+ (_ ("Options:")),
+ ('\n'),
+ (options_help_str (option_definitions)),
+ ('\n\n'),
+ (_ ("Report bugs to %s") % 'bug-lilypond@gnu.org'),
+ ('\n')]
+ map (sys.stdout.write, ls)
+
def setup_temp ():
+ """
+ Create a temporary directory, and return its name.
+ """
global temp_dir
if not keep_temp_dir_p:
temp_dir = tempfile.mktemp (program_name)
os.mkdir (temp_dir, 0777)
except OSError:
pass
-
-
+
+ return temp_dir
+
+
def system (cmd, ignore_error = 0):
+ """Run CMD. If IGNORE_ERROR is set, don't complain when CMD returns non zero.
+
+ RETURN VALUE
+
+ Exit status of CMD
+ """
+
if verbose_p:
progress (_ ("Invoking `%s\'") % cmd)
st = os.system (cmd)
if st:
- msg = ( _ ("error: ") + _ ("command exited with value %d") % st)
+ name = re.match ('[ \t]*([^ \t]*)', cmd).group (1)
+ msg = name + ': ' + _ ("command exited with value %d") % st
if ignore_error:
- sys.stderr.write (msg + ' ' + _ ("(ignored)") + ' ')
+ warning (msg + ' ' + _ ("(ignored)") + ' ')
else:
error (msg)
def cleanup_temp ():
if not keep_temp_dir_p:
if verbose_p:
- progress (_ ("Cleaning `%s'...") % temp_dir)
- system ('rm -rf %s' % temp_dir)
+ progress (_ ("Cleaning %s...") % temp_dir)
+ shutil.rmtree (temp_dir)
-def set_setting (dict, key, val):
- try:
- val = string.atof (val)
- except ValueError:
- #warning (_ ("invalid value: %s") % `val`)
- pass
+def strip_extension (f, ext):
+ (p, e) = os.path.splitext (f)
+ if e == ext:
+ e = ''
+ return p + e
- try:
- dict[key].append (val)
- except KeyError:
- warning (_ ("no such setting: %s") % `key`)
- dict[key] = [val]
-# END Library
-option_definitions = [
- ('DIR', 'b', 'build-root', _ ("unpack and build in DIR [%s]") % build_root),
- ('COMMAND', 'c', 'command', _ ("execute COMMAND, subtitute:") \
- + '\n ' + _ ("%b: build root") \
- + '\n ' + _ ("%n: package name") \
- + '\n ' + _ ("%r: release directory") \
- + '\n ' + _ ("%t: tarball") \
- + '\n ' + _ ("%v: package version") \
- ),
- ('', 'h', 'help', _ ("this help")),
- ('', 'k', 'keep', _ ("keep all output, and name the directory %s") % temp_dir),
- ('EMAIL', 'n', 'notify', _ ("upon failure notify EMAIL[,EMAIL]")),
- ('', 'r', 'remove-previous', _ ("remove previous build")),
- ('', 'V', 'verbose', _ ("verbose")),
- ('', 'v', 'version', _ ("print version number")),
- ('URL', 'u', 'url', _ ("fetch and build URL [%s]") % url),
- ('', 'w', 'warranty', _ ("show warranty and copyright")),
- ]
+notify = 0
+
+build_command = '''
+set -x
+cd %b &&
+[ -d %n-%v ] && exit 1 || true;
+mkdir -p %n-%v
+(
+tar xzf %r/%t &&
+rm -f building &&
+ln -s %n-%v building &&
+cd %n-%v &&
+./configure --prefix=$HOME/usr && make all web
+) >> %n-%v/log.txt 2>&1 &&
+rm -f %n &&
+ln -s %n-%v %n
+'''
+
def list_file (user, passwd, host, dir, file):
match = []
c = re.sub (i, expand[i], c)
return system (c, 1)
+
+
(sh, long) = getopt_args (__main__.option_definitions)
try:
- (options, files) = getopt.getopt (sys.argv[1:], sh, long)
-except:
+ (options, files) = getopt.getopt(sys.argv[1:], sh, long)
+except getopt.error, s:
+ errorport.write ('\n')
+ errorport.write (_ ("error: ") + _ ("getopt says: `%s\'" % s))
+ errorport.write ('\n')
+ errorport.write ('\n')
help ()
sys.exit (2)
-
+
for opt in options:
o = opt[0]
a = opt[1]
pass
elif o == '--help' or o == '-h':
help ()
+ sys.exit (0)
elif o == '--buid-root' or o == '-b':
build_root = a
elif o == '--command' or o == '-c':
os.chdir (patch_dir)
if not os.path.isfile (latest + '.diff.gz'):
get = get_base + latest + '.diff.gz'
- progress (_ ("Fetching `%'s...") % get)
+ progress (_ ("Fetching `%s'...") % get)
copy_url (get, '.')
if not os.path.isdir (build_root):