i.nametomajor revision d8d4fa8f33f737d82c7dcd7ddd11b4342ce4fbca
341N/A#!/bin/sh
1064N/A#
341N/A# CDDL HEADER START
341N/A#
919N/A# The contents of this file are subject to the terms of the
919N/A# Common Development and Distribution License (the "License").
919N/A# You may not use this file except in compliance with the License.
919N/A#
919N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
919N/A# or http://www.opensolaris.org/os/licensing.
919N/A# See the License for the specific language governing permissions
919N/A# and limitations under the License.
919N/A#
919N/A# When distributing Covered Code, include this CDDL HEADER in each
919N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
919N/A# If applicable, add the following below this CDDL HEADER, with the
919N/A# fields enclosed by brackets "[]" replaced with your own identifying
919N/A# information: Portions Copyright [yyyy] [name of copyright owner]
919N/A#
919N/A# CDDL HEADER END
919N/A#
341N/A
341N/A#
341N/A# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
341N/A# Use is subject to license terms.
1064N/A#
1064N/A#ident "%Z%%M% %I% %E% SMI"
1064N/A
341N/APATH=/usr/bin:/usr/sbin:$PATH; export PATH
341N/A
341N/A#
341N/A# obsolete_sparc - Filter function to remove obsolete SPARC driver entries.
341N/A# We define an associative array of bad driver names, and then nawk out
341N/A# lines where the first token is defined in our array.
341N/A#
1064N/Aobsolete_sparc()
341N/A{
341N/A nawk 'BEGIN {
341N/A obs["rip"] = 1;
341N/A obs["svloop"] = 1;
688N/A obs["tcl"] = 1;
688N/A obs["tco"] = 1;
341N/A obs["tcoo"] = 1;
688N/A obs["sp"] = 1;
688N/A obs["consfb"] = 1;
341N/A obs["dbri"] = 1;
341N/A obs["XXunusedXX"] = 1;
341N/A obs["sw"] = 1;
341N/A obs["cgtwo"] = 1;
341N/A obs["xy"] = 1;
341N/A obs["xd"] = 1;
341N/A obs["pc"] = 1;
341N/A obs["app"] = 1;
341N/A obs["evq"] = 1;
341N/A obs["win"] = 1;
341N/A obs["svarp"] = 1;
1064N/A obs["svip"] = 1;
341N/A obs["svrip"] = 1;
341N/A obs["svicmp"] = 1;
341N/A obs["svudp"] = 1;
341N/A obs["svtcp"] = 1;
341N/A obs["vme"] = 1;
341N/A obs["ie"] = 1;
341N/A obs["qe"] = 1;
341N/A obs["qec"] = 1;
341N/A obs["ncr"] = 1;
341N/A obs["xt"] = 1;
341N/A obs["id"] = 1;
1064N/A obs["vmemem"] = 1;
341N/A obs["pn"] = 1;
341N/A obs["kmac"] = 1;
341N/A obs["ipi3sc"] = 1;
688N/A obs["cgfour"] = 1;
688N/A obs["cgeight-p4"] = 1;
341N/A obs["xdc"] = 1;
341N/A obs["xyc"] = 1;
341N/A obs["mcp"] = 1;
341N/A obs["mcpzsa"] = 1;
341N/A obs["mcpp"] = 1;
1064N/A obs["be"] = 1;
341N/A obs["p9000"] = 1;
341N/A obs["p9100"] = 1;
341N/A obs["pci"] = 1;
341N/A obs["profile"] = 1;
341N/A obs["eeprom"] = 1;
341N/A obs["PFUaga"] = 1;
341N/A obs["atapicd"] = 1;
341N/A obs["cgeight"] = 1;
341N/A obs["cgfourteen"] = 1;
1064N/A obs["xbox"] = 1;
341N/A obs["sx"] = 1;
341N/A obs["sx_cmem"] = 1;
341N/A obs["stc"] = 1;
341N/A obs["bbc"] = 1;
341N/A obs["gptwo"] = 1;
341N/A obs["bwtwo"] = 1;
341N/A obs["cgthree"] = 1;
688N/A obs["obio"] = 1;
341N/A obs["cpu"] = 1;
688N/A obs["bootbus"] = 1;
688N/A obs["sbi"] = 1;
688N/A obs["mic"] = 1;
341N/A obs["pln"] = 1;
341N/A obs["soc"] = 1;
688N/A obs["sc_nct"] = 1;
341N/A obs["tomtppm"] = 1;
341N/A } !($1 in obs) { print $0 }'
341N/A}
341N/A
341N/A#
341N/A# obsolete_i386 - Filter function to remove obsolete i386 driver entries.
341N/A# We define an associative array of bad driver names, and then nawk out
341N/A# lines where the first token is defined in our array.
688N/A#
341N/Aobsolete_i386()
341N/A{
341N/A nawk 'BEGIN {
341N/A obs["aha"] = 1;
341N/A obs["aic"] = 1;
341N/A obs["app"] = 1;
341N/A obs["audiocs"] = 1;
341N/A obs["blogic"] = 1;
341N/A obs["chanmux"] = 1;
341N/A obs["chs"] = 1;
341N/A obs["cmtp"] = 1;
688N/A obs["corvette"] = 1;
341N/A obs["cpqncr"] = 1;
341N/A obs["csa"] = 1;
341N/A obs["dpt"] = 1;
341N/A obs["dsa"] = 1;
341N/A obs["eepro"] = 1;
341N/A obs["eha"] = 1;
341N/A obs["el"] = 1;
341N/A obs["elink"] = 1;
341N/A obs["elx"] = 1;
341N/A obs["envm"] = 1;
688N/A obs["esa"] = 1;
341N/A obs["esa"] = 1;
341N/A obs["iee"] = 1;
341N/A obs["ieef"] = 1;
688N/A obs["iss"] = 1;
341N/A obs["kd"] = 1;
341N/A obs["kdmouse"] = 1;
341N/A obs["lp"] = 1;
1064N/A obs["mc"] = 1;
341N/A obs["mcis"] = 1;
341N/A obs["mega"] = 1;
341N/A obs["mlx"] = 1;
341N/A obs["nee"] = 1;
341N/A obs["nei"] = 1;
341N/A obs["nfe"] = 1;
341N/A obs["objmgr"] = 1;
341N/A obs["p9000"] = 1;
341N/A obs["p9100"] = 1;
341N/A obs["pcaic"] = 1;
341N/A obs["profile"] = 1;
341N/A obs["riles"] = 1;
341N/A obs["rip"] = 1;
341N/A obs["sbpro"] = 1;
341N/A obs["smartii"] = 1;
341N/A obs["smc"] = 1;
341N/A obs["smce"] = 1;
341N/A obs["smceu"] = 1;
341N/A obs["smcf"] = 1;
341N/A obs["sp"] = 1;
341N/A obs["svarp"] = 1;
341N/A obs["svicmp"] = 1;
341N/A obs["svip"] = 1;
341N/A obs["svloop"] = 1;
688N/A obs["svrip"] = 1;
341N/A obs["svtcp"] = 1;
341N/A obs["svudp"] = 1;
341N/A obs["tcl"] = 1;
341N/A obs["tco"] = 1;
341N/A obs["tcoo"] = 1;
341N/A obs["tiqmouse"] = 1;
341N/A obs["tr"] = 1;
341N/A obs["trantor"] = 1;
341N/A obs["pci_to_i2o"] = 1;
688N/A obs["i2o_scsi"] = 1;
341N/A obs["i2o_bs"] = 1;
341N/A } !($1 in obs) { print $0 }'
341N/A}
341N/A
341N/A#
341N/A# Useful debugging which is reasonable to include in a production system:
341N/A# we copy the salient driver files to the package undo directory before
341N/A# doing any work. This will help diagnose add_drv errors before the system
341N/A# becomes an unbootable smoldering ruin.
341N/A#
341N/Afor file in driver_aliases driver_classes minor_perm name_to_major; do
341N/A cp $BASEDIR/etc/$file $PKGSAV/$file.orig >/dev/null 2>&1
1064N/Adone
341N/A
341N/A#
341N/A# check if the driver specified is already installed.
341N/A# the second token must be the decimal digit.
341N/A# ignore a comment if exists.
688N/A#
688N/Ais_installed ()
688N/A{
688N/A file=$2
341N/A nawk -v driver=$1 -v delimiter='#' ' \
341N/A $1 == driver && $2 ~ /^[0-9][0-9]*$/ \
341N/A { found = 1; exit 0 } \
341N/A $1 == driver \
341N/A { num = split($2, n_array, delimiter); \
341N/A if (num > 1 && n_array[1] ~ /^[0-9][0-9]*$/) \
341N/A { found = 1; exit 0 } \
341N/A } \
341N/A END { if (!found) exit 1 } ' $file
341N/A return $?
341N/A}
341N/A
341N/A#
341N/A# Add_drv needs /etc/driver_aliases in order to work properly; if for
341N/A# some reason it has been removed, create an empty one at this time.
341N/A# Recall that in SUNWcsr's pkginfo.tmpl, the driver_aliases class-action
341N/A# script is invoked *after* this class-action script. This is critical
341N/A# because if we are going to add_drv a new driver 'foo', and 'foo' has
341N/A# an alias 'bar', the add_drv of 'foo' will fail if the alias is already
341N/A# present. Thus new aliases must be added *after* new driver major entries.
1064N/A# The driver_aliases class-action script will add the complete set of aliases
341N/A# if we create an empty file here, so this code allows us to continue and
341N/A# get a correct upgrade in the face of a missing driver_aliases file.
341N/A#
341N/Aif [ ! -f $BASEDIR/etc/driver_aliases ]; then
688N/A touch $BASEDIR/etc/driver_aliases
341N/A chmod 0644 $BASEDIR/etc/driver_aliases
341N/A chown root $BASEDIR/etc/driver_aliases
341N/A chgrp sys $BASEDIR/etc/driver_aliases
341N/Afi
341N/A
341N/Awhile read src dest; do
341N/A if [ -f $dest ]; then
341N/A #
341N/A # Strip obsolete entries from the existing name_to_major
341N/A #
341N/A if [ $ARCH = sparc ]; then
341N/A obsolete_sparc < $dest > /tmp/onm.$$.tmp
341N/A else
341N/A obsolete_i386 < $dest > /tmp/onm.$$.tmp
341N/A fi
341N/A
341N/A cp /tmp/onm.$$.tmp $dest
341N/A rm -f /tmp/onm.$$.tmp
341N/A
341N/A #
341N/A # Remove comment and/or blank lines before reading
341N/A #
341N/A nawk '$1 !~ /^#|^$/ {print $0}' $src | sed -e 's/#.*$//' | \
341N/A while read name major; do
341N/A #
341N/A # If the driver is already present in name_to_major,
341N/A # leave the existing number and continue
341N/A #
341N/A is_installed $name $dest >/dev/null 2>&1 && continue
341N/A #
1064N/A # Otherwise add the driver to name_to_major using
341N/A # add_drv. add_drv produces spurious output even on
341N/A # success, so save its output in a temporary
341N/A # file in case an error occurs.
341N/A #
341N/A if add_drv -b $BASEDIR $name \
341N/A >/tmp/ad.$$.tmp 2>&1; then
341N/A echo "added $name to $dest"
341N/A else
341N/A echo "$PKG: failed to add $name to " \
341N/A "$dest:" >& 2
341N/A cat /tmp/ad.$$.tmp >& 2
341N/A fi
688N/A done
341N/A rm -f /tmp/ad.$$.tmp
341N/A else
341N/A #
341N/A # If no name_to_major is present on the target system,
341N/A # just copy over the one from the package.
341N/A #
341N/A cp -p $src $dest
341N/A fi
341N/Adone
1064N/Aexit 0
341N/A