pkgrepo.py revision 2453
1968N/A# The contents of this file are subject to the terms of the 1968N/A# Common Development and Distribution License (the "License"). 1968N/A# You may not use this file except in compliance with the License. 1968N/A# See the License for the specific language governing permissions 1968N/A# and limitations under the License. 1968N/A# When distributing Covered Code, include this CDDL HEADER in each 1968N/A# If applicable, add the following below this CDDL HEADER, with the 1968N/A# fields enclosed by brackets "[]" replaced with your own identifying 1968N/A# information: Portions Copyright [yyyy] [name of copyright owner] 2310N/A# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. 2028N/A """To be called at program finish.""" 1968N/A """Emit an error message prefixed by the command name """ 1968N/A # If we get passed something like an Exception, we can convert 1968N/A # If the message starts with whitespace, assume that it should come 1968N/A # *before* the command-name prefix. 1968N/A # This has to be a constant value as we can't reliably get our actual 1968N/A # program name on all platforms. 1968N/A """Emit a usage message and optionally prefix it with a more 1968N/A specific error message. Causes program to exit. 1968N/A # The full usage message isn't desired. 1978N/A pkgrepo [options] command [cmd_options] [operands] 2028N/A pkgrepo create [--version] uri_or_path 2301N/A pkgrepo add-publisher -s repo_uri_or_path publisher ... 2301N/A pkgrepo get [-F format] [-p publisher ...] -s repo_uri_or_path 2028N/A pkgrepo info [-F format] [-H] [-p publisher ...] 2301N/A pkgrepo rebuild [-p publisher ...] -s repo_uri_or_path 2132N/A [--no-catalog] [--no-index] 2301N/A pkgrepo refresh [-p publisher ...] -s repo_uri_or_path 2132N/A [--no-catalog] [--no-index] 2301N/A pkgrepo remove [-n] [-p publisher ...] -s repo_uri_or_path 2301N/A pkgrepo set [-p publisher ...] -s repo_uri_or_path 1978N/A Displays a usage message."""))
1968N/A """Parse the repository location provided and attempt to transform it 1968N/A into a valid repository URI. 2301N/A usage(_(
"At least one package pattern must be provided."),
2301N/A usage(_(
"A package repository location must be provided " 2301N/A # Don't make any changes; display list of packages to be 2301N/A # Add a newline between each publisher. 2028N/A """Return the repository object for current program configuration.""" 2028N/A usage(_(
"Network repositories are not currently supported " 2028N/A # Create transport and transport config. 2028N/A # Configure target publisher. 2142N/A """Add publisher(s) to the specified repository.""" 2142N/A usage(_(
"Network repositories are not currently supported " 2142N/A usage(_(
"At least one publisher must be specified"),
2142N/A # Elide the publishers that already exist, but retain the order 2142N/A # publishers were specified in. 2142N/A # Tricky logic; _set_pub will happily add new publishers if necessary 2142N/A # and not set any properties if you didn't specify any. 2142N/A # No publisher existed previously, so set the default publisher 2142N/A # to be the first new one that was added. 2142N/A # Some of the publishers that were requested for addition 2142N/A error(_(
"specified publisher(s) already exist: %s") %
2028N/A """Create a package repository at the given location.""" 2028N/A # This option is currently private and allows creating a 2028N/A # repository with a specific format based on version. 2028N/A usage(_(
"Only one repository location may be specified."),
2028N/A usage(_(
"Network repositories are not currently supported " 2028N/A # Attempt to create a repository at the specified location. Allow 2028N/A # whatever exceptions are raised to bubble up. 2028N/A """Display repository properties.""" 1968N/A " Supported formats: %(valid)s") % \
2028N/A # Setup transport so configuration can be retrieved. 2028N/A usage(_(
"A package repository location must be provided " 2028N/A """Display repository properties.""" 1968N/A # Configuration index is indexed by section name and property name. 2028N/A # Retrieve and flatten it to simplify listing process. 1968N/A # Set minimum widths for section and property name columns by using the 1968N/A # length of the column headers. 1968N/A # <sec_1> <prop_1> <prop_1_value> 1968N/A # <sec_2> <prop_2> <prop_2_value> 1968N/A "section" : [(
"default",
"tsv"), _(
"SECTION"),
""],
1968N/A "property" : [(
"default",
"tsv"), _(
"PROPERTY"),
""],
1968N/A "value" : [(
"default",
"tsv"), _(
"VALUE"),
""],
1968N/A # Default output formatting. 2453N/A # print without trailing newline. 1968N/A # Don't pollute other output formats. 2028N/A # Retrieve publisher information. 2028N/A # Establish initial return value and perform early exit if appropriate. 2028N/A # Don't pollute other output formats. 2132N/A """Display publisher properties.""" 2028N/A # Set minimum widths for section and property name columns by using the 2028N/A # length of the column headers and data. 2028N/A # For each requested publisher, retrieve the requested property data. 2028N/A # Determine possible set of properties and lengths. 2028N/A # Determine properties to display. 2028N/A # PUBLISHER SECTION PROPERTY VALUE 2028N/A # <pub_1> <sec_1> <prop_1> <prop_1_value> 2028N/A # <pub_1> <sec_2> <prop_2> <prop_2_value> 2028N/A "publisher" : [(
"default",
"tsv"), _(
"PUBLISHER"),
""],
2028N/A "section" : [(
"default",
"tsv"), _(
"SECTION"),
""],
2028N/A "property" : [(
"default",
"tsv"), _(
"PROPERTY"),
""],
2028N/A "value" : [(
"default",
"tsv"), _(
"VALUE"),
""],
2028N/A # Default output formatting. 2453N/A # print without trailing newline. 2028N/A # Don't pollute other output formats. 1968N/A """Display a list of known publishers and a summary of known packages 1968N/A and when the package data for the given publisher was last updated. 1968N/A " Supported formats: %(valid)s") % \
2028N/A # Setup transport so status can be retrieved. 2028N/A usage(_(
"A package repository location must be provided " 2028N/A # Retrieve repository status information. 2028N/A # Reformat the date into something more user 2028N/A # friendly (and locale specific). 2028N/A # PUBLISHER PACKAGES STATUS UPDATED 2028N/A # <pub_1> <num_uniq_pkgs> <status> <cat_last_modified> 2028N/A # <pub_2> <num_uniq_pkgs> <status> <cat_last_modified> 1968N/A "publisher" : [(
"default",
"tsv"), _(
"PUBLISHER"),
""],
1968N/A "packages" : [(
"default",
"tsv"), _(
"PACKAGES"),
""],
2028N/A "status" : [(
"default",
"tsv"), _(
"STATUS"),
""],
1968N/A "updated" : [(
"default",
"tsv"), _(
"UPDATED"),
""],
1968N/A # Default output formatting. 2453N/A # print without trailing newline. 1968N/A # Don't pollute other output formats. 1968N/A """Rebuild the repository's catalog and index data (as permitted).""" 2028N/A # Why? Who knows; but do what was requested--nothing! 2028N/A # Setup transport so operation can be performed. 2028N/A usage(_(
"A package repository location must be provided " 1968N/A """Refresh the repository's catalog and index data (as permitted).""" 1968N/A # Why? Who knows; but do what was requested--nothing! 2028N/A # Setup transport so operation can be performed. 2028N/A usage(_(
"A package repository location must be provided " 2028N/A """Set repository properties.""" 2028N/A # Attempt to parse property into components. 2028N/A # Store property values by section. 2028N/A # Parse the property value into a list if 2028N/A # necessary, otherwise append it to the list 2028N/A # of values for the property. 2028N/A # Determine if previous value is already 2028N/A # a list, and if not, convert and append 2028N/A # Otherwise, just store the value. 2028N/A usage(_(
"a property name and value must be provided in the " 2028N/A usage(_(
"A package repository location must be provided " 2028N/A """Set publisher properties.""" 2028N/A # Default to list of all publishers. 2028N/A # If there are still no known publishers, this 2028N/A # operation cannot succeed, so fail now. 2028N/A usage(_(
"One or more publishers must be specified to " 2028N/A "create and set properties for as none exist yet."),
2028N/A # Get publishers and update properties. 2028N/A # Get a copy of the existing publisher. 2028N/A # If the target property expects 2028N/A # a list, transform the provided 2028N/A # value into one if it isn't 2028N/A """Set repository properties.""" 1968N/A """Display the version of the pkg(5) API.""" 1968N/A# Establish a specific exit status which means: "python barfed an exception" 1968N/A# so that we can more easily detect these in testing of the CLI commands. 1968N/A """Catch exceptions raised by the main program function and then print 1968N/A a message and/or exit with an appropriate return code. 2126N/AThis is an internal error in pkg(5) version %(version)s. Please let the 2126N/Adevelopers know about this problem by including the information above (and 2126N/Athis message) when filing a bug at: 1968N/A # Out of memory errors can be raised as EnvironmentErrors with 1968N/A # an errno of ENOMEM, so in order to handle those exceptions 1968N/A # with other errnos, we nest this try block and have the outer 1968N/A # one handle the other instances. 1968N/A # Don't display any messages here to prevent possible further 1968N/A # broken pipe (EPIPE) errors. 1968N/A error(_(
"The pkgrepo command appears out of sync with the " 1968N/A "version is %(client)s while the library\nAPI version is " 1968N/A # Make all warnings be errors. 1968N/A # Ignore python's spurious pipe problems.