pkgrepo.py revision 3234
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen# CDDL HEADER START
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen# The contents of this file are subject to the terms of the
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen# Common Development and Distribution License (the "License").
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen# You may not use this file except in compliance with the License.
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen# See the License for the specific language governing permissions
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen# and limitations under the License.
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen# When distributing Covered Code, include this CDDL HEADER in each
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen# If applicable, add the following below this CDDL HEADER, with the
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen# fields enclosed by brackets "[]" replaced with your own identifying
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen# information: Portions Copyright [yyyy] [name of copyright owner]
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen# CDDL HEADER END
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen# Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen# pkgrepo exit codes
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen# listing constants
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo SirainenLISTING_FORMATS = ("default", "json", "json-formatted", "tsv")
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainendiff_type_f = {MINUS: "- ", PLUS: "+ ", COMMON: ""}
4081894c16e50f37639d9826ebca4394b398c35eTimo Sirainenimport pkg.client.transport.transport as transport
8e018b1e83a6e22d8c520186e3e74a4d9fcb8888Phil Carmody """To be called at program finish."""
8e018b1e83a6e22d8c520186e3e74a4d9fcb8888Phil Carmody """Emit an error message prefixed by the command name """
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen # If we get passed something like an Exception, we can convert
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen # it down to a string.
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen # If the message starts with whitespace, assume that it should come
fd1f0e9ef52b3e157cfd1a01c464c2ac7458ab17Timo Sirainen # *before* the command-name prefix.
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen # This has to be a constant value as we can't reliably get our actual
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen # program name on all platforms.
fd1f0e9ef52b3e157cfd1a01c464c2ac7458ab17Timo Sirainen progtrack = pkg.client.progress.QuietProgressTracker()
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen pkg.client.progress.FancyUNIXProgressTracker()
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen except pkg.client.progress.ProgressTrackerException:
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen pkg.client.progress.CommandLineProgressTracker()
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainendef usage(usage_error=None, cmd=None, retcode=2, full=False):
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen """Emit a usage message and optionally prefix it with a more
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen specific error message. Causes program to exit.
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen # The full usage message isn't desired.
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen logger.error(_("Try `pkgrepo --help or -?' for more "
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen "information."))
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen pkgrepo [options] command [cmd_options] [operands]
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen pkgrepo create [--version ver] uri_or_path
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen pkgrepo add-publisher -s repo_uri_or_path publisher ...
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen pkgrepo remove-publisher [-n] [--synchronous] -s repo_uri_or_path
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen publisher ...
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen pkgrepo get [-F format] [-p publisher ...] -s repo_uri_or_path
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen [--key ssl_key ... --cert ssl_cert ...] [section/property ...]
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen pkgrepo info [-F format] [-H] [-p publisher ...] -s repo_uri_or_path
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen [--key ssl_key ... --cert ssl_cert ...]
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen pkgrepo list [-F format] [-H] [-p publisher ...] -s repo_uri_or_path
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen [--key ssl_key ... --cert ssl_cert ...] [pkg_fmri_pattern ...]
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen pkgrepo contents [-m] [-t action_type ...] -s repo_uri_or_path
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen [--key ssl_key ... --cert ssl_cert ...] [pkg_fmri_pattern ...]
if not pargs:
return EXIT_OOPS
if dry_run:
return EXIT_OK
return EXIT_OK
if not path:
if not repo_uri:
global tmpdirs
if not prefix:
if not repo_uri:
if not pargs:
if abort:
return EXIT_OOPS
new_pubs = [
if make_default:
if new_pubs:
return EXIT_PARTIAL
return EXIT_OOPS
return rval
if not repo_uri:
if not pargs:
inv_pfxs = []
if inv_pfxs:
return EXIT_OOPS
if noexisting:
return EXIT_OOPS
if dry_run:
return EXIT_OK
return EXIT_OK
version = None
except ValueError:
elif pargs:
if not repo_uri:
return EXIT_OK
key = None
cert = None
if pubs:
del props
def gen_listing():
field_data = {
return EXIT_PARTIAL
return EXIT_OOPS
return EXIT_OK
if use_transport:
for p in pub_data:
if repo_uri:
return EXIT_OOPS, None, None
pargs):
return rval
pub_idx = {}
if pub_repo:
del props
def gen_listing():
field_data = {
return rval
key = None
cert = None
if pargs:
def gen_listing():
if last_update:
field_data = {
return EXIT_PARTIAL
return EXIT_OOPS
return EXIT_OK
key = None
cert = None
return rval
listed = {}
def gen_listing():
if not listed:
state = None
ret = {
yield ret
field_data = {
if not unmatched:
return EXIT_OOPS
elif unmatched:
return EXIT_PARTIAL
return EXIT_OK
global tmpdirs
key = None
cert = None
attrs = []
action_types = []
return rval
manifests = []
if not listed:
if action_types:
gen_expr = (
(m.fmri, a, None, None, None)
for m in manifests
gen_expr = (
(m.fmri, a, None, None, None)
for m in manifests
for a in m.gen_actions()
except StopIteration:
got = None
actionlist = []
if got:
if not text:
if unmatched:
if manifests:
for p in unmatched:
return rval
if not pubs:
return EXIT_OOPS
return rval
elif build_catalog:
elif build_index:
xpub)
return rval
return rval
key = None
cert = None
if pargs:
return EXIT_OK
key = None
cert = None
if pargs:
return EXIT_OK
elif add_content:
elif refresh_index:
xpub)
return rval
return rval
props = {}
if not pargs:
except ValueError:
if bad_args:
if pubs:
if not pubs:
failed = []
if not target:
val = []
if new_pub:
if failed:
return EXIT_PARTIAL
return EXIT_OOPS
return EXIT_OK
return EXIT_OK
if args:
return EXIT_OK
verify_error_header = None
verify_warning_header = None
verify_reason_headers = None
def __load_verify_msgs():
global verify_error_header
global verify_warning_header
global verify_reason_headers
return formatted_message, None
if altroot:
igf))
ignored_dep_files = []
if pargs:
if not repo_uri:
xpub)
return rval
if bad_fmri:
found_pubs = []
if bad_fmris:
return EXIT_OOPS
return EXIT_OK
ignored_dep_files = []
if pargs:
if not repo_uri:
xpub)
return rval
if not verbose:
found_pubs = []
if not fmri:
if verbose:
if broken_fmris:
if failed_fix_paths:
if bad_deps:
return EXIT_OOPS
return EXIT_OK
return text
if quiet:
return EXIT_DIFF
if not verbose:
if parsable:
if quiet:
return EXIT_DIFF
cat_lm_pub = None
cat_lm_rpub = None
if compare_cat:
return EXIT_DIFF
if not verbose:
if not same_cat:
if not same_pkgs:
com_pub_info = {}
if parsable:
if not same_cat:
if parsable:
for f in minus_fmris:
if parsable:
del minus_fmris
for f in plus_fmris:
if parsable:
del plus_fmris
if not same_pkgs:
if parsable:
if com_pub_info:
if same_repo:
return EXIT_OK
if verbose:
if parsable:
return EXIT_DIFF
if not parsable:
t_row = []
if not cell:
return EXIT_DIFF
return EXIT_OOPS
if not repo_uri:
if not com_repo_uri:
return rval
return rval
def main_func():
conf = {}
if DebugValues:
subcommand = None
if pargs:
if show_usage:
elif not subcommand:
if not func:
raise __e
return __ret
except IOError: