catalog.py revision 59
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 ... 37N/A # XXX Mirroring records also need to be allowed from client 37N/A # configuration, and not just catalogs. 30N/A # XXX It would be nice to include available tags and package sizes, 37N/A # although this could also be calculated from the set of manifests. 37N/A # XXX self.pkgs should be a dictionary, accessed by fmri string (or 50N/A # package name). Current code is O(N_packages) O(M_versions), should be 50N/A # O(1) O(M_versions), and possibly O(1) O(1). Likely a similar need for 50N/A # XXX Initial estimates suggest that the Catalog could be composed of 50N/A # 1e5 - 1e7 lines. Catalogs across these magnitudes will need to be 26N/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? 50N/A """Iterate through the catalogs, looking for an exact fmri 36N/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
45N/A """XXX -a to see all versions of all packages. Otherwise 45N/A default is to display latest version of packages.""" 45N/A # XXX no access to image means that client use of this function 45N/A # limited to unsophisticated output... 34N/A print "pkg: catalog is empty" 45N/A """Return a pair of lists, the first list being those package 45N/A FMRIs present in the current object but not in the presented 45N/A catalog, the second being those present in the presented catalog 45N/A but not in the current catalog.""" 45N/A "pkg:/test@1.0,5.10-1:20070101T120000Z",
50N/A "pkg:/test@1.0,5.11-1:20061231T120000Z",
50N/A "pkg:/test@1.0,5.11-2",
50N/A "pkg:/test@1.0,5.11-3" print "correctly determined no match for 'flob'"