1505N/A# The contents of this file are subject to the terms of the 1505N/A# Common Development and Distribution License (the "License"). 1505N/A# You may not use this file except in compliance with the License. 1505N/A# See the License for the specific language governing permissions 1505N/A# and limitations under the License. 1505N/A# When distributing Covered Code, include this CDDL HEADER in each 1505N/A# If applicable, add the following below this CDDL HEADER, with the 1505N/A# fields enclosed by brackets "[]" replaced with your own identifying 1505N/A# information: Portions Copyright [yyyy] [name of copyright owner] 3339N/A# Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. 2690N/A # store information on facets; subclass dict 1505N/A # and maintain ordered list of keys sorted 2925N/A # subclass __getitem__ so that queries w/ 2931N/A # For image planning purposes and to be able to compare facet objects 2931N/A # deterministically, facets must be sorted. They are first sorted by 2931N/A # source (more details below), then by length, then lexically. 2925N/A # Facets can come from three different sources. 2925N/A # SYSTEM facets are facets whose values are assigned by the system. 2925N/A # These are usually facets defined in packages which are not set in an 2925N/A # image, and the value assigned by the system is always true. These 2925N/A # facets will usually never be found in a Facets dictionary. (Facets 2925N/A # dictionaries only contain facets which are explicitly set.) 2925N/A # LOCAL facets are facets which have been set locally in an image 2925N/A # using pkg(1) or the pkg api. Explicitly set LOCAL facets are stored 2925N/A # in Facets.__local. Facets which are not explicitly set but match an 2925N/A # explicitly set LOCAL facet glob pattern are also considered to be 2925N/A # PARENT facets are facets which are inherited from a parent image. 2925N/A # they are managed internally by the packaging subsystem. Explicitly 2925N/A # inherited facets are stored in Facets.__inherited. Facets which are 2925N/A # not explicitly set but match an explicitly set PARENT facet glob 2925N/A # pattern are also considered to be PARENT. 2925N/A # When evaluating facets, all PARENT facets are evaluated before LOCAL 2925N/A # facets. This is done by ensuring that all PARENT facets come before 2925N/A # any LOCAL facets in __keylist. This is done because PARENT facets 2925N/A # exist to propagate faceted dependencies between linked images, which 2925N/A # is needed to ensure the solver can run successfully. ie, if a 2925N/A # parent image relaxes dependencies via facet version-locks, then the 2925N/A # child needs to inherit those facets since otherwise it is more 2925N/A # constrained in possible solutions than it's parent and likely won't 2925N/A # be able to plan an update that keeps it in sync with it's parent. 2925N/A # Sine PARENT facets take priority over LOCAL facets, it's possible to 2925N/A # have conflicts between the two. In the case where a facet is both 2925N/A # inherited and set locally, both values are preserved, but the 2925N/A # inherited value masks the local value. Users can list and update 2925N/A # local values while they are masked using pkg(1), but as long as the 2925N/A # values are masked they will not affect image planning operations. 2925N/A # Once an inherited facet that masks a local facet is removed, the 2925N/A # local facet will be restored. 2690N/A """Returns the serialized state of this object in a format 2690N/A that that can be easily stored using JSON, pickle, etc.""" 2690N/A """Update the state of this object using previously serialized 2690N/A state obtained via getstate().""" 2925N/A """Compare the facet match priority of two Facets objects. 2925N/A Since the match priority of a Facets object is dependent upon 2925N/A facet sources (local vs parent) and names, we're essentially 2925N/A ensuring that both objects have the same set of facet sources 2925N/A """Compare the facet values of two Facets objects. This 2925N/A comparison ignores any masked values.""" 2925N/A """Compare all the facet values of two Facets objects. This 2925N/A comparison takes masked values into account.""" 3253N/A # this __cmp__ is used as a helper function for the rich comparison 3253N/A # __cmp__ defined; pylint: disable=W1630 2925N/A """Compare two Facets objects. This comparison takes masked 2925N/A # check if we're getting compared against something other than 2925N/A # Check for effective facet value changes that could affect 2925N/A # Check for facet priority changes that could affect solver 2925N/A # computations. (Priority changes can occur when local or 2925N/A # inherited facets are added or removed.) 2925N/A # There are no outwardly visible facet priority or value 2925N/A # changes that could affect solver computations, but it's 2925N/A # still possible that we're changing the set of local or 2925N/A # inherited facets in a way that doesn't affect solver 2925N/A # computations. For example: we could be adding a local 2925N/A # facet with a value that is masked by an inherited facet, or 2925N/A # having a facet transition from being inherited to being 2925N/A # local without a priority or value change. Check if this is 2925N/A """redefine in terms of __cmp__()""" 2925N/A """redefine in terms of __cmp__()""" 2925N/A """redefine in terms of __cmp__()""" 2925N/A """redefine in terms of __cmp__()""" 2925N/A """redefine in terms of __cmp__()""" 2925N/A """redefine in terms of __cmp__()""" 2925N/A """Update __keysort, which is used to determine facet matching 2925N/A order. Inherited facets always take priority over local 2925N/A facets so make sure all inherited facets come before local 2931N/A facets in __keylist. All facets from a given source are 2931N/A sorted by length, and facets of equal length are sorted 2925N/A # save the facet in the local or inherited dictionary 2925N/A # clear the corresponding read-only dictionary 2925N/A # Inherited facets always take priority over local facets. 2925N/A """__setitem__ only operates on local facets.""" 2925N/A """Implement facet lookup algorithm here 2925N/A Note that _allow_facet bypasses __getitem__ for performance 2925N/A reasons; if __getitem__ changes, _allow_facet in _varcet.c 2925N/A We return a tuple of the form (<key>, <value>) where key is 2925N/A the explicitly set facet name (which may be a glob pattern) 2925N/A that matched the caller specific facet name.""" 3070N/A # The trailing '.' is to encourage namespace usage. 2925N/A # check for an attempt to delete an invalid facet 2925N/A # check for an attempt to delete an invalid local facet 2925N/A # we should never try to delete an invalid inherited facet 2925N/A # the inherited value was overriding a local value 2925N/A # that should now be exposed 2925N/A # delete item from the local or inherited dictionary 2925N/A # clear the corresponding read-only dictionary 2925N/A """__delitem__ only operates on local facets.""" 2639N/A # allow_action is provided as a native function (see end of class 2925N/A """Set an inherited facet.""" 2925N/A """Clear all inherited facet.""" 2925N/A facets present on an action.""" 2925N/A # find all the facets present in the current action 2925N/A # we found a matching facet. 2925N/A # we found a matching facet. 2925N/A """pop() only operates on local facets.""" 2925N/A # check if the user specified a default value 2925N/A """popitem() only operates on local facets.""" 2925N/A # preserve inherited facets. 2925N/A """A facet may be set via multiple sources and hence have 2925N/A multiple values. If there are multiple values for a facet, 2925N/A all but one of those values will be masked. So for a given 2925N/A facet, return a list of tuples of the form (<value>, <src>, 2925N/A <masked>) which represent all currently set values for this 2925N/A """Report the source of a facet value if we were to attempt to 2925N/A look it up in the current Facets object dictionary.""" 2925N/A # For convenience, provide callers with direct access to local and 2925N/A # parent facets via cached read-only dictionaries.