i.nametomajor revision b51e13bf985efd1ff98249cad2824f2952f13ecb
1N/A# The contents of this file are subject to the terms of the 1N/A# Common Development and Distribution License (the "License"). 1N/A# You may not use this file except in compliance with the License. 1N/A# See the License for the specific language governing permissions 1N/A# and limitations under the License. 1N/A# When distributing Covered Code, include this CDDL HEADER in each 1N/A# If applicable, add the following below this CDDL HEADER, with the 1N/A# fields enclosed by brackets "[]" replaced with your own identifying 1N/A# information: Portions Copyright [yyyy] [name of copyright owner] 1N/A# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 1N/A# Use is subject to license terms. 1N/A# obsolete_sparc - Filter function to remove obsolete SPARC driver entries. 1N/A# We define an associative array of bad driver names, and then nawk out 1N/A# lines where the first token is defined in our array. 1N/A obs["XXunusedXX"] = 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. } !($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. # check if the driver specified is already installed. # the second token must be the decimal digit. # ignore a comment if exists. $1 == driver && $2 ~ /^[0-9][0-9]*$/ \ { num = split($2, n_array, delimiter); \ if (num > 1 && n_array[1] ~ /^[0-9][0-9]*$/) \ END { if (!found) exit 1 } ' $file # 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. # Strip obsolete entries from the existing name_to_major # Remove comment and/or blank lines before reading nawk '$1 !~ /^#|^$/ {print $0}' $src |
sed -e
's/#.*$//' | \
# If the driver is already present in name_to_major, # leave the existing number and 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 no name_to_major is present on the target system, # just copy over the one from the package.