author | Shawn Walker <srw@sun.com> |
Tue, 23 Feb 2010 14:18:31 -0600 | |
changeset 1779 | b80275b45b18 |
parent 1672 | 3a71439a03f3 |
child 1836 | 33bccd66b8e2 |
permissions | -rwxr-xr-x |
1516
8c950a3b4171
10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents:
1477
diff
changeset
|
1 |
#!/usr/bin/python2.6 |
20
e5e53bc1c4d1
Cleaned up the build and install process. Turn the pkg directory into a
Danek Duvall <danek.duvall@sun.com>
parents:
14
diff
changeset
|
2 |
# |
e5e53bc1c4d1
Cleaned up the build and install process. Turn the pkg directory into a
Danek Duvall <danek.duvall@sun.com>
parents:
14
diff
changeset
|
3 |
# CDDL HEADER START |
e5e53bc1c4d1
Cleaned up the build and install process. Turn the pkg directory into a
Danek Duvall <danek.duvall@sun.com>
parents:
14
diff
changeset
|
4 |
# |
e5e53bc1c4d1
Cleaned up the build and install process. Turn the pkg directory into a
Danek Duvall <danek.duvall@sun.com>
parents:
14
diff
changeset
|
5 |
# The contents of this file are subject to the terms of the |
e5e53bc1c4d1
Cleaned up the build and install process. Turn the pkg directory into a
Danek Duvall <danek.duvall@sun.com>
parents:
14
diff
changeset
|
6 |
# Common Development and Distribution License (the "License"). |
e5e53bc1c4d1
Cleaned up the build and install process. Turn the pkg directory into a
Danek Duvall <danek.duvall@sun.com>
parents:
14
diff
changeset
|
7 |
# You may not use this file except in compliance with the License. |
e5e53bc1c4d1
Cleaned up the build and install process. Turn the pkg directory into a
Danek Duvall <danek.duvall@sun.com>
parents:
14
diff
changeset
|
8 |
# |
e5e53bc1c4d1
Cleaned up the build and install process. Turn the pkg directory into a
Danek Duvall <danek.duvall@sun.com>
parents:
14
diff
changeset
|
9 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
e5e53bc1c4d1
Cleaned up the build and install process. Turn the pkg directory into a
Danek Duvall <danek.duvall@sun.com>
parents:
14
diff
changeset
|
10 |
# or http://www.opensolaris.org/os/licensing. |
e5e53bc1c4d1
Cleaned up the build and install process. Turn the pkg directory into a
Danek Duvall <danek.duvall@sun.com>
parents:
14
diff
changeset
|
11 |
# See the License for the specific language governing permissions |
e5e53bc1c4d1
Cleaned up the build and install process. Turn the pkg directory into a
Danek Duvall <danek.duvall@sun.com>
parents:
14
diff
changeset
|
12 |
# and limitations under the License. |
e5e53bc1c4d1
Cleaned up the build and install process. Turn the pkg directory into a
Danek Duvall <danek.duvall@sun.com>
parents:
14
diff
changeset
|
13 |
# |
e5e53bc1c4d1
Cleaned up the build and install process. Turn the pkg directory into a
Danek Duvall <danek.duvall@sun.com>
parents:
14
diff
changeset
|
14 |
# When distributing Covered Code, include this CDDL HEADER in each |
e5e53bc1c4d1
Cleaned up the build and install process. Turn the pkg directory into a
Danek Duvall <danek.duvall@sun.com>
parents:
14
diff
changeset
|
15 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
e5e53bc1c4d1
Cleaned up the build and install process. Turn the pkg directory into a
Danek Duvall <danek.duvall@sun.com>
parents:
14
diff
changeset
|
16 |
# If applicable, add the following below this CDDL HEADER, with the |
e5e53bc1c4d1
Cleaned up the build and install process. Turn the pkg directory into a
Danek Duvall <danek.duvall@sun.com>
parents:
14
diff
changeset
|
17 |
# fields enclosed by brackets "[]" replaced with your own identifying |
e5e53bc1c4d1
Cleaned up the build and install process. Turn the pkg directory into a
Danek Duvall <danek.duvall@sun.com>
parents:
14
diff
changeset
|
18 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
e5e53bc1c4d1
Cleaned up the build and install process. Turn the pkg directory into a
Danek Duvall <danek.duvall@sun.com>
parents:
14
diff
changeset
|
19 |
# |
e5e53bc1c4d1
Cleaned up the build and install process. Turn the pkg directory into a
Danek Duvall <danek.duvall@sun.com>
parents:
14
diff
changeset
|
20 |
# CDDL HEADER END |
e5e53bc1c4d1
Cleaned up the build and install process. Turn the pkg directory into a
Danek Duvall <danek.duvall@sun.com>
parents:
14
diff
changeset
|
21 |
# |
1672
3a71439a03f3
13021 file manager exceptions should be api exceptions
Shawn Walker <srw@sun.com>
parents:
1633
diff
changeset
|
22 |
# Copyright 2010 Sun Microsystems, Inc. All rights reserved. |
20
e5e53bc1c4d1
Cleaned up the build and install process. Turn the pkg directory into a
Danek Duvall <danek.duvall@sun.com>
parents:
14
diff
changeset
|
23 |
# Use is subject to license terms. |
e5e53bc1c4d1
Cleaned up the build and install process. Turn the pkg directory into a
Danek Duvall <danek.duvall@sun.com>
parents:
14
diff
changeset
|
24 |
# |
e5e53bc1c4d1
Cleaned up the build and install process. Turn the pkg directory into a
Danek Duvall <danek.duvall@sun.com>
parents:
14
diff
changeset
|
25 |
|
22
379f0f6809ff
pkgsend open, pkgsend add file, pkgsend close; Transaction object
"Stephen Hahn <sch@sun.com>"
parents:
21
diff
changeset
|
26 |
# pkg.depotd - package repository daemon |
0
f08899079fb4
implemented open, add (file case), close for transactions
"Stephen Hahn <sch@sun.com>"
parents:
diff
changeset
|
27 |
|
50 | 28 |
# XXX The prototype pkg.depotd combines both the version management server that |
29 |
# answers to pkgsend(1) sessions and the HTTP file server that answers to the |
|
30 |
# various GET operations that a pkg(1) client makes. This split is expected to |
|
31 |
# be made more explicit, by constraining the pkg(1) operations such that they |
|
32 |
# can be served as a typical HTTP/HTTPS session. Thus, pkg.depotd will reduce |
|
33 |
# to a special purpose HTTP/HTTPS server explicitly for the version management |
|
34 |
# operations, and must manipulate the various state files--catalogs, in |
|
35 |
# particular--such that the pkg(1) pull client can operately accurately with |
|
36 |
# only a basic HTTP/HTTPS server in place. |
|
37 |
||
38 |
# XXX Although we pushed the evaluation of next-version, etc. to the pull |
|
39 |
# client, we should probably provide a query API to do same on the server, for |
|
40 |
# dumb clients (like a notification service). |
|
41 |
||
382
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
42 |
# The default repository path. |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
43 |
REPO_PATH_DEFAULT = "/var/pkg/repo" |
589
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
44 |
# The default path for static and other web content. |
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
45 |
CONTENT_PATH_DEFAULT = "/usr/share/lib/pkg" |
965
6efb5042a707
7552 depot aborts connection for add operations with payload greater than 100MB
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
916
diff
changeset
|
46 |
# cherrypy has a max_request_body_size parameter that determines whether the |
6efb5042a707
7552 depot aborts connection for add operations with payload greater than 100MB
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
916
diff
changeset
|
47 |
# server should abort requests with REQUEST_ENTITY_TOO_LARGE when the request |
6efb5042a707
7552 depot aborts connection for add operations with payload greater than 100MB
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
916
diff
changeset
|
48 |
# body is larger than the specified size (in bytes). The maximum size supported |
6efb5042a707
7552 depot aborts connection for add operations with payload greater than 100MB
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
916
diff
changeset
|
49 |
# by cherrypy is 2048 * 1024 * 1024 - 1 (just short of 2048MB), but the default |
6efb5042a707
7552 depot aborts connection for add operations with payload greater than 100MB
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
916
diff
changeset
|
50 |
# here is purposefully conservative. |
6efb5042a707
7552 depot aborts connection for add operations with payload greater than 100MB
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
916
diff
changeset
|
51 |
MAX_REQUEST_BODY_SIZE = 128 * 1024 * 1024 |
812
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
52 |
# The default port(s) to serve data from. |
382
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
53 |
PORT_DEFAULT = 80 |
812
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
54 |
SSL_PORT_DEFAULT = 443 |
382
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
55 |
# The minimum number of threads allowed. |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
56 |
THREADS_MIN = 1 |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
57 |
# The default number of threads to start. |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
58 |
THREADS_DEFAULT = 10 |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
59 |
# The maximum number of threads that can be started. |
1433
ad0aeca5a88a
11693 depot max threads should be increased
Shawn Walker <srw@sun.com>
parents:
1431
diff
changeset
|
60 |
THREADS_MAX = 500 |
382
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
61 |
# The default server socket timeout in seconds. We want this to be longer than |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
62 |
# the normal default of 10 seconds to accommodate clients with poor quality |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
63 |
# connections. |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
64 |
SOCKET_TIMEOUT_DEFAULT = 60 |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
65 |
# Whether modify operations should be allowed. |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
66 |
READONLY_DEFAULT = False |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
67 |
# Whether the repository catalog should be rebuilt on startup. |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
68 |
REBUILD_DEFAULT = False |
429
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
428
diff
changeset
|
69 |
# Whether the indexes should be rebuilt |
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
428
diff
changeset
|
70 |
REINDEX_DEFAULT = False |
461
37cf3ac75e37
1018 actions with payloads should include all sizes and hashes
johansen <johansen@sun.com>
parents:
452
diff
changeset
|
71 |
# Not in mirror mode by default |
37cf3ac75e37
1018 actions with payloads should include all sizes and hashes
johansen <johansen@sun.com>
parents:
452
diff
changeset
|
72 |
MIRROR_DEFAULT = False |
382
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
73 |
|
26 | 74 |
import getopt |
689
1cb7154e1592
4489 depot traceback for info operation due to changeset 660
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
617
diff
changeset
|
75 |
import gettext |
1cb7154e1592
4489 depot traceback for info operation due to changeset 660
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
617
diff
changeset
|
76 |
import locale |
466
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
77 |
import logging |
0
f08899079fb4
implemented open, add (file case), close for transactions
"Stephen Hahn <sch@sun.com>"
parents:
diff
changeset
|
78 |
import os |
468
20250d58c2ab
2309 pkg.depotd fails when -d argument is a relative pathname
Tom Mueller <Tom.Mueller@sun.com>
parents:
466
diff
changeset
|
79 |
import os.path |
812
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
80 |
import OpenSSL.crypto as crypto |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
81 |
import subprocess |
52
d7c452ef7ae1
Sanitize getopt exception handling
Danek Duvall <danek.duvall@sun.com>
parents:
50
diff
changeset
|
82 |
import sys |
812
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
83 |
import tempfile |
451
74f1fe85fe2d
1324 RSS / Atom feeds of repository updates
Shawn Walker <shawn.walker@sun.com>
parents:
445
diff
changeset
|
84 |
import urlparse |
0
f08899079fb4
implemented open, add (file case), close for transactions
"Stephen Hahn <sch@sun.com>"
parents:
diff
changeset
|
85 |
|
382
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
86 |
try: |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
87 |
import cherrypy |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
88 |
version = cherrypy.__version__.split('.') |
452
01f53c6381af
2714 image-update failure during update phase
Shawn Walker <shawn.walker@sun.com>
parents:
451
diff
changeset
|
89 |
if map(int, version) < [3, 1, 0]: |
382
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
90 |
raise ImportError |
452
01f53c6381af
2714 image-update failure during update phase
Shawn Walker <shawn.walker@sun.com>
parents:
451
diff
changeset
|
91 |
elif map(int, version) >= [3, 2, 0]: |
382
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
92 |
raise ImportError |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
93 |
except ImportError: |
751
b68bf0bec185
5466 depot should give a clear failure message if unable to import mako templates
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
742
diff
changeset
|
94 |
print >> sys.stderr, """cherrypy 3.1.0 or greater (but less than """ \ |
b68bf0bec185
5466 depot should give a clear failure message if unable to import mako templates
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
742
diff
changeset
|
95 |
"""3.2.0) is required to use this program.""" |
382
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
96 |
sys.exit(2) |
22
379f0f6809ff
pkgsend open, pkgsend add file, pkgsend close; Transaction object
"Stephen Hahn <sch@sun.com>"
parents:
21
diff
changeset
|
97 |
|
812
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
98 |
from pkg.misc import port_available, msg, emsg, setlocale |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
99 |
import pkg.client.api_errors as api_errors |
1477
716ae8c79b11
12580 depot default to an indexer sort file max size of "None"
John.Sonnenschein@Sun.COM
parents:
1475
diff
changeset
|
100 |
import pkg.indexer as indexer |
873
b95d76c53b5e
2691 ability to publish packages to local disk repository
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
858
diff
changeset
|
101 |
import pkg.portable.util as os_util |
812
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
102 |
import pkg.search_errors as search_errors |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
103 |
import pkg.server.depot as ds |
873
b95d76c53b5e
2691 ability to publish packages to local disk repository
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
858
diff
changeset
|
104 |
import pkg.server.depotresponse as dr |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
105 |
import pkg.server.repository as sr |
428
e011e45fe2cd
2239 repository attribute system needed
Shawn Walker <shawn.walker@sun.com>
parents:
409
diff
changeset
|
106 |
import pkg.server.repositoryconfig as rc |
466
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
107 |
|
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
108 |
|
466
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
109 |
class LogSink(object): |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
110 |
"""This is a dummy object that we can use to discard log entries |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
111 |
without relying on non-portable interfaces such as /dev/null.""" |
23
51b8b48fea32
begin server source reorganization
"Stephen Hahn <sch@sun.com>"
parents:
22
diff
changeset
|
112 |
|
466
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
113 |
def write(self, *args, **kwargs): |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
114 |
"""Discard the bits.""" |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
115 |
pass |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
116 |
|
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
117 |
def flush(self, *args, **kwargs): |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
118 |
"""Discard the bits.""" |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
119 |
pass |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
120 |
|
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
121 |
|
1633
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
122 |
def usage(text=None, retcode=2, full=False): |
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
123 |
"""Optionally emit a usage message and then exit using the specified |
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
124 |
exit code.""" |
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
125 |
|
466
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
126 |
if text: |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
127 |
emsg(text) |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
128 |
|
1633
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
129 |
if not full: |
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
130 |
# The full usage message isn't desired. |
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
131 |
emsg(_("Try `pkg.depotd --help or -?' for more " |
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
132 |
"information.")) |
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
133 |
sys.exit(retcode) |
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
134 |
|
26 | 135 |
print """\ |
589
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
136 |
Usage: /usr/lib/pkg.depotd [-d repo_dir] [-p port] [-s threads] |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
137 |
[-t socket_timeout] [--cfg-file] [--content-root] |
1633
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
138 |
[--disable-ops op[/1][,...]] [--debug feature_list] |
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
139 |
[--log-access dest] [--log-errors dest] [--mirror] [--nasty] |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
140 |
[--set-property <section.property>=<value>] |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1020
diff
changeset
|
141 |
[--proxy-base url] [--readonly] [--rebuild] [--ssl-cert-file] |
1475
a667a9efcae9
7360 indexing workfile size should be configurable
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents:
1433
diff
changeset
|
142 |
[--ssl-dialog] [--ssl-key-file] [--sort-file-max-size size] |
a667a9efcae9
7360 indexing workfile size should be configurable
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents:
1433
diff
changeset
|
143 |
[--writable-root dir] |
382
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
144 |
|
1542
c97893ed7cd4
12891 pkgsend publish should support the --no-index flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1516
diff
changeset
|
145 |
--add-content Check the repository on startup and add any new |
c97893ed7cd4
12891 pkgsend publish should support the --no-index flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1516
diff
changeset
|
146 |
packages found. Cannot be used with --mirror or |
c97893ed7cd4
12891 pkgsend publish should support the --no-index flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1516
diff
changeset
|
147 |
--readonly. |
812
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
148 |
--cfg-file The pathname of the file from which to read and to |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
149 |
write configuration information. |
589
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
150 |
--content-root The file system path to the directory containing the |
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
151 |
the static and other web content used by the depot's |
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
152 |
browser user interface. The default value is |
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
153 |
'/usr/share/lib/pkg'. |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
154 |
--disable-ops A comma separated list of operations that the depot |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
155 |
should not configure. If, for example, you wanted |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
156 |
to omit loading search v1, 'search/1' should be |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
157 |
provided as an argument, or to disable all search |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
158 |
operations, simply 'search'. |
858
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
159 |
--debug The name of a debug feature to enable; or a whitespace |
1633
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
160 |
or comma separated list of features to enable. |
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
161 |
Possible values are: headers. |
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
162 |
--exit-ready Perform startup processing (including rebuilding |
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
163 |
catalog or indices, if requested) and exit when |
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
164 |
ready to start serving packages. |
466
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
165 |
--log-access The destination for any access related information |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
166 |
logged by the depot process. Possible values are: |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
167 |
stderr, stdout, none, or an absolute pathname. The |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
168 |
default value is stdout if stdout is a tty; otherwise |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
169 |
the default value is none. |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
170 |
--log-errors The destination for any errors or other information |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
171 |
logged by the depot process. Possible values are: |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
172 |
stderr, stdout, none, or an absolute pathname. The |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
173 |
default value is stderr. |
589
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
174 |
--mirror Package mirror mode; publishing and metadata operations |
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
175 |
disallowed. Cannot be used with --readonly or |
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
176 |
--rebuild. |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1020
diff
changeset
|
177 |
--nasty Instruct the server to misbehave. At random intervals |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1020
diff
changeset
|
178 |
it will time-out, send bad responses, hang up on |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1020
diff
changeset
|
179 |
clients, and generally be hostile. The option |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1020
diff
changeset
|
180 |
takes a value (1 to 100) for how nasty the server |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1020
diff
changeset
|
181 |
should be. |
589
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
182 |
--proxy-base The url to use as the base for generating internal |
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
183 |
redirects and content. |
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
184 |
--readonly Read-only operation; modifying operations disallowed. |
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
185 |
Cannot be used with --mirror or --rebuild. |
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
186 |
--rebuild Re-build the catalog from pkgs in depot. Cannot be |
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
187 |
used with --mirror or --readonly. |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
188 |
--set-property Used to specify initial repository configuration |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
189 |
property values or to update existing ones; can |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
190 |
be specified multiple times. If used with --readonly |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
191 |
this acts as a temporary override. |
812
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
192 |
--ssl-cert-file The absolute pathname to a PEM-encoded Certificate file. |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
193 |
This option must be used with --ssl-key-file. Usage of |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
194 |
this option will cause the depot to only respond to SSL |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
195 |
requests on the provided port. |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
196 |
--ssl-dialog Specifies what method should be used to obtain the |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
197 |
passphrase needed to decrypt the file specified by |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
198 |
--ssl-key-file. Supported values are: builtin, |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
199 |
exec:/path/to/program, or smf:fmri. The default value |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
200 |
is builtin. |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
201 |
--ssl-key-file The absolute pathname to a PEM-encoded Private Key file. |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
202 |
This option must be used with --ssl-cert-file. Usage of |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
203 |
this option will cause the depot to only respond to SSL |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
204 |
requests on the provided port. |
1475
a667a9efcae9
7360 indexing workfile size should be configurable
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents:
1433
diff
changeset
|
205 |
--sort-file-max-size |
a667a9efcae9
7360 indexing workfile size should be configurable
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents:
1433
diff
changeset
|
206 |
The maximum size of the indexer sort file. Used to |
a667a9efcae9
7360 indexing workfile size should be configurable
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents:
1433
diff
changeset
|
207 |
limit the amount of RAM the depot uses for indexing, |
a667a9efcae9
7360 indexing workfile size should be configurable
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents:
1433
diff
changeset
|
208 |
or increase it for speed. |
975
346745ea94fe
2701 "scratch area" for depot
Brock Pytlik <bpytlik@sun.com>
parents:
965
diff
changeset
|
209 |
--writable-root The path to a directory to which the program has write |
346745ea94fe
2701 "scratch area" for depot
Brock Pytlik <bpytlik@sun.com>
parents:
965
diff
changeset
|
210 |
access. Used with --readonly to allow server to |
346745ea94fe
2701 "scratch area" for depot
Brock Pytlik <bpytlik@sun.com>
parents:
965
diff
changeset
|
211 |
create needed files, such as search indices, without |
346745ea94fe
2701 "scratch area" for depot
Brock Pytlik <bpytlik@sun.com>
parents:
965
diff
changeset
|
212 |
needing write access to the package information. |
1633
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
213 |
|
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
214 |
Options: |
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
215 |
--help or -? |
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
216 |
|
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
217 |
Environment: |
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
218 |
PKG_REPO Used as default repo_dir if -d not provided. |
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
219 |
PKG_DEPOT_CONTENT Used as default content_root if --content-root |
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
220 |
not provided.""" |
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
221 |
sys.exit(retcode) |
14
969c85e852af
start pkg graph management, annotate pkgsend with server states
"Stephen Hahn <sch@sun.com>"
parents:
3
diff
changeset
|
222 |
|
382
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
223 |
class OptionError(Exception): |
429
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
428
diff
changeset
|
224 |
"""Option exception. """ |
14
969c85e852af
start pkg graph management, annotate pkgsend with server states
"Stephen Hahn <sch@sun.com>"
parents:
3
diff
changeset
|
225 |
|
404
e5329e84b9a8
2331 depot command-line parsing errors cause traceback
Shawn Walker <swalker@opensolaris.org>
parents:
386
diff
changeset
|
226 |
def __init__(self, *args): |
e5329e84b9a8
2331 depot command-line parsing errors cause traceback
Shawn Walker <swalker@opensolaris.org>
parents:
386
diff
changeset
|
227 |
Exception.__init__(self, *args) |
30 | 228 |
|
382
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
229 |
if __name__ == "__main__": |
30 | 230 |
|
791
123e9401e939
5778 Inability to set locale leads to stack trace
Danek Duvall <danek.duvall@sun.com>
parents:
775
diff
changeset
|
231 |
setlocale(locale.LC_ALL, "") |
689
1cb7154e1592
4489 depot traceback for info operation due to changeset 660
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
617
diff
changeset
|
232 |
gettext.install("pkg", "/usr/share/locale") |
1cb7154e1592
4489 depot traceback for info operation due to changeset 660
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
617
diff
changeset
|
233 |
|
858
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
234 |
debug_features = { |
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
235 |
"headers": False, |
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
236 |
} |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
237 |
disable_ops = {} |
382
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
238 |
port = PORT_DEFAULT |
812
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
239 |
port_provided = False |
382
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
240 |
threads = THREADS_DEFAULT |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
241 |
socket_timeout = SOCKET_TIMEOUT_DEFAULT |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
242 |
readonly = READONLY_DEFAULT |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
243 |
rebuild = REBUILD_DEFAULT |
429
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
428
diff
changeset
|
244 |
reindex = REINDEX_DEFAULT |
451
74f1fe85fe2d
1324 RSS / Atom feeds of repository updates
Shawn Walker <shawn.walker@sun.com>
parents:
445
diff
changeset
|
245 |
proxy_base = None |
461
37cf3ac75e37
1018 actions with payloads should include all sizes and hashes
johansen <johansen@sun.com>
parents:
452
diff
changeset
|
246 |
mirror = MIRROR_DEFAULT |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1020
diff
changeset
|
247 |
nasty = False |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1020
diff
changeset
|
248 |
nasty_value = 0 |
797
fddb78531f55
5211 cfg_cache needs to be able to live elsewhere
Brock Pytlik <bpytlik@sun.com>
parents:
791
diff
changeset
|
249 |
repo_config_file = None |
1477
716ae8c79b11
12580 depot default to an indexer sort file max size of "None"
John.Sonnenschein@Sun.COM
parents:
1475
diff
changeset
|
250 |
sort_file_max_size = indexer.SORT_FILE_MAX_SIZE |
812
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
251 |
ssl_cert_file = None |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
252 |
ssl_key_file = None |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
253 |
ssl_dialog = "builtin" |
975
346745ea94fe
2701 "scratch area" for depot
Brock Pytlik <bpytlik@sun.com>
parents:
965
diff
changeset
|
254 |
writable_root = None |
1542
c97893ed7cd4
12891 pkgsend publish should support the --no-index flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1516
diff
changeset
|
255 |
add_content = False |
c97893ed7cd4
12891 pkgsend publish should support the --no-index flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1516
diff
changeset
|
256 |
exit_ready = False |
258
b3b7592412ec
270 Need ability to rename packages
johansen <johansen@sun.com>
parents:
239
diff
changeset
|
257 |
|
382
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
258 |
if "PKG_REPO" in os.environ: |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
259 |
repo_path = os.environ["PKG_REPO"] |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
260 |
else: |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
261 |
repo_path = REPO_PATH_DEFAULT |
30 | 262 |
|
589
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
263 |
try: |
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
264 |
content_root = os.environ["PKG_DEPOT_CONTENT"] |
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
265 |
except KeyError: |
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
266 |
try: |
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
267 |
content_root = os.path.join(os.environ['PKG_HOME'], |
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
268 |
'share/lib/pkg') |
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
269 |
except KeyError: |
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
270 |
content_root = CONTENT_PATH_DEFAULT |
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
271 |
|
466
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
272 |
# By default, if the destination for a particular log type is not |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
273 |
# specified, this is where we will send the output. |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
274 |
log_routes = { |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
275 |
"access": "none", |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
276 |
"errors": "stderr" |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
277 |
} |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
278 |
log_opts = ["--log-%s" % log_type for log_type in log_routes] |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
279 |
|
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
280 |
# If stdout is a tty, then send access output there by default instead |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
281 |
# of discarding it. |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
282 |
if os.isatty(sys.stdout.fileno()): |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
283 |
log_routes["access"] = "stdout" |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
284 |
|
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
285 |
opt = None |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
286 |
repo_props = {} |
54
a0c517c20618
Don't throw an exception if the depot can't find a file
Danek Duvall <danek.duvall@sun.com>
parents:
52
diff
changeset
|
287 |
try: |
1633
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
288 |
long_opts = ["add-content", "cfg-file=", "content-root=", |
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
289 |
"debug=", "disable-ops=", "exit-ready", "help", "mirror", |
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
290 |
"nasty=", "set-property=", "proxy-base=", "readonly", |
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
291 |
"rebuild", "refresh-index", "ssl-cert-file=", "ssl-dialog=", |
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
292 |
"ssl-key-file=", "sort-file-max-size=", "writable-root="] |
1475
a667a9efcae9
7360 indexing workfile size should be configurable
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents:
1433
diff
changeset
|
293 |
|
466
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
294 |
for opt in log_opts: |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
295 |
long_opts.append("%s=" % opt.lstrip('--')) |
1633
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
296 |
opts, pargs = getopt.getopt(sys.argv[1:], "d:np:s:t:?", |
466
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
297 |
long_opts) |
1633
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
298 |
|
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
299 |
show_usage = False |
135
a1e20e9a9845
add CLI test suite, correct bugs found by test suite, ration out CLI options
Stephen Hahn <sch@Sun.COM>
parents:
119
diff
changeset
|
300 |
for opt, arg in opts: |
a1e20e9a9845
add CLI test suite, correct bugs found by test suite, ration out CLI options
Stephen Hahn <sch@Sun.COM>
parents:
119
diff
changeset
|
301 |
if opt == "-n": |
a1e20e9a9845
add CLI test suite, correct bugs found by test suite, ration out CLI options
Stephen Hahn <sch@Sun.COM>
parents:
119
diff
changeset
|
302 |
sys.exit(0) |
a1e20e9a9845
add CLI test suite, correct bugs found by test suite, ration out CLI options
Stephen Hahn <sch@Sun.COM>
parents:
119
diff
changeset
|
303 |
elif opt == "-d": |
382
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
304 |
repo_path = arg |
135
a1e20e9a9845
add CLI test suite, correct bugs found by test suite, ration out CLI options
Stephen Hahn <sch@Sun.COM>
parents:
119
diff
changeset
|
305 |
elif opt == "-p": |
a1e20e9a9845
add CLI test suite, correct bugs found by test suite, ration out CLI options
Stephen Hahn <sch@Sun.COM>
parents:
119
diff
changeset
|
306 |
port = int(arg) |
812
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
307 |
port_provided = True |
382
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
308 |
elif opt == "-s": |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
309 |
threads = int(arg) |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
310 |
if threads < THREADS_MIN: |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
311 |
raise OptionError, \ |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
312 |
"minimum value is %d" % THREADS_MIN |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
313 |
if threads > THREADS_MAX: |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
314 |
raise OptionError, \ |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
315 |
"maximum value is %d" % THREADS_MAX |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
316 |
elif opt == "-t": |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
317 |
socket_timeout = int(arg) |
1542
c97893ed7cd4
12891 pkgsend publish should support the --no-index flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1516
diff
changeset
|
318 |
elif opt == "--add-content": |
c97893ed7cd4
12891 pkgsend publish should support the --no-index flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1516
diff
changeset
|
319 |
add_content = True |
812
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
320 |
elif opt == "--cfg-file": |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
321 |
repo_config_file = os.path.abspath(arg) |
589
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
322 |
elif opt == "--content-root": |
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
323 |
if arg == "": |
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
324 |
raise OptionError, "You must specify " \ |
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
325 |
"a directory path." |
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
326 |
content_root = arg |
858
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
327 |
elif opt == "--debug": |
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
328 |
if arg is None or arg == "": |
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
329 |
raise OptionError, \ |
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
330 |
"A debug feature must be specified." |
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
331 |
|
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
332 |
# A list of features can be specified using a |
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
333 |
# "," or any whitespace character as separators. |
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
334 |
if "," in arg: |
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
335 |
features = arg.split(",") |
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
336 |
else: |
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
337 |
features = arg.split() |
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
338 |
|
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
339 |
for f in features: |
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
340 |
if f not in debug_features: |
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
341 |
raise OptionError, \ |
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
342 |
"Invalid debug feature: " \ |
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
343 |
"%s." % f |
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
344 |
debug_features[f] = True |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
345 |
elif opt == "--disable-ops": |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
346 |
if arg is None or arg == "": |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
347 |
raise OptionError, \ |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
348 |
"An argument must be specified." |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
349 |
|
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
350 |
disableops = arg.split(",") |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
351 |
for s in disableops: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
352 |
if "/" in s: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
353 |
op, ver = s.rsplit("/", 1) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
354 |
else: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
355 |
op = s |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
356 |
ver = "*" |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
357 |
|
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
358 |
if op not in \ |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
359 |
ds.DepotHTTP.REPO_OPS_DEFAULT: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
360 |
raise OptionError( |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
361 |
"Invalid operation " |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
362 |
"'%s'." % s) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
363 |
|
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
364 |
disable_ops.setdefault(op, []) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
365 |
disable_ops[op].append(ver) |
1542
c97893ed7cd4
12891 pkgsend publish should support the --no-index flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1516
diff
changeset
|
366 |
elif opt == "--exit-ready": |
c97893ed7cd4
12891 pkgsend publish should support the --no-index flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1516
diff
changeset
|
367 |
exit_ready = True |
466
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
368 |
elif opt in log_opts: |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
369 |
if arg is None or arg == "": |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
370 |
raise OptionError, \ |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
371 |
"You must specify a log " \ |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
372 |
"destination." |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
373 |
log_routes[opt.lstrip("--log-")] = arg |
1633
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
374 |
elif opt in ("--help", "-?"): |
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
375 |
show_usage = True |
589
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
376 |
elif opt == "--mirror": |
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
377 |
mirror = True |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1020
diff
changeset
|
378 |
elif opt == "--nasty": |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1020
diff
changeset
|
379 |
value_err = None |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1020
diff
changeset
|
380 |
try: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1020
diff
changeset
|
381 |
nasty_value = int(arg) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1020
diff
changeset
|
382 |
except ValueError, e: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1020
diff
changeset
|
383 |
value_err = e |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1020
diff
changeset
|
384 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1020
diff
changeset
|
385 |
if value_err or (nasty_value > 100 or |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1020
diff
changeset
|
386 |
nasty_value < 1): |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1020
diff
changeset
|
387 |
raise OptionError, "Invalid value " \ |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1020
diff
changeset
|
388 |
"for nasty option.\n Please " \ |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1020
diff
changeset
|
389 |
"choose a value between 1 and 100." |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1020
diff
changeset
|
390 |
nasty = True |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
391 |
elif opt == "--set-property": |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
392 |
try: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
393 |
prop, p_value = arg.split("=", 1) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
394 |
p_sec, p_name = prop.split(".", 1) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
395 |
except ValueError: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
396 |
usage(_("property arguments must be of " |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
397 |
"the form '<section.property>=" |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
398 |
"<value>'.")) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
399 |
repo_props.setdefault(p_sec, {}) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
400 |
repo_props[p_sec][p_name] = p_value |
589
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
401 |
elif opt == "--proxy-base": |
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
402 |
# Attempt to decompose the url provided into |
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
403 |
# its base parts. This is done so we can |
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
404 |
# remove any scheme information since we |
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
405 |
# don't need it. |
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
406 |
scheme, netloc, path, params, query, \ |
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
407 |
fragment = urlparse.urlparse(arg, |
765
3cc1f2dff092
5668 proxy base should allow https
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
751
diff
changeset
|
408 |
"http", allow_fragments=0) |
3cc1f2dff092
5668 proxy base should allow https
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
751
diff
changeset
|
409 |
|
3cc1f2dff092
5668 proxy base should allow https
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
751
diff
changeset
|
410 |
if not netloc: |
3cc1f2dff092
5668 proxy base should allow https
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
751
diff
changeset
|
411 |
raise OptionError, "Unable to " \ |
3cc1f2dff092
5668 proxy base should allow https
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
751
diff
changeset
|
412 |
"determine the hostname from " \ |
3cc1f2dff092
5668 proxy base should allow https
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
751
diff
changeset
|
413 |
"the provided URL; please use a " \ |
3cc1f2dff092
5668 proxy base should allow https
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
751
diff
changeset
|
414 |
"fully qualified URL." |
589
2480ab0274d1
242 desire ability to set content root
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
468
diff
changeset
|
415 |
|
765
3cc1f2dff092
5668 proxy base should allow https
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
751
diff
changeset
|
416 |
scheme = scheme.lower() |
3cc1f2dff092
5668 proxy base should allow https
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
751
diff
changeset
|
417 |
if scheme not in ("http", "https"): |
3cc1f2dff092
5668 proxy base should allow https
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
751
diff
changeset
|
418 |
raise OptionError, "Invalid URL; http " \ |
3cc1f2dff092
5668 proxy base should allow https
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
751
diff
changeset
|
419 |
"and https are the only supported " \ |
3cc1f2dff092
5668 proxy base should allow https
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
751
diff
changeset
|
420 |
"schemes." |
3cc1f2dff092
5668 proxy base should allow https
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
751
diff
changeset
|
421 |
|
3cc1f2dff092
5668 proxy base should allow https
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
751
diff
changeset
|
422 |
# Rebuild the url with the sanitized components. |
873
b95d76c53b5e
2691 ability to publish packages to local disk repository
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
858
diff
changeset
|
423 |
proxy_base = urlparse.urlunparse((scheme, |
b95d76c53b5e
2691 ability to publish packages to local disk repository
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
858
diff
changeset
|
424 |
netloc, path, params, query, fragment)) |
135
a1e20e9a9845
add CLI test suite, correct bugs found by test suite, ration out CLI options
Stephen Hahn <sch@Sun.COM>
parents:
119
diff
changeset
|
425 |
elif opt == "--readonly": |
382
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
426 |
readonly = True |
157
504b9e6d213c
Catalog should be on-disk instead of in memory
johansen <johansen@sun.com>
parents:
146
diff
changeset
|
427 |
elif opt == "--rebuild": |
382
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
428 |
rebuild = True |
429
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
428
diff
changeset
|
429 |
elif opt == "--refresh-index": |
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
428
diff
changeset
|
430 |
# Note: This argument is for internal use |
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
428
diff
changeset
|
431 |
# only. It's used when pkg.depotd is reexecing |
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
428
diff
changeset
|
432 |
# itself and needs to know that's the case. |
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
428
diff
changeset
|
433 |
# This flag is purposefully omitted in usage. |
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
428
diff
changeset
|
434 |
# The supported way to forcefully reindex is to |
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
428
diff
changeset
|
435 |
# kill any pkg.depot using that directory, |
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
428
diff
changeset
|
436 |
# remove the index directory, and restart the |
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
428
diff
changeset
|
437 |
# pkg.depot process. The index will be rebuilt |
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
428
diff
changeset
|
438 |
# automatically on startup. |
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
428
diff
changeset
|
439 |
reindex = True |
812
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
440 |
elif opt == "--ssl-cert-file": |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
441 |
if arg == "none": |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
442 |
continue |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
443 |
|
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
444 |
ssl_cert_file = arg |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
445 |
if not os.path.isabs(ssl_cert_file): |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
446 |
raise OptionError, "The path to " \ |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
447 |
"the Certificate file must be " \ |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
448 |
"absolute." |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
449 |
elif not os.path.exists(ssl_cert_file): |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
450 |
raise OptionError, "The specified " \ |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
451 |
"file does not exist." |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
452 |
elif not os.path.isfile(ssl_cert_file): |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
453 |
raise OptionError, "The specified " \ |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
454 |
"pathname is not a file." |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
455 |
elif opt == "--ssl-key-file": |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
456 |
if arg == "none": |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
457 |
continue |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
458 |
|
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
459 |
ssl_key_file = arg |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
460 |
if not os.path.isabs(ssl_key_file): |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
461 |
raise OptionError, "The path to " \ |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
462 |
"the Private Key file must be " \ |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
463 |
"absolute." |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
464 |
elif not os.path.exists(ssl_key_file): |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
465 |
raise OptionError, "The specified " \ |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
466 |
"file does not exist." |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
467 |
elif not os.path.isfile(ssl_key_file): |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
468 |
raise OptionError, "The specified " \ |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
469 |
"pathname is not a file." |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
470 |
elif opt == "--ssl-dialog": |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
471 |
if arg != "builtin" and not \ |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
472 |
arg.startswith("exec:/") and not \ |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
473 |
arg.startswith("smf:"): |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
474 |
raise OptionError, "Invalid value " \ |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
475 |
"specified. Expected: builtin, " \ |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
476 |
"exec:/path/to/program, or " \ |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
477 |
"smf:fmri." |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
478 |
|
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
479 |
f = arg |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
480 |
if f.startswith("exec:"): |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
481 |
if os_util.get_canonical_os_type() != \ |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
482 |
"unix": |
873
b95d76c53b5e
2691 ability to publish packages to local disk repository
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
858
diff
changeset
|
483 |
# Don't allow a somewhat |
b95d76c53b5e
2691 ability to publish packages to local disk repository
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
858
diff
changeset
|
484 |
# insecure authentication method |
b95d76c53b5e
2691 ability to publish packages to local disk repository
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
858
diff
changeset
|
485 |
# on some platforms. |
b95d76c53b5e
2691 ability to publish packages to local disk repository
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
858
diff
changeset
|
486 |
raise OptionError, "exec is " \ |
b95d76c53b5e
2691 ability to publish packages to local disk repository
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
858
diff
changeset
|
487 |
"not a supported dialog " \ |
b95d76c53b5e
2691 ability to publish packages to local disk repository
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
858
diff
changeset
|
488 |
"type for this operating " \ |
b95d76c53b5e
2691 ability to publish packages to local disk repository
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
858
diff
changeset
|
489 |
"system." |
812
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
490 |
|
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
491 |
f = os.path.abspath(f.split( |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
492 |
"exec:")[1]) |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
493 |
|
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
494 |
if not os.path.isfile(f): |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
495 |
raise OptionError, "Invalid " \ |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
496 |
"file path specified for " \ |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
497 |
"exec." |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
498 |
|
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
499 |
f = "exec:%s" % f |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
500 |
|
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
501 |
ssl_dialog = f |
1475
a667a9efcae9
7360 indexing workfile size should be configurable
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents:
1433
diff
changeset
|
502 |
elif opt == "--sort-file-max-size": |
a667a9efcae9
7360 indexing workfile size should be configurable
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents:
1433
diff
changeset
|
503 |
if arg == "": |
a667a9efcae9
7360 indexing workfile size should be configurable
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents:
1433
diff
changeset
|
504 |
raise OptionError, "You must specify " \ |
a667a9efcae9
7360 indexing workfile size should be configurable
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents:
1433
diff
changeset
|
505 |
"a maximum sort file size." |
a667a9efcae9
7360 indexing workfile size should be configurable
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents:
1433
diff
changeset
|
506 |
sort_file_max_size = arg |
975
346745ea94fe
2701 "scratch area" for depot
Brock Pytlik <bpytlik@sun.com>
parents:
965
diff
changeset
|
507 |
elif opt == "--writable-root": |
346745ea94fe
2701 "scratch area" for depot
Brock Pytlik <bpytlik@sun.com>
parents:
965
diff
changeset
|
508 |
if arg == "": |
346745ea94fe
2701 "scratch area" for depot
Brock Pytlik <bpytlik@sun.com>
parents:
965
diff
changeset
|
509 |
raise OptionError, "You must specify " \ |
346745ea94fe
2701 "scratch area" for depot
Brock Pytlik <bpytlik@sun.com>
parents:
965
diff
changeset
|
510 |
"a directory path." |
346745ea94fe
2701 "scratch area" for depot
Brock Pytlik <bpytlik@sun.com>
parents:
965
diff
changeset
|
511 |
writable_root = arg |
873
b95d76c53b5e
2691 ability to publish packages to local disk repository
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
858
diff
changeset
|
512 |
except getopt.GetoptError, _e: |
b95d76c53b5e
2691 ability to publish packages to local disk repository
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
858
diff
changeset
|
513 |
usage("pkg.depotd: %s" % _e.msg) |
b95d76c53b5e
2691 ability to publish packages to local disk repository
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
858
diff
changeset
|
514 |
except OptionError, _e: |
b95d76c53b5e
2691 ability to publish packages to local disk repository
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
858
diff
changeset
|
515 |
usage("pkg.depotd: option: %s -- %s" % (opt, _e)) |
382
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
516 |
except (ArithmeticError, ValueError): |
466
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
517 |
usage("pkg.depotd: illegal option value: %s specified " \ |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
518 |
"for option: %s" % (arg, opt)) |
451
74f1fe85fe2d
1324 RSS / Atom feeds of repository updates
Shawn Walker <shawn.walker@sun.com>
parents:
445
diff
changeset
|
519 |
|
1633
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
520 |
if show_usage: |
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
521 |
usage(retcode=0, full=True) |
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
522 |
|
1542
c97893ed7cd4
12891 pkgsend publish should support the --no-index flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1516
diff
changeset
|
523 |
if rebuild and add_content: |
c97893ed7cd4
12891 pkgsend publish should support the --no-index flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1516
diff
changeset
|
524 |
usage("--add-content cannot be used with --rebuild") |
445
76b03dd5a4ac
2693 Indexing code and catalog code should respect --read-only
Brock Pytlik <bpytlik@sun.com>
parents:
429
diff
changeset
|
525 |
if rebuild and reindex: |
466
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
526 |
usage("--refresh-index cannot be used with --rebuild") |
1542
c97893ed7cd4
12891 pkgsend publish should support the --no-index flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1516
diff
changeset
|
527 |
if (rebuild or add_content) and (readonly or mirror): |
1633
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
528 |
usage("--readonly and --mirror cannot be used with --rebuild " |
927bff25c41c
6284 depot should support --help and -? options
Shawn Walker <srw@sun.com>
parents:
1542
diff
changeset
|
529 |
"or --add-content") |
1020
765f4ea49070
7729 writable-root support doesn't allow depot contents to be read only
Brock Pytlik <bpytlik@sun.com>
parents:
975
diff
changeset
|
530 |
if reindex and mirror: |
765f4ea49070
7729 writable-root support doesn't allow depot contents to be read only
Brock Pytlik <bpytlik@sun.com>
parents:
975
diff
changeset
|
531 |
usage("--mirror cannot be used with --refresh-index") |
765f4ea49070
7729 writable-root support doesn't allow depot contents to be read only
Brock Pytlik <bpytlik@sun.com>
parents:
975
diff
changeset
|
532 |
if reindex and readonly and not writable_root: |
765f4ea49070
7729 writable-root support doesn't allow depot contents to be read only
Brock Pytlik <bpytlik@sun.com>
parents:
975
diff
changeset
|
533 |
usage("--readonly can only be used with --refresh-index if " |
765f4ea49070
7729 writable-root support doesn't allow depot contents to be read only
Brock Pytlik <bpytlik@sun.com>
parents:
975
diff
changeset
|
534 |
"--writable-root is used") |
451
74f1fe85fe2d
1324 RSS / Atom feeds of repository updates
Shawn Walker <shawn.walker@sun.com>
parents:
445
diff
changeset
|
535 |
|
812
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
536 |
if (ssl_cert_file and not ssl_key_file) or (ssl_key_file and not |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
537 |
ssl_cert_file): |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
538 |
usage("The --ssl-cert-file and --ssl-key-file options must " |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
539 |
"must both be provided when using either option.") |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
540 |
elif ssl_cert_file and ssl_key_file and not port_provided: |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
541 |
# If they didn't already specify a particular port, use the |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
542 |
# default SSL port instead. |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
543 |
port = SSL_PORT_DEFAULT |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
544 |
|
429
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
428
diff
changeset
|
545 |
# If the program is going to reindex, the port is irrelevant since |
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
428
diff
changeset
|
546 |
# the program will not bind to a port. |
1542
c97893ed7cd4
12891 pkgsend publish should support the --no-index flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1516
diff
changeset
|
547 |
if not reindex and not exit_ready: |
429
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
428
diff
changeset
|
548 |
available, msg = port_available(None, port) |
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
428
diff
changeset
|
549 |
if not available: |
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
428
diff
changeset
|
550 |
print "pkg.depotd: unable to bind to the specified " \ |
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
428
diff
changeset
|
551 |
"port: %d. Reason: %s" % (port, msg) |
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
428
diff
changeset
|
552 |
sys.exit(1) |
612
353fef98c569
4102 test suite fails if /usr/share/lib/pkg doesn't exist
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
589
diff
changeset
|
553 |
else: |
1542
c97893ed7cd4
12891 pkgsend publish should support the --no-index flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1516
diff
changeset
|
554 |
# Not applicable if we're not going to serve content |
612
353fef98c569
4102 test suite fails if /usr/share/lib/pkg doesn't exist
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
589
diff
changeset
|
555 |
content_root = None |
386
5cd680466abe
2147 depot should check port instead of showing traceback if port binding fails
Shawn Walker <swalker@opensolaris.org>
parents:
382
diff
changeset
|
556 |
|
812
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
557 |
key_data = None |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
558 |
if not reindex and ssl_cert_file and ssl_key_file and \ |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
559 |
ssl_dialog != "builtin": |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
560 |
cmdline = None |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
561 |
def get_ssl_passphrase(*ignored): |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
562 |
p = None |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
563 |
try: |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
564 |
p = subprocess.Popen(cmdline, shell=True, |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
565 |
stdout=subprocess.PIPE, |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
566 |
stderr=None) |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
567 |
p.wait() |
873
b95d76c53b5e
2691 ability to publish packages to local disk repository
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
858
diff
changeset
|
568 |
except Exception, __e: |
812
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
569 |
print "pkg.depotd: an error occurred while " \ |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
570 |
"executing [%s]; unable to obtain the " \ |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
571 |
"passphrase needed to decrypt the SSL" \ |
873
b95d76c53b5e
2691 ability to publish packages to local disk repository
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
858
diff
changeset
|
572 |
"private key file: %s" % (cmdline, __e) |
812
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
573 |
sys.exit(1) |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
574 |
return p.stdout.read().strip("\n") |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
575 |
|
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
576 |
if ssl_dialog.startswith("exec:"): |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
577 |
cmdline = "%s %s %d" % (ssl_dialog.split("exec:")[1], |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
578 |
"''", port) |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
579 |
elif ssl_dialog.startswith("smf:"): |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
580 |
cmdline = "/usr/bin/svcprop -p " \ |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
581 |
"pkg_secure/ssl_key_passphrase %s" % ( |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
582 |
ssl_dialog.split("smf:")[1]) |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
583 |
|
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
584 |
# The key file requires decryption, but the user has requested |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
585 |
# exec-based authentication, so it will have to be decoded first |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
586 |
# to an un-named temporary file. |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
587 |
try: |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
588 |
key_file = file(ssl_key_file, "rb") |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
589 |
pkey = crypto.load_privatekey(crypto.FILETYPE_PEM, |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
590 |
key_file.read(), get_ssl_passphrase) |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
591 |
|
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
592 |
key_data = tempfile.TemporaryFile() |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
593 |
key_data.write(crypto.dump_privatekey( |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
594 |
crypto.FILETYPE_PEM, pkey)) |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
595 |
key_data.seek(0) |
873
b95d76c53b5e
2691 ability to publish packages to local disk repository
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
858
diff
changeset
|
596 |
except EnvironmentError, _e: |
812
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
597 |
print "pkg.depotd: unable to read the SSL private " \ |
873
b95d76c53b5e
2691 ability to publish packages to local disk repository
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
858
diff
changeset
|
598 |
"key file: %s" % _e |
812
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
599 |
sys.exit(1) |
873
b95d76c53b5e
2691 ability to publish packages to local disk repository
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
858
diff
changeset
|
600 |
except crypto.Error, _e: |
812
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
601 |
print "pkg.depotd: authentication or cryptography " \ |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
602 |
"failure while attempting to decode\nthe SSL " \ |
873
b95d76c53b5e
2691 ability to publish packages to local disk repository
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
858
diff
changeset
|
603 |
"private key file: %s" % _e |
812
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
604 |
sys.exit(1) |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
605 |
else: |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
606 |
# Redirect the server to the decrypted key file. |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
607 |
ssl_key_file = "/dev/fd/%d" % key_data.fileno() |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
608 |
|
452
01f53c6381af
2714 image-update failure during update phase
Shawn Walker <shawn.walker@sun.com>
parents:
451
diff
changeset
|
609 |
# Setup our global configuration. |
466
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
610 |
gconf = { |
858
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
611 |
"checker.on": True, |
382
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
612 |
"environment": "production", |
466
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
613 |
"log.screen": False, |
965
6efb5042a707
7552 depot aborts connection for add operations with payload greater than 100MB
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
916
diff
changeset
|
614 |
"server.max_request_body_size": MAX_REQUEST_BODY_SIZE, |
858
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
615 |
"server.shutdown_timeout": 0, |
452
01f53c6381af
2714 image-update failure during update phase
Shawn Walker <shawn.walker@sun.com>
parents:
451
diff
changeset
|
616 |
"server.socket_host": "0.0.0.0", |
382
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
617 |
"server.socket_port": port, |
858
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
618 |
"server.socket_timeout": socket_timeout, |
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
619 |
"server.ssl_certificate": ssl_cert_file, |
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
620 |
"server.ssl_private_key": ssl_key_file, |
382
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
621 |
"server.thread_pool": threads, |
742
909b912fa942
3011 new depot index page desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
689
diff
changeset
|
622 |
"tools.log_headers.on": True, |
858
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
623 |
"tools.encode.on": True |
466
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
624 |
} |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
625 |
|
858
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
626 |
if debug_features["headers"]: |
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
627 |
# Despite its name, this only logs headers when there is an |
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
628 |
# error; it's redundant with the debug feature enabled. |
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
629 |
gconf["tools.log_headers.on"] = False |
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
630 |
|
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
631 |
# Causes the headers of every request to be logged to the error |
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
632 |
# log; even if an exception occurs. |
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
633 |
gconf["tools.log_headers_always.on"] = True |
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
634 |
cherrypy.tools.log_headers_always = cherrypy.Tool( |
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
635 |
"on_start_resource", |
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
636 |
cherrypy.lib.cptools.log_request_headers) |
c8f3fcec3301
6245 intent information is not properly sent
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
817
diff
changeset
|
637 |
|
466
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
638 |
log_type_map = { |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
639 |
"errors": { |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
640 |
"param": "log.error_file", |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
641 |
"attr": "error_log" |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
642 |
}, |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
643 |
"access": { |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
644 |
"param": "log.access_file", |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
645 |
"attr": "access_log" |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
646 |
} |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
647 |
} |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
648 |
|
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
649 |
for log_type in log_type_map: |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
650 |
dest = log_routes[log_type] |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
651 |
if dest in ("stdout", "stderr", "none"): |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
652 |
if dest == "none": |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
653 |
h = logging.StreamHandler(LogSink()) |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
654 |
else: |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
655 |
h = logging.StreamHandler(eval("sys.%s" % \ |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
656 |
dest)) |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
657 |
|
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
658 |
h.setLevel(logging.DEBUG) |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
659 |
h.setFormatter(cherrypy._cplogging.logfmt) |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
660 |
log_obj = eval("cherrypy.log.%s" % \ |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
661 |
log_type_map[log_type]["attr"]) |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
662 |
log_obj.addHandler(h) |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
663 |
# Since we've replaced cherrypy's log handler with our |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
664 |
# own, we don't want the output directed to a file. |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
665 |
dest = "" |
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
666 |
gconf[log_type_map[log_type]["param"]] = dest |
382
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
667 |
|
612
353fef98c569
4102 test suite fails if /usr/share/lib/pkg doesn't exist
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
589
diff
changeset
|
668 |
cherrypy.config.update(gconf) |
353fef98c569
4102 test suite fails if /usr/share/lib/pkg doesn't exist
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
589
diff
changeset
|
669 |
|
353fef98c569
4102 test suite fails if /usr/share/lib/pkg doesn't exist
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
589
diff
changeset
|
670 |
# Now that our logging, etc. has been setup, it's safe to perform any |
353fef98c569
4102 test suite fails if /usr/share/lib/pkg doesn't exist
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
589
diff
changeset
|
671 |
# remaining preparation. |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
672 |
|
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
673 |
# Initialize repository state. |
1542
c97893ed7cd4
12891 pkgsend publish should support the --no-index flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1516
diff
changeset
|
674 |
fork_allowed = not reindex and not exit_ready |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
675 |
try: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
676 |
repo = sr.Repository(auto_create=not readonly, |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
677 |
cfgpathname=repo_config_file, fork_allowed=fork_allowed, |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
678 |
log_obj=cherrypy, mirror=mirror, properties=repo_props, |
1542
c97893ed7cd4
12891 pkgsend publish should support the --no-index flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1516
diff
changeset
|
679 |
read_only=readonly, refresh_index=not add_content, |
c97893ed7cd4
12891 pkgsend publish should support the --no-index flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1516
diff
changeset
|
680 |
repo_root=repo_path, sort_file_max_size=sort_file_max_size, |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
681 |
writable_root=writable_root) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
682 |
except sr.RepositoryError, _e: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
683 |
emsg("pkg.depotd: %s" % _e) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
684 |
sys.exit(1) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
685 |
except rc.RequiredPropertyValueError, _e: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
686 |
emsg("pkg.depotd: repository configuration error: %s" % _e) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
687 |
emsg("Please use the --set-property option to provide a value, " |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
688 |
"or update the cfg_cache file for the repository to " |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
689 |
"correct this.") |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
690 |
sys.exit(1) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
691 |
except rc.PropertyError, _e: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
692 |
emsg("pkg.depotd: repository configuration error: %s" % _e) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
693 |
sys.exit(1) |
1672
3a71439a03f3
13021 file manager exceptions should be api exceptions
Shawn Walker <srw@sun.com>
parents:
1633
diff
changeset
|
694 |
except search_errors.IndexingException, _e: |
3a71439a03f3
13021 file manager exceptions should be api exceptions
Shawn Walker <srw@sun.com>
parents:
1633
diff
changeset
|
695 |
emsg("pkg.depotd: %s" % str(_e), "INDEX") |
3a71439a03f3
13021 file manager exceptions should be api exceptions
Shawn Walker <srw@sun.com>
parents:
1633
diff
changeset
|
696 |
sys.exit(1) |
1779
b80275b45b18
14176 copytree callers must catch shutil.Error and not traceback
Shawn Walker <srw@sun.com>
parents:
1672
diff
changeset
|
697 |
except (api_errors.UnknownErrors, api_errors.PermissionsException), _e: |
1672
3a71439a03f3
13021 file manager exceptions should be api exceptions
Shawn Walker <srw@sun.com>
parents:
1633
diff
changeset
|
698 |
emsg("pkg.depotd: %s" % str(_e)) |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
699 |
sys.exit(1) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
700 |
|
612
353fef98c569
4102 test suite fails if /usr/share/lib/pkg doesn't exist
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
589
diff
changeset
|
701 |
if reindex: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
702 |
# Initializing the repository above updated search indices |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
703 |
# as needed; nothing left to do, so exit. |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
704 |
sys.exit(0) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
705 |
|
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
706 |
if nasty: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
707 |
repo.cfg.set_nasty(nasty_value) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
708 |
|
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
709 |
if rebuild: |
617
d146e7256c65
4048 A PartialIndexingException on the depot shouldn't stack trace or cause usage to be displayed
Brock Pytlik <bpytlik@sun.com>
parents:
612
diff
changeset
|
710 |
try: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
711 |
repo.rebuild() |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
712 |
except sr.RepositoryError, e: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
713 |
emsg(str(e), "REBUILD") |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
714 |
sys.exit(1) |
975
346745ea94fe
2701 "scratch area" for depot
Brock Pytlik <bpytlik@sun.com>
parents:
965
diff
changeset
|
715 |
except (search_errors.IndexingException, |
1779
b80275b45b18
14176 copytree callers must catch shutil.Error and not traceback
Shawn Walker <srw@sun.com>
parents:
1672
diff
changeset
|
716 |
api_errors.UnknownErrors, |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
717 |
api_errors.PermissionsException), e: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
718 |
emsg(str(e), "INDEX") |
617
d146e7256c65
4048 A PartialIndexingException on the depot shouldn't stack trace or cause usage to be displayed
Brock Pytlik <bpytlik@sun.com>
parents:
612
diff
changeset
|
719 |
sys.exit(1) |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
720 |
|
1542
c97893ed7cd4
12891 pkgsend publish should support the --no-index flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1516
diff
changeset
|
721 |
elif add_content: |
c97893ed7cd4
12891 pkgsend publish should support the --no-index flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1516
diff
changeset
|
722 |
try: |
c97893ed7cd4
12891 pkgsend publish should support the --no-index flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1516
diff
changeset
|
723 |
repo.add_content() |
c97893ed7cd4
12891 pkgsend publish should support the --no-index flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1516
diff
changeset
|
724 |
except sr.RepositoryError, e: |
c97893ed7cd4
12891 pkgsend publish should support the --no-index flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1516
diff
changeset
|
725 |
emsg(str(e), "ADD_CONTENT") |
c97893ed7cd4
12891 pkgsend publish should support the --no-index flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1516
diff
changeset
|
726 |
sys.exit(1) |
c97893ed7cd4
12891 pkgsend publish should support the --no-index flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1516
diff
changeset
|
727 |
except (search_errors.IndexingException, |
1779
b80275b45b18
14176 copytree callers must catch shutil.Error and not traceback
Shawn Walker <srw@sun.com>
parents:
1672
diff
changeset
|
728 |
api_errors.UnknownErrors, |
1542
c97893ed7cd4
12891 pkgsend publish should support the --no-index flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1516
diff
changeset
|
729 |
api_errors.PermissionsException), e: |
c97893ed7cd4
12891 pkgsend publish should support the --no-index flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1516
diff
changeset
|
730 |
emsg(str(e), "INDEX") |
c97893ed7cd4
12891 pkgsend publish should support the --no-index flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1516
diff
changeset
|
731 |
sys.exit(1) |
c97893ed7cd4
12891 pkgsend publish should support the --no-index flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1516
diff
changeset
|
732 |
|
c97893ed7cd4
12891 pkgsend publish should support the --no-index flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1516
diff
changeset
|
733 |
# ready to start depot; exit now if requested |
c97893ed7cd4
12891 pkgsend publish should support the --no-index flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1516
diff
changeset
|
734 |
if exit_ready: |
c97893ed7cd4
12891 pkgsend publish should support the --no-index flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1516
diff
changeset
|
735 |
sys.exit(0) |
c97893ed7cd4
12891 pkgsend publish should support the --no-index flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1516
diff
changeset
|
736 |
|
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
737 |
# Next, initialize depot. |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
738 |
if nasty: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
739 |
depot = ds.NastyDepotHTTP(repo, content_root, |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
740 |
disable_ops=disable_ops) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
741 |
else: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
742 |
depot = ds.DepotHTTP(repo, content_root, |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
743 |
disable_ops=disable_ops) |
612
353fef98c569
4102 test suite fails if /usr/share/lib/pkg doesn't exist
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
589
diff
changeset
|
744 |
|
451
74f1fe85fe2d
1324 RSS / Atom feeds of repository updates
Shawn Walker <shawn.walker@sun.com>
parents:
445
diff
changeset
|
745 |
# Now build our site configuration. |
382
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
746 |
conf = { |
452
01f53c6381af
2714 image-update failure during update phase
Shawn Walker <shawn.walker@sun.com>
parents:
451
diff
changeset
|
747 |
"/": { |
01f53c6381af
2714 image-update failure during update phase
Shawn Walker <shawn.walker@sun.com>
parents:
451
diff
changeset
|
748 |
# We have to override cherrypy's default response_class so that |
01f53c6381af
2714 image-update failure during update phase
Shawn Walker <shawn.walker@sun.com>
parents:
451
diff
changeset
|
749 |
# we have access to the write() callable to stream data |
01f53c6381af
2714 image-update failure during update phase
Shawn Walker <shawn.walker@sun.com>
parents:
451
diff
changeset
|
750 |
# directly to the client. |
873
b95d76c53b5e
2691 ability to publish packages to local disk repository
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
858
diff
changeset
|
751 |
"wsgi.response_class": dr.DepotResponse, |
452
01f53c6381af
2714 image-update failure during update phase
Shawn Walker <shawn.walker@sun.com>
parents:
451
diff
changeset
|
752 |
}, |
382
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
753 |
"/robots.txt": { |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
754 |
"tools.staticfile.on": True, |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
755 |
"tools.staticfile.filename": os.path.join(depot.web_root, |
382
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
756 |
"robots.txt") |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
757 |
}, |
95304bd3b365
1854 rework depot to use higher-level framework
Shawn Walker <swalker@opensolaris.org>
parents:
374
diff
changeset
|
758 |
} |
145
08bee7fd13f6
Add versioning to the protocols
Danek Duvall <danek.duvall@sun.com>
parents:
135
diff
changeset
|
759 |
|
451
74f1fe85fe2d
1324 RSS / Atom feeds of repository updates
Shawn Walker <shawn.walker@sun.com>
parents:
445
diff
changeset
|
760 |
if proxy_base: |
74f1fe85fe2d
1324 RSS / Atom feeds of repository updates
Shawn Walker <shawn.walker@sun.com>
parents:
445
diff
changeset
|
761 |
# This changes the base URL for our server, and is primarily |
74f1fe85fe2d
1324 RSS / Atom feeds of repository updates
Shawn Walker <shawn.walker@sun.com>
parents:
445
diff
changeset
|
762 |
# intended to allow our depot process to operate behind Apache |
74f1fe85fe2d
1324 RSS / Atom feeds of repository updates
Shawn Walker <shawn.walker@sun.com>
parents:
445
diff
changeset
|
763 |
# or some other webserver process. |
74f1fe85fe2d
1324 RSS / Atom feeds of repository updates
Shawn Walker <shawn.walker@sun.com>
parents:
445
diff
changeset
|
764 |
# |
74f1fe85fe2d
1324 RSS / Atom feeds of repository updates
Shawn Walker <shawn.walker@sun.com>
parents:
445
diff
changeset
|
765 |
# Visit the following URL for more information: |
74f1fe85fe2d
1324 RSS / Atom feeds of repository updates
Shawn Walker <shawn.walker@sun.com>
parents:
445
diff
changeset
|
766 |
# http://cherrypy.org/wiki/BuiltinTools#tools.proxy |
74f1fe85fe2d
1324 RSS / Atom feeds of repository updates
Shawn Walker <shawn.walker@sun.com>
parents:
445
diff
changeset
|
767 |
proxy_conf = { |
74f1fe85fe2d
1324 RSS / Atom feeds of repository updates
Shawn Walker <shawn.walker@sun.com>
parents:
445
diff
changeset
|
768 |
"tools.proxy.on": True, |
74f1fe85fe2d
1324 RSS / Atom feeds of repository updates
Shawn Walker <shawn.walker@sun.com>
parents:
445
diff
changeset
|
769 |
"tools.proxy.local": "", |
74f1fe85fe2d
1324 RSS / Atom feeds of repository updates
Shawn Walker <shawn.walker@sun.com>
parents:
445
diff
changeset
|
770 |
"tools.proxy.base": proxy_base |
74f1fe85fe2d
1324 RSS / Atom feeds of repository updates
Shawn Walker <shawn.walker@sun.com>
parents:
445
diff
changeset
|
771 |
} |
74f1fe85fe2d
1324 RSS / Atom feeds of repository updates
Shawn Walker <shawn.walker@sun.com>
parents:
445
diff
changeset
|
772 |
|
74f1fe85fe2d
1324 RSS / Atom feeds of repository updates
Shawn Walker <shawn.walker@sun.com>
parents:
445
diff
changeset
|
773 |
# Now merge or add our proxy configuration information into the |
74f1fe85fe2d
1324 RSS / Atom feeds of repository updates
Shawn Walker <shawn.walker@sun.com>
parents:
445
diff
changeset
|
774 |
# existing configuration. |
74f1fe85fe2d
1324 RSS / Atom feeds of repository updates
Shawn Walker <shawn.walker@sun.com>
parents:
445
diff
changeset
|
775 |
for entry in proxy_conf: |
74f1fe85fe2d
1324 RSS / Atom feeds of repository updates
Shawn Walker <shawn.walker@sun.com>
parents:
445
diff
changeset
|
776 |
conf["/"][entry] = proxy_conf[entry] |
74f1fe85fe2d
1324 RSS / Atom feeds of repository updates
Shawn Walker <shawn.walker@sun.com>
parents:
445
diff
changeset
|
777 |
|
814
76909c2cad8f
5603 server catalog permissions should be 644, not 600
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
812
diff
changeset
|
778 |
try: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
779 |
root = cherrypy.Application(depot) |
466
7cfb6502ff1b
2333 control over access / error log destination desired
Shawn Walker <shawn.walker@sun.com>
parents:
461
diff
changeset
|
780 |
cherrypy.quickstart(root, config=conf) |
873
b95d76c53b5e
2691 ability to publish packages to local disk repository
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
858
diff
changeset
|
781 |
except Exception, _e: |
812
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
782 |
emsg("pkg.depotd: unknown error starting depot server, " \ |
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
783 |
"illegal option value specified?") |
873
b95d76c53b5e
2691 ability to publish packages to local disk repository
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
858
diff
changeset
|
784 |
emsg(_e) |
812
7e82ae7acf48
2154 pkg.depotd should offer SSL/HTTPS option
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
797
diff
changeset
|
785 |
sys.exit(1) |