pkgplan.py revision 3415
50N/A# The contents of this file are subject to the terms of the 50N/A# Common Development and Distribution License (the "License"). 50N/A# You may not use this file except in compliance with the License. 50N/A# See the License for the specific language governing permissions 50N/A# and limitations under the License. 50N/A# When distributing Covered Code, include this CDDL HEADER in each 50N/A# If applicable, add the following below this CDDL HEADER, with the 50N/A# fields enclosed by brackets "[]" replaced with your own identifying 50N/A# information: Portions Copyright [yyyy] [name of copyright owner] 3402N/A# Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. 50N/A """A package plan takes two package FMRIs and an Image, and produces the 50N/A set of actions required to take the Image from the origin FMRI to the 66N/A If the destination FMRI is None, the package is removed. 2690N/A # we don't serialize __xferfiles or __xfersize since those should be 2690N/A # recalculated after after a plan is loaded (since the contents of the 2690N/A # download cache may have changed). 2690N/A # we don't serialize __origin_mfst, __destination_mfst, or 2690N/A # __repair_actions since we only support serializing pkgplans which 2690N/A # have had their actions evaluated and merged, and when action 2690N/A # evaluation is complete these fields are cleared. 2690N/A # we don't serialize our image object pointer. that has to be reset 2690N/A # after this object is reloaded. 2690N/A # make sure all __state__noserialize values are valid 2690N/A # figure out which state we are saving. 2690N/A # describe our state and the types of all objects 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 # validate unserialized state 2690N/A # (see comments above __state__noserialize) 2690N/A # we use __slots__, so create a state dictionary 2690N/A """Update the state of this object using previously serialized 2690N/A state obtained via getstate().""" 2690N/A # get the name of the object we're dealing with 2690N/A # decode serialized state into python objects 2690N/A # we use __slots__, so directly update attributes 2690N/A # update unserialized state 2690N/A # (see comments above __state__noserialize) 2690N/A """Allocate a new object using previously serialized state 2690N/A obtained via getstate().""" 1618N/A """Adds a license status entry for the given src and dest 1618N/A 'src' should be None or the source action for a license. 1618N/A 'dest' must be the destination action for a license.""" 1505N/A """Propose origin and dest fmri, manifest""" 3159N/A """Generate the on-disk state (attributes) of the action 3159N/A # If file to repair isn't on-disk, treat as install 3159N/A # If associated user / group can't be determined, treat 3159N/A # as install. This is not optimal for repairs, but 3159N/A # ensures proper ownership of file is set. 3159N/A # No need to generate hash of on-disk content as verify 3159N/A # short-circuits hash comparison by setting replace_required 3159N/A # flag on action. The same is true for preserved files which 3159N/A # will automatically handle content replacement if needed based 3159N/A # on the result of _check_preserve. 1505N/A # I'd like a cleaner solution than this; we need to actually 2453N/A # construct a list of actions as things currently are rather 2453N/A # than just re-applying the current set of actions. 583N/A # Create a list of (src, dst) pairs for the actions to send to 3159N/A # If an uninstall causes a fixup to happen, we can't 3159N/A # generate an on-disk state action because the result 3159N/A # of needsdata is different between propose and execute. 3159N/A # Therefore, we explicitly assign None to src for actions 3159N/A # dest is none for removals. 3159N/A # src can be None or an action representing on-disk state 307N/A """ updates a set of installed fmris to reflect 66N/A """Determine the actions required to transition the package.""" 2026N/A # If new actions are being installed, check the destination 2261N/A # Since user removed publisher, assume this is 2261N/A # the same as if they had set signature-policy 2261N/A # ignore for the publisher. 2797N/A # Repaired packages use a manifest synthesized 2797N/A # from the installed one; so retrieve the 2797N/A # installed one for our signature checks. 2261N/A # Only perform signature verification logic if 2261N/A # there are signatures or if signature-policy 2458N/A "check-certificate-revocation"))
307N/A # figure out how many implicit directories disappear in this 307N/A # transition and add directory remove actions. These won't 307N/A # do anything unless no pkgs reference that directory in 1045N/A # Retrieving origin_dirs first and then checking it for any 1045N/A # entries allows avoiding an unnecessary expanddirs for the 1045N/A # destination manifest when it isn't needed. 2277N/A # Manifest.get_directories() returns implicit directories, which 2277N/A # means that this computation ends up re-adding all the explicit 2277N/A # directories getting removed to the removed list. This is 400N/A # Stash information needed by legacy actions. 2453N/A # Add any install repair actions to the update list 2453N/A # Initial installs require acceptance. 2117N/A # If src action required acceptance, 2117N/A # then license was already accepted 2117N/A # before, and if the hashes are the 2117N/A # same for the license payload, then 2117N/A # it doesn't need to be accepted again. 3415N/A # Keep a cache of dir actions with salvage-from attrs. 3415N/A # Since directories are installed in top-down order, 3415N/A # we need this list to make sure we salvage contents 3415N/A # as accurately as possible. For example, where: 3415N/A # We must ensure that we don't try to salvage 3415N/A # is being installed, otherwise that content will 3415N/A # the salvaged to the wrong place. 1618N/A """A generator function that yields tuples of the form (license, 1618N/A entry). Where 'entry' is a dict containing the license status 1618N/A """Sets the license status for the given license entry. 1618N/A 'plicense' should be the value of the license attribute for the 1618N/A destination license action. 1618N/A 'accepted' is an optional parameter that can be one of three 1618N/A None leaves accepted status unchanged 1618N/A False sets accepted status to False 1618N/A True sets accepted status to True 1618N/A 'displayed' is an optional parameter that can be one of three 1618N/A None leaves displayed status unchanged 1618N/A False sets displayed status to False 1618N/A True sets displayed status to True""" 2407N/A """Return tuple of compressed bytes possibly downloaded 2407N/A and number of bytes laid down; ignore removals 2407N/A because they're usually pinned by snapshots""" 388N/A """Perform actions required prior to installation or removal of 66N/A This method executes each action's preremove() or preinstall() 66N/A methods, as well as any package-wide steps that need to be taken 1618N/A # Determine if license acceptance requirements have been met as 481N/A """Download data for any actions that need it.""" 2690N/A """Load previously downloaded data for actions that need it.""" 237N/A """ perform action for installation of package""" 1755N/A # Don't log these as they're expected, and should be 1618N/A """ handle action updates""" 1755N/A # Don't log these as they're expected, and should be 237N/A """ handle action removals""" 1755N/A # Don't log these as they're expected, and should be 3255N/A """handle a retry operation""" 400N/A """Perform actions required after install or remove of a pkg. 66N/A This method executes each action's postremove() or postinstall() 66N/A methods, as well as any package-wide steps that need to be taken 66N/A # record that package states are consistent 2293N/A """Used to save unexpected files or directories found during 2293N/A plan execution. Salvaged items are tracked in the imageplan. 3121N/A # get just the file path that was salvaged 2470N/A """move unpackaged contents to specified destination""" 2470N/A # remove leading / if present 3415N/A # The salvaged locations known to us are a list of tuples of 3415N/A # the form (old dir, lost+found salvage dir) and stored in 3415N/A # self.image.imageplan.pd._salvaged[:] 3415N/A # Check if this salvage-from is also the best match for other 3415N/A # possibly previously packaged subdirs of this directory. 3415N/A # On the other hand, if we package another directory, with 3415N/A # to salvage the .ssh content, not the action that salvages