depot.py revision 452
20N/A# The contents of this file are subject to the terms of the 20N/A# Common Development and Distribution License (the "License"). 20N/A# You may not use this file except in compliance with the License. 20N/A# See the License for the specific language governing permissions 20N/A# and limitations under the License. 20N/A# When distributing Covered Code, include this CDDL HEADER in each 20N/A# If applicable, add the following below this CDDL HEADER, with the 20N/A# fields enclosed by brackets "[]" replaced with your own identifying 20N/A# information: Portions Copyright [yyyy] [name of copyright owner] 260N/A# Copyright 2008 Sun Microsystems, Inc. All rights reserved. 20N/A# Use is subject to license terms. 22N/A# pkg.depotd - package repository daemon 50N/A# XXX The prototype pkg.depotd combines both the version management server that 50N/A# answers to pkgsend(1) sessions and the HTTP file server that answers to the 50N/A# various GET operations that a pkg(1) client makes. This split is expected to 50N/A# be made more explicit, by constraining the pkg(1) operations such that they 50N/A# can be served as a typical HTTP/HTTPS session. Thus, pkg.depotd will reduce 50N/A# to a special purpose HTTP/HTTPS server explicitly for the version management 50N/A# operations, and must manipulate the various state files--catalogs, in 50N/A# particular--such that the pkg(1) pull client can operately accurately with 50N/A# XXX We should support simple "last-modified" operations via HEAD queries. 50N/A# XXX Although we pushed the evaluation of next-version, etc. to the pull 50N/A# client, we should probably provide a query API to do same on the server, for 50N/A# dumb clients (like a notification service). 382N/A# The default authority for the depot. 382N/A# The default repository path. 382N/A# The default port to serve data from. 382N/A# The minimum number of threads allowed. 382N/A# The default number of threads to start. 382N/A# The maximum number of threads that can be started. 382N/A# The default server socket timeout in seconds. We want this to be longer than 382N/A# the normal default of 10 seconds to accommodate clients with poor quality 382N/A# Whether modify operations should be allowed. 382N/A# Whether the repository catalog should be rebuilt on startup. 429N/A# Whether the indexes should be rebuilt 452N/A print """cherrypy 3.1.0 or greater (but less than 3.2.0) is """ \
382N/A """required to use this program.""" 451N/A [-d repo_dir] [-p port] [-s threads] [-t socket_timeout] 135N/A --readonly Read-only operation; modifying operations disallowed 157N/A --rebuild Re-build the catalog from pkgs in depot 445N/A Cannot be used with --readonly 451N/A --proxy-base The url to use as the base for generating internal 429N/A """Option exception. """ 451N/A [
"readonly",
"rebuild",
"proxy-base=",
"refresh-index"])
429N/A # Note: This argument is for internal use 429N/A # only. It's used when pkg.depotd is reexecing 429N/A # itself and needs to know that's the case. 429N/A # This flag is purposefully omitted in usage. 429N/A # The supported way to forcefully reindex is to 429N/A # kill any pkg.depot using that directory, 429N/A # remove the index directory, and restart the 429N/A # pkg.depot process. The index will be rebuilt 429N/A # automatically on startup. 451N/A # Attempt to decompose the url provided into 451N/A # its base parts. This is done so we can 451N/A # remove any scheme information since we 451N/A # Rebuild the url without the scheme and 451N/A # remove the leading // urlunparse adds. 382N/A print "pkg.depotd: option: %s -- %s" % (
opt, e)
382N/A print "pkg.depotd: illegal option value: %s specified " \
445N/A print "--refresh-index cannot be used with --rebuild" 445N/A print "--readonly cannot be used with --rebuild" 445N/A print "--readonly cannot be used with --refresh-index" 429N/A # If the program is going to reindex, the port is irrelevant since 429N/A # the program will not bind to a port. 429N/A print "pkg.depotd: unable to bind to the specified " \
382N/A print "pkg.depotd: an error occurred while trying to " \
382N/A "initialize the depot repository directory " \
452N/A # Setup our global configuration. 382N/A "environment":
"production",
452N/A "server.socket_host":
"0.0.0.0",
451N/A # Now build our site configuration. 452N/A # We have to override cherrypy's default response_class so that 452N/A # we have access to the write() callable to stream data 452N/A # directly to the client. 382N/A "tools.staticdir.dir":
"" 451N/A # This changes the base URL for our server, and is primarily 451N/A # intended to allow our depot process to operate behind Apache 451N/A # or some other webserver process. 451N/A # Visit the following URL for more information: 451N/A "tools.proxy.local":
"",
451N/A # Now merge or add our proxy configuration information into the 451N/A # existing configuration. 382N/A print "pkg.depotd: unknown error starting depot, illegal " \
382N/A "option value specified?"