home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March / PCWK3A99.iso / Unixware / IMAGES / HBA_IMAG / dpt / install / postinstall < prev    next >
Encoding:
Text File  |  1998-08-07  |  4.9 KB  |  213 lines

  1. #ident    "@(#)pkg.ihvhba:i386/pkg/ihvhba/dpt/postinstall    1.1.2.2"
  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.  
  104.     [ -f ${1}.h ] && {
  105.         mv ${1}.h /usr/include/sys
  106.         chown bin /usr/include/sys/${1}.h
  107.         chgrp bin /usr/include/sys/${1}.h
  108.     }
  109. }
  110.  
  111. register() {
  112. if [ $OVERLAY ]
  113. then
  114. installf -c none $PKGINST - << !!EOF
  115. /etc/conf/pack.d/$PKGINST/Driver.o
  116. /etc/conf/pack.d/$PKGINST/disk.cfg
  117. /etc/conf/pack.d/$PKGINST/space.c
  118. /etc/conf/drvmap.d/$PKGINST
  119. /etc/conf/mdevice.d/$PKGINST
  120. !!EOF
  121. else
  122. installf -c none $PKGINST - << !!EOF
  123. /etc/conf/pack.d/${PKGINST}/disk.cfg
  124. /etc/loadmods
  125. !!EOF
  126. fi
  127. [ -f /usr/include/sys/${PKGINST}.h ] && {
  128.     installf -c none $PKGINST /usr/include/sys/${PKGINST}.h
  129. }
  130. installf -f $PKGINST
  131. }
  132.  
  133. # Messaging related stuff
  134. PKGMSG=hba.pkg
  135. LOCALE=${LC_ALL:-${LC_MESSAGES:-${LANG:-"C"}}}
  136. # Check if we're installing during initial system installation.
  137. # If so, set ROOT=/mnt; otherwise ROOT is null.  Make sure that
  138. # we're not pkgadd'ing over a pkg that was installed during that
  139. # first system installation (i.e., check UPDATE).
  140. ROOT=
  141. [ "$SETNAME" = "from_loadhba" -a "$UPDATE" != "yes" ] && ROOT="/mnt"
  142. LC_MESSAGES=$ROOT/usr/lib/locale/$LOCALE
  143.  
  144. if [ ! -f ${LC_MESSAGES}/LC_MESSAGES/${PKGMSG} ]
  145. then
  146.     if [ -f ${REQDIR}/inst/locale/${LOCALE}/$PKGMSG} -a \
  147.         -d ${ROOT}/usr/lib/locale/${LOCALE}/LC_MESSAGES ]
  148.     then
  149.         cp ${REQDIR}/inst/locale/${LOCALE}/${PKGMSG} \
  150.             ${LC_MESSAGES}/LC_MESSAGES
  151.     fi
  152. fi
  153. 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`
  154.  
  155.  
  156. FAILURE=1    # fatal error
  157.  
  158. CONFDIR=/etc/conf
  159. CONFBIN=${CONFDIR}/bin
  160. ERR=/tmp/err.out
  161.  
  162. cd /tmp/${PKGINST}
  163. [ -f /tmp/${PKGINST}/Driver.o ] || do_extract
  164. do_install ${PKGINST}
  165.  
  166. if test -f /bin/grep
  167. then
  168.     grep $PKGINST /etc/loadmods >/dev/null
  169.     [ $? -ne 0 ] &&
  170.         cat /tmp/$PKGINST/loadmods >>/etc/loadmods
  171. else
  172.     cat /tmp/$PKGINST/loadmods >>/etc/loadmods
  173. fi
  174.  
  175. # Register changes made to system into the contents file
  176. register
  177.  
  178. # Cleanup temporary files and directories
  179. rm -fr /tmp/${PKGINST} /tmp/hbacpio.z >/dev/null 2>&1
  180. removef ${PKGINST} /tmp /tmp/${PKGINST} /tmp/${PKGINST}/Drvmap \
  181.     /tmp/${PKGINST}/modcpio.z /tmp/hbacpio.z /tmp/${PKGINST}/Master \
  182.     /tmp/${PKGINST}/System >/dev/null 2>&1
  183. removef -f ${PKGINST} >/dev/null 2>&1
  184.  
  185. # If this package is being added as an add-on package (not being installed 
  186. # from the initial system installation via loadhba), then for non-ISA cards
  187. # which have boardids run 'dcu -s'.
  188. if [ "$ROOT" != "/mnt" ]
  189. then
  190.     cat /etc/conf/drvmap.d/${PKGINST} | awk -F'|' '
  191.         BEGIN {
  192.             BOARDID = 1
  193.         }
  194.     
  195.         {
  196.             if (NF > 1) {
  197.                 if ($2 !~ /Y/)
  198.                     if ($2 !~ /N/)
  199.                         if($3 != "") {
  200.                             BOARDID = 0
  201.                             exit
  202.                         }
  203.             }
  204.         }
  205.     
  206.         END {
  207.             exit BOARDID 
  208.         }'
  209.     [ $? -eq 0 ] && /sbin/dcu -s
  210. fi
  211. /etc/conf/bin/idbuild
  212. exit 0
  213.