depot.py revision 176
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] 20N/A# Copyright 2007 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). 135N/A --readonly Read-only operation; modifying operations disallowed 157N/A --rebuild Re-build the catalog from pkgs in depot 174N/A # Try to guard against a non-existent catalog. The catalog open will 174N/A # raise an exception, and only the attributes will have been sent. But 174N/A # because we've sent data already (never mind the response header), we 174N/A # can't raise an exception here, or a 500 header will get sent as well. 30N/A """The request is an encoded pkg FMRI. If the version is specified 50N/A incompletely, we return an error, as the client is expected to form 50N/A correct requests, based on its interpretation of the catalog and its 30N/A # Parse request into FMRI component and decode. 30N/A # Open manifest and send. 119N/A with the requested filenames.""" 119N/A # If the sender doesn't specify the content length, reject this request. 119N/A # Calling read() with no size specified will force the server to block 119N/A # until the client sends EOF, an undesireable situation 30N/A """The request is the SHA-1 hash name for the file.""" 22N/A # XXX Authentication will be handled by virtue of possessing a signed 22N/A # certificate (or a more elaborate system). 0N/A # Pull transaction ID from headers. 22N/A # Pull transaction ID from headers. 145N/A # Make sure that we have a integer protocol version 145N/A # If we get here, we know that 'operation' is supported. 145N/A # Assume 'version' is not supported for that operation. 145N/A vns =
"Version '%s' not supported for operation '%s'\n" 174N/A # XXX op_call may already have spit some data out to the 174N/A # client, in which case this response just corrupts that 174N/A # datastream. I don't know of any way to tell whether 174N/A # data has already been sent. 157N/A [
"readonly",
"rebuild"])
135N/A print "pkg.depotd: unknown option '%s'" % e.
opt