hardlink.py revision 1713
#
# 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 (hard) link packaging object
This module contains the HardLinkAction class, which represents a hardlink-type
packaging object."""
import errno
import link
import os
import stat
"""Class representing a hardlink-type packaging object."""
name = "hardlink"
def get_target_path(self):
""" return a path for target that is relative to image"""
# paths are either relative to path or absolute;
# both need to be passed through os.path.normpath to ensure
# that all ".." are removed to constrain target to image
else:
return target
"""Client-side method that installs a hard link."""
try:
except EnvironmentError, e:
raise ActionExecutionError(self, e,
"missing hard link target '%s'" % target)
else:
raise ActionExecutionError(self, e)
"""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."""
#
# We only allow hard links to regular files, so the hard
# link should lstat() as a regular file.
#
if abort:
assert errors
# No point in continuing if no target
if errors:
try:
"inodes not the same") %
except OSError, e: