directory.py revision 3339
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] 1685N/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.""" 307N/A """Returns a list of attributes that have different values 307N/A between 'other' and 'self'. This differs from the generic 307N/A Action's differences() method in that it normalizes the 'mode' 307N/A attribute so that, say, '0755' and '755' are treated as 72N/A """Create a directory.""" 1784N/A # makedirs failed for some component 289N/A # Treat EROFS like EEXIST if both are 1507N/A # applicable, since we'll end up with 95N/A # User has replaced directory with a 95N/A # link, or a package has been poorly 95N/A # implemented. It isn't safe to 95N/A # simply re-create the directory as 95N/A # that won't restore the files that 95N/A # are supposed to be contained within. 95N/A "directory {0}; it has been " 95N/A "replaced with a link. To " 95N/A "continue, please remove the " 95N/A "link or restore the directory " 72N/A "to its original location and " 72N/A # User has replaced directory with a 271N/A # file, or a package has been poorly 271N/A # implemented. Salvage what's there, 1685N/A # The directory already exists, but 1685N/A # ensure that the mode matches what's 289N/A """Client-side method that installs a directory.""" 462N/A # Mode isn't valid, so let validate raise a more 140N/A # Mode isn't valid, so let validate raise a more 941N/A # Don't allow installation through symlinks. 941N/A # XXX Hack! (See below comment.) 1755N/A # The downside of chmodding the directory is that as a non-root 1755N/A # user, if we set perms u-w, we won't be able to put anything in 1755N/A # it, which is often not what we want at install time. We save 1755N/A # the chmods for the postinstall phase, but it's always possible 1755N/A # that a later package install will want to place something in 1755N/A # this directory and then be unable to. So perhaps we need to 1755N/A # (in all action types) chmod the parent directory to u+w on # failure, and chmod it back aftwards. The trick is to # recognize failure due to missing file_dac_write in contrast to # other failures. Or can we require that everyone simply have # file_dac_write who wants to use the tools. Probably not. # Assume chmod failed due to a # if we're salvaging contents, move 'em now. # directories with "salvage-from" attribute # set will scavenge any available contents # that matches specified directory and # move it underneath itself on install or update. # This is here to support directory rename # when old directory has unpackaged contents, or # consolidation of content from older directories. # Assume chown failed due to a """Returns a tuple of lists of the form (errors, warnings, info). The error list will be empty if the action has been correctly installed in the given image.""" # Cannot remove directory since it's # Either the user or another package has changed # this directory into a link or file. Salvage # what's there and drive on. # User has replaced directory with mountpoint, # or a package has been poorly implemented. err_txt = _(
"Unable to remove {0}; it is " "in use as a mountpoint. To " "continue, please unmount the " "filesystem at the target " "location and try again.").
format(
# os.path.ismount() is broken for lofs # filesystems, so give a more generic err_txt = _(
"Unable to remove {0}; it " "is in use by the system, another " """Generates the indices needed by the search dictionary. See """Performs additional validation of action attributes that for performance or other reasons cannot or should not be done during Action object creation. An ActionError exception (or subclass of) will be raised if any attributes are not valid. This is primarily intended for use during publication or during error handling to provide additional diagonostics. 'fmri' is an optional package FMRI (object or string) indicating what package contained this action."""