catalog.py revision 73
23N/A# The contents of this file are subject to the terms of the 23N/A# Common Development and Distribution License (the "License"). 23N/A# You may not use this file except in compliance with the License. 23N/A# See the License for the specific language governing permissions 23N/A# and limitations under the License. 23N/A# When distributing Covered Code, include this CDDL HEADER in each 23N/A# If applicable, add the following below this CDDL HEADER, with the 23N/A# fields enclosed by brackets "[]" replaced with your own identifying 23N/A# information: Portions Copyright [yyyy] [name of copyright owner] 23N/A# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23N/A# Use is subject to license terms. 34N/A """A Catalog is the representation of the package FMRIs available to 34N/A this client or repository. Both purposes utilize the same storage 26N/A The serialized structure of the repository is an unordered list of 26N/A available package versions, followed by an unordered list of 26N/A incorporation relationships between packages. This latter section 26N/A allows the graph to be topologically sorted by the client. 50N/A S Last-Modified: [timespec] 37N/A XXX A authority mirror-uri ... 59N/A # XXX Mirroring records also need to be allowed from client 59N/A # configuration, and not just catalogs. 59N/A # XXX It would be nice to include available tags and package sizes, 59N/A # although this could also be calculated from the set of manifests. 59N/A # XXX self.pkgs should be a dictionary, accessed by fmri string (or 59N/A # package name). Current code is O(N_packages) O(M_versions), should be 59N/A # O(1) O(M_versions), and possibly O(1) O(1). Likely a similar need for 59N/A # XXX Initial estimates suggest that the Catalog could be composed of 59N/A # 1e5 - 1e7 lines. Catalogs across these magnitudes will need to be 59N/A # spread out into chunks, and may require a delta-oriented update 36N/A # each V line is an fmri 37N/A # XXX This package is already in the catalog 37N/A # with some version set. Are we updating the 37N/A # version set or merging the two? 73N/A # Skip the append in the else clause 50N/A """Iterate through the catalogs, looking for an exact fmri 50N/A match. XXX Returns a list of Package objects.""" 50N/A """Iterate through the catalogs, looking for a regular 50N/A expression match. Returns an unsorted list of PkgFmri 50N/A s = s +
"C %s\n" % p
26N/A s = s +
"I %s\n" % r
59N/A """XXX -a to see all versions of all packages. Otherwise 59N/A default is to display latest version of packages.""" 59N/A # XXX no access to image means that client use of this function 59N/A # limited to unsophisticated output... 59N/A print "pkg: catalog is empty" 34N/A """Return a pair of lists, the first list being those package 34N/A FMRIs present in the current object but not in the presented 34N/A catalog, the second being those present in the presented catalog 34N/A but not in the current catalog.""" 59N/A "pkg:/test@1.0,5.10-1:20070101T120000Z",
59N/A "pkg:/test@1.0,5.11-1:20061231T120000Z",
45N/A "pkg:/test@1.0,5.11-2",
45N/A "pkg:/test@1.0,5.11-3" 50N/A print "correctly determined no match for 'flob'"