depot.py revision 617
290N/A# The contents of this file are subject to the terms of the 290N/A# Common Development and Distribution License (the "License"). 290N/A# You may not use this file except in compliance with the License. 290N/A# See the License for the specific language governing permissions 290N/A# and limitations under the License. 290N/A# When distributing Covered Code, include this CDDL HEADER in each 290N/A# If applicable, add the following below this CDDL HEADER, with the 290N/A# fields enclosed by brackets "[]" replaced with your own identifying 290N/A# information: Portions Copyright [yyyy] [name of copyright owner] 1902N/A# Copyright 2008 Sun Microsystems, Inc. All rights reserved. 395N/A# Use is subject to license terms. 454N/A# pkg.depotd - package repository daemon 448N/A# XXX The prototype pkg.depotd combines both the version management server that 290N/A# answers to pkgsend(1) sessions and the HTTP file server that answers to the 290N/A# various GET operations that a pkg(1) client makes. This split is expected to 290N/A# be made more explicit, by constraining the pkg(1) operations such that they 383N/A# can be served as a typical HTTP/HTTPS session. Thus, pkg.depotd will reduce 290N/A# to a special purpose HTTP/HTTPS server explicitly for the version management 395N/A# operations, and must manipulate the various state files--catalogs, in 290N/A# particular--such that the pkg(1) pull client can operately accurately with 1516N/A# XXX We should support simple "last-modified" operations via HEAD queries. 849N/A# XXX Although we pushed the evaluation of next-version, etc. to the pull 290N/A# client, we should probably provide a query API to do same on the server, for 290N/A# dumb clients (like a notification service). 290N/A# The default authority for the depot. 290N/A# The default repository path. 290N/A# The default path for static and other web content. 290N/A# The default port to serve data from. 290N/A# The minimum number of threads allowed. 1660N/A# The default number of threads to start. 1660N/A# The maximum number of threads that can be started. 1660N/A# The default server socket timeout in seconds. We want this to be longer than 1660N/A# the normal default of 10 seconds to accommodate clients with poor quality 1660N/A# Whether modify operations should be allowed. 1660N/A# Whether the repository catalog should be rebuilt on startup. 1660N/A# Whether the indexes should be rebuilt 1660N/A# Not in mirror mode by default 465N/A print """cherrypy 3.1.0 or greater (but less than 3.2.0) is """ \
1099N/A """required to use this program.""" 1391N/A """This is a dummy object that we can use to discard log entries 1391N/A without relying on non-portable interfaces such as /dev/null.""" 742N/A [-t socket_timeout] [--content-root] [--log-access dest] 941N/A [--log-errors dest] [--mirror] [--proxy-base url] [--readonly] 941N/A --content-root The file system path to the directory containing the 941N/A the static and other web content used by the depot's 941N/A browser user interface. The default value is 941N/A --log-access The destination for any access related information 1191N/A logged by the depot process. Possible values are: 1513N/A stderr, stdout, none, or an absolute pathname. The 1191N/A default value is stdout if stdout is a tty; otherwise 1191N/A --log-errors The destination for any errors or other information 1191N/A logged by the depot process. Possible values are: 1191N/A stderr, stdout, none, or an absolute pathname. The 1660N/A --mirror Package mirror mode; publishing and metadata operations 1660N/A disallowed. Cannot be used with --readonly or 448N/A --proxy-base The url to use as the base for generating internal 534N/A --readonly Read-only operation; modifying operations disallowed. 534N/A Cannot be used with --mirror or --rebuild. 534N/A --rebuild Re-build the catalog from pkgs in depot. Cannot be 534N/A used with --mirror or --readonly. 290N/A """Option exception. """ 1674N/A # By default, if the destination for a particular log type is not 1674N/A # specified, this is where we will send the output. 1544N/A # If stdout is a tty, then send access output there by default instead 395N/A "readonly",
"rebuild",
"refresh-index"]
1231N/A "You must specify a log " \
395N/A # Attempt to decompose the url provided into 395N/A # its base parts. This is done so we can 395N/A # remove any scheme information since we 290N/A # Rebuild the url without the scheme and 290N/A # remove the leading // urlunparse adds. 290N/A # Note: This argument is for internal use 395N/A # only. It's used when pkg.depotd is reexecing 1024N/A # itself and needs to know that's the case. 413N/A # This flag is purposefully omitted in usage. 1544N/A # The supported way to forcefully reindex is to 1557N/A # kill any pkg.depot using that directory, 1506N/A # remove the index directory, and restart the 413N/A # pkg.depot process. The index will be rebuilt 413N/A # automatically on startup. 413N/A usage(
"pkg.depotd: illegal option value: %s specified " \
395N/A usage(
"--refresh-index cannot be used with --rebuild")
395N/A usage(
"--readonly and --mirror cannot be used with --rebuild")
1452N/A usage(
"--readonly and --mirror cannot be used with " \
395N/A # If the program is going to reindex, the port is irrelevant since 424N/A # the program will not bind to a port. 742N/A print "pkg.depotd: unable to bind to the specified " \
742N/A # Not applicable for reindexing operations. 395N/A print "pkg.depotd: an error occurred while trying to " \
1483N/A "initialize the depot repository directory " \
395N/A # Setup our global configuration. 1902N/A # Global cherrypy configuration 1099N/A "environment":
"production",
1498N/A "server.socket_host":
"0.0.0.0",
290N/A "param":
"log.error_file",
591N/A "param":
"log.access_file",
290N/A # Since we've replaced cherrypy's log handler with our 290N/A # own, we don't want the output directed to a file. 395N/A # Now that our logging, etc. has been setup, it's safe to perform any 290N/A # remaining preparation. 395N/A # Now build our site configuration. 591N/A # We have to override cherrypy's default response_class so that 591N/A # we have access to the write() callable to stream data 591N/A # directly to the client. 591N/A "tools.staticdir.dir":
"" 395N/A # This changes the base URL for our server, and is primarily 395N/A # intended to allow our depot process to operate behind Apache 290N/A # or some other webserver process. 395N/A # Visit the following URL for more information: 290N/A "tools.proxy.local":
"",
395N/A # Now merge or add our proxy configuration information into the 290N/A # existing configuration. 506N/A usage(
"pkg.depotd: unknown error starting depot, illegal " \
506N/A "option value specified?")