home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-08-12 | 30.3 KB | 1,110 lines |
- #ident "@(#)request 17.8 98/08/12"
- #copyright "%c%"
- #!/usr/bin/sh
-
- # Variables which can be set in /tmp/${PKGINST}.vars
- #
- # SILENT_INSTALL=true Install the update without any prompts
- # UPDATE_BACKUP=true Backup to disk (or skip if false) without prompts
- # SKIP_CHECK_SPACE=true Assume enough space to install update without prompts
- # UPDATE_ALL=true Update installed packages even if already updated
-
- [ -f /tmp/${PKGINST}.vars ] && . /tmp/${PKGINST}.vars
-
- if [ "${SILENT_INSTALL}" = "true" ]
- then UPDATE_BACKUP=${UPDATE_BACKUP:-"true"}
- SKIP_CHECK_SPACE=${SKIP_CHECK_SPACE:-"true"}
- UPDATE_ALL=${UPDATE_ALL:-"true"}
- fi
-
- #
- # Notes:
- #
- # Since CLASSES var is not properly passed due to a bug, make sure it is
- # sent to response file $1 to work around it.
- #
-
- #
- # Define any variables needed during package installation
- #
-
- BIN=/usr/bin
- USBIN=/usr/sbin
- CONFDIR=/etc/conf
- CONFBIN=${CONFDIR}/bin
- CPIOFILE=update.cpio
- TTY=/dev/tty
- UPD_INUM=`echo ${PKG} | ${BIN}/sed -e "s/update//"`
- UPD_NUM=${RELEASE}
- UPDINST=${REQDIR}
- UPDLOGFILE=/var/sadm/install/logs/${PKGINST}.out
- UPDTMP=/tmp/${PKGINST}
- UPDVARFILE=${1}
- UPDBKUPDIR=/var/sadm/bkup/${PKGINST}
- UPDCNTFILE=${UPDBKUPDIR}/upd.cnt
- UPDMENUANS=${UPDTMP}/results
- UPDMENUDIR=${UPDINST}
- UPDPKGDIR=/var/sadm/pkg/${PKGINST}
- #
- # Export any vars we may need in child scripts
- #
- export BIN USBIN CONFDIR CONFBIN CPIOFILE DeskTopOwn LANG TTY
- export UPD_INUM UPD_NUM UPDINST UPDLANG UPDLOGFILE UPDTMP UPDVARFILE
- export UPDBKUPDIR UPDCNTFILE UPDMENUANS UPDMENUDIR UPDPKGDIR
- export UPD_INSTRM UPD_instrm UPD_INSTRMED UPD_BKUPREST UPD_NUM UPD_INUM
- export ProcMsg GenericProcMsg
- export SILENT_INSTALL
-
- #
- # Define the backup deletion routine for when an interrupting signal comes in
- #
- DeleteBackupExit ()
- {
- LogMsg "DeleteBackupExit: `GetText STARTED`"
- DbgMsg "DeleteBackupExit: STARTED"
- UPDCNT=999999
- [ -f ${UPDCNTFILE} ] && . ${UPDCNTFILE}
- UPDCNT=`expr ${UPDCNT} + 1`
- if [ "${UPDCNT}" -eq 0 ]
- then ${BIN}/rm -rf ${UPDBKUPDIR}
- else ${BIN}/rm -rf ${UPDBKUPDIR}/bkup${UPDCNT}
- fi
- LogMsg "DeleteBackupExit: `GetText EXITED` - ${1}"
- DbgMsg "DeleteBackupExit: EXITED - ${1}"
- RmExit ${1}
- }
-
- #
- # Define the routine to run when an interrupting signal is received
- #
- TrapCmd ()
- {
- MsgHandler 1 UpdIntrMsg
- DeleteBackupExit 3
- }
-
- #
- # Load RC Script
- #
- . ${UPDINST}/updpkg.rc
- DbgMsg "\n\nPKGADD OF ${NAME} BEGUN `date`\n\n"
- LogMsg "request: `GetText STARTED`"
- DbgMsg "request: STARTED"
- DbgMsg " request: loaded updpkg.rc procedures"
- DbgMsg " request: Variables initially set:"
- DbgMsg " NAME='${NAME}'"
- DbgMsg " PKG='${PKG}'"
- DbgMsg " ARCH='${ARCH}'"
- DbgMsg " RELEASE='${RELEASE}'"
- DbgMsg " IRELEASE='${IRELEASE}'"
- DbgMsg " VERSION='${VERSION}'"
- DbgMsg " CATEGORY='${CATEGORY}'"
- DbgMsg " VENDOR='${VENDOR}'"
- DbgMsg " BASEDIR='${BASEDIR}'"
- DbgMsg " PKGSAV='${PKGSAV}'"
- DbgMsg " CLASSES='${CLASSES}'"
- DbgMsg " BIN='${BIN}'"
- DbgMsg " USBIN='${USBIN}'"
- DbgMsg " CONFDIR='${CONFDIR}'"
- DbgMsg " CONFBIN='${CONFBIN}'"
- DbgMsg " CPIOFILE='${CPIOFILE}'"
- DbgMsg " TTY='${TTY}'"
- DbgMsg " UPD_INUM='${UPD_INUM}'"
- DbgMsg " UPD_NUM='${UPD_NUM}'"
- DbgMsg " UPDINST='${UPDINST}'"
- DbgMsg " UPLOGFILE='${UPDLOGFILE}'"
- DbgMsg " UPDTMP='${UPDTMP}'"
- DbgMsg " UPVARFILE='${UPDVARFILE}'"
- DbgMsg " UPDBKUPDIR='${UPDBKUPDIR}'"
- DbgMsg " UPDCNTFILE='${UPDCNTFILE}'"
- DbgMsg " UPDMENUANS='${UPDMENUANS}'"
- DbgMsg " UPDMENUDIR='${UPDMENUDIR}'"
- DbgMsg " UPDPKGDIR='${UPDPKGDIR}'"
-
- #
- # Create a temporary work directory and backup directory
- #
- DbgMsg " request: remake dir UPDTMP=${UPDTMP}"
- ${BIN}/rm -rf ${UPDTMP} 2> /dev/null
- ${BIN}/mkdir -p ${UPDTMP}
-
-
- #
- # Subroutine to setup and process the language selection screen if LANG was
- # set to an invalid language for the install
- #
- # $1 - input is the LANG setting without extensions, i.e. base language.
- ValidateLang ()
- {
- LogMsg "ValidateLang: `GetText STARTED`"
- DbgMsg "ValidateLang: STARTED - try lang ${1}"
- DbgMsg " UPDSupportedLang='${UPDSupportedLang}'"
- #
- # Validate against the supported listof languages
- #
- for lg in ${UPDSupportedLang}
- do
- if [ "${1}" = "${lg}" ]
- then
- UPDLANG=${1}
- LogMsg "ValidateLang: `GetText COMPLETED` - UPDLANG=${UPDLANG}"
- DbgMsg "ValidateLang: COMPLETED - Valid Lang - UPDLANG=${UPDLANG}"
- return 0
- fi
- done
-
- # If silent install is being done, and we have an invalid LANG,
- # set it to C
- if [ "$SILENT_INSTALL" = "true" ]
- then
- UPDLANG="C"
- return 0
- fi
-
- #
- # Load Common locale menu color functions.
- #
- DbgMsg " ValidateLang: dot in /etc/inst/locale/C/menus/menu_colors.sh"
- . /etc/inst/locale/C/menus/menu_colors.sh
-
- #
- # Display language selection menu.
- #
- UpdLangSel=${1}
- DbgMsg " UpdLangSel=${UpdLangSel}"
- export UpdLangSel UPDLangSelect UpdLangChoices
-
- menu_colors regular
- DbgMsg " ValidateLang: run menu updlang.menu"
- DbgMsg " UPDINST=${UPDINST}"
- DbgMsg " UPDMENUANS=${UPDMENUANS}"
- LANG=C ${USBIN}/menu -r -f ${UPDINST}/updlang.menu -o ${UPDMENUANS} 1>${TTY} 2>/dev/null <${TTY}
-
- #
- # Process language selection.
- #
- . ${UPDMENUANS}
- UPDLANG=${UpdLangChoices}
-
- unset lg UpdLangSel UPDLangSelect UpdLangChoices
- LogMsg "ValidateLang: `GetText COMPLETED` - UPDLANG=${UPDLANG}"
- DbgMsg "ValidateLang: COMPLETED - Selected Lang - UPDLANG=${UPDLANG}"
- return 0
- }
-
- #
- # Setup language information
- #
- DbgMsg " request: Enter lang determination: LANG=${LANG}"
- if [ -z "${LANG}" ]
- then
- # Default to Common.
- LANG="C"
- UPDLANG=${LANG}
- else
- DbgMsg " request: undefined LANG, so exec ValidateLang"
- # Strip out country if present.
- ValidateLang `echo ${LANG} | ${BIN}/sed -e 's/_.*$//'`
- LANG=${UPDLANG}
- DbgMsg " request: ValidateLang set LANG to ${LANG}"
- fi
- DbgMsg " request: LANG=${LANG}, UPDLANG=${UPDLANG}, should be equal"
-
- MenuLang
- #
- # Trap any interrupting signals, which will terminate the install
- #
- trap 'TrapCmd' 2 3 15
-
- UPD_INSTRM="${UPD_INSTRM_i}"
- UPD_instrm="${UPD_instrm_i}"
- UPD_INSTRMED="${UPD_INSTRMED_i}"
- UPD_BKUPREST="${UPD_BKUPREST_i}"
- export UPD_INSTRM UPD_instrm UPD_INSTRMED UPD_BKUPREST
- unset UPD_INSTRM_i UPD_instrm_i UPD_INSTRMED_i UPD_BKUPREST_i
- unset UPD_INSTRM_r UPD_instrm_r UPD_INSTRMED_r UPD_BKUPREST_r
- DbgMsg " UPD_INSTRM=${UPD_INSTRM}"
- DbgMsg " UPD_instrm=${UPD_instrm}"
- DbgMsg " UPD_INSTRMED=${UPD_INSTRMED}"
- DbgMsg " UPD_BKUPREST=${UPD_BKUPREST}"
- DbgMsg " ProcMsg=${ProcMsg}"
- DbgMsg " GenericProcMsg=${GenericProcMsg}"
-
- #
- # Find out who the desktop owners are
- #
- DbgMsg " request: exec GetDeskTopOwners"
- GetDeskTopOwners
- DbgMsg " request: After GetDeskTopOwners, DeskTopOwn=${DeskTopOwn}"
-
- #
- # Check if an unsuccessful removal of the update was done. If so, abort
- #
- DbgMsg " request: check for existence of ${UPDPKGDIR}/removing"
- DbgMsg " this indicates an unsuccessful removal was done, and if so, abort"
- DbgMsg " UPDPKGDIR=${UPDPKGDIR}"
- if [ -f ${UPDPKGDIR}/removing ]
- then
- DbgMsg " request: ${UPDPKGDIR}/removing exists, so abort"
- MsgHandler 3 UpdRemovalMsg
- LogMsg "\nUpdRemovalMsg:\n${UpdRemovalMsg}"
- LogMsg "request: `GetText COMPLEXIT` - 1\n"
- DbgMsg " request: COMPLEXIT - 1\n"
- RmExit 1
- fi
-
- #
- # Is this update installation an overlay?
- #
- DbgMsg " request: run '/usr/bin/pkginfo ${PKGINST}' to see if it pre-exists"
- DbgMsg " PKGINST=${PKGINST}"
- ${BIN}/pkginfo ${PKGINST} >/dev/null 2>&1
- if [ ${?} -eq 0 ]
- then
- # This is an overlay installation.
- LogMsg "request: `GetText ISOVERLAY`"
- DbgMsg " request: Package ${PKGINST} already exists, so it is overlay"
- UPDOVERLAY=true
- else
- LogMsg "request: `GetText NOTOVERLAY`"
- DbgMsg " request: Package ${PKGINST} does not exist, so it is update"
- UPDOVERLAY=false
- fi
-
- #
- # If this is an overlay, is the current version of the Update installed the
- # same as the version being installed? If not, abort the installation.
- # Different versions of the Update can not be installed in overlay mode,
- # since different files may be installed or backed up.
- #
- if [ "${UPDOVERLAY}" = "true" ]
- then
- DbgMsg " Overlay, so make sure we are overlaying same version."
- # Change the locale information to C
- if [ "${LANG}" != "C" -a "${LANG}" != "en" ]
- then
- SetCLocale
- fi
- Version=`${BIN}/pkginfo -l ${PKGINST} 2>/dev/null | \
- ${BIN}/grep "VERSION:" | ${BIN}/cut -d':' -f2 | \
- ${BIN}/sed -e "s/^ *//g"`
- RestoreLocale
- unset langchg
- DbgMsg " request: Compare installed and installing versions, flag as error if diff"
- DbgMsg " request: Version=${Version}, VERSION=${VERSION}"
- if [ "${VERSION}" != "${Version}" ]
- then
- export Version
- MsgHandler 3 UpdVersionMsg
- LogMsg "\nUpdVersionMsg:\n${UpdVersionMsg}"
- LogMsg "request: `GetText COMPLEXIT` - 1"
- DbgMsg " request: Not allowed to overlay differing versions"
- DbgMsg " request: COMPLEXIT - 1\n"
- RmExit 1
- fi
- unset Version
- else
- DbgMsg " They do not, so the update or overlay may proceed"
- fi
-
- #
- # Make sure Update Package is compatible with Operating System.
- #
- DbgMsg " request: exec OSBaseChk"
- OSBaseChk
-
- #
- # Make sure the kernel tools are available.
- #
- DbgMsg " request: exec KernelToolsChk"
- KernelToolsChk
-
- if [ "${UPDATE_ALL}" = "true" -o "${UPDOVERLAY}" != "true" ]
- then
- ${BIN}/rm -rf /etc/inst/locale/*/menus/${PKGINST} 2> /dev/null
- fi
-
- #
- # Setup where menus and text files will be found for the specified language
- #
- DbgMsg " request: set lang specific menu and text file dir"
- if [ "${UPDLANG}" = "en" ]
- then UPDMENUDIR=/etc/inst/locale/C/menus/${PKGINST}
- else UPDMENUDIR=/etc/inst/locale/${UPDLANG}/menus/${PKGINST}
- fi
- if [ "${SILENT_INSTALL}" != "true" ]
- then ${BIN}/rm -f ${UPDMENUDIR}/working.kill 2>/dev/null
- fi
- if [ ! -x ${UPDMENUDIR}/menucmd ]
- then ${BIN}/mkdir -p ${UPDMENUDIR} 2>/dev/null
- ${BIN}/cp ${UPDINST}/menucmd ${UPDMENUDIR}/menucmd
- ${BIN}/chmod 555 ${UPDMENUDIR}/menucmd
- #jillp debug
- DbgMsg " request: copied ${UPDINST}/menucmd ${UPDMENUDIR}/menucmd"
- fi
- # And get the working menu now in case others want to use it
- if [ ! -f ${UPDMENUDIR}/wrking.menu ]
- then
- SrcMenu=${UPDINST}/wrking.menu.${UPDLANG}.Z
- [ -f ${SrcMenu} ] || SrcMenu=${UPDINST}/wrking.menu.Z
- ${BIN}/zcat ${SrcMenu} | ${BIN}/sed -e '/^#ident/d' \
- > ${UPDMENUDIR}/wrking.menu
- unset SrcMenu
- fi
- export UPDMENUDIR
- DbgMsg " request: UPDMENUDIR=${UPDMENUDIR}"
-
- #
- # Silent install stuff for Compaq
- #
- DbgMsg " request: If Compaq SmartStart install, /tmp/unixware.dat will exist"
- if [ -f /tmp/unixware.dat ]
- then
- DbgMsg " It does, so it is Compaq SmartStart install"
- LogMsg "request: `GetText COMPAQINST` `GetText STARTED`"
- ${BIN}/chmod +rx /tmp/unixware.dat
- eval "`${BIN}/cat /tmp/unixware.dat | grep -v '\[' | ${BIN}/sed 's/export \([^=]*\)\(.*\)/\1\2 \; export \1/'`"
- LogMsg "request: `GetText COMPAQINST` `GetText COMPLETED`"
- DbgMsg " All vars in /tmp/unixware.dat exported for install"
- else
- DbgMsg " It does not, so not Compaq SmartStart install"
- fi
-
- #
- # Select CLASSES to reflect only those packages which are installed on this
- # system, and are a valid release to install on top of
- #
- DbgMsg " request: Update CLASSES to reflect only those installed on the system"
- DbgMsg " as well as having valid releases"
- NEW_CLASSES=""
- DbgMsg " before: CLASSES='${CLASSES}'"
- for pkg in ${CLASSES}
- do
- if [ -f /var/sadm/pkg/${pkg}/pkginfo -a \
- ! -f /var/sadm/pkg/${pkg}/!I-Lock! -a \
- ! -f /var/sadm/pkg/${pkg}/!R-Lock! ]
- then
- ${BIN}/rm -f ${UPDTMP}/goodver
- Ver=`grep "^VERSION=" /var/sadm/pkg/${pkg}/pkginfo | cut -f2 -d'='`
- # bl15.3v1s VERSION=7 bl15.3v1t VERSION=7.0.0t uw7L VERSION=7.0.0u
- if [ "${Ver}" = "7" ]
- then
- > ${UPDTMP}/goodver
- else
- DbgMsg " request: check non 7 pkg version"
- DbgMsg " pkg='${pkg}', ver='${Ver}'"
- vver=""
- while read x
- do
- vpkg=`echo "${x}" | cut -d'=' -f1`
- DbgMsg " vpkg='${vpkg}'"
- if [ "${vpkg}" = "${pkg}" ]
- then
- vver=`echo "${x}" | cut -d'=' -f2-`
- DbgMsg " vver='${vver}'"
- if [ "${vver}" = "${Ver}" ]
- then
- > ${UPDTMP}/goodver
- DbgMsg " Found it!"
- break
- fi
- fi
- done < ${UPDINST}/Versions
- fi
- if [ -f ${UPDTMP}/goodver ]
- then
- NEW_CLASSES="${NEW_CLASSES} ${pkg}"
- else
- # Legitimate for nics package version to be greater than
- # 7, so force addition of nics to CLASSES
- if [ "${pkg}" = "nics" ]
- then
- NEW_CLASSES="${NEW_CLASSES} ${pkg}"
- DbgMsg " request: forced addition of nics to CLASSES"
- else
- DbgMsg " request: bad class: pkg=${pkg}, ver=${Ver}"
- # We're not updating this, but mark it as dealt with
- echo "no" > /var/sadm/pkg/${pkg}/${PKGINST}
- fi
- fi
- fi
- done
- DbgMsg " inbetween: NEW_CLASSES='${NEW_CLASSES}'"
- unset pkg vpkg vver Ver x
- ${BIN}/rm -f ${UPDTMP}/goodver
-
-
- #
- # Sweep out already updated classes, and add pseudo-classes.
- #
- if [ "${UPDATE_ALL}" = "true" -o "${UPDOVERLAY}" != "true" ]
- then
- ${BIN}/rm -f /var/sadm/pkg/*/${PKGINST} 2> /dev/null
- fi
- CLASSES=""
- for pkg in $NEW_CLASSES
- do
- newer_pkginfo=`find /var/sadm/pkg/${pkg}/pkginfo -newer \
- /var/sadm/pkg/${pkg}/${PKGINST} 2> /dev/null`
- [ "$?" != "0" -o "$newer_pkginfo" != "" ] || continue
- # #
- # # Note: cases below assume CLASSES in alphabetical order
- # #
- case ${pkg} in
- *) CLASSES="${CLASSES} ${pkg}" ;;
- esac
- done
- export CLASSES
- DbgMsg " after: CLASSES=${CLASSES}"
- unset NEW_CLASSES newer_pkginfo
-
- # Fix bkrs permissions before we decide that there's no more to do...
- # Would prefer to say "-c OAM_extended" but installf prohibits it
- case " ${CLASSES} " in
- *\ bkrs\ *)
- ${BIN}/chmod 0111 /usr/sbin/urestore >/dev/null 2>&1
- ${USBIN}/installf bkrs /usr/sbin/urestore \
- f 111 '?' '?' '?' '?' '?' >/dev/null 2>&1
- ${USBIN}/installf -f bkrs >/dev/null 2>&1
- > /var/sadm/pkg/bkrs/${PKGINST}
- [ "${CLASSES}" = " bkrs" ] && CLASSES=""
- ;;
- esac
-
- if [ -z "${CLASSES}" ]
- then
- LogMsg " request: `GetText COMPLEXIT`"
- DbgMsg " request: nothing to update, exit"
- MsgHandler 1 UpdNoneMsg
- RmExit 77
- fi
-
-
- #
- # Update the number of update packages that have been overlayed
- #
- DbgMsg " request: Check if this is an overlay"
- if [ "${UPDOVERLAY}" = "true" -o -f ${UPDCNTFILE} ]
- then
- UPDCNT=999999
- [ -f ${UPDCNTFILE} ] && . ${UPDCNTFILE}
- UPDCNT=`${BIN}/expr ${UPDCNT} + 1`
- else
- ${BIN}/rm -rf ${UPDBKUPDIR}
- ${BIN}/mkdir -p ${UPDBKUPDIR}
- echo "UPDCNT=-1" >${UPDCNTFILE}
- UPDCNT=0
- fi
- DbgMsg " request: UPDCNT=${UPDCNT}"
-
- #
- # Create variables based on the backup directory
- #
- UPDBACKUP=${UPDBKUPDIR}/bkup${UPDCNT}
- UPDCONTENTS=${UPDBACKUP}/contents
- UPDFILELIST=${UPDBACKUP}/filelist
- UPDBKUPFILE=${UPDBACKUP}/${CPIOFILE}
- DbgMsg " request: define vars based on bkup dir"
- DbgMsg " UPDBACKUP=${UPDBACKUP}"
- DbgMsg " UPDCONTENTS=${UPDCONTENTS}"
- DbgMsg " UPDFILELIST=${UPDFILELIST}"
- DbgMsg " UPDBKUPFILE=${UPDBKUPFILE}"
-
- #
- # Create the backup directory
- #
- DbgMsg " request: Create a backup dir - ${UPDBACKUP}"
- ${BIN}/rm -rf ${UPDBACKUP}
- ${BIN}/mkdir -p ${UPDBACKUP}
-
- [ -f ${UPDBKUPDIR}/classes ] || > ${UPDBKUPDIR}/classes
- [ -f ${UPDBKUPDIR}/filelist ] || > ${UPDBKUPDIR}/filelist
- [ -f ${UPDBKUPDIR}/contents ] || > ${UPDBKUPDIR}/contents
-
- # Reset the ulimit for a large cpio file
- DbgMsg " UPD_ULIMIT=${UPD_ULIMIT}"
- [ $UPD_ULIMIT ] || UPD_ULIMIT=81920
- DbgMsg " request: UPD_ULIMIT=${UPD_ULIMIT}"
-
- #
- # Create environment variable list for use by the packaging scripts.
- #
- DbgMsg " request: create env var list"
- ${BIN}/cat > ${UPDVARFILE} <<!
- BIN=${BIN}
- CLASSES="${CLASSES}"
- CONFDIR=${CONFDIR}
- CONFBIN=${CONFBIN}
- DeskTopOwn=${DeskTopOwn}
- TTY=${TTY}
- UPD_INUM=${UPD_INUM}
- UPD_NUM=${UPD_NUM}
- UPD_ULIMIT=${UPD_ULIMIT}
- UPDBACKUP=${UPDBACKUP}
- UPDBKUPDIR=${UPDBKUPDIR}
- UPDBKUPFILE=${UPDBKUPFILE}
- UPDCNT=${UPDCNT}
- UPDCNTFILE=${UPDCNTFILE}
- UPDINST=${UPDINST}
- UPDLANG=${UPDLANG}
- UPDLOGFILE=${UPDLOGFILE}
- UPDMENUANS=${UPDMENUANS}
- UPDMENUDIR=${UPDMENUDIR}
- UPDPKGDIR=${UPDPKGDIR}
- UPDTMP=${UPDTMP}
- USBIN=${USBIN}
- !
- DbgMsg " request: ${UPDVARFILE} start:"
- DbgAddFile ${UPDVARFILE}
- DbgMsg " request: ${UPDVARFILE} end:"
-
- #
- # ALL THE BACKUP STUFF IS BELOW HERE
- #
- # THE BACKUP ROUTINES ARE BELOW
- #
-
- #
- # The actual backup routine via cpio
- # $1 = the device or dir to output to
- # $2 = dmsg, only if this is a disk backup
- #
- DeviceBackup ()
- {
- LogMsg "Devicebackup: `GetText STARTED`"
- DbgMsg "Devicebackup: STARTED arg1=${1}, arg2=${2}"
-
- # Must be in the root directory to take a backup.
- cd /
-
- # Files used below.
- CFERR=${UPDTMP}/upd.cpio.err
- CFOUT=${UPDTMP}/upd.cpio.out
- CMPERR=${UPDTMP}/upd.cmp.err
- CFINPUT=${UPDTMP}/updbkup.list
- ${BIN}/rm -f ${CFERR} ${CFOUT} ${CMPERR} ${CFINPUT}
- DbgMsg " CFERR=${CFERR}"
- DbgMsg " CFOUT=${CFOUT}"
- DbgMsg " CMPERR=${CMPERR}"
- # Create backup list.
- DbgMsg " DeviceBackup: creates a relative path list of files"
- DbgMsg " UPDFILELIST=${UPDFILELIST}"
- ${BIN}/sed -e '1,$s;^/;;' ${UPDFILELIST} | \
- ${BIN}/sort -u >${CFINPUT}
- DbgMsg " DeviceBackup: ${CFINPUT} CONTENTS - used for bkup:"
- DbgAddFile "${CFINPUT}"
- DbgMsg " DeviceBackup: ${CFINPUT} CONTENTS end:"
-
- # Sync before starting the backup.
- /sbin/sync
-
- DbgMsg " DeviceBackup: run the cpio to disk dir ${1}"
- ${BIN}/cpio -ocuBd < ${CFINPUT} 2>${CFERR} | \
- ${BIN}/compress -f 2>${CMPERR} > ${1}.Z
- burc=${?}
- DbgMsg " DeviceBackup: cpio rc=${burc}"
- ${BIN}/grep "ERROR" ${CFERR} >/dev/null 2>&1
- greprc=${?}
- if [ ${burc} -ne 0 -o ${greprc} -eq 0 -o -s ${CMPERR} ]
- then
- UPD_CPIOERR="${CFERR}\n${CMPERR}"
- export UPD_CPIOERR
- if [ "$SILENT_INSTALL" != "true" ]
- then
- MenuCmd error mederr
- fi
- unset UPD_CPIOERR
- LogMsg "DeviceBackup: cpio `GetText FAILED`"
- DbgMsg " DeviceBackup: cpio FAILED"
- LogMsg "DeviceBackup: `GetText COMPLRET` - 2"
- LogMsg "DeviceBackup: COMPLRET - 2"
- return 2 # return to previous menu to retry.
- fi
-
- ${BIN}/rm -f ${CFERR} ${CFOUT} ${CMPERR} ${CFINPUT}
- unset greprc CFERR CFOUT CMPERR CFINPUT
-
- # Create the space file for the actual disk space
- # used by the update backup.
- DbgMsg " UPDBACKUP=${UPDBACKUP}"
- DbgMsg " UPDBKUPDIR=${UPDBKUPDIR}"
- size=`${BIN}/du -s ${UPDBACKUP} | ${BIN}/cut -f1`
- DbgMsg " Devicebackup: size of this backup: ${size}"
- if [ -f ${UPDBKUPDIR}/space ]
- then
- # Add space together to get grand total.
- DbgMsg " Devicebackup: add size of this backup to ${UPDBKUPDIR}/space"
- . ${UPDBKUPDIR}/space
- UPDSPACEREQ=`${BIN}/expr ${UPDSPACEREQ} + ${size}`
- echo "UPDSPACEREQ=${UPDSPACEREQ}" > ${UPDBKUPDIR}/space
- DbgMsg " new size in ${UPDBKUPDIR}/space = ${UPDSPACEREQ}"
- else
- # First installation.
- echo "UPDSPACEREQ=${size}" > ${UPDBKUPDIR}/space
- DbgMsg " size in ${UPDBKUPDIR}/space = ${size}"
- fi
- ${BIN}/chmod 744 ${UPDBKUPDIR}/space
- DbgMsg " ${UPDBKUPDIR}/space CONTENTS START:"
- DbgAddFile ${UPDBKUPDIR}/space
- DbgMsg " ${UPDBKUPDIR}/space CONTENTS END"
-
- if [ "$SILENT_INSTALL" != "true" ]
- then
- # Display backup successful message.
- DbgMsg " DeviceBackup: display brsucc.menu"
- MenuCmd regular brsucc
- ${BIN}/sleep 3
- fi
- LogMsg "DeviceBackup: `GetText COMPLRET` - ${burc}"
- DbgMsg "DeviceBackup: COMPLRET - ${burc}"
- return ${burc}
- }
-
- #
- # Do the backup to disk
- #
- BackupToDir ()
- {
- LogMsg "BackupToDir: `GetText STARTED`"
- DbgMsg "BackupToDir: STARTED"
- if [ "$SILENT_INSTALL" != "true" ]
- then
- MenuCmd regular brmsg
- fi
-
- # Increase ulimit for creating a very large cpio file.
- DbgMsg " UPD_ULIMIT=${UPD_ULIMIT}"
- ulimit ${UPD_ULIMIT}
-
- # Perform backup to disk.
- DbgMsg " BackupToDir: exec DeviceBackup"
- DeviceBackup ${UPDBKUPFILE} dmsg
- cpiorc=${?}
- DbgMsg " BackupToDir: DeviceBackup rc=${cpiorc}"
- if [ ${cpiorc} -ne 0 ]
- then
- LogMsg "BackupToDir: `GetText COMPLRET` - ${cpiorc}"
- DbgMsg "BackupToDir: backup failed COMPLRET - ${cpiorc}"
- return ${cpiorc}
- fi
- DbgMsg " BackupToDir: backup succeeded, mark with file ${UPDBACKUP}/bkup.disk"
- ${BIN}/touch ${UPDBACKUP}/bkup.disk >/dev/null 2>&1
-
- # Compress the cpio file to save disk space, if it was
- # not compressed during backup using cpio command.
- DbgMsg " BackupToDir: compress backup if not compressed"
- DbgMsg " UPDBACKUP=${UPDBACKUP}"
- DbgMsg " UPDBKUPFILE=${UPDBKUPFILE}"
- cd ${UPDBACKUP}
- if [ ! -f ${UPDBKUPFILE}.Z ]
- then
- ${BIN}/compress ${UPDBKUPFILE} >/dev/null 2>&1
- rc=${rc}
- if [ ${rc} -ne 0 ]
- then
- # Installation is not dependent on compress
- # to succeed. Log a message indicating
- # the failure.
- LogMsg "BackupToDir: compress `GetText FAILED` - rc=${rc}"
- DbgMsg " BackupToDir: compress FAILED - rc=${rc}"
- ${BIN}/rm -f ${UPDBKUPFILE}.Z
- fi
- fi
-
- cd /
- if [ "$SILENT_INSTALL" != "true" ]
- then
- MenuClear
- fi
- LogMsg "BackupToDir: `GetText COMPLRET` - ${cpiorc}"
- DbgMsg "BackupToDir: COMPLRET - ${cpiorc}"
- return ${cpiorc}
- }
-
-
- #
- # The actual main backup routine, which ends up calling the others
- #
- BackupMain ()
- {
- LogMsg "BackupMain: `GetText STARTED`"
- DbgMsg "BackupMain: STARTED"
-
- DbgMsg " BackupMain: Check SILENT_INSTALL='${SILENT_INSTALL}'"
- if [ "$SILENT_INSTALL" = "true" ]
- then
- DbgMsg " BackupMain: exec silent BackupToDir"
- else
- DbgMsg " BackupMain: exec BackupToDir"
- fi
-
- #
- # If filelist is empty, then don't even make a record of
- # this backup, since there nothing will get backed up.
- #
- if [ -s ${UPDFILELIST} ]
- then
- BackupToDir
- case ${?} in
- 0) # Backup successful
- DbgMsg " BackupMain: backup succeeded"
- loop=0
- ;;
- *) # Give up
- # MenuClear
- MsgHandler 3 SilBkupFailMsg
- LogMsg "BackupMain: `GetText COMPLEXIT` - 1"
- DbgMsg "BackupMain: backup failed, exit"
- DeleteBackupExit 1
- ;;
- esac
- fi
- LogMsg "BackupMain: `GetText COMPLETED`"
- DbgMsg "BackupMain: COMPLETED"
- }
-
- #
- # Create Software Installation Database information for the files being
- # replaced by the update information for possible restore at some
- # future date
- #
- CreateSIDB ()
- {
- LogMsg "CreateSIDB: `GetText STARTED`"
- DbgMsg "CreateSIDB: STARTED"
-
- if [ ! -s ${UPDFILELIST} ]
- then > ${UPDCONTENTS}
- DbgMsg " CreateSIDB: Empty filelist to empty contents"
- LogMsg "CreateSIDB: `GetText COMPLETED`"
- DbgMsg "CreateSIDB: COMPLETED"
- return
- fi
-
- # Save the current setting of CLASSES. Need to unset
- # so that the pkgchk command does not use it to limit
- # its search of the SIDB. Restore and export the CLASSES
- # variable after the pkgchk is done.
- SAV_CLASSES="${CLASSES}"
- unset CLASSES
-
- # Need the C locale for the keywords in the awk script
- # below to be found and parsed properly.
- SetCLocale
-
- # Extract file contents information for restore purposes.
- # All together, there are too many files, so we must break them up.
- DbgMsg " UPDFILELIST=${UPDFILELIST}"
- DbgMsg " UPDINST=${UPDINST}"
- DbgMsg " UPDMENUDIR=${UPDMENUDIR}"
- DbgMsg " UPDTMP=${UPDTMP}"
- DbgMsg " UPD_INUM=${UPD_INUM}"
- DbgMsg " UPDCONTENTS=${UPDCONTENTS}"
- DbgMsg " request: run split on ${UPDFILELIST}"
- [ -x ${UPDMENUDIR}/split ] || {
- ${BIN}/cp ${UPDINST}/split ${UPDMENUDIR}/split
- ${BIN}/chmod 555 ${UPDMENUDIR}/split
- }
- ${UPDMENUDIR}/split -l 50 ${UPDFILELIST} ${UPDTMP}/filelist.
- for file in ${UPDTMP}/filelist.*
- do
- ${USBIN}/pkgchk -l -i ${file} | ${BIN}/awk '
- {
- if (ref == 1) {
- pkg=1
- ref = 0
- while (pkg <= NF) {
- if (typ == "l" || typ == "s") {
- if (typ == "s") {
- printf("%s %s=%s s\n", $pkg, fi, lf)
- } else {
- if (substr(lf, 1, 1) == "/") {
- printf("%s %s=%s l\n", $pkg, fi, lf)
- } else {
- printf("%s %s=/%s l\n", $pkg, fi, lf)
- }
- }
- } else {
- printf("%s %s %s %s %s %s %s %s %s\n", $pkg, fi, typ, mode, owner, grp, level, fixed, inh)
- }
- pkg++
- }
- }
- if ($1 ~/Pathname/)
- fi=$2
- if($1 ~/Type/) {
- if ($2 ~/volatile/)
- typ="v"
- else if ($2 ~/linked/)
- typ="l"
- else if ($2 ~/symbolic/)
- typ="s"
- else if ($2 ~/directory/)
- typ="d"
- else
- typ="f"
- }
- if ($1 ~/Source/)
- lf=$4
- if($2 ~/mode/)
- mode=$3
- if($2 ~/owner/)
- owner=$3
- if($2 ~/group/)
- grp=$3
- if($3 ~/level/)
- level=$6
- if($2 ~/fixed/)
- fixed=$6
- if($2 ~/inheritable/)
- inh=$6
- if($0 ~/Referenced/) {
- ref=1
- }
- }' | ${BIN}/sed -e "/^update${UPD_INUM} /d" >>${UPDCONTENTS}
- rc=${?}
- DbgMsg " request: pkgchk of ${file} had rc=${rc}"
- ${BIN}/rm -f ${file}
- done
-
- # Restore CLASSES to its original settings.
- CLASSES="${SAV_CLASSES}"
- export CLASSES
- unset SAV_CLASSES
-
- # Restore the Locale to it original setting.
- RestoreLocale
- DbgMsg " CreateSIDB: Updated file extraction rc - ${rc}"
-
- LogMsg "CreateSIDB: `GetText COMPLETED`"
- DbgMsg "CreateSIDB: COMPLETED"
- }
-
- MakeFileList ()
- {
- LogMsg "MakeFileList: `GetText STARTED`"
- DbgMsg "MakeFileList: STARTED"
- DbgMsg " MakeFileList: create backup file list ${UPDFILELIST} from ${UPDINST}/Files"
-
- #
- # If we already have a backup of the class, omit it.
- # Unsatisfactory, but problems either way - we need
- # to avoid backing up New files added by a previous
- # application of the update to the class (UPDATE_ALL,
- # or package added, updated, removed, reupdated).
- # The O/N distinction (which could have helped some)
- # has become unreliable, Ns have been wilfully changed
- # to Os to avoid the earlier bug when this code made
- # no attempt to backup Ns (there from 2.1.1 or PTFs).
- #
- for pkg in ${CLASSES}
- do ${BIN}/grep "^${pkg}$" ${UPDBKUPDIR}/classes >/dev/null &&
- continue
- ${BIN}/grep -h " ${pkg} " \
- ${UPDINST}/Files ${UPDINST}/Backup.add
- done | ${BIN}/cut -f5 -d' ' | ${BIN}/sort -u >${UPDFILELIST}.tmp
-
- for pkg in ${CLASSES}
- do echo ${pkg}
- done | ${BIN}/sort -u >${UPDBACKUP}/classes
-
- #
- # Now, make sure each file is installed on the system.
- # If it is not, then it is removed from the list
- #
- DbgMsg " MakeFileList: Make sure each file exists"
- while read inp
- do [ -r "${inp}" -o -h "${inp}" ] && echo "${inp}"
- done < ${UPDFILELIST}.tmp > ${UPDFILELIST}
- ${BIN}/rm -f ${UPDFILELIST}.tmp
- unset pkg inp key
-
- LogMsg "MakeFileList: `GetText COMPLETED`"
- DbgMsg "MakeFileList: COMPLETED"
- }
-
- MakeTempFiles ()
- {
- LogMsg "MakeTempFiles: `GetText STARTED`"
- DbgMsg "MakeTempFiles: STARTED"
- # Go through the list of files, checking if it is a tmp file or not
- # Make a link between the object already on the target and the temporary staging
- # position for the file. This is so that the original file can be backed up but
- # under the 'tmp' directory path. The postinstall and postremove scripts
- # manipulate the 'tmp' versions of files up a directory level to the proper place.
- ${BIN}/grep -h "^.T" ${UPDINST}/Files ${UPDINST}/Backup.add > ${UPDTMP}/TFiles
- while read PFILE
- do
- if ${BIN}/grep " ${PFILE}$" ${UPDTMP}/TFiles >/dev/null
- then
- FILE=`echo "${PFILE}" | ${BIN}/sed 's%^/.*/%%g'| ${BIN}/sed 's%^/%%'`
- DIR=`echo "${PFILE}" | ${BIN}/sed 's%/[^/]*$%%g'`
- TDIR="${DIR}/tmp"
- DbgMsg " ${PFILE} - temp ${TDIR}/${FILE}"
- ${BIN}/mkdir -p ${TDIR} > /dev/null 2>&1
- ${BIN}/ln -f ${PFILE} ${TDIR}/${FILE} 1>/dev/null 2>&1
- echo "${TDIR}/${FILE}"
- else
- DbgMsg " ${PFILE} - normal"
- echo "${PFILE}"
- fi
- done < ${UPDFILELIST}.tmp > ${UPDFILELIST}
-
- ${BIN}/rm -f ${UPDTMP}/TFiles
- LogMsg "MakeTempFiles: `GetText COMPLETED`"
- DbgMsg "MakeTempFiles: COMPLETED"
- }
-
- #
- # Determine disk space required
- #
- GOTSPACE=yes
- DF=1
- UPD_BKUP_KB=X
-
- if [ "${SKIP_CHECK_SPACE}" != "true" ]
- then
- DbgMsg " request: exec CheckSpace"
- CheckSpace || GOTSPACE=no
-
- # DF=1 if there is enough disk space for backup on to disk
- # UPD_BKUP_KB Kilo Bytes required for backup on disk
-
- DbgMsg " GOTSPACE=${GOTSPACE}"
- DbgMsg " DF=${DF}"
- DbgMsg " UPD_BKUP_KB=${UPD_BKUP_KB}"
- fi
-
- export DF UPD_BKUP_KB
-
- if [ "$SILENT_INSTALL" != "true" -a "${SKIP_CHECK_SPACE}" != "true" ]
- then
- MenuCmd regular space ${UPDMENUANS}
- # Get answer
- . ${UPDMENUANS}
- if [ "${RETURN_VALUE}" = "2" ]
- then
- MenuClear
- LogMsg " request: `GetText USERTERM`"
- DbgMsg " request: User terminated at space menu"
- DeleteBackupExit 3
- fi
- fi
-
- if [ "${GOTSPACE}" = "no" ]
- then
- MenuClear
- MsgHandler 3 InstNoSpace
- DbgMsg " request: exited, since there is not enough install space"
- DeleteBackupExit 1
- fi
-
-
- # If we have selected to skip the backup, skip the rest
- if [ "${UPDATE_BACKUP}" = "false" ]
- then DbgMsg " request: UPDATE_BACKUP=${UPDATE_BACKUP} skips backup"
- fi
- if [ "${UPDCNT}" -gt 0 ]
- then PREVCNT=`expr ${UPDCNT} - 1`
- if [ ! -d ${UPDBKUPDIR}/bkup${PREVCNT} ]
- then DbgMsg " request: bkup${PREVCNT} was skipped before"
- UPDATE_BACKUP=false
- fi
- fi
- if [ "${UPDATE_BACKUP}" = "false" ]
- then
- DbgMsg " Skipping backup, so remove dir UPDBACKUP=${UPDBACKUP}"
- DbgMsg " UPDMENUANS=${UPDMENUANS}"
- DbgMsg " UPDBACKUP=${UPDBACKUP}"
- DbgMsg " UPDVARFILE=${UPDVARFILE}"
- ${BIN}/rm -rf ${UPDMENUANS} ${UPDBACKUP}
- LogMsg "Request: `GetText BUSKIPPED`"
- LogMsg "Request: `GetText COMPLEXIT`"
- DbgMsg "Request: COMPLETED"
- if [ "$ISL_INSTALL" != "true" ]
- then
- MenuClear
- fi
- exit 0
- fi
-
- #
- # Set some vars which will help determine backup status
- #
- AUX=0
- export AUX
- DbgMsg " AUX=${AUX}"
-
- if [ "$SILENT_INSTALL" != "true" ]
- then
- # Display a status menu.
- DbgMsg " request: display flist.menu"
- MenuCmd regular flist
- fi
-
- # Create a file list of the files to be saved during
- # the backup.
- DbgMsg " request: exec MakeFileList"
- MakeFileList
-
- # Save software installation database information for
- # files being replaced.
- DbgMsg " request: exec CreateSIDB"
- CreateSIDB
-
- # Do whatever is necessary for tmp files, marked in Files
- # Temporarily copy over the file list as a save
- ${BIN}/mv -f ${UPDFILELIST} ${UPDFILELIST}.tmp 2>/dev/null
-
- DbgMsg " request: exec MakeTempFiles"
- MakeTempFiles
-
- # Clear status menu.
- if [ "$SILENT_INSTALL" != "true" ]
- then
- MenuClear
- fi
-
- # Perform backup procedures.
- DbgMsg " request: exec BackupMain"
- BackupMain
-
- # Restore the file list
- ${BIN}/mv ${UPDFILELIST}.tmp ${UPDFILELIST} 2>/dev/null
-
- if [ -s "${UPDFILELIST}" ]
- then
- DbgMsg " Successful backup, updating total contents and filelist"
- ${BIN}/sort -u ${UPDBKUPDIR}/classes ${UPDBACKUP}/classes \
- >${UPDBKUPDIR}/classes.tmp
- ${BIN}/sort -u ${UPDBKUPDIR}/filelist ${UPDFILELIST} \
- >${UPDBKUPDIR}/filelist.tmp
- ${BIN}/sort -u ${UPDBKUPDIR}/contents ${UPDCONTENTS} \
- >${UPDBKUPDIR}/contents.tmp
- echo "UPDCNT=${UPDCNT}" >${UPDCNTFILE}
- ${BIN}/mv -f ${UPDBKUPDIR}/contents.tmp ${UPDBKUPDIR}/contents
- ${BIN}/mv -f ${UPDBKUPDIR}/classes.tmp ${UPDBKUPDIR}/classes
- ${BIN}/mv -f ${UPDBKUPDIR}/filelist.tmp ${UPDBKUPDIR}/filelist
- DbgMsg " Successful UPDCNT=${UPDCNT} now fixed in ${UPDCNTFILE}"
- else
- DbgMsg " Empty filelist, removing dir ${UPDBACKUP}"
- ${BIN}/rm -rf ${UPDBACKUP}
- UPDCNT=`${BIN}/expr ${UPDCNT} - 1`
- echo "UPDCNT=${UPDCNT}" >>${UPDVARFILE}
- DbgMsg " Previous UPDCNT=${UPDCNT} will remain in ${UPDCNTFILE}"
- fi
-
- #
- # Final steps of the request script
- #
- DbgMsg " UPDMENUANS=${UPDMENUANS}"
- ${BIN}/rm -f ${UPDMENUANS}
- if [ "$SILENT_INSTALL" != "true" ]
- then
- MenuClear
- fi
-
- LogMsg "request: `GetText COMPLEXIT` - 0"
- DbgMsg "request: COMPLEXIT - 0"
- exit 0
-