#
# 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 copy
import os
"""Reads the pkg(7) publisher JSON formatted data at 'location'
or from the provided file-like object 'fileobj' and returns a
tuple. The first element of the tuple is a list of publisher objects.
The second element is a dictionary of image properties.
'proxy_host' is the string to replace the special string
'http://<sysrepo>' with when it starts any uri.
'data' is a string containing the p5s data.
"""
res = []
# If the URI contains <sysrepo> then it's served
# directly by the system-repository.
r = publisher.RepositoryURI(
else:
# This URI needs to be proxied through the
# system-repository, so we assign it a special
# ProxyURI, which gets replaced by the actual
# URI of the system-repository in
# imageconfig.BlendedConfig.__merge_publishers
return res
try:
except ValueError as e:
# Not a valid JSON file.
raise api_errors.InvalidP5SFile(e)
try:
except KeyError:
except ValueError:
if ver > CURRENT_VERSION:
raise api_errors.UnsupportedP5SFile()
pubs = []
props = {}
try:
# For each set of publisher information in the parsed p5s file,
# build a Publisher object.
for p in plist:
if not prefix:
prefix = "Unknown"
v = p.get("signature-policy")
if v is not None:
v = p.get("signature-required-names")
if v is not None:
r = p.get("repository", None)
if r:
rargs = {}
for prop in ("collection_type",
"description", "name",
"refresh_seconds", "sticky"):
continue
continue
continue
props["publisher-search-order"] = \
"signature-policy")
if sig_pol is not None:
"signature-required-names")
if req_names is not None:
"""Writes the publisher, repository, and provided package names to the
provided file-like object 'fileobj' in JSON p5i format.
'fileobj' is an object that has a 'write' method that accepts data to be
written as a parameter.
'pubs' is a list of Publisher objects.
'cfg' is an ImageConfig which contains the properties of the image on
which the generated p5s file is based."""
res = []
for u in urls:
if m.scheme == "http":
elif m.scheme == "https":
# The system depot handles connecting to the
# proxied https repositories, so the client
# should communicate over http to prevent it
# from doing tunneling.
m.change_scheme("http")
elif m.scheme == "file":
# The system depot provides direct access to
# file repositories. The token <sysrepo> will
# be replaced in the client with the url it uses
# to communicate with the system repository.
))
else:
u.scheme)
# Remove duplicates, since the system-repository can only
# provide one path to a given origin. This can happen if the
# with one using http and the other using https, but both using
# the same netloc and path.
# into a set is not appropriate.
res_unique = []
return res_unique
dump_struct = {
"publishers": [],
"image_properties": {},
"version": CURRENT_VERSION,
}
for p in pubs:
d = None
if p.repository:
r = p.repository
reg_uri = ""
d = {
"collection_type": r.collection_type,
"description": r.description,
"mirrors": mirrors,
"name": r.name,
"origins": origins,
"refresh_seconds": r.refresh_seconds,
"related_uris": [
u.uri for u in r.related_uris
],
}
dpub = {
"alias": p.alias,
"name": p.prefix,
"repository": d,
"sticky": p.sticky,
}
if srn:
dpub["signature-required-names"] = \
p.properties["signature-required-names"]
if p in prefixes
]
if req_names: