src/pkgdep.py
author Brock Pytlik <bpytlik@sun.com>
Thu, 16 Jul 2009 19:21:13 -0700
changeset 1231 f7b99e8118d2
child 1337 52e101b7cc31
permissions -rwxr-xr-x
9290 need a way to find the file dependencies of a package 9908 variant.py should be moved from client specific code
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1231
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     1
#!/usr/bin/python2.4
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     2
#
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     3
# CDDL HEADER START
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     4
#
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     5
# The contents of this file are subject to the terms of the
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     6
# Common Development and Distribution License (the "License").
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     7
# You may not use this file except in compliance with the License.
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     8
#
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     9
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    10
# or http://www.opensolaris.org/os/licensing.
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    11
# See the License for the specific language governing permissions
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    12
# and limitations under the License.
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    13
#
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    14
# When distributing Covered Code, include this CDDL HEADER in each
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    15
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    16
# If applicable, add the following below this CDDL HEADER, with the
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    17
# fields enclosed by brackets "[]" replaced with your own identifying
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    18
# information: Portions Copyright [yyyy] [name of copyright owner]
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    19
#
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    20
# CDDL HEADER END
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    21
#
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    22
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    23
#
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    24
# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    25
# Use is subject to license terms.
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    26
#
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    27
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    28
import errno
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    29
import getopt
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    30
import gettext
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    31
import locale
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    32
import os
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    33
import sys
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    34
import traceback
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    35
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    36
import pkg
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    37
import pkg.misc as misc
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    38
import pkg.publish.dependencies as dependencies
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    39
from pkg.misc import msg, emsg, PipeError
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    40
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    41
def error(text, cmd=None):
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    42
        """Emit an error message prefixed by the command name """
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    43
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    44
        if cmd:
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    45
                text = "%s: %s" % (cmd, text)
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    46
        else:
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    47
                # If we get passed something like an Exception, we can convert
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    48
                # it down to a string.
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    49
                text = str(text)
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    50
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    51
        # If the message starts with whitespace, assume that it should come
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    52
        # *before* the command-name prefix.
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    53
        text_nows = text.lstrip()
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    54
        ws = text[:len(text) - len(text_nows)]
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    55
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    56
        # This has to be a constant value as we can't reliably get our actual
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    57
        # program name on all platforms.
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    58
        emsg(ws + "pkgdep: " + text_nows)
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    59
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    60
def usage(usage_error=None, cmd=None, retcode=2):
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    61
        """Emit a usage message and optionally prefix it with a more specific
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    62
        error message.  Causes program to exit."""
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    63
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    64
        if usage_error:
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    65
                error(usage_error, cmd=cmd)
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    66
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    67
        print _("""\
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    68
Usage:
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    69
        pkgdep [options] manifest proto_dir
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    70
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    71
Options:
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    72
        -I              show internally satisfied dependencies
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    73
        -M              echo the input manifest before showing dependencies
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    74
        -m              show file types for which no analysis was performed
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    75
        --help or -?    display usage message
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    76
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    77
Environment:
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    78
        PKG_SEND_PLATFORM
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    79
        PKG_SEND_ISALIST""")
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    80
        sys.exit(retcode)
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    81
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    82
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    83
def main_func():
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    84
        misc.setlocale(locale.LC_ALL, "", error)
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    85
        gettext.install("pkg", "/usr/share/locale")
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    86
        
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    87
        try:
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    88
                opts, pargs = getopt.getopt(sys.argv[1:], "IMm?",
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    89
                    ["help"])
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    90
        except getopt.GetoptError, e:
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    91
                usage(_("illegal global option -- %s") % e.opt)
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    92
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    93
        remove_internal_deps = True
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    94
        platform = None
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    95
        isalist = None
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    96
        echo_manf = False
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    97
        show_missing = False
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    98
        show_usage = False
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    99
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   100
        for opt, arg in opts:
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   101
                if opt == "-I":
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   102
                        remove_internal_deps = False
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   103
                elif opt == "-M":
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   104
                        echo_manf = True
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   105
                elif opt == "-m":
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   106
                        show_missing = True
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   107
                elif opt in ("--help", "-?"):
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   108
                        show_usage = True
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   109
        if show_usage:
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   110
                usage(retcode=0)
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   111
        if len(pargs) != 2:
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   112
                usage()
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   113
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   114
        retcode = 0
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   115
                
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   116
        manf = pargs[0]
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   117
        proto_dir = pargs[1]
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   118
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   119
        try:
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   120
                ds, es, ms = dependencies.list_implicit_deps(manf, proto_dir,
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   121
                    remove_internal_deps)
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   122
        except IOError, e:
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   123
                if e.errno == errno.ENOENT:
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   124
                        error("Could not find manifest file %s" % manf)
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   125
                        return 1
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   126
                raise
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   127
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   128
        if echo_manf:
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   129
                fh = open(manf, "rb")
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   130
                for l in fh:
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   131
                        msg(l.rstrip())
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   132
                fh.close()
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   133
        
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   134
        for d in sorted(ds):
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   135
                msg(d)
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   136
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   137
        if show_missing:
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   138
                for m in ms:
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   139
                        emsg(m)
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   140
                
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   141
        for e in es:
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   142
                emsg(e)
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   143
                retcode = 1
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   144
        return retcode
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   145
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   146
#
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   147
# Establish a specific exit status which means: "python barfed an exception"
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   148
# so that we can more easily detect these in testing of the CLI commands.
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   149
#
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   150
if __name__ == "__main__":
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   151
        try:
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   152
                __ret = main_func()
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   153
        except RuntimeError, _e:
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   154
                emsg("pkgdep: %s" % _e)
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   155
                __ret = 1
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   156
        except (PipeError, KeyboardInterrupt):
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   157
                # We don't want to display any messages here to prevent
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   158
                # possible further broken pipe (EPIPE) errors.
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   159
                __ret = 1
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   160
        except SystemExit, _e:
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   161
                raise _e
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   162
        except:
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   163
                traceback.print_exc()
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   164
                error(
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   165
                    _("\n\nThis is an internal error.  Please let the "
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   166
                    "developers know about this\nproblem by filing a bug at "
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   167
                    "http://defect.opensolaris.org and including the\nabove "
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   168
                    "traceback and this message.  The version of pkg(5) is "
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   169
                    "'%s'.") % pkg.VERSION)
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   170
                __ret = 99
f7b99e8118d2 9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   171
        sys.exit(__ret)