# HG changeset patch # User Paul Crowley # Date 1236420314 0 # Node ID 535502c18eaad098437e49adea1e26a68e4b6d75 # Parent 78777f5093033a58a6e6be3391d52257519def8d Give install real command line options diff -r 78777f509303 -r 535502c18eaa install --- a/install Sat Mar 07 09:55:01 2009 +0000 +++ b/install Sat Mar 07 10:05:14 2009 +0000 @@ -5,6 +5,18 @@ import os import pwd import subprocess +import optparse + +oparser = optparse.OptionParser() + +oparser.add_option("--prefix") +oparser.add_option("--root") +oparser.set_defaults(root="", prefix="/usr/local") +(options, args) = oparser.parse_args() + +if len(args) > 0: + oparser.print_help() + sys.exit(-1) # This must be run as root, because it must create an hg user. # Normally the clean thing to do is let it fail with a permission error @@ -16,15 +28,10 @@ print >>sys.stderr, "Install must be run as root user" sys.exit(-1) -if len(sys.argv) > 2: - print >>sys.stderr, "Usage: install []" - sys.exit(-1) -if len(sys.argv) == 2: - dest = sys.argv[1] + '/lib/mercurial-server' -else: - dest = '/usr/local/lib/mercurial-server' +dest = options.prefix + "/lib/mercurial-server" def installFiles(d, *sources): + d = options.root + d os.makedirs(d) for f in sources: shutil.copy(f, d)