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