postinstall revision 7c478bd95313f5f23a4c958a745db2134aa03244
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (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
# 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
#
#ident "%Z%%M% %I% %E% SMI"
#
# Copyright 2004 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
export PATH
EXIT=0
ARCH="`uname -p`"
NAMEMAJOR="$BASEDIR/etc/name_to_major"
#
# Routine to remove current entries for a device in /devices,
# /dev, and /etc/path_to_inst.
#
RmDevice()
{
rm -f $1
linkslist=`find dev -type l -print`
for l in $linkslist
do
dorm=`ls -l $l | grep $1`
if [ "$dorm"X != "X" ]
then
rm -f $l
fi
done
instname=`expr $1 : devices'\(.*'$m'.*\):.*`
cp $BASEDIR/etc/path_to_inst /tmp/p2i.$$
cat /tmp/p2i.$$ |
sed '\?'$instname'?d' > /tmp/np2i.$$
if [ -s /tmp/np2i.$$ ]
then
chmod 444 $BASEDIR/etc/path_to_inst
chown root $BASEDIR/etc/path_to_inst
chgrp sys $BASEDIR/etc/path_to_inst
fi
rm /tmp/p2i.$$
}
# This function will check if the module has an entry in etc/name_to_major
# If not simply calls add_drv with the arguments given. If there is
# such an entry in name_to_major file, it adds entries in driver_aliases
# driver_classes and minor_perm if necessary.
# The syntax of this function is the same as add_drv.
check_add_drv()
{
basedir=/
alias=""
class=""
ADD_ALIAS=0
ADD_CLASS=0
ADD_MINOR=0
OPTIND=1
IS_NET_DRIVER=0
cmd="add_drv"
while getopts i:b:m:c:n opt
do
case $opt in
i ) ADD_ALIAS=1
alias=$OPTARG
cmd=$cmd" -i '$alias'"
;;
m ) ADD_MINOR=1
minor=$OPTARG
cmd=$cmd" -m '$minor'"
;;
c) ADD_CLASS=1
class=$OPTARG
cmd=$cmd" -c $class"
;;
b) basedir=$OPTARG
cmd=$cmd" -b $basedir"
;;
n) IS_NET_DRIVER=1
;;
\?) echo "check_add_drv can not handle this option"
return
;;
esac
done
shift `/usr/bin/expr $OPTIND - 1`
drvname=$1
cmd=$cmd" "$drvname
drvname=`echo $drvname | /usr/bin/sed 's;.*/;;g'`
if [ $? -ne 0 ]
then
eval $cmd
else
# entry already in name_to_major, add alias, class, minorperm
# if necessary
if [ $ADD_ALIAS = 1 ]
then
for i in $alias
do
if [ $? -ne 0 ]
then
echo "$drvname $i" >> $basedir/etc/driver_aliases
fi
done
fi
if [ $ADD_CLASS = 1 ]
then
if [ $? -ne 0 ]
then
echo "$drvname\t$class" >> $basedir/etc/driver_classes
fi
fi
if [ $ADD_MINOR = 1 ]
then
if [ $? -ne 0 ]
then
minorentry="$drvname:$minor"
echo $minorentry >> $basedir/etc/minor_perm
fi
fi
fi
# The following clone device/dev is needed for Custom Jumpstart
if [ $IS_NET_DRIVER -eq 1 ]
then
CLONE_DEVICE=devices/pseudo/clone@0:$drvname
set `/usr/bin/grep "^clone[ ]" $basedir/etc/name_to_major`
CLONE_MAJ=$2
set `/usr/bin/grep "^$drvname[ ]" $basedir/etc/name_to_major`
DRIVER_MAJ=$2
mknod $basedir/$CLONE_DEVICE c $CLONE_MAJ $DRIVER_MAJ
chmod 600 $basedir/$CLONE_DEVICE
chgrp sys $basedir/$CLONE_DEVICE
chown root $basedir/$CLONE_DEVICE
ln -s ../$CLONE_DEVICE $basedir/dev/$drvname
fi
}
#
# Several mouse drivers on the Intel platform will have different
# device names with SunOS 5.6 than with previous releases. We want to
# remove the old names at this time so that the configuration reboot
# will cleanly create the new device names.
#
if [ "${ARCH}" = "i386" ]
then
for m in logi msm kdmouse asy
do
cd ${BASEDIR}
devlist=`find devices -name $m"*" -print`
for d in $devlist
do
prefix=`expr $d : '\(.*'$m'\).*'`
fulldev=`basename $d`
ioaddr=`expr $fulldev : $m'@\(.*\),.*'`
#
# Chance to bail now if we don't appear to need
# to do the conversion.
#
if [ "$ioaddr" = "1" ]
then
continue
else
if [ "$ioaddr" != "" ]
then
RmDevice $d
fi
fi
done
done
touch ${BASEDIR}/reconfigure
DELCONF1="platform/i86pc/kernel/drv/logi.conf"
DELCONF2="platform/i86pc/kernel/drv/msm.conf"
if [ -f $BASEDIR/$DELCONF1 ] ; then
rm $BASEDIR/$DELCONF1
fi
if [ -f $BASEDIR/$DELCONF2 ] ; then
rm $BASEDIR/$DELCONF2
fi
fi
# add_drv ecpp driver if not already installed
modnum=`grep -c ecpp ${NAMEMAJOR}`
if [ "$modnum" = "0" ]; then
# add new entries to name_to_major, minor_perm, driver_classes files
/usr/sbin/add_drv -b ${BASEDIR} -i '"lp"' -m '* 0666 root sys' -n ecpp
fi
exit 0