directory.py revision 3047
# Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. """module describing a directory packaging object This module contains the DirectoryAction class, which represents a directory-type packaging object.""" """Class representing a directory-type packaging object.""" """Returns a list of attributes that have different values between 'other' and 'self'. This differs from the generic Action's differences() method in that it normalizes the 'mode' attribute so that, say, '0755' and '755' are treated as """Client-side method that installs a directory.""" # Mode isn't valid, so let validate raise a more # Mode isn't valid, so let validate raise a more # Don't allow installation through symlinks. # XXX Hack! (See below comment.) # makedirs failed for some component # Treat EROFS like EEXIST if both are # applicable, since we'll end up with # User has replaced directory with a # link, or a package has been poorly # implemented. It isn't safe to # simply re-create the directory as # that won't restore the files that # are supposed to be contained within. "directory %s; it has been " "replaced with a link. To " "continue, please remove the " "link or restore the directory " "to its original location and " # User has replaced directory with a # file, or a package has been poorly # implemented. Salvage what's there, # The directory already exists, but # ensure that the mode matches what's # The downside of chmodding the directory is that as a non-root # user, if we set perms u-w, we won't be able to put anything in # it, which is often not what we want at install time. We save # the chmods for the postinstall phase, but it's always possible # that a later package install will want to place something in # this directory and then be unable to. So perhaps we need to # (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. # 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. """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 %s; it is " "in use as a mountpoint. To " "continue, please unmount the " "filesystem at the target " "location and try again.") %
path # os.path.ismount() is broken for lofs # filesystems, so give a more generic err_txt = _(
"Unable to remove %s; it " "is in use by the system, another " "process, or as a mountpoint.") \
"""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."""