home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March B / SCO_CASTOR4RRT.iso / c7xx / install / postinstall < prev    next >
Text File  |  1998-08-19  |  5KB  |  208 lines

  1. #ident    "@(#)pkg.ihvhba:i386/pkg/ihvhba/c7xx/postinstall    1.1.2.1"
  2.  
  3. do_extract () {
  4.  
  5.     ###
  6.     # Extract Driver.o from loadable module
  7.     ###
  8.     mv /tmp/$PKGINST/$PKGINST /tmp/$PKGINST/Driver.o
  9.  
  10.     for sec in data data1 rodata rodata1 text
  11.     do
  12.         mcs -n .drv_$sec -d Driver.o
  13.         mcs -n .rel.drv_$sec -d Driver.o
  14.     done
  15.  
  16.     mcs -n .mod_dep -d Driver.o
  17.     mcs -n .rel.mod_dep -d Driver.o
  18.  
  19.     ###
  20.     # remove .comment because it is now about 2k.  Really it should be 
  21.     # pstamped note that all our loadable drivers have large .comment 
  22.     # sections that should be pstamped.
  23.     ###
  24.  
  25.     mcs -d Driver.o
  26. }
  27.  
  28. abort_install () {
  29.  
  30.     message -d ${FAIL_INST}
  31.     if [ $OVERLAY ]
  32.     then
  33.         if [ -d /var/sadm/hba.save/$PKGINST ]
  34.         then
  35.             SVDIR=/var/sadm/hba.save/$PKGINST
  36.             for FILE in Driver.o space.c disk.cfg
  37.             do
  38.                 if [ -f $SVDIR/pack.d/$FILE ]
  39.                 then 
  40.                     cp $SVDIR/pack.d/$FILE /etc/conf/pack.d/$PKGINST
  41.                 fi
  42.             done
  43.             if [ -f $SVDIR/drvmap.d/$PKGINST ]
  44.             then
  45.                 cp $SVDIR/drvmap.d/$PKGINST /etc/conf/drvmap.d
  46.             fi
  47.             if [ -f $SVDIR/mdevice.d/$PKGINST ]
  48.             then
  49.                 cp $SVDIR/mdevice.d/$PKGINST /etc/conf/mdevice.d
  50.             fi
  51.         fi
  52.     fi
  53.     exit ${FAILURE}
  54. }
  55.  
  56. do_install () {
  57.  
  58.     ${CONFBIN}/idinstall -P ${PKGINST} -a ${1} > ${ERR} 2>&1
  59.     RET=$?
  60.     if [ ${RET} != 0 ]
  61.     then
  62.         OVERLAY=1
  63.         SVDIR=/var/sadm/hba.save/$PKGINST
  64.  
  65.         if [ ! -d $SVDIR/pack.d ]
  66.         then
  67.             mkdir -p $SVDIR/pack.d 2>&1 >/dev/null
  68.         fi
  69.  
  70.         for FILE in Driver.o space.c disk.cfg
  71.         do
  72.             mv /etc/conf/pack.d/$PKGINST/$FILE $SVDIR/pack.d
  73.             if [ "$FILE" = "space.c" ]
  74.             then
  75.                mv /tmp/$PKGINST/Space.c /etc/conf/pack.d/$PKGINST/space.c
  76.             else
  77.                mv /tmp/$PKGINST/$FILE /etc/conf/pack.d/$PKGINST/$FILE
  78.             fi
  79.             [ $? -ne 0 ] && abort_install
  80.         done
  81.  
  82.         if [ ! -d $SVDIR/drvmap.d ]
  83.         then
  84.             mkdir $SVDIR/drvmap.d 2>&1 >/dev/null
  85.         fi
  86.         mv /etc/conf/drvmap.d/$PKGINST $SVDIR/drvmap.d
  87.         mv /tmp/$PKGINST/Drvmap /etc/conf/drvmap.d/$PKGINST
  88.         [ $? -ne 0 ] && abort_install
  89.  
  90.         if [ ! -d $SVDIR/mdevice.d ]
  91.         then
  92.             mkdir $SVDIR/mdevice.d 2>&1 >/dev/null
  93.         fi
  94.         mv /etc/conf/mdevice.d/$PKGINST $SVDIR/mdevice.d
  95.         mv /tmp/$PKGINST/Master /etc/conf/mdevice.d/$PKGINST
  96.         [ $? -ne 0 ] && abort_install
  97.     else
  98.         rm -f ${ERR}
  99.         mv disk.cfg /etc/conf/pack.d/${1}
  100.         chown bin /etc/conf/pack.d/${1}/disk.cfg 
  101.         chgrp bin /etc/conf/pack.d/${1}/disk.cfg
  102.     fi
  103.     mv ${1}.h /usr/include/sys
  104.     chown bin /usr/include/sys/${1}.h
  105.     chgrp bin /usr/include/sys/${1}.h
  106. }
  107.  
  108. register() {
  109. if [ $OVERLAY ]
  110. then
  111. installf -c none $PKGINST - << !!EOF
  112. /etc/conf/pack.d/$PKGINST/Driver.o
  113. /etc/conf/pack.d/$PKGINST/disk.cfg
  114. /etc/conf/pack.d/$PKGINST/space.c
  115. /etc/conf/drvmap.d/$PKGINST
  116. /etc/conf/mdevice.d/$PKGINST
  117. !!EOF
  118. else
  119. installf -c none $PKGINST - << !!EOF
  120. /etc/conf/pack.d/${PKGINST}/disk.cfg
  121. /usr/include/sys/${PKGINST}.h
  122. /etc/loadmods
  123. !!EOF
  124. fi
  125. installf -f $PKGINST
  126. }
  127.  
  128. # Messaging related stuff
  129. PKGMSG=hba.pkg
  130. LOCALE=${LC_ALL:-${LC_MESSAGES:-${LANG:-"C"}}}
  131. # Check if we're installing during initial system installation.
  132. # If so, set ROOT=/mnt; otherwise ROOT is null.  Make sure that
  133. # we're not pkgadd'ing over a pkg that was installed during that
  134. # first system installation (i.e., check UPDATE).
  135. ROOT=
  136. [ "$SETNAME" = "from_loadhba" -a "$UPDATE" != "yes" ] && ROOT="/mnt"
  137. LC_MESSAGES=$ROOT/usr/lib/locale/$LOCALE
  138.  
  139. if [ ! -f ${LC_MESSAGES}/LC_MESSAGES/${PKGMSG} ]
  140. then
  141.     if [ -f ${REQDIR}/inst/locale/${LOCALE}/$PKGMSG} -a \
  142.         -d ${ROOT}/usr/lib/locale/${LOCALE}/LC_MESSAGES ]
  143.     then
  144.         cp ${REQDIR}/inst/locale/${LOCALE}/${PKGMSG} \
  145.             ${LC_MESSAGES}/LC_MESSAGES
  146.     fi
  147. fi
  148. FAIL_INST=`pfmt -s ERROR -g ${PKGMSG}:2 "The installation cannot be completed due to an error in the driver installation during the installation of the %s module.  The file %s contains the errors." "${PKGINST}" "${ERR}" 2>&1`
  149.  
  150.  
  151. FAILURE=1    # fatal error
  152.  
  153. CONFDIR=/etc/conf
  154. CONFBIN=${CONFDIR}/bin
  155. ERR=/tmp/err.out
  156.  
  157. cd /tmp/${PKGINST}
  158. [ -f /tmp/${PKGINST}/Driver.o ] || do_extract
  159. do_install ${PKGINST}
  160.  
  161. if test -f /bin/grep
  162. then
  163.     grep $PKGINST /etc/loadmods >/dev/null
  164.     [ $? -ne 0 ] &&
  165.         cat /tmp/$PKGINST/loadmods >>/etc/loadmods
  166. else
  167.     cat /tmp/$PKGINST/loadmods >>/etc/loadmods
  168. fi
  169.  
  170. # Register changes made to system into the contents file
  171. register
  172.  
  173. # Cleanup temporary files and directories
  174. rm -fr /tmp/${PKGINST} /tmp/hba.cpio.z >/dev/null 2>&1
  175. removef ${PKGINST} /tmp /tmp/${PKGINST} /tmp/${PKGINST}/Drvmap \
  176.     /tmp/${PKGINST}/mod.cpio.z /tmp/hba.cpio.z /tmp/${PKGINST}/Master \
  177.     /tmp/${PKGINST}/System >/dev/null 2>&1
  178. removef -f ${PKGINST} >/dev/null 2>&1
  179.  
  180. # If this package is being added as an add-on package (not being installed 
  181. # from the initial system installation via loadhba), then for non-ISA cards
  182. # which have boardids run 'dcu -s'.
  183. if [ "$ROOT" != "/mnt" ]
  184. then
  185.     cat /etc/conf/drvmap.d/${PKGINST} | awk -F'|' '
  186.         BEGIN {
  187.             BOARDID = 1
  188.         }
  189.     
  190.         {
  191.             if (NF > 1) {
  192.                 if ($2 !~ /Y/)
  193.                     if ($2 !~ /N/)
  194.                         if($3 != "") {
  195.                             BOARDID = 0
  196.                             exit
  197.                         }
  198.             }
  199.         }
  200.     
  201.         END {
  202.             exit BOARDID 
  203.         }'
  204.     [ $? -eq 0 ] && /sbin/dcu -s
  205. fi
  206. /etc/conf/bin/idbuild
  207. exit 0
  208.