Home | History | Annotate | Download | only in common_files
      1 #!/bin/sh
      2 #
      3 # CDDL HEADER START
      4 #
      5 # The contents of this file are subject to the terms of the
      6 # Common Development and Distribution License (the "License").
      7 # You may not use this file except in compliance with the License.
      8 #
      9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     10 # or http://www.opensolaris.org/os/licensing.
     11 # See the License for the specific language governing permissions
     12 # and limitations under the License.
     13 #
     14 # When distributing Covered Code, include this CDDL HEADER in each
     15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     16 # If applicable, add the following below this CDDL HEADER, with the
     17 # fields enclosed by brackets "[]" replaced with your own identifying
     18 # information: Portions Copyright [yyyy] [name of copyright owner]
     19 #
     20 # CDDL HEADER END
     21 #
     22 
     23 #
     24 # Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
     25 # Use is subject to license terms.
     26 #
     27 #ident	"%Z%%M%	%I%	%E% SMI"
     28 
     29 PATH=/usr/bin:/usr/sbin:$PATH; export PATH
     30 
     31 #
     32 # obsolete_sparc - Filter function to remove obsolete SPARC driver aliases.
     33 # Use sed to delete lines matching driver aliases we want to remove.
     34 #
     35 obsolete_sparc()
     36 {
     37 	sed \
     38 	    -e '/^[ 	]*cpu[ 	][ 	]*modi4v0m$/d' \
     39 	    -e '/^[ 	]*cpu[ 	][ 	]*modi4v0m[ 	#].*$/d' \
     40 	    -e '/^[ 	]*PFUaga[ 	][ 	]*PFU,aga$/d' \
     41 	    -e '/^[ 	]*PFUaga[ 	][ 	]*PFU,aga[ 	#].*$/d' \
     42 	    -e '/^[ 	]*dbri[ 	][ 	]*SUNW,DBRIs3$/d' \
     43 	    -e '/^[ 	]*dbri[ 	][ 	]*SUNW,DBRIs3[ 	#].*$/d' \
     44 	    -e '/^[ 	]*dbri[ 	][ 	]*SUNW,DBRId$/d' \
     45 	    -e '/^[ 	]*dbri[ 	][ 	]*SUNW,DBRId[ 	#].*$/d' \
     46 	    -e '/^[ 	]*dbri[ 	][ 	]*SUNW,DBRIe$/d' \
     47 	    -e '/^[ 	]*dbri[ 	][ 	]*SUNW,DBRIe[ 	#].*$/d' \
     48 	    -e '/^[ 	]*dbri[ 	][ 	]*SUNW,DBRIf$/d' \
     49 	    -e '/^[ 	]*dbri[ 	][ 	]*SUNW,DBRIf[ 	#].*$/d' \
     50 	    -e '/^[ 	]*leo[ 	][ 	]*SUNW,leo104$/d' \
     51 	    -e '/^[ 	]*leo[ 	][ 	]*SUNW,leo104[ 	#].*$/d' \
     52 	    -e '/^[ 	]*atapicd[ 	][ 	]*"ide-cdrom"$/d' \
     53 	    -e '/^[ 	]*atapicd[ 	][ 	]*"ide-cdrom"[ 	#].*$/d' \
     54 	    -e '/^[ 	]*cpu[ 	][ 	]*TI,TMS390Z50$/d' \
     55 	    -e '/^[ 	]*cpu[ 	][ 	]*TI,TMS390Z50[ 	#].*$/d' \
     56 	    -e '/^[ 	]*obio[ 	][ 	]*bootbus$/d' \
     57 	    -e '/^[ 	]*obio[ 	][ 	]*bootbus[ 	#].*$/d' \
     58 	    -e '/^[ 	]*sw[ 	][ 	]*drum$/d' \
     59 	    -e '/^[ 	]*sw[ 	][ 	]*drum[ 	#].*$/d' \
     60 	    -e '/^[ 	]*ie[ 	][ 	]*sie$/d' \
     61 	    -e '/^[ 	]*ie[ 	][ 	]*sie[ 	#].*$/d' \
     62 	    -e '/^[ 	]*sbus[ 	][ 	]*sbi$/d' \
     63 	    -e '/^[ 	]*sbus[ 	][ 	]*sbi[ 	#].*$/d' \
     64 	    -e '/^[ 	]*pn[ 	][ 	]*SUNW,pn$/d' \
     65 	    -e '/^[ 	]*pn[ 	][ 	]*SUNW,pn[ 	#].*$/d' \
     66 	    -e '/^[ 	]*glm[ 	][ 	]*SUNW,glm$/d' \
     67 	    -e '/^[ 	]*glm[ 	][ 	]*SUNW,glm[ 	#].*$/d' \
     68 	    -e '/^[ 	]*gpio_87317[ 	][ 	]*"gpio"$/d' \
     69 	    -e '/^[ 	]*gpio_87317[ 	][ 	]*"gpio"[ 	#].*$/d' \
     70 	    -e '/^[ 	]*pci[ 	][ 	]*SUNW,pci$/d' \
     71 	    -e '/^[ 	]*pci[ 	][ 	]*SUNW,pci[ 	#].*$/d' \
     72 	    -e '/^[ 	]*pci[ 	][ 	]*"pci108e,8000"$/d' \
     73 	    -e '/^[ 	]*pci[ 	][ 	]*"pci108e,8000"[ 	#].*$/d' \
     74 	    -e '/^[ 	]*pci[ 	][ 	]*"pci108e,a000"$/d' \
     75 	    -e '/^[ 	]*pci[ 	][ 	]*"pci108e,a000"[ 	#].*$/d' \
     76 	    -e '/^[ 	]*pci[ 	][ 	]*"pciclass,060000"$/d' \
     77 	    -e '/^[ 	]*pci[ 	][ 	]*"pciclass,060000"[ 	#].*$/d' \
     78 	    -e '/^[ 	]*px[ 	][ 	]*"pci108e,80f0"$/d' \
     79 	    -e '/^[ 	]*px[ 	][ 	]*"pci108e,80f0"[ 	#].*$/d' \
     80 	    -e '/^[ 	]*px_pci[ 	][ 	]*"pci1033,124"$/d' \
     81 	    -e '/^[ 	]*px_pci[ 	][ 	]*"pci1033,124"[ 	#].*$/d' \
     82 	    -e '/^[ 	]*px_pci[ 	][ 	]*"pci1033,125"$/d' \
     83 	    -e '/^[ 	]*px_pci[ 	][ 	]*"pci1033,125"[ 	#].*/d' \
     84 	    -e '/^[ 	]*px_pci[ 	][ 	]*"pci8086,340"$/d' \
     85 	    -e '/^[ 	]*px_pci[ 	][ 	]*"pci8086,340"[ 	#].*$/d' \
     86 	    -e '/^[ 	]*px_pci[ 	][ 	]*"pci8086,341"$/d' \
     87 	    -e '/^[ 	]*px_pci[ 	][ 	]*"pci8086,341"[ 	#].*$/d' \
     88 	    -e '/^[ 	]*px_pci[ 	][ 	]*"pci10b5,8532"$/d' \
     89 	    -e '/^[ 	]*px_pci[ 	][ 	]*"pci10b5,8532"[ 	#].*$/d' \
     90 	    -e '/^[ 	]*px_pci[ 	][ 	]*"pci10b5,8516"$/d' \
     91 	    -e '/^[ 	]*px_pci[ 	][ 	]*"pci10b5,8516"[ 	#].*$/d' \
     92 	    -e '/^[ 	]*sx[ 	][ 	]*SUNW,sx$/d' \
     93 	    -e '/^[ 	]*sx[ 	][ 	]*SUNW,sx[ 	#].*$/d' \
     94 	    -e '/^[ 	]*sx[ 	][ 	]*"SUNW,sx"$/d' \
     95 	    -e '/^[ 	]*sx[ 	][ 	]*"SUNW,sx"[ 	#].*$/d' \
     96 	    -e '/^[ 	]*xbox[ 	][ 	]*SUNW,xbox$/d' \
     97 	    -e '/^[ 	]*xbox[ 	][ 	]*SUNW,xbox[ 	#].*$/d' \
     98 	    -e '/^[ 	]*xbox[ 	][ 	]*"SUNW,xbox"$/d' \
     99 	    -e '/^[ 	]*xbox[ 	][ 	]*"SUNW,xbox"[ 	#].*$/d' \
    100 	    -e '/^[ 	]*stc[ 	][ 	]*SUNW,spif$/d' \
    101 	    -e '/^[ 	]*stc[ 	][ 	]*SUNW,spif[ 	#].*$/d' \
    102 	    -e '/^[ 	]*fjulsa[ 	][ 	]*"pci13e9,30"$/d' \
    103 	    -e '/^[ 	]*fjulsa[ 	][ 	]*"pci13e9,30"[ 	#].*$/d' \
    104 	    -e '/^[ 	]*fjulsa[ 	][ 	]*"pci1000,30"$/d' \
    105 	    -e '/^[ 	]*fjulsa[ 	][ 	]*"pci1000,30"[ 	#].*$/d' \
    106 	    -e '/^[ 	]*cpu[ 	][ 	]*TI,TMS390Z55$/d' \
    107 	    -e '/^[ 	]*cpu[ 	][ 	]*TI,TMS390Z55[ 	#].*$/d' \
    108 	    -e '/^[ 	]*mic[ 	][ 	]*SUNW,mic$/d' \
    109 	    -e '/^[ 	]*mic[ 	][ 	]*SUNW,mic[ 	#].*$/d' \
    110 	    -e '/^[ 	]*pln[ 	][ 	]*SUNW,pln$/d' \
    111 	    -e '/^[ 	]*pln[ 	][ 	]*SUNW,pln[ 	#].*$/d' \
    112 	    -e '/^[ 	]*soc[ 	][ 	]*SUNW,soc$/d' \
    113 	    -e '/^[ 	]*soc[ 	][ 	]*SUNW,soc[ 	#].*$/d' \
    114 	    -e '/^[ 	]*sc_nct[ 	][ 	]*"nct-ds80ch11-smc"$/d' \
    115 	    -e '/^[ 	]*sc_nct[ 	][ 	]*"nct-ds80ch11-smc"[ 	#].*$/d' \
    116 	    -e '/^[ 	]*tomtppm[ 	][ 	]*jbus-ppm$/d' \
    117 	    -e '/^[ 	]*tomtppm[ 	][ 	]*jbus-ppm[ 	#].*$/d'
    118 }
    119 
    120 #
    121 # obsolete_i386 - Filter function to remove obsolete i386 driver aliases.
    122 #
    123 obsolete_i386() {
    124 	sed \
    125 	    -e '/^[ 	]*elx[^l].*10b7,9000.*/d' \
    126 	    -e '/^[ 	]*elx[^l].*10b7,9050.*/d' \
    127 	    -e '/^[ 	]*dpt[ 	][ 	]*"pci1044,a400"$/d' \
    128 	    -e '/^[ 	]*dpt[ 	][ 	]*"pci1044,a400"[ 	#].*$/d' \
    129 	    -e '/^[ 	]*audiocs[ 	][ 	]*"SUNW,CS4231"$/d' \
    130 	    -e '/^[ 	]*audiocs[ 	][ 	]*"SUNW,CS4231"[ 	#].*$/d' \
    131 	    -e '/^[ 	]*blogic[ 	][ 	]*"pci104b,1040"$/d' \
    132 	    -e '/^[ 	]*blogic[ 	][ 	]*"pci104b,1040"[ 	#].*$/d' \
    133 	    -e '/^[ 	]*mega[ 	][ 	]*"pci101e,9010"$/d' \
    134 	    -e '/^[ 	]*mega[ 	][ 	]*"pci101e,9010"[ 	#].*$/d' \
    135 	    -e '/^[ 	]*mlx[ 	][ 	]*"pci1069,1"$/d' \
    136 	    -e '/^[ 	]*mlx[ 	][ 	]*"pci1069,1"[ 	#].*$/d' \
    137 	    -e '/^[ 	]*mlx[ 	][ 	]*"pci1069,2"$/d' \
    138 	    -e '/^[ 	]*mlx[ 	][ 	]*"pci1069,2"[ 	#].*$/d' \
    139 	    -e '/^[ 	]*mlx[ 	][ 	]*"pci1069,10"$/d' \
    140 	    -e '/^[ 	]*mlx[ 	][ 	]*"pci1069,10"[ 	#].*$/d' \
    141 	    -e '/^[ 	]*mlx[ 	][ 	]*"pci1069,11"$/d' \
    142 	    -e '/^[ 	]*mlx[ 	][ 	]*"pci1069,11"[ 	#].*$/d' \
    143 	    -e '/^[ 	]*p9000[ 	][ 	]*"pci100e,9001"$/d' \
    144 	    -e '/^[ 	]*p9000[ 	][ 	]*"pci100e,9001"[ 	#].*$/d' \
    145 	    -e '/^[ 	]*p9100[ 	][ 	]*"pci100e,9100"$/d' \
    146 	    -e '/^[ 	]*p9100[ 	][ 	]*"pci100e,9100"[ 	#].*$/d' \
    147 	    -e '/^[ 	]*pcie_pci[ 	][ 	]*"pciex1011,1"$/d' \
    148 	    -e '/^[ 	]*pcie_pci[ 	][ 	]*"pciex1011,1"[ 	#].*$/d' \
    149 	    -e '/^[ 	]*pcie_pci[ 	][ 	]*"pciex1011,21"$/d' \
    150 	    -e '/^[ 	]*pcie_pci[ 	][ 	]*"pciex1011,21"[ 	#].*$/d' \
    151 	    -e '/^[ 	]*pcie_pci[ 	][ 	]*"pciex1014,22"$/d' \
    152 	    -e '/^[ 	]*pcie_pci[ 	][ 	]*"pciex1014,22"[ 	#].*$/d' \
    153 	    -e '/^[ 	]*spwr[ 	][ 	]*"pci10b8,0005"$/d' \
    154 	    -e '/^[ 	]*spwr[ 	][ 	]*"pci10b8,0005"[ 	#].*$/d' \
    155 	    -e '/^[ 	]*chs[ 	][ 	]*"pci1014,2e"$/d' \
    156 	    -e '/^[ 	]*chs[ 	][ 	]*"pci1014,2e"[ 	#].*$/d' \
    157 	    -e '/^[ 	]*cpqncr[ 	][ 	]*"pcie11,7004"$/d' \
    158 	    -e '/^[ 	]*cpqncr[ 	][ 	]*"pcie11,7004"[ 	#].*$/d' \
    159 	    -e '/^[ 	]*smartii[ 	][ 	]*"pcie11,4030"$/d' \
    160 	    -e '/^[ 	]*smartii[ 	][ 	]*"pcie11,4030"[ 	#].*$/d' \
    161 	    -e '/^[ 	]*smartii[ 	][ 	]*"pcie11,4031"$/d' \
    162 	    -e '/^[ 	]*smartii[ 	][ 	]*"pcie11,4031"[ 	#].*$/d' \
    163 	    -e '/^[ 	]*pci_to_i2o[ 	][ 	]*"pciclass,0e0001"$/d' \
    164 	    -e '/^[ 	]*pci_to_i2o[ 	][ 	]*"pciclass,0e0001"[ 	#].*$/d'
    165 }
    166 
    167 #
    168 # check if the driver aliase specified is already installed.
    169 # ignore a comment if exists.
    170 #
    171 is_installed ()
    172 {
    173 	file=$3
    174 	nawk -v driver=$1 -v alias=$2 -v delimiter='#' ' \
    175 	$1 == driver && $2 == alias \
    176 		{ found = 1; exit 0 } \
    177 	$1 == driver \
    178 		{ num = split($2, a_array, delimiter); \
    179 			if (num > 1 && a_array[1] == alias) \
    180 				{ found = 1; exit 0 } \
    181 		} \
    182 	END { if (!found) exit 1 } ' $file
    183 	return $?
    184 }
    185 
    186 #
    187 # Generate /etc/driver_aliases file.  Each entry present in $src (the copy
    188 # of driver_aliases being delivered by the package) is automatically added
    189 # to $dest (the driver_aliases file on the target system) if not already
    190 # present; thus it is NOT necessary to add any code below to cause a new
    191 # alias which has been added to the driver_aliases source to be added to
    192 # the target system on upgrade.
    193 #
    194 while read src dest; do
    195 	if [ -f $dest ]; then
    196 		#
    197 		# Strip obsolete entries from the existing driver_aliases
    198 		#
    199 		if [ $ARCH = sparc ]; then
    200 			obsolete_sparc < $dest > /tmp/oda.$$.tmp
    201 			cp /tmp/oda.$$.tmp $dest
    202 			rm -f /tmp/oda.$$.tmp
    203 		elif [ $ARCH = i386 ]; then
    204 			obsolete_i386 < $dest > /tmp/oda.$$.tmp
    205 			cp /tmp/oda.$$.tmp $dest
    206 			rm -f /tmp/oda.$$.tmp
    207 		fi
    208 		#
    209 		# Remove comment and/or blank lines before reading
    210 		#
    211 		egrep -v -e "^[ 	]*#.*$|^[ 	]*$" $src | \
    212 		    sed -e 's/#.*$//' > /tmp/oda.$$.tmp
    213 		#
    214 		# If the alias is not present in the driver_aliases
    215 		# file, then append it:
    216 		#
    217 		while read driver alias; do
    218 			is_installed $driver $alias $dest \
    219 			    >/dev/null 2>&1 || echo "$driver $alias" >>$dest
    220 		done < /tmp/oda.$$.tmp
    221 		rm -f /tmp/oda.$$.tmp
    222 	else
    223 		#
    224 		# If no driver_aliases is present on the target system,
    225 		# just copy over the one from the package.
    226 		#
    227 		cp -p $src $dest
    228 	fi
    229 done
    230 exit 0
    231