#
# 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 six
import sys
"""Performs the subprocess invocation and returns
(status, outputbuffer) to the caller"""
# leverage smf test infrastructure
if DebugValues["firmware-dependency-bypass"]:
return (True, None)
if cmds_dir: # we're testing;
else:
firmware_dir = "/usr/lib/fwenum"
])
# Set up the default return values
ret = 0
buf = ""
# use a cache since each check may be expensive and each
# pkg version may have the same dependency.
# ignore non-solaris systems here
try:
args,
# output from proc is bytes
except OSError as e:
# we have no enumerator installed. This can
# occur if this driver is being installed for
# the first time or, more likely, we just added
# enumerators and a firmware dependency for the
# first time. For now, drive on and ignore this
# to permit the addition of such dependencies
# concurrently with their enumerarators.
buf = (_("Firmware dependency error:"
" Cannot exec {0}: {1}").format(
ret = -1
"""Check cpu dependency.
returns ((true, false, none (internal error)), error text)"""
if ret == 0:
elif ret == -1:
elif ret == 1:
# the cpu version enumerator returns 1 and
# prints the appropriate string if the system
# we're running this on does not match the
# We're not checking for valid args here since
# since that's already been done by the enumerator
if pvtype == "iset":
vtype = "Instruction Set Element(s)"
elif pvtype == "plat":
vtype = "Platform Name(s)"
else:
vtype = "CPU Name(s)"
try:
pass
try:
pass
(_("cpu dependency error: '{0}' does "
"not meet the the minimum "
"requirement for {1} {2}\n").
else:
# enumerator error
(_("cpu dependency error: "
"Unable to verify cpu type\n")))
"""Check driver firmware dependency.
returns ((true, false, none (internal error)), error text)"""
# if there was output, something went wrong.
"check.minimum-version",
# Since generic errors are often exit(1),
# map this to an internal error.
ret = 255
if ret == 0:
elif ret == -1:
(_("There are {0} instances of downrev "
"firmware for the '{1}' devices present "
"on this system. Update each to version "
"{2} or newer.").
elif ret == 240:
(_("There are 240 or more "
"instances of downrev firmware for the"
"'{0}' devices present on this system. "
"Update each to version {1} or better.").
elif ret < 0:
ans = (None,
(_("Firmware dependency error: {0} "
"exited due to signal {1}").format(
else:
ans = (None,
(_("Firmware dependency error: General "
"internal error {0} running '{1}': '{2}'").