packages/upgrade-X
author Alan Coopersmith <Alan.Coopersmith@Sun.COM>
Tue, 20 May 2008 20:12:13 -0700
changeset 420 418befc73299
parent 416 11d4c8bb0652
child 443 1bf075e9c322
permissions -rw-r--r--
6702592 Replace xterm with opensrc version [fix packaging of resize.1 man page]

#!/bin/ksh

###
#
# @(#)upgrade-X	1.37 08/05/14
#
# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, and/or sell copies of the Software, and to permit persons
# to whom the Software is furnished to do so, provided that the above
# copyright notice(s) and this permission notice appear in all copies of
# the Software and that both the above copyright notice(s) and this
# permission notice appear in supporting documentation.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
# OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
# INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
# Except as contained in this notice, the name of a copyright holder
# shall not be used in advertising or otherwise to promote the sale, use
# or other dealings in this Software without prior written authorization
# of the copyright holder.
#
###########################################################################
#
# Description: This script upgrades X software on a Solaris 10 or Nevada
#	       system. It should be run as root from a X 6.6.3 package area.
#
# Arguments:	-a 	Install ALL packages.  Now is the default behaviour.
#		-q	Be quiet and don't report packages that aren't 
#			installed.
#
###

    # Update this when X package version number changes
    XVERS="6.9.0.5.11"

###
#  
#   First check for a correct upgrade environment. 
#
###

    MACH=`uname -p`

    DATE=`LANG=C date '+%d%b%y-%H:%M:%S'`

    USER=`/bin/id | grep root | wc -l`
    if [ $USER -eq 0 ]
    then
	echo ""
        echo "You must be root to run this script"
        echo ""
        exit 1
    fi


    X_BASE_PKG=SUNWxwplt/pkginfo

    if [ -f ${X_BASE_PKG} ]; then
        X_VERSION=`grep PRODVERS ${X_BASE_PKG} | /bin/cut -f2 -d=`
	X_BUILD=`nawk '/^VERSION=/ {FS="[,.]+" ; print $(NF-4)/100}' ${X_BASE_PKG} `
    else
	echo ""
        echo "Cannot find base X package -- SUNWxwplt" 
	echo "You need to run this script from the X ${XVERS} package area"
        echo ""
        exit 1
    fi

    if [ -z "${X_VERSION}" ]; then
	echo ""
        echo "Cannot find SUNWxwplt package version." 
	echo "It should have a X ${XVERS} version string"
        echo ""
        exit 1
    else
      if [ "${X_VERSION}" != "${XVERS}" ]; then
	echo ""
        echo "SUNWxwplt package has wrong version (${X_VERSION})." 
	echo "It should have a X ${XVERS} version string"
        echo ""
        #exit 1
      fi
    fi

    case "X$(uname -r)" in

	X5.10)
	PKG_UPGRADE_LOG=/var/tmp/SunSoft_X${XVERS}_B${X_BUILD}_upgrade.log.${DATE}
	;;

	X5.10.1)
	PKG_UPGRADE_LOG=/var/tmp/SunSoft_X${XVERS}_B${X_BUILD}_upgrade.log.${DATE}
	;;

	X5.11)
	PKG_UPGRADE_LOG=/var/tmp/SunSoft_X${XVERS}_B${X_BUILD}_upgrade.log.${DATE}
	;;

	*)
	echo "Incorrect Solaris version number"
	echo "X ${XVERS} is only supported on Solaris 10 or later"
	exit 1
	;;
    esac

####
#
#   Process command line options
#
####

INSTALLALL=1
QUIET=0

while getopts aq flag ; do
    case $flag in
      a)	INSTALLALL=1 ;;
      q)	QUIET=1 ;;
      ?)	printf "Usage: %s: [-a] [-q]\n"  $0
		exit 1 ;;
    esac
done

####
#
#   List of packages to upgrade
#
####        

# Packages to add even if not installed and -a not specified
FORCE_ADD=""

# SUNWxwsvr split into SUNWxwsvr & SUNWxscreensaver-hacks* packages
if [ -d SUNWxscreensaver ] ; then
    PKGS_XSS="SUNWxscreensaver SUNWxscreensaver-hacks"
    PKGS_XSS_sparc="SUNWxscreensaver-hacks-gl"
    PKGS_XSS_REM="SUNWxwsvr"
else
    if [ -d SUNWxscreensaver-hacks ] ; then
	if [ -d SUNWxscreensaver-hacks-gl ] ; then
	    PKGS_XSS="SUNWxwsvr SUNWxscreensaver-hacks SUNWxscreensaver-hacks-gl"
	    PKGS_XSS_REM="SUNWxscreensaver"
	else
	    PKGS_XSS="SUNWxwsvr SUNWxscreensaver-hacks"
	    PKGS_XSS_REM="SUNWxscreensaver SUNWxscreensaver-hacks-gl"
	fi
    else
	PKGS_XSS="SUNWxwsvr"
	PKGS_XSS_sparc=""
	PKGS_XSS_REM="SUNWxscreensaver SUNWxscreensaver-hacks SUNWxscreensaver-hacks-gl"
    fi
