pkgrepo.py revision 1978
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] 3158N/A# Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved. 2843N/A """Emit an error message prefixed by the command name """ 3210N/A # If we get passed something like an Exception, we can convert 2616N/A # If the message starts with whitespace, assume that it should come 2301N/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. 2028N/A """Emit a usage message and optionally prefix it with a more 2028N/A specific error message. Causes program to exit. 1968N/A # The full usage message isn't desired. 1968N/A pkgrepo [options] command [cmd_options] [operands] 1968N/A pkgrepo publisher [-F format] [-H] [publisher ...] 1968N/A pkgrepo rebuild [--no-index] 1968N/A pkgrepo refresh [--no-catalog] [--no-index] 2301N/A A URI or filesystem path representing the location of a package 2301N/A repository. Currently, only filesystem-based repositories are 2301N/A Displays a usage message."""))
1968N/A """Parse the repository location provided and attempt to transform it 1968N/A into a valid repository URI. 1968N/A # Convert the file path to a URI. 2970N/A usage(_(
"Network repositories are not currently supported."),
2864N/A # During urlunparsing below, ensure that the path starts with 2028N/A # only one '/' character, if any are present. 2864N/A # Rebuild the url with the sanitized components. 2864N/A """Return the repository object for current program configuration.""" 3138N/A """Create a package repository at the given location.""" 3210N/A usage(_(
"Only one repository location may be specified."),
1968N/A # Attempt to create a repository at the specified location. Allow 1968N/A # whatever exceptions are raised to bubble up. 1968N/A """Print a columnar listing defined by provided values.""" 1968N/A # Custom sort function for preserving field ordering 2028N/A # Functions for manipulating field_data records 2301N/A # Create a formatting string for the default output 2301N/A # Create a formatting string for the tsv output 2301N/A # Extract the list of headers from the field_data dictionary. Ensure 2301N/A # they are extracted in the desired order by using the custom sort 3171N/A # Output a header if desired. 2301N/A """Display the list of properties for the repository.""" 2301N/A " Supported formats: %(valid)s") % \
2990N/A # Configuration index is indexed by section name and property name. 2990N/A # Flatten it to simplify listing process. 2028N/A # Set minimum widths for section and property name columns by using the 2028N/A # length of the column headers. 2073N/A # <sec_1> <prop_1> <prop_1_value> 2073N/A # <sec_2> <prop_2> <prop_2_value> 3140N/A "section" : [(
"default",
"tsv"), _(
"SECTION"),
""],
3140N/A "property" : [(
"default",
"tsv"), _(
"PROPERTY"),
""],
3140N/A "value" : [(
"default",
"tsv"), _(
"VALUE"),
""],
3140N/A # Default output formatting. 2142N/A # Don't pollute other output formats. 2142N/A """Set a repository property.""" 2142N/A usage(_(
"a property name and value must be provided in the " 2142N/A """Display a list of known publishers and a summary of known packages 2142N/A and when the package data for the given publisher was last updated. 2970N/A " Supported formats: %(valid)s") % \
2970N/A # PUBLISHER PACKAGES VERSIONS UPDATED 3158N/A # <pub_1> <num_uniq_pkgs> <num_pkg_vers> <cat_last_modified> 3158N/A # <pub_2> <num_uniq_pkgs> <num_pkg_vers> <cat_last_modified> 2970N/A "publisher" : [(
"default",
"tsv"), _(
"PUBLISHER"),
""],
2970N/A "packages" : [(
"default",
"tsv"), _(
"PACKAGES"),
""],
2970N/A "versions" : [(
"default",
"tsv"), _(
"VERSIONS"),
""],
2970N/A "updated" : [(
"default",
"tsv"), _(
"UPDATED"),
""],
2970N/A # Default output formatting. 2970N/A # Don't pollute other output formats. 2970N/A """Rebuild the repository's catalog and index data (as permitted).""" 2028N/A # Always build search indexes seperately (and if permitted). 2028N/A """Refresh the repository's catalog and index data (as permitted).""" 2028N/A # Why? Who knows; but do what was requested--nothing! 2028N/A # Always update search indexes separately (and if permitted). 2028N/A """Display the version of the pkg(5) API.""" 2028N/A# Establish a specific exit status which means: "python barfed an exception" 2028N/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. 1968N/A "developers know about this\nproblem by filing a bug at " 1968N/A "traceback and this message. The version of pkg(5) is " 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. 3158N/A # Don't display any messages here to prevent possible further 3158N/A # broken pipe (EPIPE) errors. 2453N/A error(_(
"The pkgrepo command appears out of sync with the " 2453N/A "version is %(client)s while the library\nAPI version is " 2028N/A # Make all warnings be errors. 2028N/A # Ignore python's spurious pipe problems.