DirectoryBundle.py revision 2112
#
# 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
#
#
#
import os
import stat
class DirectoryBundle(object):
"""The DirectoryBundle class assists in the conversion of a directory
tree to a pkg(5) package by traversing the tree and emitting actions for
all files, directories, and links found therein.
Paths are published relative to the given directory. Hardlinks are
resolved as long as their companions are in the tree as well.
All owners are set to "root" and groups to "bin", as the ownership
information is not considered to be valid. These can be set by the
caller once the action has been emitted.
"""
# XXX This could be more intelligent. Or get user input. Or
# extend API to take FMRI.
# Pre-populate self.inodes with the paths of known targets
for p in self.targetpaths:
if act:
yield act
# Any inode in self.inodes will either have been visited
# before or will have been pre-populated from the list
# of known targets. Create file actions for known
# targets and unvisited inodes.
else:
# Find the relative path to the link target.