directory.py revision 1846
#
# 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
#
#
# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
"""module describing a directory packaging object
This module contains the DirectoryAction class, which represents a
directory-type packaging object."""
import os
import errno
import stat
import generic
"""Class representing a directory-type packaging object."""
__slots__ = []
name = "dir"
key_attr = "path"
def directory_references(self):
"""Client-side method that installs a directory."""
mode = None
try:
except (TypeError, ValueError):
# Mode isn't valid, so let validate raise a more
# informative error.
if orig:
try:
except (TypeError, ValueError):
# Mode isn't valid, so let validate raise a more
# informative error.
# XXX Hack! (See below comment.)
if not orig:
try:
except OSError, e:
# Treat EROFS like EEXIST if both are
# applicable, since we'll end up with
# EROFS instead.
return
raise
raise
# 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.
try:
except OSError, e:
raise
"""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."""
try:
except OSError, e:
pass
# cannot remove directory since it's
# not empty...
raise
def generate_indices(self):
"""Generates the indices needed by the search dictionary. See
generic.py for a more detailed explanation."""
return [
("directory", "basename",
None),
None)
]
"""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."""