manifest.py revision 307
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye# CDDL HEADER START
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye# The contents of this file are subject to the terms of the
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye# Common Development and Distribution License (the "License").
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye# You may not use this file except in compliance with the License.
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye# See the License for the specific language governing permissions
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye# and limitations under the License.
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye# When distributing Covered Code, include this CDDL HEADER in each
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye# If applicable, add the following below this CDDL HEADER, with the
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye# fields enclosed by brackets "[]" replaced with your own identifying
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye# information: Portions Copyright [yyyy] [name of copyright owner]
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye# CDDL HEADER END
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye# Use is subject to license terms.
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbyefrom pkg.actions.attribute import AttributeAction
eb1776903fd1f998009e97470a65fba8a499a0d9Lubos Kosco# The type member is used for the ordering of actions.
eb1776903fd1f998009e97470a65fba8a499a0d9Lubos Kosco """A Manifest is the representation of the actions composing a specific
bd4999e099547832430739402d07284e957f32ddTrond Norbye package version on both the client and the repository. Both purposes
3bd91b9bbb9915421b772c357165fbc6fdeaf286Trond Norbye utilize the same storage format.
2fb25e01a103edabe94194fc7927339be9d26f35Vladimir Kotal The serialized structure of a manifest is an unordered list of actions.
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye The special action, "set", represents a package attribute.
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye The reserved attribute, "fmri", represents the package and version
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye described by this manifest. It is available as a string via the
eb1776903fd1f998009e97470a65fba8a499a0d9Lubos Kosco attributes dictionary, and as an FMRI object from the fmri member.
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye The list of manifest-wide reserved attributes is
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye base_directory Default base directory, for non-user images.
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye fmri Package FMRI.
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye isa Package is intended for a list of ISAs.
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye platform Package is intended for a list of platforms.
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye relocatable Suitable for User Image.
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye All non-prefixed attributes are reserved to the framework. Third
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye parties may prefix their attributes with a reversed domain name, domain
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye name, or stock symbol. An example might be
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye com.example,supported
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye as an indicator that a specific package version is supported by the
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye vendor, example.com.
ff5eba819da0cf7964d884630fb13262ef12c505Trond Norbye manifest.null is provided as the null manifest. Differences against the
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye null manifest result in the complete set of attributes and actions of
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye the non-null manifest, meaning that all operations can be viewed as
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye tranitions between the manifest being installed and the manifest already
eb1776903fd1f998009e97470a65fba8a499a0d9Lubos Kosco present in the image (which may be the null manifest).
bd4999e099547832430739402d07284e957f32ddTrond Norbye """Return three lists of action pairs representing origin and
eb1776903fd1f998009e97470a65fba8a499a0d9Lubos Kosco destination actions. The first list contains the pairs
bd4999e099547832430739402d07284e957f32ddTrond Norbye representing additions, the second list contains the pairs
bd4999e099547832430739402d07284e957f32ddTrond Norbye representing updates, and the third list contains the pairs
bd4999e099547832430739402d07284e957f32ddTrond Norbye represnting removals. All three lists are in the order in which
bd4999e099547832430739402d07284e957f32ddTrond Norbye they should be executed."""
bd4999e099547832430739402d07284e957f32ddTrond Norbye # XXX Do we need to find some way to assert that the keys are
bd4999e099547832430739402d07284e957f32ddTrond Norbye # all unique?
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye added = [(None, sdict[i]) for i in sset - oset]
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye removed = [(odict[i], None) for i in oset - sset]
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye # XXX for now, we force license actions to always be
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye # different to insure that existing license files for
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye # new versions are always installed
7bcb663889f8c13133d37c58e284e507dab284c0Vladimir Kotal if odict[i].different(sdict[i]) or i[0] == "license"
7bcb663889f8c13133d37c58e284e507dab284c0Vladimir Kotal # XXX Do changed actions need to be sorted at all? This is
7bcb663889f8c13133d37c58e284e507dab284c0Vladimir Kotal # likely to be the largest list, so we might save significant
7bcb663889f8c13133d37c58e284e507dab284c0Vladimir Kotal # time by not sorting. Should we sort above? Insert into a
7bcb663889f8c13133d37c58e284e507dab284c0Vladimir Kotal # sorted list?
eb1776903fd1f998009e97470a65fba8a499a0d9Lubos Kosco # singlesort = lambda x: x[0] or x[1]
f60d84bfe9ece4779c642dfe4849acd35ade9388Trond Norbye """Where difference() returns three lists, combined_difference()
3bd91b9bbb9915421b772c357165fbc6fdeaf286Trond Norbye returns a single list of the concatenation of th three."""
2fb25e01a103edabe94194fc7927339be9d26f35Vladimir Kotal """Output expects that self is newer than other. Use of sets
2fb25e01a103edabe94194fc7927339be9d26f35Vladimir Kotal requires that we convert the action objects into some marshalled
2fb25e01a103edabe94194fc7927339be9d26f35Vladimir Kotal form, otherwise set member identities are derived from the
2fb25e01a103edabe94194fc7927339be9d26f35Vladimir Kotal object pointers, rather than the contents."""
def fun(a):
alldups = []
if dups:
return alldups
def opener():
return opener
l = l.lstrip()
except KeyError:
raise SyntaxError, \
action_dict = {}
if k in action_dict:
dict((i, t) for i in v))
action_dict[k] = \
dict((i, t) for i in v)
if k in action_dict:
action_dict[k][v] = t
action_dict[k] = { v: t }
return action_dict
except KeyError:
return default
values = [
except KeyError:
if values:
return True
return False