pkgplan.py revision 2054
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
#
import errno
import itertools
import os
"""A package plan takes two package FMRIs and an Image, and produces the
set of actions required to take the Image from the origin FMRI to the
destination FMRI.
If the destination FMRI is None, the package is removed.
"""
"image", "origin_fmri", "pkg_summary", "__destination_mfst",
"__license_status", "__origin_mfst", "__progtrack",
"__repair_actions", "__xferfiles", "__xfersize"]
self.destination_fmri = None
self.origin_fmri = None
self.pkg_summary = None
self.__license_status = {}
self.__repair_actions = []
return s
"""Adds a license status entry for the given src and dest
license actions.
'src' should be None or the source action for a license.
'dest' must be the destination action for a license."""
"src": src,
"dest": dest,
"accepted": False,
"displayed": False,
}
"""Propose origin and dest fmri, manifest"""
# self.origin_fmri = None
# I'd like a cleaner solution than this; we need to actually
# construct a list of actions as things currently are rather than
# just re-applying the current set of actions.
#
# Create a list of (src, dst) pairs for the actions to send to
# execute_repair. src is none in this case since we aren't
# upgrading, just repairing.
# Only install actions, no update or remove
def get_actions(self):
raise NotImplementedError()
def get_nactions(self):
""" updates a set of installed fmris to reflect
proposed new state"""
if self.origin_fmri:
if self.destination_fmri:
"""Determine the actions required to transition the package."""
# Assume that origin actions are unique, but make sure that
# destination ones are.
if ddups:
# If new actions are being installed, check the destination
# manifest for signatures.
if self.destination_fmri is not None:
# Check that the publisher's CA certs validate against
# the image's trust anchors.
try:
"signature", new_excludes),
except apx.SigningException, e:
raise
# figure out how many implicit directories disappear in this
# transition and add directory remove actions. These won't
# do anything unless no pkgs reference that directory in
# new state....
# Retrieving origin_dirs first and then checking it for any
# entries allows avoiding an unnecessary expanddirs for the
# destination manifest when it isn't needed.
# No longer needed.
self.__origin_mfst = None
if origin_dirs:
absent_dirs = origin_dirs - \
for a in absent_dirs:
# Stash information needed by legacy actions.
self.pkg_summary = \
# No longer needed.
self.__destination_mfst = None
# Add any repair actions to the update list
def get_licenses(self):
"""A generator function that yields tuples of the form (license,
entry). Where 'entry' is a dict containing the license status
information."""
"""Sets the license status for the given license entry.
'plicense' should be the value of the license attribute for the
destination license action.
'accepted' is an optional parameter that can be one of three
values:
None leaves accepted status unchanged
False sets accepted status to False
True sets accepted status to True
'displayed' is an optional parameter that can be one of three
values:
None leaves displayed status unchanged
False sets displayed status to False
True sets displayed status to True"""
if accepted is not None:
if displayed is not None:
def get_xferstats(self):
def get_xfername(self):
if self.destination_fmri:
if self.origin_fmri:
return None
def preexecute(self):
"""Perform actions required prior to installation or removal of
a package.
This method executes each action's preremove() or preinstall()
methods, as well as any package-wide steps that need to be taken
at such a time.
"""
# Determine if license acceptance requirements have been met as
# early as possible.
errors = []
if errors:
if dest:
else:
"""Download data for any actions that need it."""
if mfile is None:
return
def gen_install_actions(self):
def gen_removal_actions(self):
def gen_update_actions(self):
""" perform action for installation of package"""
try:
# Don't log these as they're expected, and should be
# handled by the caller.
raise
except Exception, e:
raise
""" handle action updates"""
try:
# Don't log these as they're expected, and should be
# handled by the caller.
raise
except Exception, e:
raise
""" handle action removals"""
try:
# Don't log these as they're expected, and should be
# handled by the caller.
raise
except Exception, e:
raise
def postexecute(self):
"""Perform actions required after install or remove of a pkg.
This method executes each action's postremove() or postinstall()
methods, as well as any package-wide steps that need to be taken
at such a time.
"""
# record that package states are consistent
if dest:
else: