#!/bin/ksh93
###
#
# @(#)upgrade-X 1.46 09/01/27
#
# Copyright 2009 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 Nevada
# system. It should be run as root from a X package area.
#
# Arguments: -a Ignored (was: install ALL packages, which is now the
# default behaviour.)
# -q Be quiet and don't report packages that aren't
# installed.
# -R path Install under alternate root path (passed to pkgadd)
#
###
# Update this when X package version number changes
XVERS="6.9.0.5.11"
# Set up error reporting function
progname="$0"
function fatal_error
{
print -u2 "${progname}: ERROR: $*"
exit 1
}
####
#
# Process command line options
#
####
QUIET=0
ALTROOT=""
while getopts aqR: flag ; do
case $flag in
a) ;;
q) QUIET=1 ;;
R) ALTROOT="${OPTARG}" ;;
?) printf "Usage: %s: [-q]\n" $0
exit 1 ;;
esac
done
ADDITIONAL_PKG_FLAGS=""
if [[ ! -z "${ALTROOT}" ]] ; then
ADDITIONAL_PKG_FLAGS+="-R ${ALTROOT}"
fi
# Make sure directories that are needed, but not included in pkgmaps
# are created in alternate roots.
# Arguments: directory_path permissions owner:group
function altroot_dir_check
{
if [[ ( ! -z "${ALTROOT}" ) && ( ! -d "${ALTROOT}$1" ) ]] ; then
print "Creating ${ALTROOT}$1"
mkdir -p "${ALTROOT}$1"
chown $3 "${ALTROOT}$1"
chmod $2 "${ALTROOT}$1"
fi
}
altroot_dir_check / root:root 0755
###
#
# 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
fatal_error "You must be root to run this script"
fi
X_BASE_PKG=SUNWxwplt/pkginfo
if [[ -f ${X_BASE_PKG} ]]; then
X_ARCH="$(awk -F= '$1 == "ARCH" {print $2}' ${X_BASE_PKG})"
X_VERSION="$(awk -F= '$1 == "SUNW_PRODVERS" {print $2}' ${X_BASE_PKG})"
X_BUILD="$(nawk '/^VERSION=/ {FS="[,.]+" ; print $(NF-4)/100}' ${X_BASE_PKG})"
else
fatal_error "Cannot find base X package -- SUNWxwplt\n" \
"You need to run this script from the X ${XVERS} package area"
fi
if [[ "${X_ARCH}" != "${MACH}" ]]; then
fatal_error "SUNWxwplt package has wrong architecture (${X_ARCH}).\n" \
"It should have a ${MACH} architecture string."
fi
if [[ -z "${X_VERSION}" ]]; then
fatal_error "Cannot find SUNWxwplt package version.\n" \
"It should have a X ${XVERS} version string."
else
if [[ "${X_VERSION}" != "${XVERS}" ]]; then
fatal_error "SUNWxwplt package has wrong version (${X_VERSION}).\n" \
"It should have a X ${XVERS} version string."
fi
fi
if [[ ( -z "${ALTROOT}" ) && ( "$(uname -r)" != "5.11" ) ]] ; then
fatal_error "Incorrect Solaris version number.\n" \
"X ${XVERS} is only supported on Solaris Nevada"
fi
if [[ -f /usr/bin/pkg ]] ; then
if /usr/bin/pkg list SUNWxwplt > /dev/null 2>&1 ; then
fatal_error "Cannot run on system with IPS installed X packages."
fi
fi
PKG_UPGRADE_LOG="${ALTROOT}/var/tmp/SunSoft_X${XVERS}_B${X_BUILD}_upgrade.log.${DATE}"
altroot_dir_check /var 0755 root:sys
altroot_dir_check /var/tmp 1777 root:sys
####
#
# List of packages to upgrade
#
####
# List of official (deliverable) X Consolidation packages for all platforms
# and all supported builds/releases
# Packages needed to be able to run mkfontdir come first, since later packages
# will need them - those are SUNWfreetype2 & SUNWxwfsw. The rest are listed
# in alphabetical order.
pkg_list="
SUNWfreetype2
SUNWxwfsw
SUNWfontconfig
SUNWfontconfig-root
SUNWfontconfig-docs
SUNWpciaccess
SUNWpixman
SUNWvncviewer
SUNWxcursor-themes
SUNWxorg-cfg
SUNWxorg-client-docs
SUNWxorg-client-programs
SUNWxorg-clientlibs
SUNWxorg-compatlinks
SUNWxorg-devel-docs
SUNWxorg-graphics-ddx
SUNWxorg-headers
SUNWxorg-server
SUNWxorg-tsol-module
SUNWxprint-server
SUNWxscreensaver-hacks
SUNWxscreensaver-hacks-gl
SUNWxsun-server
SUNWxvnc
SUNWxwacx
SUNWxwcft
SUNWxwdem
SUNWxwdxm
SUNWxwfnt
SUNWxwfs
SUNWxwhl
SUNWxwice
SUNWxwinc
SUNWxwman
SUNWxwmod
SUNWxwoft
SUNWxwopt
SUNWxwpft
SUNWxwplr
SUNWxwplt
SUNWxwpmn
SUNWxwrtl
SUNWxwslb
SUNWxwsrv
SUNWxwsvr
SUNWxwts
SUNWxwxft
"
# Some packages are only built for certain platforms currently
case "${MACH}" in
sparc)
pkg_list+=" SUNWxwpsr"
;;
i386)
pkg_list+=" SUNWxorg-mesa"
;;
esac
####
#
# Deal with changes since various older Nevada builds
#
####
# Packages to remove first, either because they are obsolete and not
# being replaced, or because they have been modified to conflict with
# other packages, and need to be removed before those other packages
# are added
REM_PKGS=""
# snv_19: SUNWxwfnt split into SUNWxwfnt & SUNWxwfsw packages [6276301]
# Need to remove SUNWxwfnt before installing SUNWxwfsw if
# SUNWxwfsw is not currently installed
if ! /bin/pkginfo ${ADDITIONAL_PKG_FLAGS} -q SUNWxwfsw ; then
REM_PKGS+=" SUNWxwfnt"
fi
# snv_42: 6424854 Xsun & Xprt servers split out of SUNWxwplt
# Need to remove SUNWxwplt before installing SUNWxsun-server if
# SUNWxsun-server isn't currently installed
if ! /bin/pkginfo ${ADDITIONAL_PKG_FLAGS} -q SUNWxsun-server ; then
REM_PKGS+=" SUNWxwplt"
fi
# snv_46: 6261914 Removal of STSF & Xst [PSARC 2006/087]
REM_PKGS+=" SUNWstsf SUNWstsfr SUNWxwxst"
# snv_91: 6699573 CDE Font Administration Tools removal [LSARC 2008/010]
REM_PKGS+=" SUNWxwfa"
# snv_97: 6731942 Remove SUNWxwsrc package
REM_PKGS+=" SUNWxwsrc"
# snv_98: 6741034 Merge SUNWi1of into SUNWxwfnt
REM_PKGS+=" SUNWi1of"
# snv_107: 6582489 X11R7.4: Xorg server 1.5.3 and associated driver updates
# Merged SUNWxorg-doc into SUNWxorg-server & SUNWxorg-graphics-ddx
REM_PKGS+=" SUNWxorg-doc"
# snv_108: 6798225 stop building/delivering SUNWxwdim
REM_PKGS+=" SUNWxwdim"
# Various compatibility links in SUNWxorg-server have been replaced with
# files in other packages, so we need to remove SUNWxorg-server first
# (for example: 6658871 changed /usr/X11/lib/X11/fonts/Type1 from a link
# in SUNWxorg-server to a directory in SUNWxwcft, 6684643 changed
# /usr/X11/lib/X11/rgb.txt from a link to a file in SUNWxwplt and so on)
if /bin/pkginfo ${ADDITIONAL_PKG_FLAGS} -q SUNWxorg-server ; then
REM_PKGS+=" SUNWxorg-server"
fi
# Check for shared SMF manifest scripts now required by our packages
if [[ ! -f /usr/sadm/install/scripts/i.manifest ]] ; then
fatal_error "Cannot install on a Nevada build older than nv_17.\n" \
"This build of X requires a system with the shared SMF manifest class\n" \
"action scripts installed in /usr/sadm/install/scripts/i.manifest\n" \
"(See Solaris bug id 6209178)\n"
fi
# /etc/svc & /var/svc/profile directories needed by manifest packaging scripts
altroot_dir_check /etc 0755 root:sys
altroot_dir_check /etc/svc 0755 root:sys
altroot_dir_check /var/svc 0755 root:sys
altroot_dir_check /var/svc/profile 0755 root:sys
# Need to be able to install symlinks to /usr/lib/isaexec in SUNWxorg-server
if [[ (! -z "${ALTROOT}") && (! -f "${ALTROOT}/usr/lib/isaexec") ]] ; then
altroot_dir_check /usr 0755 root:sys
altroot_dir_check /usr/lib 0755 root:sys
touch ${ALTROOT}/usr/lib/isaexec
fi
# S10/greenline upgrade support
function 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
#
###
print ""
print "Starting X ${XVERS} Build ${X_BUILD} upgrade"
if [[ ! -z ${ALTROOT} ]] ; then
print " in alternate root ${ALTROOT}"
fi
print " An upgrade log file can be found at:"
print " $PKG_UPGRADE_LOG"
print ""
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/4992643
if [[ -f ${ALTROOT}/usr/openwin/server/etc/OWconfig ]]; then
cp ${ALTROOT}/usr/openwin/server/etc/OWconfig ${ALTROOT}/var/tmp/OWconfig.${DATE}
fi
# Remove all instances of the specified package
function remove_package
{
pkg=$1
if /bin/pkginfo ${ADDITIONAL_PKG_FLAGS} -q ${pkg}.\* ; then
for p in $(pkginfo ${ADDITIONAL_PKG_FLAGS} ${pkg}.\* | awk '{print $2}') ; do
if [[ -z ${ALTROOT} ]] ; then
case "$pkg" in
SUNWxwplr*)
svc_disable network/fs/tcp6 network/fs-tcp6.xml
svc_disable application/opengl/ogl-select
svc_disable application/x11/xfs
svc_disable application/x11/xvnc-inetd
;;
SUNWfontconfig-root*)
svc_disable application/font/fc-cache
;;
SUNWstsfr*)
svc_disable application/font/stfsloader
;;
esac
fi
/usr/sbin/pkgrm ${ADDITIONAL_PKG_FLAGS} ${VERBOSE} ${p} 2>&1 \
| tee -a ${PKG_UPGRADE_LOG} | grep $pkg
done
fi
}
for pkg in ${REM_PKGS} ; do
remove_package $pkg
done
for pkg in ${pkg_list} ; do
remove_package $pkg
if [[ -e $pkg ]] ; then
/usr/sbin/pkgadd ${ADDITIONAL_PKG_FLAGS} -S ${VERBOSE} -d . $pkg 2>&1 \
| tee -a ${PKG_UPGRADE_LOG} | grep $pkg
print ""
else
if [[ $QUIET -eq 0 ]] ; then
print "No replacement found for $pkg"
fi
fi
done
# Start the rebuild of fontconfig caches now, instead of at next reboot
if [[ -z "${ALTROOT}" ]] ; then
/usr/sbin/svccfg -s application/font/fc-cache setprop options/force_rebuild="true"
/usr/sbin/svcadm restart application/font/fc-cache
fi
print "X ${XVERS} upgrade is complete"
print " "
print " An upgrade log file can be found at:"
print " $PKG_UPGRADE_LOG"
exit 0