fi

# SUNWxwfnt split into SUNWxwfnt & SUNWxwfsw packages
if [ -d SUNWxwfsw ] ; then
    PKGS_FSW="SUNWxwfsw SUNWxwfnt"

    /bin/pkginfo -q SUNWxwfsw
    FOUNDPKG=$?
    # Need to remove SUNWxwfnt before installing SUNWxwfsw if it's never
    # been installed before and then make sure both packages are added
    if [ $FOUNDPKG -ne 0 ]; then
	PKGS_FNT_REM="SUNWxwfnt"
	FORCE_ADD="${FORCE_ADD} ${PKGS_FSW}"
    fi
else
    PKGS_FNT_REM="SUNWxwfsw"
    PKGS_FSW="SUNWxwfnt"
fi

# Xsun & Xprt servers split out of SUNWxwplt
PKGS_SRV="SUNWxsun-server SUNWxprint-server"

if [ -d SUNWxsun-server ] ; then
    if [ -d SUNWxsun-keytables ] ; then
	PKGS_SRV="SUNWxsun-keytables ${PKGS_SRV}"
    fi
    FORCE_ADD="${FORCE_ADD} ${PKGS_SRV}"
    PKGS_PLT="SUNWxwplt ${PKGS_SRV}"
else
    REM_PKGS="${REM_PKGS} ${PKGS_SRV}"
    PKGS_PLT="SUNWxwplt"
fi

    PKGS_32="${PKGS_FSW} SUNWxwice ${PKGS_PLT} SUNWi1of SUNWxwacx SUNWxwcft SUNWxwdim SUNWxwdxm SUNWxwdem SUNWxwfa SUNWxwfs SUNWxwhl SUNWxwinc SUNWxwman SUNWxwmod SUNWxwoft SUNWxwpmn SUNWxwrtl SUNWxwslb SUNWxwsrc SUNWxwpft SUNWxwsrv SUNWfreetype2 SUNWxwplr SUNWfontconfig SUNWfontconfig-root SUNWfontconfig-docs SUNWxwopt SUNWxwxft SUNWxcursor-themes SUNWxvnc SUNWvncviewer ${PKGS_XSS}"

    PKGS_32_sparc="SUNWxwpsr ${PKGS_XSS_sparc}"

    PKGS_64="SUNWxwicx SUNWxwmox SUNWxwplx SUNWxwrtx SUNWxwslx SUNWfreetype2-64"

# Old packages to remove and not replace
    REM_PKGS="${REM_PKGS} SUNWftyp2 SUNWftypx ${PKGS_XSS_REM} ${PKGS_FNT_REM} SUNWstsf SUNWstsfr SUNWxwxst SUNWxwfa"


# Packages moved from XORG tree
PKGS_XORG_LIBS="SUNWxorg-clientlibs SUNWxorg-devel-docs SUNWxorg-headers \
    SUNWxorg-compatlinks"

PKGS_XORG_APPS="SUNWxorg-client-docs SUNWxorg-client-programs"

PKGS_XORG_SRVR="SUNWxorg-server SUNWxorg-graphics-ddx SUNWxorg-cfg \
    SUNWxorg-doc"

PKGS_XORG_MESA="SUNWxorg-mesa"

if [ -d SUNWxorg-clientlibs ] ; then
    FORCE_ADD="${FORCE_ADD} ${PKGS_XORG_LIBS}"
    PKGS_32="${PKGS_32} ${PKGS_XORG_LIBS}"
fi

if [ -d SUNWxorg-client-programs ] ; then
    FORCE_ADD="${FORCE_ADD} ${PKGS_XORG_APPS}"
    PKGS_32="${PKGS_32} ${PKGS_XORG_APPS}"
fi

if [ -d SUNWxorg-server ] ; then
    FORCE_ADD="${FORCE_ADD} ${PKGS_XORG_SRVR}"
    PKGS_32="${PKGS_32} ${PKGS_XORG_SRVR}"
fi

if [ -d SUNWxorg-mesa ] ; then
    FORCE_ADD="${FORCE_ADD} ${PKGS_XORG_MESA}"
    PKGS_32="${PKGS_32} ${PKGS_XORG_MESA}"
fi

# 6658871 changed /usr/X11/lib/X11/fonts/Type1 from a link in SUNWxorg-server
# to a directory in SUNWxwcft, need to remove old link before installing 
# directory
if [ -L /usr/X11/lib/X11/fonts/Type1 ] ; then
    REM_PKGS="SUNWxorg-server"
    FORCE_ADD="${FORCE_ADD} SUNWxorg-server"
fi

if [ "$MACH" = "sparc" ]; then
    # special for S10 - builds before 34 had separate 64-bit packages
    # they were merged into core packages at build 34.
    pkg_list="${PKGS_32} ${PKGS_32_sparc}"
    REM_PKGS="${REM_PKGS} ${PKGS_64}"
else
    pkg_list="${PKGS_32}"
fi

