Give install real command line options release_0.5
authorPaul Crowley <paul@lshift.net>
Sat, 07 Mar 2009 10:05:14 +0000
changeset 87 535502c18eaa
parent 86 78777f509303
child 88 ae1503386576
Give install real command line options
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 [<destination-prefix>]"
-    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)