manifest.py revision 2091
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch# CDDL HEADER START
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch# The contents of this file are subject to the terms of the
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch# Common Development and Distribution License (the "License").
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch# You may not use this file except in compliance with the License.
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch# See the License for the specific language governing permissions
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch# and limitations under the License.
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch# When distributing Covered Code, include this CDDL HEADER in each
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch# If applicable, add the following below this CDDL HEADER, with the
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch# fields enclosed by brackets "[]" replaced with your own identifying
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch# information: Portions Copyright [yyyy] [name of copyright owner]
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch# CDDL HEADER END
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Boschfrom pkg.misc import EmptyDict, EmptyI, expanddirs, PKG_FILE_MODE, PKG_DIR_MODE
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Boschfrom pkg.actions.attribute import AttributeAction
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan BoschManifestDifference = namedtuple("ManifestDifference", "added changed removed")
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch """A Manifest is the representation of the actions composing a specific
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch package version on both the client and the repository. Both purposes
6135260095e1704ed6edff9d00bdfc043c11429cTimo Sirainen utilize the same storage format.
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch The serialized structure of a manifest is an unordered list of actions.
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch The special action, "set", represents a package attribute.
3b986520baac0b2faee1196f9122f1dbdc245434Aki Tuomi The reserved attribute, "fmri", represents the package and version
3b986520baac0b2faee1196f9122f1dbdc245434Aki Tuomi described by this manifest. It is available as a string via the
49fc09f995183d44e004bbc3eb9b6c6c7b6cae7fTimo Sirainen attributes dictionary, and as an FMRI object from the fmri member.
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch The list of manifest-wide reserved attributes is
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch base_directory Default base directory, for non-user images.
49fc09f995183d44e004bbc3eb9b6c6c7b6cae7fTimo Sirainen fmri Package FMRI.
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch isa Package is intended for a list of ISAs.
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch platform Package is intended for a list of platforms.
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch relocatable Suitable for User Image.
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch All non-prefixed attributes are reserved to the framework. Third
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch parties may prefix their attributes with a reversed domain name, domain
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch name, or stock symbol. An example might be
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch com.example,supported
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch as an indicator that a specific package version is supported by the
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch vendor, example.com.
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch manifest.null is provided as the null manifest. Differences against the
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch null manifest result in the complete set of attributes and actions of
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch the non-null manifest, meaning that all operations can be viewed as
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch tranitions between the manifest being installed and the manifest already
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch present in the image (which may be the null manifest).
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch self.attributes = {} # package-wide attributes
return ManifestDifference(
def hashify(v):
return frozenset(v)
changed = [
m_dicts = [
dict(
for a in m.actions)
for m in compare_m
m_sets = [
for m in m_dicts
return tuple(
if not src:
elif not dest:
return out
for c in excludes:
for c in excludes:
def fun(a):
alldups = []
if dups:
return alldups
errors = []
for l in content:
l = l.lstrip()
elif accumulate:
l = accumulate + l
if errors:
if pathname:
except EnvironmentError, e:
if signatures:
log=None):
if log is None:
log = lambda x: None
action_dict = {}
if full_value is None:
if full_value is None:
if full_value is None:
for t in tok
], cp)
while line:
except KeyError, k:
if return_line:
arg = l
return action_dict
except EnvironmentError, e:
e.filename)
except EnvironmentError, e:
e.filename)
except EnvironmentError, e:
e.filename)
return variants
return [variants]
except KeyError:
return default
return True
return False
return size
pathname=None):
if not contents:
elif excludes:
elif excludes:
return True
return False
f.close()
f.write(s)
f.close()
for d in dirs:
for v in dirs[d]:
for t in v.iteritems()))
dirs = {}
v, f = a.get_varcet_keys()
if d not in dirs:
for d in dirs:
if {} in dirs[d]:
dirs[d] = [{}]
return dirs
except EnvironmentError, e:
except EnvironmentError, e:
alist = [
f.close()
s = set([
for a in alist
return list(s)
excludes):
excludes):
f.close()
return False
f.close()
return True
except KeyError:
return default
return ManifestDifference([], [],