PSARC 2007/045 I2O EOL and EOF
4863632 Hey Hey! Ho Ho! I2O Has Got to Go!
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 2006 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
26 #
27 #ident "@(#)i.nametomajor 1.36 06/09/11 SMI"
28
29 PATH=/usr/bin:/usr/sbin:$PATH; export PATH
30
31 #
32 # obsolete_sparc - Filter function to remove obsolete SPARC driver entries.
33 # We define an associative array of bad driver names, and then nawk out
34 # lines where the first token is defined in our array.
35 #
36 obsolete_sparc()
37 {
38 nawk 'BEGIN {
39 obs["rip"] = 1;
40 obs["svloop"] = 1;
41 obs["tcl"] = 1;
42 obs["tco"] = 1;
43 obs["tcoo"] = 1;
44 obs["sp"] = 1;
45 obs["consfb"] = 1;
46 obs["dbri"] = 1;
47 obs["XXunusedXX"] = 1;
48 obs["sw"] = 1;
49 obs["cgtwo"] = 1;
50 obs["xy"] = 1;
51 obs["xd"] = 1;
52 obs["pc"] = 1;
53 obs["app"] = 1;
54 obs["evq"] = 1;
55 obs["win"] = 1;
56 obs["svarp"] = 1;
57 obs["svip"] = 1;
58 obs["svrip"] = 1;
59 obs["svicmp"] = 1;
60 obs["svudp"] = 1;
61 obs["svtcp"] = 1;
62 obs["vme"] = 1;
63 obs["ie"] = 1;
64 obs["qe"] = 1;
65 obs["qec"] = 1;
66 obs["ncr"] = 1;
67 obs["xt"] = 1;
68 obs["id"] = 1;
69 obs["vmemem"] = 1;
70 obs["pn"] = 1;
71 obs["kmac"] = 1;
72 obs["ipi3sc"] = 1;
73 obs["cgfour"] = 1;
74 obs["cgeight-p4"] = 1;
75 obs["xdc"] = 1;
76 obs["xyc"] = 1;
77 obs["mcp"] = 1;
78 obs["mcpzsa"] = 1;
79 obs["mcpp"] = 1;
80 obs["be"] = 1;
81 obs["p9000"] = 1;
82 obs["p9100"] = 1;
83 obs["pci"] = 1;
84 obs["profile"] = 1;
85 obs["eeprom"] = 1;
86 obs["PFUaga"] = 1;
87 obs["atapicd"] = 1;
88 obs["cgeight"] = 1;
89 obs["cgfourteen"] = 1;
90 obs["xbox"] = 1;
91 obs["sx"] = 1;
92 obs["sx_cmem"] = 1;
93 obs["stc"] = 1;
94 obs["bbc"] = 1;
95 obs["gptwo"] = 1;
96 obs["bwtwo"] = 1;
97 obs["cgthree"] = 1;
98 obs["obio"] = 1;
99 obs["cpu"] = 1;
100 obs["bootbus"] = 1;
101 obs["sbi"] = 1;
102 obs["mic"] = 1;
103 obs["pln"] = 1;
104 obs["soc"] = 1;
105 obs["sc_nct"] = 1;
106 obs["tomtppm"] = 1;
107 } !($1 in obs) { print $0 }'
108 }
109
110 #
111 # obsolete_i386 - Filter function to remove obsolete i386 driver entries.
112 # We define an associative array of bad driver names, and then nawk out
113 # lines where the first token is defined in our array.
114 #
115 obsolete_i386()
116 {
117 nawk 'BEGIN {
118 obs["aha"] = 1;
119 obs["aic"] = 1;
120 obs["app"] = 1;
121 obs["audiocs"] = 1;
122 obs["blogic"] = 1;
123 obs["chanmux"] = 1;
124 obs["chs"] = 1;
125 obs["cmtp"] = 1;
126 obs["corvette"] = 1;
127 obs["cpqncr"] = 1;
128 obs["csa"] = 1;
129 obs["dpt"] = 1;
130 obs["dsa"] = 1;
131 obs["eepro"] = 1;
132 obs["eha"] = 1;
133 obs["el"] = 1;
134 obs["elink"] = 1;
135 obs["elx"] = 1;
136 obs["envm"] = 1;
137 obs["esa"] = 1;
138 obs["esa"] = 1;
139 obs["iee"] = 1;
140 obs["ieef"] = 1;
141 obs["iss"] = 1;
142 obs["kd"] = 1;
143 obs["kdmouse"] = 1;
144 obs["lp"] = 1;
145 obs["mc"] = 1;
146 obs["mcis"] = 1;
147 obs["mega"] = 1;
148 obs["mlx"] = 1;
149 obs["nee"] = 1;
150 obs["nei"] = 1;
151 obs["nfe"] = 1;
152 obs["objmgr"] = 1;
153 obs["p9000"] = 1;
154 obs["p9100"] = 1;
155 obs["pcaic"] = 1;
156 obs["profile"] = 1;
157 obs["riles"] = 1;
158 obs["rip"] = 1;
159 obs["smartii"] = 1;
160 obs["smc"] = 1;
161 obs["smce"] = 1;
162 obs["smceu"] = 1;
163 obs["smcf"] = 1;
164 obs["sp"] = 1;
165 obs["svarp"] = 1;
166 obs["svicmp"] = 1;
167 obs["svip"] = 1;
168 obs["svloop"] = 1;
169 obs["svrip"] = 1;
170 obs["svtcp"] = 1;
171 obs["svudp"] = 1;
172 obs["tcl"] = 1;
173 obs["tco"] = 1;
174 obs["tcoo"] = 1;
175 obs["tiqmouse"] = 1;
176 obs["tr"] = 1;
177 obs["trantor"] = 1;
178 } !($1 in obs) { print $0 }'
179 }
180
181 #
182 # Useful debugging which is reasonable to include in a production system:
183 # we copy the salient driver files to the package undo directory before
184 # doing any work. This will help diagnose add_drv errors before the system
185 # becomes an unbootable smoldering ruin.
186 #
187 for file in driver_aliases driver_classes minor_perm name_to_major; do
188 cp $BASEDIR/etc/$file $PKGSAV/$file.orig >/dev/null 2>&1
189 done
190
191 #
192 # check if the driver specified is already installed.
193 # the second token must be the decimal digit.
194 # ignore a comment if exists.
195 #
196 is_installed ()
197 {
198 file=$2
199 nawk -v driver=$1 -v delimiter='#' ' \
200 $1 == driver && $2 ~ /^[0-9][0-9]*$/ \
201 { found = 1; exit 0 } \
202 $1 == driver \
203 { num = split($2, n_array, delimiter); \
204 if (num > 1 && n_array[1] ~ /^[0-9][0-9]*$/) \
205 { found = 1; exit 0 } \
206 } \
207 END { if (!found) exit 1 } ' $file
208 return $?
209 }
210
211 #
212 # Add_drv needs /etc/driver_aliases in order to work properly; if for
213 # some reason it has been removed, create an empty one at this time.
214 # Recall that in SUNWcsr's pkginfo.tmpl, the driver_aliases class-action
215 # script is invoked *after* this class-action script. This is critical
216 # because if we are going to add_drv a new driver 'foo', and 'foo' has
217 # an alias 'bar', the add_drv of 'foo' will fail if the alias is already
218 # present. Thus new aliases must be added *after* new driver major entries.
219 # The driver_aliases class-action script will add the complete set of aliases
220 # if we create an empty file here, so this code allows us to continue and
221 # get a correct upgrade in the face of a missing driver_aliases file.
222 #
223 if [ ! -f $BASEDIR/etc/driver_aliases ]; then
224 touch $BASEDIR/etc/driver_aliases
225 chmod 0644 $BASEDIR/etc/driver_aliases
226 chown root $BASEDIR/etc/driver_aliases
227 chgrp sys $BASEDIR/etc/driver_aliases
228 fi
229
230 while read src dest; do
231 if [ -f $dest ]; then
232 #
233 # Strip obsolete entries from the existing name_to_major
234 #
235 if [ $ARCH = sparc ]; then
236 obsolete_sparc < $dest > /tmp/onm.$$.tmp
237 else
238 obsolete_i386 < $dest > /tmp/onm.$$.tmp
239 fi
240
241 cp /tmp/onm.$$.tmp $dest
242 rm -f /tmp/onm.$$.tmp
243
244 #
245 # Remove comment and/or blank lines before reading
246 #
247 nawk '$1 !~ /^#|^$/ {print $0}' $src | sed -e 's/#.*$//' | \
248 while read name major; do
249 #
250 # If the driver is already present in name_to_major,
251 # leave the existing number and continue
252 #
253 is_installed $name $dest >/dev/null 2>&1 && continue
254 #
255 # Otherwise add the driver to name_to_major using
256 # add_drv. add_drv produces spurious output even on
257 # success, so save its output in a temporary
258 # file in case an error occurs.
259 #
260 if add_drv -b $BASEDIR $name \
261 >/tmp/ad.$$.tmp 2>&1; then
262 echo "added $name to $dest"
263 else
264 echo "$PKG: failed to add $name to " \
265 "$dest:" >& 2
266 cat /tmp/ad.$$.tmp >& 2
267 fi
268 done
269 rm -f /tmp/ad.$$.tmp
270 else
271 #
272 # If no name_to_major is present on the target system,
273 # just copy over the one from the package.
274 #
275 cp -p $src $dest
276 fi
277 done
278 exit 0
--- EOF ---