#
# 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
#
#
#
"""SystemV / Solaris packages.
This module allows the new Solaris packaging system to interface with
System V style packages, both in directory format and in datastream
format.
When a package is in datastream format, it may be compressed with gzip.
XXX Some caveats about rewinding a datastream or multiple packages per
datastream.
"""
import errno
import gzip
import os
import sys
"""A class that represents a single line of a SysV package's pkgmap.
XXX This class should probably disappear once pkg.manifest? is a bit
more fleshed out.
"""
try:
except ValueError:
return
array[3:]
else:
# some packages have $BASEDIR in the pkgmap; this needs to
# be handled specially
# this will cause the pkg to have a NULL path after
# basedir removal, which breaks things. Make this
# entry go away by pretending it is an 'i' type file.
else:
pass
# XXX This needs to have a constructor that takes a pkg: FMRI (the new name of
# the package). - sch
#
# XXX want to be able to pull datastream packages from the web. Should the
# constructor be able to interpret path as a URI, or should we have an optional
# "fileobj" argument which can point to an http stream?
"""A SolarisPackage represents a System V package for Solaris.
"""
"""The constructor for the SolarisPackage class.
The "path" argument may be a directory -- in which case it is
assumed to be a directory-format package -- or a file -- in
which case it's tested whether or not it's a datastream package.
"""
fo = f
else:
f.seek(0)
try:
fo = g
else:
raise IOError("not a package")
except IOError as e:
if e.args[0] not in (
"Not a gzipped file",
"not a package"):
raise
else:
g.close()
pkgs = []
while True:
if line == PKG_HDR_END:
break
"{0} contains {1} packages".format(
# The cpio archive containing all the packages' pkginfo
# and pkgmap files starts on the next 512-byte boundary
# after the header, so seek to that point.
# We're going to need to extract and cache the contents
# of the pkginfo and pkgmap files because we're not
# guaranteed random access to the datastream. At least
# they should be reasonably small in size; the largest
# delivered in Solaris is a little over 2MB.
# XXX Here we allow for only one package. :(
else:
self.datastream = None
# Snag BASEDIR, and remove leading and trailing slashes.
try:
except KeyError:
# XXX This is obviously bogus, but the dependency information is
# in the main archive, which we haven't read in the constructor
if self.datastream:
return []
try:
except IOError as xxx_todo_changeme:
# Missing depend file is just fine
# Missing depend file is just fine
return []
else:
raise
deps = []
continue
try:
except ValueError:
return deps
pkginfo = {}
if self.datastream:
else:
continue
# Eliminate comments, but special-case the faspac turd.
pkginfo["faspac"] = \
continue
# Expose the platform-specific package name, too.
platext = {
"i386.i86pc": ".i",
"sparc.sun4u": ".u",
"sparc.sun4v": ".v",
}
pkginfo["PKG.PLAT"] = \
return pkginfo
pkgmap = []
if self.datastream:
else:
continue
continue
return pkgmap
if __name__ == "__main__":
print()
print()
print(d)