#
# 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 cherrypy
import itertools
import os
import six
"""This class represents a base API object that is provided by the
server to clients. A base API object is required when creating
objects for any other interface provided by the API. This allows
the server to provide a set of private object references that are
needed by interfaces to provide functionality to clients.
"""
# A protected reference to a pkg.server.depot object.
# A protected reference to a cherrypy request object.
# A protected reference to the publisher this interface is for.
"""Private base class used for api interface objects.
"""
if version_id not in compatible_versions:
"""This class presents an interface to server catalog objects that
clients may use.
"""
# Constants used to reference specific values that info can return.
# Constants for some state information returned by package matching
# functions.
"""A generator function that produces FMRIs as it iterates
over the contents of the server's catalog.
'ordered' is an optional boolean value that indicates that
results should sorted by stem and then by publisher and
be in descending version order. If False, results will be
in a ascending version order on a per-publisher, per-stem
basis."""
try:
except srepo.RepositoryMirrorError:
return iter(())
"""A generator function that produces a list of tuples of the
form (fmri, states) in the catalog incorporated by the named
package and its dependencies and any packages that are not
incorporated by the named packages or their dependencies. FMRIs
are returned ordered by stem and descending version. State
is a set of PKG_STATES applicable to the 'fmri'."""
try:
except srepo.RepositoryMirrorError:
return
# Seed the set of allowed packages with the set of FMRIs that
# were started with since they don't likely incorporate
# themselves.
)
# pfmri is not leaked from the above list comprehension in
# Python 3, so we need to use pfmris[-1] explicitly.
# Add packages not incorporated by the recursively discovered
# incorporations above.
for f in flist:
continue
if aname == "pkg.renamed":
if avalue == "true":
break
if aname == "pkg.obsolete":
if avalue == "true":
break
return (
)
if a.name != "depend":
continue
continue
# Versionless incorporations don't make sense so don't
# recurse any further.
if not iver:
continue
continue
for f in flist:
continue
if aname == "pkg.renamed":
if avalue == "true":
break
if aname == "pkg.obsolete":
if avalue == "true":
break
"""A generator function that produces tuples of the form:
(
(
pub, - (string) the publisher of the package
stem, - (string) the name of the package
version - (string) the version of the package
),
states, - (list) states
attributes - (dict) package attributes
)
Results are always sorted by stem, publisher, and then in
descending version order.
'collect_attrs' is an optional boolean that indicates whether
all package attributes should be collected and returned in the
fifth element of the return tuple. If False, that element will
be an empty dictionary.
'matched' is an optional set to add matched patterns to.
'patterns' is an optional list of FMRI wildcard strings to
filter results by.
'pubs' is an optional list of publisher prefixes to restrict
the results to.
'unmatched' is an optional set to add unmatched patterns to.
'return_fmris' is an optional boolean value that indicates that
an FMRI object should be returned in place of the (pub, stem,
ver) tuple that is normally returned."""
try:
except srepo.RepositoryMirrorError:
return iter(())
"""Gathers information about fmris. fmri_strings is a list
of fmri_names for which information is desired. It
returns a dictionary of lists. The keys for the dictionary are
the constants specified in the class definition. The values are
lists of PackageInfo objects or strings."""
if bad_opts:
fmris = []
notfound = []
illegals = []
for pattern in fmri_strings:
try:
pfmri = None
continue
else:
if not pfmri:
# Set of options that can use catalog data.
# Set of options that require manifest retrieval.
pis = []
for f in fmris:
packaging_date = \
states = None
description = None
if cat_opts & info_needed:
if cat_info is not None:
cat_info = [
]
try:
except srepo.RepositoryError as e:
continue
continue
if act_opts & info_needed:
"link", excludes))
"hardlink", excludes))
"file", excludes))
"dir", excludes))
return {
}
"""Returns a datetime object representing the date and time at
which the catalog was last modified. Returns None if not
available.
"""
try:
except srepo.RepositoryMirrorError:
return None
return c.last_modified
"""The total number of packages in the catalog. Returns None
if the catalog is not available.
"""
try:
except srepo.RepositoryMirrorError:
return None
return c.package_count
"""The total number of package versions in the catalog. Returns
None if the catalog is not available.
"""
try:
except srepo.RepositoryMirrorError:
return None
return c.package_version_count
"""Searches the catalog for actions or packages (as determined
by 'return_type') matching the specified 'tokens'.
'tokens' is a string using pkg(7) query syntax.
'case_sensitive' is an optional, boolean value indicating
whether matching entries must have the same case as that of
the provided tokens.
'return_type' is an optional, constant value indicating the
type of results to be returned. This constant value should be
one provided by the pkg.server.query_parser.Query class.
'start_point' is an optional, integer value indicating how many
search results should be discarded before returning any results.
None is interpreted to mean 0.
'num_to_return' is an optional, integer value indicating how
many search results should be returned. None means return all
results.
'matching_version' is a string in the format expected by the
pkg.version.MatchingVersion class that will be used to further
filter the search results as they are retrieved.
'return_latest' is an optional, boolean value that will cause
only the latest versions of packages to be returned. Ignored
if 'return_type' is not qp.Query.RETURN_PACKAGES.
"""
if not tokens:
return []
if not self.search_available:
return []
if start_point is None:
start_point = 0
found = 0
last_stem = None
if found and \
break
if mver is not None:
continue
if return_latest and \
# Latest version filtering can only be
# done for packages as only they are
# guaranteed to be in version order.
continue
else:
found += 1
if found > start_point:
yield result
try:
except StopIteration:
return
if return_latest and \
a = resa[2]
b = resb[2]
# Version in descending order.
b.version) * -1
if matching_version or return_latest:
# Additional filtering needs to be performed and
# the results yielded one by one.
mver = None
if matching_version:
None)
# Results should be retrieved here so that an exception
# can be immediately raised.
return_type, None, None)
if not res_list:
return
if not res_list:
return
return res_list[0]
"""Returns a Boolean value indicating whether search
functionality is available for the catalog.
"""
try:
except srepo.RepositoryUnknownPublisher:
return False
return rstore.search_available
"""Private function. Returns the license info from the
manifest mfst."""
license_lst = []
s = BytesIO()
s.close()
return license_lst
"""Returns the version of the catalog or None if no catalog
is available.
"""
try:
except srepo.RepositoryMirrorError:
return None
if hasattr(c, "version"):
return c.version
# Assume version 0.
return 0
"""This class presents a read-only interface to configuration
information and statistics about the depot that clients may use.
"""
"""The number of /catalog operation requests that have occurred
during the current server session.
"""
"""The file system path where the server's content and web
directories are located.
"""
"""The number of /file operation requests that have occurred
during the current server session.
"""
"""The number of package transactions awaiting completion.
"""
"""The number of /manifest operation requests that have occurred
during the current server session.
"""
"""A Boolean value indicating whether the server is currently
operating in mirror mode.
"""
"""A Boolean value indicating whether the server is currently
operating in readonly mode.
"""
"""The file system path where the server's web content is
located.
"""
"""Returns a dictionary of depot configuration properties
organized by section, with each section's keys as a list.
See pkg.depotd(8) for the list of properties.
"""
rval = {}
return rval
"""Returns the current value of a depot configuration
property for the specified section.
"""
"""Returns a dictionary of repository configuration
properties organized by section, with each section's keys
as a list.
Available properties are as follows:
Section Property Description
========== ========== ===============
publisher prefix The name of the default
publisher to use for packaging
operations if one is not
provided.
repository version An integer value representing
the version of the repository's
format.
"""
rval = {}
return rval
"""Returns the current value of a repository configuration
property for the specified section.
"""
"""This class presents an interface to server request objects that
clients may use.
"""
"""Returns a list of the languages accepted by the client
sorted by priority. This information is derived from the
Accept-Language header provided by the client.
"""
alist = []
return alist
"""Returns uri relative to the current request path.
"""
"""Instruct the server to log the provided message to its error
logs.
"""
"""A dict containing the parameters sent in the request, either
in the query string or in the request body.
"""
"""A string containing the "path_info" portion of the requested
URL.
"""
"""The Publisher object for the package data related to this
request or None if not available.
"""
try:
except srepo.RepositoryUnknownPublisher:
return None
"""A string containing the "query_string" portion of the
requested URL.
"""
"""Create an absolute URL for the given path.
If 'path' starts with a slash ('/'), this will return (base +
script_name + path + qs). If it does not start with a slash,
this returns (base url + script_name [+ request.path_info] +
path + qs).
If script_name is None, an appropriate value will be
automatically determined from the current request path.
If no parameters are specified, an absolute URL for the current
request path (minus the querystring) by passing no args. If
url(qs=request.query_string), is called, the original client URL
(assuming no internal redirections) should be returned.
If relative is None or not provided, an appropriate value will
be automatically determined. If False, the output will be an
absolute URL (including the scheme, host, vhost, and
script_name). If True, the output will instead be a URL that
is relative to the current request path, perhaps including '..'
atoms. If relative is the string 'server', the output will
instead be a URL that is relative to the server root; i.e., it
will start with a slash.
"""