#
# 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 errno
import operator
import os
import six
# pkg classes
# EmptyI for argument defaults; can't import from misc due to circular
# dependency.
self.__verbose_info = []
return self.__verbose_info
return _("""
The pkg client api module can not be invoked from an setuid executable.""")
"""Private base exception class for all History exceptions."""
"""Used to indicate that an unexpected error occurred while loading
History operation information.
The first argument should be an exception object related to the
error encountered.
"""
"""Used to indicate that invalid time / range values were provided to
history API functions."""
pass
"""Used to indicate that an unexpected error occurred while storing
History operation information.
The first argument should be an exception object related to the
error encountered.
"""
pass
"""Used to indicate that an unexpected error occurred while purging
History operation information.
The first argument should be an exception object related to the
error encountered.
"""
pass
"""Used to indicate that the image is currently locked by another thread
or process and cannot be modified."""
return _("The image cannot be modified as it is "
"currently in use by another package client: "
"{pid_name} on {host}, pid {pid}.").format(
return _("The image cannot be modified as it is "
"currently in use by another package client: "
"{pid_name} on an unknown host, pid {pid}.").format(
return _("The image cannot be modified as it is "
"currently in use by another package client: "
"pid {pid} on {host}.").format(
return _("The image cannot be modified as it is currently "
"in use by another package client.")
"""Used when an image was not found"""
"""Used to indicate that an image cannot be used until its format is
updated."""
return _("The image rooted at {0} is written in an older format "
"and must be updated before the requested operation can be "
"""Used when insuffcient space exists for proposed operation"""
return _("Insufficient disk space available ({avail}) "
"for estimated need ({needed}) for {use}").format(
)
"""Base exception class for plan preparation errors."""
pass
"""Used to indicate that the requested operation could not be completed
as one or more packages contained invalid metadata."""
"""'errors' should be a list of exceptions or strings
indicating what packages had errors and why."""
return _("The requested operation cannot be completed due "
"to invalid package metadata. Details follow:\n\n"
"""Used to indicate that license-related errors occurred during
plan evaluation or execution."""
displayed=None):
"""Used to indicate that plan evaluation or execution failed due
to license-related errors for a package."""
"""'errors' should be a list of LicenseAcceptanceError
exceptions."""
"""A list of LicenseAcceptanceError exceptions."""
"""Used to indicate that image plan evaluation or execution failed due
to license-related errors."""
"""'errors' should be a list of PkgLicenseErrors exceptions."""
"""Returns a dictionary indexed by package FMRI string of
lists of LicenseAcceptanceError exceptions."""
"""Returns a string representation of the license errors."""
output = ""
output += _(" License requires "
"acceptance.")
output += _(" License must be viewed.")
output += "\n"
return output
"""Used to indicate that image plan evaluation or execution failed due
pass
pass
pass
"""Used to indicate that the image plan is no longer valid, likely as a
result of an image state change since the plan was created."""
return _("The plan for the current operation is no longer "
"valid. The image has likely been modified by another "
"process or client. Please try the operation again.")
return _("Invalid package state change attempted '{states}' "
return _("pkg(7) out of date")
return _("Requested operation cannot be performed "
"in live image.")
return _("Requested operation cannot be performed "
"in live image.")
pass
pass
pass
return _("Could not operate on {0}\nbecause of "
"insufficient permissions. Please try the "
"command again as a privileged user.").format(
else:
return _("""
Could not complete the operation because of insufficient permissions.
Please try the command again as a privileged user.
""")
assert path
return _("Could not operate on {0}\nbecause the file is "
"in use. Please stop using the file and try the\n"
return _("Insufficient access to complete the requested "
"operation.\nPlease try the operation again as a "
"privileged user.")
"""Used to indicate that the operation was attempted on a
read-only filesystem"""
return _("Could not complete the operation on {0}: "
return _("Could not complete the operation: read-only "
"filesystem.")
return _("Unable to obtain or operate on lock at {0}.\n"
"Please try the operation again as a privileged "
"""Used to indicate which patterns were not matched or illegal during
a package name matching operation."""
res = []
if self.unmatched_fmris:
s = _("The following pattern(s) did not match any "
"packages:")
res += [s]
if self.multiple_matches:
s = _("'{0}' matches multiple packages")
s = _("'{0}' is an illegal FMRI")
s = _("The following different patterns specify the "
"same package(s):")
res += [s]
res += [
]
"""Used to indicate that the requested operation could not be executed
due to unexpected changes in image state after planning was completed.
"""
return _("The files listed below were modified after operation "
"planning was complete or were missing during plan "
"execution; this may indicate an administrative issue or "
"system configuration issue:\n{0}".format(
res = []
if self.unmatched_fmris:
s = _("""\
The following pattern(s) did not match any allowable packages. Try
using a different matching pattern, or refreshing publisher information:
""")
res += [s]
if self.rejected_pats:
s = _("""\
The following pattern(s) only matched packages rejected by user request. Try
using a different matching pattern, or refreshing publisher information:
""")
res += [s]
if self.wrong_variants:
s = _("""\
The following pattern(s) only matched packages that are not available
res += [s]
if self.wrong_publishers:
s = _("The following patterns only matched packages "
"that are from publishers other than that which "
"supplied the already installed version of this package")
res += [s]
if self.multiple_matches:
s = _("'{0}' matches multiple packages")
if self.missing_matches:
s = _("'{0}' matches no installed packages")
s = _("'{0}' is an illegal fmri")
s = _("'{p}' supports the following architectures: "
"{archs}")
a = _("Image architecture is defined as: {0}")
s = _("'{p}' depends on obsolete package '{op}'")
s = _("The proposed operation can not be performed for "
"the following package(s) as they are already "
"installed: ")
res += [s]
s = _("The following mediations are not syntactically "
"valid:")
s = _("The following patterns specify different "
"versions of the same package(s):")
res += [s]
res += [
", ".join(
]
if self.no_solution:
res += [_("No solution was found to satisfy constraints")]
s = _("""\
Syncing this linked image would require the following package updates:
""")
res += [s]
if self.no_version:
if self.no_tmp_origins:
s = _("""
The proposed operation on this parent image can not be performed because
temporary origins were specified and this image has children. Please either
retry the operation again without specifying any temporary origins, or if
packages from additional origins are required, please configure those origins
persistently.""")
res = [s]
res += [_("Package {pkg} is missing a dependency: "
"{dep}").format(
res += [_("The following files are not packaged in this image:")]
if self.solver_errors:
res += ["\n"]
res += [_("Solver dependency errors:")]
res += [_("The following packages are already "
"installed in this image; use uninstall to "
"avoid these:")]
if self.would_install:
res += [_("The following packages are a target "
"of group dependencies; use install to unavoid "
"these:")]
if self.not_avoided:
res += [_("The following packages are not on the "
"avoid list, so they\ncannot be removed from it.")]
i = 0
i, pub)
mod = []
if not sticky:
if mod:
i += 1
if self.linked_pub_error:
res = []
Invalid child image publisher configuration. Child image publisher
configuration must be a superset of the parent image publisher configuration.
Please update the child publisher configuration to match the parent. If the
child image is a zone this can be done automatically by detaching and
attaching the zone.
The parent image has the following enabled publishers:"""))
The child image has the following enabled publishers:"""))
if self.no_repo_pubs:
res += [_("The following publishers do not have any "
"configured package repositories and cannot be "
"used in package dehydration or rehydration "
"operations:\n")]
"""Used to indicate that the imageplan would result in one or more sets
of conflicting actions, meaning that more than one action would exist on
the system with the same key attribute value in the same namespace.
There are three categories, each with its own subclass:
- multiple files delivered to the same path or drivers, users, groups,
etc, delivered with the same key attribute;
- multiple objects delivered to the same path which aren't the same
type;
- multiple directories, links, or hardlinks delivered to the same path
but with conflicting attributes.
"""
"""A container for multiple ConflictingActionError exception objects
that can be raised as a single exception."""
"""Multiple actions of the same type have been delivered with the same
key attribute (when not allowed)."""
s = _("The following packages all deliver {action} "
s += "\n {0}".format(p)
s += _("\n\nThese packages cannot be installed "
"together. Any non-conflicting subset\nof "
"the above packages can be installed.")
else:
s = _("The package {pfmri} delivers multiple copies "
s += _("\nThis package must be corrected before it "
"can be installed.")
return s
"""Multiple actions of different types have been delivered with the same
'path' attribute. While this exception could represent other action
groups which share a single namespace, none such exist."""
ad = {}
s = _("The following packages deliver conflicting "
s += _("\n\nThese packages cannot be installed "
"together. Any non-conflicting subset\nof "
"the above packages can be installed.")
else:
s = _("The package {pfmri} delivers conflicting "
s += _("\nThis package must be corrected before it "
"can be installed.")
return s
"""Multiple actions of the same type representing the same object have
have been delivered, but with conflicting attributes, such as two
directories at /usr with groups 'root' and 'sys', or two 'root' users
with uids '0' and '7'."""
# Trim the action's attributes to only those required to be
# unique.
(k, v)
if ((k in action.unique_attrs and
k.startswith("mediator")))
)
return action
d = {}
for a in actions:
l = sorted([
])
s = _("The requested change to the system attempts to install "
"multiple actions\nfor {a} '{k}' with conflicting "
if num <= 5:
if num == 1:
t = _(" {n:d} package delivers '{a}':\n")
else:
t = _(" {n:d} packages deliver '{a}':\n")
else:
t = _(" {n:d} packages deliver '{a}', including:\n")
s += _("\nThis package must be corrected before it "
"can be installed.")
else:
s += _("\n\nThese packages cannot be installed "
"together. Any non-conflicting subset\nof "
"the above packages can be installed.")
return s
"""Used to indicate that a file is delivered to image dir"""
"""fmri is the package fmri
actions should be a dictionary of which key is the
error type and value is a list of actions"""
generic = _("The following items are outside the boundaries "
"of the target image:\n\n")
outside_be = _("The following items are delivered outside "
"the target boot environment:\n\n")
reserved = _("The following items are delivered to "
"reserved directories:\n\n")
}
if actions:
else:
"""This function is used to append errors in the error
dictionary"""
if action:
"""Return whether error dictionary is empty"""
s = ""
for err_type in error_list:
continue
s += ("The package {0} delivers items"
" outside the boundaries of"
" the target image and can not be"
s += ("The package {0} delivers items"
" outside the target boot"
" environment and can not be"
else:
s += ("The package {0} delivers items"
" to reserved directories and can"
s += (" {0} {1}\n").format(
return s
"""A container for multiple ImageBoundaryError exception objects
that can be raised as a single exception."""
generic = _("The following packages deliver items outside "
"the boundaries of the target image and can not be "
"installed:\n\n")
outside_be = _("The following packages deliver items outside "
"the target boot environment and can not be "
"installed:\n\n")
reserved = _("The following packages deliver items to reserved "
"directories and can not be installed:\n\n")
}
s = ""
cur_errs = []
# If err does not contain this error type
# we just ignore this.
continue
if not cur_errs:
continue
continue
s += (" {0} {1}\n").format(
s += "\n"
return s
def list_to_lang(l):
"""Takes a list of items and puts them into a string, with commas in
between items, and an "and" between the last two items. Special cases
for lists of two or fewer items, and uses the Oxford comma."""
if not l:
return ""
if len(l) == 1:
return l[0]
if len(l) == 2:
# Used for a two-element list
return _("{penultimate} and {ultimate}").format(
penultimate=l[0],
ultimate=l[1]
)
# In order to properly i18n this construct, we create two templates:
# one for each element save the last, and one that tacks on the last
# element.
# 'elementtemplate' is for each element through the penultimate
elementtemplate = _("{0}, ")
# 'listtemplate' concatenates the concatenation of non-ultimate elements
# and the ultimate element.
listtemplate = _("{list}and {tail}")
return listtemplate.format(
tail=l[-1]
)
"""Used to indicate that action execution (such as install, remove,
etc.) failed even though the action is valid.
In particular, this exception indicates that something went wrong in the
application (or unapplication) of the action to the system, and is most
likely not an error in the pkg(7) code."""
use_errno=None):
"""'action' is the object for the action that failed during the
requested operation.
'details' is an optional message explaining what operation
failed, why it failed, and why it cannot continue. It should
also include a suggestion as to how to resolve the situation
if possible.
'error' is an optional exception object that may have been
raised when the operation failed.
'fmri' is an optional package FMRI indicating what package
was being operated on at the time the error occurred.
'use_errno' is an optional boolean value indicating whether
the strerror() text of the exception should be used. If
'details' is provided, the default value is False, otherwise
True."""
if use_errno == None:
# If details were provided, don't use errno unless
# explicitly requested.
errno = ""
# Fall back on the wrapped exception if we don't have anything
# useful.
details = _("Requested operation failed for action "
"{action}:\n{details}").format(
elif details:
details = _("Requested operation failed for package "
# If we only have one of the two, no need for the colon.
"""Base exception class for all catalog exceptions."""
if args:
else:
"""Used to indicate that the specified FMRI is not valid for catalog
operations because it is missing publisher information."""
return _("The FMRI '{0}' does not contain publisher information "
"and cannot be used for catalog operations.").format(
"""Used to indicate an operation on the catalog's meta_root failed
because the meta_root is invalid."""
return _("Catalog meta_root '{root}' is invalid; unable "
"""Used to indicate the server catalog files do not have the expected
permissions."""
"""files should contain a list object with each entry consisting
of a tuple of filename, expected_mode, received_mode."""
if not files:
files = []
msg = _("The following catalog files have incorrect "
"permissions:\n")
msg += _("\t{fname}: expected mode: {emode}, found "
return msg
"""Used to indicate that the Catalog signatures are not valid."""
return _("The signature data for the '{0}' catalog file is not "
"""Used to indicate that the requested catalog updates could not be
applied as the new catalog data is significantly different such that
the old catalog cannot be updated to match it."""
return _("Unable to determine the updates needed for "
"the current catalog using the provided catalog "
"""Used to indicate that the specified catalog operation could not be
performed since it would result in a duplicate catalog entry."""
return _("Unable to perform '{op}' operation for catalog "
"{name}; completion would result in a duplicate entry "
"""Used to indicate that an update request for the catalog could not
be performed because update requirements were not satisfied."""
return _("Catalog updates can only be applied to an on-disk "
"catalog.")
"""Used to indicate a Catalog file could not be loaded."""
return _("Catalog file '{0}' is invalid.\nUse 'pkgrepo rebuild' "
"""Used to indicate that a Catalog's attributes and parts do not
match. This is likely the result of an attributes file being
retrieved which doesn't match the parts that were retrieved such
as in a misconfigured or stale cache case."""
return _("The content of the catalog for publisher '{0}' "
"doesn't match the catalog's attributes. This is "
"likely the result of a mix of older and newer "
"catalog files being provided for the publisher.").format(
"""Used to indicate that the specified catalog updates are for an older
version of the catalog and cannot be applied."""
return _("Unable to determine the updates needed for the "
"catalog using the provided catalog update data in '{0}'. "
"The specified catalog updates are for an older version "
"""Used to indicate that an entry for the specified package FMRI or
pattern could not be found in the catalog."""
return _("'{0}' could not be found in the catalog.").format(
"""Used to indicate that the specified CatalogUpdate operation is
unknown."""
"""Raised when the catalog finds a CatalogPart that is unrecognized
or invalid."""
return _("Unrecognized, unknown, or invalid CatalogPart '{0}'").format(
"""Used to indicate that some of the specified patterns to a catalog
matching function did not match any catalog entries, or were invalid
patterns."""
outstr = ""
# Illegal FMRIs have their own __str__ method
outstr += _("No matching package could be found for "
"the following FMRIs in any of the catalogs for "
"the current publishers:\n")
outstr += \
_("{0} (pattern did not match)\n").format(x)
outstr += _("{0} (publisher did not "
"match)\n").format(x)
outstr += \
_("{0} (version did not match)\n").format(x)
return outstr
# SearchExceptions
"""Based class used for all search-related api exceptions."""
pass
"""Raised when the server cannot understand the format of the
search request."""
"""Returned when the search cannot find any matches."""
return _("The search at url {0} returned no results.").format(
"""This class wraps exceptions which could appear while trying to
do a search request."""
s = _("Some repositories failed to respond appropriately:\n")
s += _("{o}:\n{msg}\n").format(
s += _("{0} did not return a valid "
s += _("Some repositories don't support requested "
"search operation:\n")
s += _("{o}:\n{msg}\n").format(
return s
"""This exception is thrown when a local search is performed without
an index. It's raised after all results have been yielded."""
return _("Search performance is degraded.\n"
"Run 'pkg rebuild-index' to improve search speed.")
"""Returned when a search protocol is not supported by the
remote server."""
s = _("Search repository does not support the requested "
"protocol:")
return s
return False
return True
return True
return False
# IndexingExceptions.
""" The base class for all exceptions that can occur while indexing. """
"""This is used when the index is not in a correct state."""
return _("The search index appears corrupted.")
"""This is used when the existing index is found to have inconsistent
versions."""
"""This is used when an attempt to modify an index locked by another
process or thread is made."""
""" This is used when the indexer is unable to create, move, or remove
files or directories it should be able to. """
return "Could not remove or create " \
"{0} because of incorrect " \
"permissions. Please correct this issue then " \
"""This exception is used to wrap an indexing exception during install,
uninstall, or update so that a more appropriate error message can be
displayed to the user."""
"""This exception is used to wrap an indexing exception during install,
uninstall, or update which was recovered from by performing a full
reindex."""
pass
# Query Parsing Exceptions
"""This exception is used when the children of a boolean operation
have different return types. The command 'pkg search foo AND <bar>'
is the simplest example of this."""
self.e = e
self.e = e
"""Removal of a package which satisfies dependencies has been attempted.
The first argument to the constructor is the FMRI which we tried to
remove, and is available as the "fmri" member of the exception. The
second argument is the list of dependent packages that prevent the
removal of the package, and is available as the "dependents" member.
"""
s = _("Unable to remove '{0}' due to the following packages "
s += "\n".join(
)
return s
s = _("\nThis is happening because the following "
"packages needed to be repaired as\npart of this "
"operation:\n\n ")
s += _("\n\nYou will need to reestablish your access to the "
"repository or remove the\npackages in the list above.")
return s
return ""
"""Raised when the depot doesn't have versions of operations
that the client needs to operate successfully."""
s = _("Unable to contact valid package repository")
s += ("\nEncountered the following error(s):\n{0}").format(
s += _str_autofix(self)
return s
"""Base exception class used for all data related errors."""
if args:
else:
"""Used to indicate that the specified location does not contain a
valid p5i-formatted file."""
return _("The provided p5i data is in an unrecognized "
"format or does not contain valid publisher "
return _("The provided p5i data is in an unrecognized format "
"or does not contain valid publisher information.")
"""Used to indicate that the specified location does not contain a
valid p5i-formatted file."""
return _("The provided p5s data is in an unrecognized "
"format or does not contain valid publisher "
return _("The provided p5s data is in an unrecognized format "
"or does not contain valid publisher information.")
"""Used to indicate that an attempt to read an unsupported version
of pkg(7) info file was attempted."""
return _("Unsupported pkg(7) publisher information data "
"format.")
"""Used to indicate that an attempt to read an unsupported version
of pkg(7) info file was attempted."""
return _("Unsupported pkg(7) publisher and image information "
"data format.")
"""Used to indicate that an attempt to read an unsupported version
of pkg(7) info file was attempted."""
return _("{0} is not a supported version for creating a "
"""Abstract exception class for all transport exceptions.
Specific transport exceptions should be implemented in the
transport code. Callers wishing to catch transport exceptions
should use this class. Subclasses must implement all methods
defined here that raise NotImplementedError."""
raise NotImplementedError()
return _str_autofix(self)
"""Used to indicate that a a requested resource could not be
retrieved."""
return _("Error encountered while retrieving data from "
"'{location}':\n{data}").format(
return _("Error encountered while retrieving data from: {0}").format(
"""Used to indicate that an invalid transport location was provided."""
return _("'{0}' is not a valid boot environment name.").format(
"""Used to indicate that there is an existing boot environment
with this name"""
return _("The boot environment '{0}' already "
d = {
}
return _("The boot environment '{be_name}' already "
"exists in zone '{zonename}'.").format(**d)
return _("""\
Boot environment naming during package install is not supported on this
version of Solaris. Please update without the --be-name option.""")
return _("Unable to clone the current boot environment.")
d = {
}
return _("""\
A problem occurred while attempting to rename the boot environment
currently named {orig} to {dest}.""").format(**d)
return _("Unable to mount {name} at {mt}").format(
return _("""\
Naming a boot environment when operating on a non-live image is
not allowed.""")
s = _("Info does not recognize the following options:")
return s
"""This is used when the index hash value doesn't match the hash of the
packages installed in the image."""
pass
"""Base exception class for all publisher exceptions."""
if args:
else:
"""Used to indicate an operation on the publisher's meta_root failed
because the meta_root is invalid."""
return _("Publisher meta_root '{root}' is invalid; unable "
"""Used to indicate that a publisher alias is not valid."""
return _("'{0}' is not a valid publisher alias.").format(
"""Used to indicate that a publisher name is not valid."""
return _("'{0}' is not a valid publisher name.").format(
"""Used to indicate that a publisher name is not valid."""
return _("'{pkg_pub}' is a reserved publisher and does not "
"contain the requested package: pkg:/{pkg_name}").format(
"""Used to indicate that the specified repository attribute value is
invalid."""
return _("'{value}' is not a valid value for repository "
"attribute '{attribute}'.").format(
"""Used to indicate that the specified repository collection type is
invalid."""
return _("'{0}' is not a valid repository collection type.").format(
"""Used to indicate that a repository URI is not syntactically valid."""
"""Used to indicate that the priority specified for a repository URI is
not valid."""
return _("'{0}' is not a valid URI priority; integer value "
"""Used to indicate that the specified repository URI sort policy is
invalid."""
return _("'{0}' is not a valid repository URI sort policy.").format(
"""Used to indicate that an attempt to use a disabled publisher occurred
during an operation."""
return _("Publisher '{0}' is disabled and cannot be used for "
"""Used to indicate that a publisher with the same name or alias already
exists for an image."""
return _("A publisher with the same name or alias as '{0}' "
"""Used to indicate that a repository with the same origin uris
already exists for a publisher."""
return _("A repository with the same name or origin URIs "
"""Used to indicate that a repository URI is already in use by another
repository mirror."""
return _("Mirror '{0}' already exists for the specified "
"""Used to indicate that a repository URI is already in use by the
system publisher."""
return _("Mirror '{0}' is already accessible through the "
"""Used to indicate that a repository URI is already in use by another
repository origin."""
return _("Origin '{0}' already exists for the specified "
"""Used to indicate that a repository URI is already in use by the
system publisher."""
return _("Origin '{0}' is already accessible through the "
"""Used to indicate that a system publisher origin may not be
removed."""
return _("Unable to remove origin '{0}' since it is provided "
"""Used to indicate that a system publisher mirror may not be
removed."""
return _("Unable to remove mirror '{0}' since it is provided "
"""Used to indicate that a Publisher has no repository information
configured and so transport operations cannot be performed."""
return _("""
The requested operation requires that one or more package repositories are
configured for publisher '{0}'.
Use 'pkg set-publisher' to add new package repositories or restore previously
"""Used to indicate an attempt to search a repo before or after itself"""
return _("Cannot search a repository before or after itself")
"""Used to indicate an attempt to order a publisher relative to an
unknown publisher."""
return _("{0} is an unknown publisher; no other publishers can "
"""Used to indicate that an attempt to remove the selected repository
for a publisher was made."""
return _("Cannot remove the selected repository for a "
"publisher.")
"""Used to indicate that no matching legal URI could be found using the
provided criteria."""
"""Used to indicate that no matching publisher could be found using the
provided criteria."""
"""Used to indicate that one or more publisher prefixes are unknown by
the specified repository."""
return _("The repository at {location} does not "
"contain package data for {unknown}; only "
"{known}.\n\nThis is either because the "
"repository location is not valid, or because the "
"provided publisher does not match those known by "
"the repository.").format(
return _("One or more of the repository origin(s) "
"listed below contains package data for "
"{known}; not {unknown}:\n\n{origins}\n\n"
"This is either because one of the repository "
"origins is not valid for this publisher, or "
"because the list of known publishers retrieved "
"from the repository origin does not match the "
return _("The specified publisher repository does not "
"contain any package data for {unknown}; only "
"""Used to indicate that no matching related URI could be found using
the provided criteria."""
"""Used to indicate that no matching repository could be found using the
provided criteria."""
"""Used to indicate that a repository URI could not be found in the
list of repository mirrors."""
"""The publisher has no active repositories that support the
requested operation."""
return _("Publisher '{pub}' has no repositories that support "
"""Used to indicate that the specified repository does not provide
publisher configuration information."""
return _("The specified package repository does not "
"provide publisher configuration information.")
return _("The package repository at {0} does not "
"provide publisher configuration information or "
"the information provided is incomplete.").format(
return _("One of the package repository origins for {0} does "
"not provide publisher configuration information or the "
"""Used to indicate that a repository URI could not be found in the
list of repository origins."""
"""Used to indicate that the specified repository URI uses an
unsupported scheme."""
illegals = []
msg = _("The follwing URIs use unsupported "
"schemes. Supported schemes are "
"file://, http://, and https://.")
for i, s in illegals:
msg += _("\n {uri} (scheme: "
return msg
i, s = illegals[0]
return _("The URI '{uri}' uses the unsupported "
"scheme '{scheme}'. Supported schemes are "
"file://, http://, and https://.").format(
return _("The specified URI uses an unsupported scheme."
" Supported schemes are: file://, http://, and "
"https://.")
"""Used to indicate that the specified repository URI attribute is not
supported for the URI's scheme."""
return _("'{attr}' is not supported for '{scheme}'.").format(
"""Used to indicate that the specified proxy URI is unsupported."""
return _("The proxy URI '{uri}' uses the unsupported "
"scheme '{scheme}'. Currently the only supported "
"scheme is http://.").format(
return _("The specified proxy URI uses an unsupported scheme."
" Currently the only supported scheme is: http://.")
"""Used to indicate that a proxy URI is not syntactically valid."""
"""Used when a pkg client needs to communicate with the system
repository but can't find the configuration for it."""
return _("""\
pkg is configured to use the system repository (via the use-system-repo
property) but it could not get the host and port from
svc:/application/pkg/zones-proxy-client nor svc:/application/pkg/system-repository, and
the PKG_SYSREPO_URL environment variable was not set. Please try enabling one
of those services or setting the PKG_SYSREPO_URL environment variable.
""")
"""This exception is raised when a user attempts to modify a system
publisher."""
self.s = s
return self.s
"""The base class for exceptions related to manifest signing."""
# This string method is used by subclasses to fill in the details
# about the package and signature involved.
return _("The relevant signature action is "
"found in {pfmri} and has a hash of "
"{hsh}").format(
return _("The package involved is {0}").format(
return _("The relevant signature action's value "
return ""
"""Exception used when a key, certificate or CRL file is not in a
recognized format."""
"""Exception used when a signature reports a version which this version
of pkg(7) doesn't support."""
return _("The signature action {act} was made using a "
"version ({ver}) this version of pkg(7) doesn't "
"""Base class for exceptions encountered while establishing the chain
of trust."""
"""Exception used when a certificate does not match its expected hash
value."""
return _("Certificate {0} has been modified on disk. Its hash "
"""Exception used when a chain of trust is rooted in an untrusted
self-signed certificate."""
return _("Chain was rooted in an untrusted self-signed "
"""Exception used when a chain of trust can not be established between
the leaf certificate and a trust anchor."""
s = ""
s = _("The following problems were encountered:\n") + \
return _("The certificate which issued this "
"certificate: {subj} could not be found. The issuer "
"""Exception used when a chain of trust contains a revoked certificate.
"""
return _("This certificate was revoked:{cert} for this "
"""Exception used when a signature could not be verified by the
expected certificate."""
return _("A signature in {pfmri} could not be "
"verified for "
"this reason:\n{reason}\nThe signature's hash is "
return _("The signature with this signature value:\n"
"{sigval}\n could not be verified for this reason:\n"
"""Exception used when signatures were required but none were found."""
return _("The policy for {pub_str} requires "
"signatures to be present but no signature was "
"found in {fmri_str}.").format(
return _("The policy for {pub_str} requires signatures to be "
"present but no signature was found.").format(
"""Exception used when a signature policy required names to be seen
which weren't seen."""
return _("The policy for {pub_str} requires certain "
"CNs to be seen in a chain of trust. The following "
"required names couldn't be found for this "
"package:{fmri_str}.\n{missing}").format(
return _("The policy for {pub_str} requires certain CNs to "
"be seen in a chain of trust. The following required names "
"""Exception used when a certificate in the chain of trust uses a
critical extension pkg doesn't understand."""
return _("The certificate whose subject is {cert} could not "
"be verified because it uses an unsupported critical "
"extension.\nExtension name: {name}\nExtension "
"""Exception used when a certificate in the chain of trust has
invalid extensions."""
s = _("The certificate whose subject is {cert} could not be "
"verified because it has invalid extensions:\n{error}"
return s
"""Exception used when a certificate in the chain of trust has been used
inappropriately. An example would be a certificate which was only
supposed to be used to sign code being used to sign other certificates.
"""
return _("The certificate whose subject is {cert} could not "
"be verified because it has been used inappropriately. "
"The way it is used means that the value for extension "
"{name} must include '{use}' but the value was "
"""Exception used when a certificate in the chain of trust has been used
inappropriately. An example would be a certificate which was only
supposed to be used to sign code being used to sign other certificates.
"""
return _("The certificate whose subject is {cert} could not "
"be verified because it has been used inappropriately. "
"There can only be {cl} certificates between this "
"certificate and the leaf certificate. There are {al} "
"certificates between this certificate and the leaf in "
"this chain.").format(
)
"""Exception used when a package already has a signature action which is
nearly identical to the one being added but differs on some
attributes."""
s = _("The signature to be added to the package has the same "
"hash ({hash}), algorithm ({algorithm}), and "
"version ({version}) as an existing signature, but "
"doesn't match the signature exactly. For this signature "
"to be added, the existing signature must be removed.").format(
)
s += _("The package being signed was {pkg}").format(
return s
"""Exception used when a package already has a signature action which is
nearly identical to the one being added but differs on some
attributes."""
return _("{0} could not be signed because it already has two "
"copies of this signature in it. One of those signature "
"actions must be removed before the package is given to "
"""Exception used when a property was set to an invalid value."""
"""Base exception class for all certificate exceptions."""
if args:
else:
"""Used to indicate that a certificate has expired."""
return _("Certificate '{cert}' for publisher "
"'{pub}' needed to access '{uri}', "
"has expired. Please install a valid "
return _("Certificate '{cert}' for publisher "
"'{pub}', has expired. Please install a valid "
return _("Certificate '{cert}', needed to access "
"'{uri}', has expired. Please install a valid "
return _("Certificate '{0}' has expired. Please install a "
"""Used to collect ExpiredCertficate exceptions."""
else:
else:
msg = ""
return _("One or more client key and certificate files have "
"expired. Please\nupdate the configuration for the "
"""Used to indicate that a certificate has expired."""
if publisher:
if uri:
return _("Certificate '{cert}' for publisher "
"'{pub}', needed to access '{uri}', "
"will expire in '{days}' days.").format(
return _("Certificate '{cert}' for publisher "
"'{pub}' will expire in '{days}' days.").format(
if uri:
return _("Certificate '{cert}', needed to access "
"'{uri}', will expire in '{days}' days.").format(
return _("Certificate '{cert}' will expire in "
"""Used to indicate that a certificate is invalid."""
if publisher:
if uri:
return _("Certificate '{cert}' for publisher "
"'{pub}', needed to access '{uri}', is "
return _("Certificate '{cert}' for publisher "
if uri:
return _("Certificate '{cert}' needed to access "
"""Used to indicate that a key could not be found."""
if publisher:
if uri:
return _("Unable to locate key '{key}' for "
"publisher '{pub}' needed to access "
return _("Unable to locate key '{key}' for publisher "
)
if uri:
return _("Unable to locate key '{key}' needed to "
"""Used to indicate that a certificate could not be found."""
if publisher:
if uri:
return _("Unable to locate certificate "
"'{cert}' for publisher '{pub}' needed "
"to access '{uri}'.").format(
return _("Unable to locate certificate '{cert}' for "
if uri:
return _("Unable to locate certificate '{cert}' "
"needed to access '{uri}'.").format(
return _("Unable to locate certificate '{0}'.").format(
"""Used to indicate that a certificate is not yet valid (future
effective date)."""
if publisher:
if uri:
return _("Certificate '{cert}' for publisher "
"'{pub}', needed to access '{uri}', "
"has a future effective date.").format(
return _("Certificate '{cert}' for publisher "
"'{pub}' has a future effective date.").format(
if uri:
return _("Certificate '{cert}' needed to access "
"'{uri}' has a future effective date.").format(
return _("Certificate '{0}' has a future effective date.").format(
"""This exception is used when the server returns a line which the
client cannot parse correctly."""
"""This exception is used when a file was given as an argument but
no such file could be found."""
"""Base exception class for all manifest exceptions."""
if args:
else:
"""Used to indicate that the Manifest signatures are not valid."""
return _("The signature data for the manifest of the "
return _("The signature data for the manifest is not valid.")
"""Used to indicate that one or more exceptions were encountered.
This is intended for use with where multiple exceptions for multiple
files are encountered and the errors have been condensed into a
single exception and re-raised. One example case would be rmtree()
with shutil.Error."""
# Image creation exceptions
raise NotImplementedError()
return _("there is already an image at: {0}.\nTo override, use "
"""Used to indicate that the image configuration is invalid."""
return _("The configuration data for the image rooted at "
"""Used to indicate that the image at a specific location is in a format
not supported by this version of the pkg(7) API."""
return _("The image rooted at {0} is invalid or is not "
"supported by this version of the packaging system.").format(
return _("the specified image path is not empty: {0}.\nTo "
"""Converts the provided exception into an ApiException equivalent if
possible. Returns a new exception object if converted or the original
if not.
'ignored_errors' is an optional list of errno values for which None
should be returned.
"""
if not hasattr(e, "errno"):
return e
if e.errno in ignored_errors:
return None
return PermissionsException(e.filename)
return ReadOnlyFileSystemException(e.filename)
return e
attach_bad_prop=None,
attach_bad_prop_value=None,
attach_child_notsup=None,
attach_parent_notsup=None,
attach_root_as_child=None,
attach_with_curpath=None,
child_bad_img=None,
child_diverged=None,
child_dup=None,
child_not_in_altroot=None,
child_not_nested=None,
child_op_failed=None,
child_path_notabs=None,
child_unknown=None,
cmd_failed=None,
cmd_output_invalid=None,
detach_child_notsup=None,
detach_from_parent=None,
detach_parent_notsup=None,
img_linked=None,
intermediate_image=None,
lin_malformed=None,
link_to_self=None,
parent_bad_img=None,
parent_bad_notabs=None,
parent_bad_path=None,
parent_nested=None,
parent_not_in_altroot=None,
pkg_op_failed=None,
self_linked=None,
self_not_child=None,
unparsable_output=None):
# first deal with an error bundle
if bundle:
for e in bundle:
assert isinstance(e, LinkedImageException)
# set default error return value
if exitrv == None:
return
err = None
if attach_bad_prop is not None:
if attach_bad_prop_value is not None:
err = _("Invalid linked image attach property "
"value: {0}").format(
if attach_child_notsup is not None:
err = _("Linked image type does not support child "
if attach_parent_notsup is not None:
err = _("Linked image type does not support parent "
if attach_root_as_child is not None:
if attach_with_curpath is not None:
err = _("Cannot link images when an image is not at "
"its default location. The image currently "
"located at:\n {curpath}\n"
"is normally located at:\n {path}\n").format(
)
if child_bad_img is not None:
if exitrv == None:
if lin:
err = _("Can't initialize child image "
"({lin}) at path: {path}").format(
)
else:
err = _("Can't initialize child image "
if child_diverged is not None:
if exitrv == None:
if child_dup is not None:
err = _("A linked child image with this name "
if child_not_in_altroot is not None:
err = _("Child image '{path}' is not located "
"within the parent's altroot '{altroot}'").format(
)
if child_not_nested is not None:
err = _("Child image '{cpath}' is not nested "
"within the parent image '{ppath}'").format(
)
if child_op_failed is not None:
if exitrv == None:
if lin:
err = _("Failed '{op}' for child image "
"({lin}) at path: {path}: "
"{strerror}").format(
strerror=e,
)
else:
err = _("Failed '{op}' for child image "
"at path: {path}: {strerror}").format(
strerror=e,
)
if child_path_notabs is not None:
if child_unknown is not None:
if cmd_failed is not None:
err = _("The following subprocess returned an "
"unexpected exit code of {rv:d}:\n {cmd}").format(
if errout:
err += _("\nAnd generated the following error "
if cmd_output_invalid is not None:
err = _(
"The following subprocess:\n"
" {cmd}\n"
"Generated the following unexpected output:\n"
"{output}\n".format(
if detach_child_notsup is not None:
err = _("Linked image type does not support "
if detach_from_parent is not None:
if exitrv == None:
err = _("Parent linked to child, can not detach "
if detach_parent_notsup is not None:
err = _("Linked image type does not support "
if img_linked is not None:
if intermediate_image is not None:
err = _(
"Intermediate image '{ipath}' found between "
"child '{cpath}' and "
"parent '{ppath}'").format(
)
if lin_malformed is not None:
err = _("Invalid linked image name '{0}'. "
"Linked image names have the following format "
"'<linked_image plugin>:<linked_image name>'").format(
if link_to_self is not None:
err = _("Can't link image to itself: {0}")
if parent_bad_img is not None:
if exitrv == None:
if parent_bad_notabs is not None:
if parent_bad_path is not None:
if exitrv == None:
if parent_nested is not None:
err = _("A parent image '{ppath}' can not be nested "
"within a child image '{cpath}'").format(
)
if parent_not_in_altroot is not None:
err = _("Parent image '{path}' is not located "
"within the child's altroot '{altroot}'").format(
)
if pkg_op_failed is not None:
assert lin
assert op is not None
if e is None:
err = _("""
A '{op}' operation failed for child '{lin}' with an unexpected
return value of {exitrv:d} and generated the following output:
{errout}
"""
).format(
)
else:
err = _("""
A '{op}' operation failed for child '{lin}' with an unexpected
exception:
{e}
The child generated the following output:
{errout}
"""
).format(
e=e,
)
if self_linked is not None:
if self_not_child is not None:
if exitrv == None:
if unparsable_output is not None:
err = _("""
A '{op}' operation for child '{lin}' generated non-json output.
The json parser failed with the following error:
{e}
The child generated the following output:
{errout}
"""
).format(
e=e,
)
# set default error return value
if exitrv == None:
self.lix_bundle = None
"self.lix_err = {0}, self.lix_bundle = {1}".format(
# single error
# concatenate multiple errors
bundle_str = []
for e in self.lix_bundle:
"""Used if an argument to pkg freeze isn't valid."""
version_mismatch=None, versionless_uninstalled=None):
res = []
if self.multiversions:
s = _("""\
The following packages were frozen at two different versions by
the patterns provided. The package stem and the versions it was frozen at are
provided:""")
res += [s]
s = _("""\
The following patterns contained wildcards but matched no
installed packages.""")
res += [s]
if self.version_mismatch:
s = _("""\
The following patterns attempted to freeze the listed packages
at a version different from the version at which the packages are installed.""")
res += [s]
res += [
for stem
]
s = _("""\
The following patterns don't match installed packages and
contain no version information. Uninstalled packages can only be frozen by
providing a version at which to freeze them.""")
res += [s]
"""Used to indicate the freeze state file could not be loaded."""
return _("The freeze state file '{0}' is invalid.").format(
"""Used when the version on the freeze state file isn't the version
that's expected."""
return _("The freeze state file '{loc}' was expected to have "
"a version of {exp}, but its version was {found}").format(
)
"""Used to indicate an issue with verifying options passed to a certain
operation."""
valid_args=[]):
# In case the user provided a custom message we just take it and
# append the according options.
return _("Option '{option}' may not be repeated.").format(
return _("Argument '{op1}' for option '{op2}' may "
s = _("Argument '{op1}' for option '{op2}' is "
if self.valid_args:
return s
return _("The '{op1}' and '{op2}' option may "
return _("'{op1}' may only be used with "
return _("'{op1}' may only be used with "
return _("Either '{op1}' or '{op2}' must be "
else:
else:
msgs = []
"""Used to indicate that an image state file has been replaced
with a symlink."""
return _("Cannot update file: '{file}' at path "
"'{path}', contains a symlink. "
"[Error '{errno:d}': '{error}']").format(
)
"""Used to indicate that a configuration file is invalid
or broken"""
return _("Cannot parse configuration file "
"""Used to indicate that globbing for variant is not supported."""
return _("Globbing is not supported for variants.")