equal
deleted
inserted
replaced
3 import sys |
3 import sys |
4 import shutil |
4 import shutil |
5 import os |
5 import os |
6 import pwd |
6 import pwd |
7 import subprocess |
7 import subprocess |
|
8 import optparse |
|
9 |
|
10 oparser = optparse.OptionParser() |
|
11 |
|
12 oparser.add_option("--prefix") |
|
13 oparser.add_option("--root") |
|
14 oparser.set_defaults(root="", prefix="/usr/local") |
|
15 (options, args) = oparser.parse_args() |
|
16 |
|
17 if len(args) > 0: |
|
18 oparser.print_help() |
|
19 sys.exit(-1) |
8 |
20 |
9 # This must be run as root, because it must create an hg user. |
21 # This must be run as root, because it must create an hg user. |
10 # Normally the clean thing to do is let it fail with a permission error |
22 # Normally the clean thing to do is let it fail with a permission error |
11 # if a non-root user tries to run it, but I don't want anyone thinking |
23 # if a non-root user tries to run it, but I don't want anyone thinking |
12 # that they can make it work as non-root by changing install paths. |
24 # that they can make it work as non-root by changing install paths. |
14 |
26 |
15 if os.getgid() != 0: |
27 if os.getgid() != 0: |
16 print >>sys.stderr, "Install must be run as root user" |
28 print >>sys.stderr, "Install must be run as root user" |
17 sys.exit(-1) |
29 sys.exit(-1) |
18 |
30 |
19 if len(sys.argv) > 2: |
31 dest = options.prefix + "/lib/mercurial-server" |
20 print >>sys.stderr, "Usage: install [<destination-prefix>]" |
|
21 sys.exit(-1) |
|
22 if len(sys.argv) == 2: |
|
23 dest = sys.argv[1] + '/lib/mercurial-server' |
|
24 else: |
|
25 dest = '/usr/local/lib/mercurial-server' |
|
26 |
32 |
27 def installFiles(d, *sources): |
33 def installFiles(d, *sources): |
|
34 d = options.root + d |
28 os.makedirs(d) |
35 os.makedirs(d) |
29 for f in sources: |
36 for f in sources: |
30 shutil.copy(f, d) |
37 shutil.copy(f, d) |
31 |
38 |
32 installFiles(dest, |
39 installFiles(dest, |