# Check for new package required by SUNWfontconfig in s10_64 & later
/usr/xpg4/bin/grep -q SUNWlexpt SUNWfontconfig/install/depend 
if [ $? -eq 0 ] ; then
    pkginfo -q SUNWlexpt
    if [ $? -eq 1 ] ; then
	echo "This build of X requires SUNWlexpt be installed."
	echo "Please install it from an s10_63 or later install image or"
	echo "from /ws/sfw10-gate/packages/`uname -p`/"
	exit 1
    fi
fi

# Check for shared SMF manifest scripts now required by our packages
if [ ! -f /usr/sadm/install/scripts/i.manifest ] ; then
    echo "This build of X requires a system with the shared SMF manifest class"
    echo "action scripts installed in /usr/sadm/install/scripts/i.manifest"
    echo "(See Solaris bug id 6209178)"
    exit 1
fi

# S10/greenline upgrade support
svc_disable() 
{
    svcname="svc:$1:default";
    if [ "$2" = "" ] ; then
	manifest="/var/svc/manifest/$1.xml"
    else
	manifest="/var/svc/manifest/$2"
    fi

    if [ -f $manifest ] ; then
	/usr/sbin/svcadm -v disable -s $svcname 2>&1 | tee -a $PKG_UPGRADE_LOG
    fi
}


###
#
#   Do the upgrade
#
###

    echo ""
    echo "Starting X ${XVERS} Build ${X_BUILD} upgrade."
    echo "  An upgrade log file can be found at:"
    echo "    $PKG_UPGRADE_LOG"
    echo ""

    VERBOSE="-n -a /tmp/admin.$$"

    cat >/tmp/admin.$$ <<EOF
basedir=default
mail=
runlevel=quit
conflict=nocheck
setuid=nocheck
action=nocheck
partial=nocheck
instance=unique
idepend=nocheck
rdepend=nocheck
space=quit
EOF

# Back up OWconfig before adding/removing packages to 
# workaround pkg bug 4946663

    cp /usr/openwin/server/etc/OWconfig /var/tmp/OWconfig.${DATE}

    for pkg in $REM_PKGS
    do
	/bin/pkginfo -q ${pkg}
	FOUNDPKG=$?
	if [ $FOUNDPKG -eq 0 ]; then
	    case "$pkg" in
		SUNWstsfr*)
		    svc_disable application/font/stfsloader
		    ;;
	    esac
	    /usr/sbin/pkgrm $VERBOSE ${pkg}.* 2>&1 | tee -a $PKG_UPGRADE_LOG | grep $pkg
	fi
    done

    for pkg in $pkg_list
    do
	/bin/pkginfo -q ${pkg}.\*
	FOUNDPKG=$?
	if [ $FOUNDPKG -eq 0 ]; then

	    for p in $(pkginfo ${pkg}.\* | awk '{print $2}') ; do
		case "$pkg" in
		    SUNWxwplr*) 
			svc_disable network/fs/tcp6 network/fs-tcp6.xml
			svc_disable application/x11/xfs
			svc_disable application/opengl/ogl-select
			svc_disable application/x11/xvnc-inetd
			;;
		    SUNWfontconfig-root*)
			svc_disable application/font/fc-cache
			;;
		    SUNWstsfr*)
			svc_disable application/font/stfsloader
			;;
		esac

		/usr/sbin/pkgrm $VERBOSE ${p} 2>&1 | tee -a $PKG_UPGRADE_LOG | grep $pkg
	    done
	else
	    echo $FORCE_ADD | /usr/xpg4/bin/grep -q ${pkg}
	    FOUNDPKG=$?
	fi

	if [ $FOUNDPKG -eq 0 -o $INSTALLALL -eq 1 ]; then
	  if [ -e $pkg ] ; then
	    /usr/sbin/pkgadd $VERBOSE  -d `pwd` $pkg 2>&1 | tee -a $PKG_UPGRADE_LOG | grep $pkg
	    echo ""
	  else
	    if [ $QUIET -eq 0 ] ; then
	        echo "No replacement found for $pkg"
	    fi
	  fi
	else
	    if [ $QUIET -eq 0 ] ; then
	      if [ -d $pkg ] ; then
	    	echo "Warning:  ${pkg} not currently installed - not installing new ${pkg}."
  	    	echo "  Run upgrade-X -a to install all new packages."
		echo ""
	      fi
	    fi
	fi
    done

# S10/greenline upgrade support
if [ -x /usr/sbin/inetconv ] ; then
    echo "Updating legacy Greenline/inetd manifests"

    /usr/sbin/inetconv -i /etc/inet/inetd.conf
fi

    echo "X ${XVERS} upgrade is complete"
    echo " "
    echo "  An upgrade log file can be found at:"
    echo "    $PKG_UPGRADE_LOG"

#echo ""
#echo "WARNING: You should compare /usr/openwin/server/etc/OWconfig to the copy"
#echo "saved in /var/tmp/OWconfig.${DATE} to see if you"
#echo "lost important bits from other packages.  (See bug id 4946663 for info.)"