depot.py revision 258
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] 3158N/A# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 395N/A# Use is subject to license terms. 883N/A# pkg.depotd - package repository daemon 290N/A# XXX The prototype pkg.depotd combines both the version management server that 448N/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 290N/A# can be served as a typical HTTP/HTTPS session. Thus, pkg.depotd will reduce 383N/A# to a special purpose HTTP/HTTPS server explicitly for the version management 290N/A# operations, and must manipulate the various state files--catalogs, in 395N/A# particular--such that the pkg(1) pull client can operately accurately with 849N/A# XXX We should support simple "last-modified" operations via HEAD queries. 2508N/A# XXX Although we pushed the evaluation of next-version, etc. to the pull 2826N/A# client, we should probably provide a query API to do same on the server, for 290N/A# dumb clients (like a notification service). 1660N/A --readonly Read-only operation; modifying operations disallowed 1660N/A --rebuild Re-build the catalog from pkgs in depot 290N/A # Try to guard against a non-existent catalog. The catalog open will 2494N/A # raise an exception, and only the attributes will have been sent. But 2494N/A # because we've sent data already (never mind the response header), we 2494N/A # can't raise an exception here, or a 500 header will get sent as well. 290N/A """The request is an encoded pkg FMRI. If the version is specified 3185N/A incompletely, we return an error, as the client is expected to form 2523N/A correct requests, based on its interpretation of the catalog and its 2867N/A # Parse request into FMRI component and decode. 2240N/A with the requested filenames.""" 1506N/A # If the sender doesn't specify the content length, reject this request. 2928N/A # Calling read() with no size specified will force the server to block 395N/A # until the client sends EOF, an undesireable situation 395N/A # If the sender doesn't specify the content length, reject this request. 395N/A # Calling read() with no size specified will force the server to block 1968N/A # until the client sends EOF, an undesireable situation 395N/A """The request is the SHA-1 hash name for the file.""" 3139N/A # XXX Authentication will be handled by virtue of possessing a signed 3139N/A # certificate (or a more elaborate system). 2516N/A # Pull transaction ID from headers. 3139N/A # Pull transaction ID from headers. 742N/A # Make sure that we have a integer protocol version 1099N/A # If we get here, we know that 'operation' is supported. 2867N/A # Assume 'version' is not supported for that operation. 2223N/A vns =
"Version '%s' not supported for operation '%s'\n" 2310N/A # XXX op_call may already have spit some data out to the 2310N/A # client, in which case this response just corrupts that 2310N/A # datastream. I don't know of any way to tell whether 2310N/A # data has already been sent. 395N/A print "pkg.depotd: illegal option -- %s" % e.
opt 1632N/A "Insufficient privilege to bind to port %d." %
port 2339N/A "Use the -p option to pick another port, if desired."