49N/A# The contents of this file are subject to the terms of the 49N/A# Common Development and Distribution License (the "License"). 49N/A# You may not use this file except in compliance with the License. 49N/A# See the License for the specific language governing permissions 49N/A# and limitations under the License. 49N/A# When distributing Covered Code, include this CDDL HEADER in each 49N/A# If applicable, add the following below this CDDL HEADER, with the 49N/A# fields enclosed by brackets "[]" replaced with your own identifying 49N/A# information: Portions Copyright [yyyy] [name of copyright owner] 3339N/A# Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. 49N/A"""module describing a directory packaging object 49N/AThis module contains the DirectoryAction class, which represents a 49N/Adirectory-type packaging object.""" 49N/A """Class representing a directory-type packaging object.""" 2205N/A """Returns a list of attributes that have different values 2205N/A between 'other' and 'self'. This differs from the generic 2205N/A Action's differences() method in that it normalizes the 'mode' 2205N/A attribute so that, say, '0755' and '755' are treated as 3109N/A # makedirs failed for some component 3109N/A # Treat EROFS like EEXIST if both are 3109N/A # applicable, since we'll end up with 3109N/A # User has replaced directory with a 3109N/A # link, or a package has been poorly 3109N/A # implemented. It isn't safe to 3109N/A # simply re-create the directory as 3109N/A # that won't restore the files that 3109N/A # are supposed to be contained within. 3158N/A "directory {0}; it has been " 3109N/A "replaced with a link. To " 3109N/A "continue, please remove the " 3109N/A "link or restore the directory " 3109N/A "to its original location and " 3109N/A # User has replaced directory with a 3109N/A # file, or a package has been poorly 3109N/A # implemented. Salvage what's there, 3109N/A # The directory already exists, but 3109N/A # ensure that the mode matches what's 49N/A """Client-side method that installs a directory.""" 1755N/A # Mode isn't valid, so let validate raise a more 1784N/A # Mode isn't valid, so let validate raise a more 1859N/A # Don't allow installation through symlinks. 95N/A # XXX Hack! (See below comment.) 95N/A # The downside of chmodding the directory is that as a non-root 95N/A # user, if we set perms u-w, we won't be able to put anything in 95N/A # it, which is often not what we want at install time. We save 95N/A # the chmods for the postinstall phase, but it's always possible 95N/A # that a later package install will want to place something in 95N/A # this directory and then be unable to. So perhaps we need to 95N/A # (in all action types) chmod the parent directory to u+w on 95N/A # failure, and chmod it back aftwards. The trick is to 95N/A # recognize failure due to missing file_dac_write in contrast to 95N/A # other failures. Or can we require that everyone simply have 95N/A # file_dac_write who wants to use the tools. Probably not. 3109N/A # Assume chmod failed due to a 2818N/A # if we're salvaging contents, move 'em now. 2818N/A # directories with "salvage-from" attribute 2818N/A # set will scavenge any available contents 2818N/A # that matches specified directory and 2818N/A # move it underneath itself on install or update. 2818N/A # This is here to support directory rename 2818N/A # when old directory has unpackaged contents, or 2818N/A # consolidation of content from older directories. 3176N/A # Assume chown failed due to a 1685N/A """Returns a tuple of lists of the form (errors, warnings, 1685N/A info). The error list will be empty if the action has been 1685N/A correctly installed in the given image.""" 1859N/A # Cannot remove directory since it's 1859N/A # Either the user or another package has changed 1859N/A # this directory into a link or file. Salvage 1859N/A # what's there and drive on. 1859N/A # User has replaced directory with mountpoint, 1859N/A # or a package has been poorly implemented. 2987N/A "in use as a mountpoint. To " 2987N/A "continue, please unmount the " 2987N/A "filesystem at the target " 1859N/A # os.path.ismount() is broken for lofs 1859N/A # filesystems, so give a more generic 2987N/A "is in use by the system, another " 1100N/A """Generates the indices needed by the search dictionary. See 1755N/A """Performs additional validation of action attributes that 1755N/A for performance or other reasons cannot or should not be done 1755N/A during Action object creation. An ActionError exception (or 1755N/A subclass of) will be raised if any attributes are not valid. 1755N/A This is primarily intended for use during publication or during 1755N/A error handling to provide additional diagonostics. 1755N/A 'fmri' is an optional package FMRI (object or string) indicating 1755N/A what package contained this action."""