Packaging ASE on Solaris

From SybaseWiki
Revision as of 23:12, 9 January 2009 by Psap (Talk | contribs) (space)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Introduction

On the Solaris platform you can use packages as an easy way to install software. This document shows you how to create a package for a Sybase ASE software installation. It will install the Sybase software, not create a server. The package will make use of the silent installation option of an ASE distribution, rather than using a pre-cooked tar file.

The package itself can be build by a non privileged user, but the actual installation (with pkgadd) or removal of the package (pkgrm) must be done with a privileged account (root).

Get the software

Get the Sybase software that you want to package. This should be at least the base installation software and optionaly an EBF file. The package will take care of g-unzipping the files and un-tarring them, so you also need the GNU version of tar.

Prepare for silent installation

The silent installation of ASE requires an option file. The base installation and the EBF each have their own option file. Follow these steps to create them, the example below is based on an ASE 15.0.2 distribution and EBF 15651 (ESD 4).

  • gunzip the base installation file
gunzip ase1502_solsparc64.tgz
  • Untar the file
tar -xf ase1502_solsparc64.tar
  • Run setup in console mode and tell it also to create an options file based on the provided answers. The questions usually speak for themselves. Do not configure a server at this point.
./setup -console -options-record $PWD/ase1502_options.txt
  • Open the newly created options file and put a # at the beginning of the starting with “-P installLocation”.

When you want to add an EBF on top of the base installation then follow these additional steps:

  • gunzip the ebf installation file
gunzip EBF15651.tgz
  • Untar the file, but use GNU tar now.
tar -xf EBF15651.tar
  • Go into the ebf directory
cd ebf15651
  • Run setup in console mode and tell it also to create an options file based on the provided answers.
./setup -console -options-record $PWD/ase1502_ebf_options.txt

When setup starts you may see this error message, but you can safely ignore it:

could not load service implementor com.installshield.wizard.platform.solaris.SolarisSystemUtilServiceImpl due to the following exception:
java.lang.NoClassDefFoundError: com/installshield/wizard/platform/common/environment/EnvironmentVariableManager

Again, do not configure a server at this point.

  • Open the newly created options file and put a # at the beginning of the line starting with “-P installLocation”.

Set a name for the package

A package has a name and this technical name cannot be longer that 9 characters. In this example ASE1502-4 will be used (ASE 15.0.2 ESD 4).

Create the directory structure

Run the following commands to setup the required directory structure.

mkdir packages
cd packages
mkdir ASE1502-4
mkdir ASE1502-4/pkgadd_software
mkdir ASE1502-4/pkgadd_logfile
mkdir Infofiles

The directory ASE1502-4/pkgadd_software will be used to stored the Sybase supplied software in it, the GNU-tar executable and the created option files.

The directory ASE1502-4/pkgadd_logfile is used to store the script that controls the main part of the software installation. The script itself will not be distributed but executed during the installation. The output of the script will then re-appear in the installation directory with the same name as the script.

Store the files in ASE1502-4/pkgadd_software

Now store the ASE base installation software (e.g. ase1502_solsparc64.tgz), as well as the EBF file (if you have one) in the ASE1502-4/pkgadd_software directory. Copy the created options file in it too. Finally, copy the GNU-tar executable to it.

Create the installation script

Now we will create the installation script. The script is executed when pkgadd is run.

Create the installation script called sybase_install in the directory ASE1502-4/pkgadd_logfile. The script is given here:

#

if [ "$1" = install ]
then
  echo ""
  echo "This file contains the output of the pkgadd installation script"
  echo ""

  # Set LOC to installation directory
  LOC=${BASEDIR}/${PKG}

  # Pkgadd runs from it's own directory and that's not what we want
  cd ${LOC}/pkgadd_software

  echo "Unzipping full distro"
  gunzip ${FULL_DISTRO}.tgz
  if [ $? -ne 0 ]
  then
    exit 2
  fi

  echo "Untarring with distributed gnutar"
  ./tar -xf ${FULL_DISTRO}.tar
  if [ $? -ne 0 ]
  then
    exit 2
  fi

  echo "-P installLocation=${LOC}" >> ase1502_options.txt

  echo "Running setup of full distro"
  ./setup -is:javaconsole -silent -options "${LOC}/pkgadd_software/ase1502_options.txt" -W SybaseLicense.agreeToLicense=true
  if [ $? -ne 0 ]
  then
    exit 2
  fi
  echo "Done with full installation"

  echo "Cleanup of full installation work files"
  rm ${FULL_DISTRO}.tar README.SAMreport media.inf setup
  rm -R JVM archives samreport suite
  touch ${FULL_DISTRO}.tgz

  if [ "${EBF}" = "" ]
  then
    echo "No EBF detected."
  else
    echo "Sybase EBF ${EBF} detected."

    echo "Unzipping EBF"
    gunzip ${EBF}.tgz
    if [ $? -ne 0 ]
    then
      exit 2
    fi

    echo "Untarring EBF with distributed gnutar"
    ./tar -xf ${EBF}.tar
    if [ $? -ne 0 ]
    then
      exit 2
    fi

    DIR=`echo "${EBF}" | tr "[:upper:]" "[:lower:]"`

    if [ ! -d ${DIR} ]
    then
      echo "Could not find directory ${DIR}, aborting."
      exit 2
    fi

    echo "-P installLocation=${LOC}" >> ase1502_ebf_options.txt

    # Install the EBF.
    # The installation will return error 210 with this message:
    # could not load service implementor com.installshield.wizard.platform.solariis.SolarisSystemUtilServiceImpl due to the following exception: java.lang.NoClassDefFoundError: com/installshield/wizard/platform/common/environment/EnvironmentVariableManager
    ${DIR}/setup -is:javaconsole -silent -options "${LOC}/pkgadd_software/ase1502_ebf_options.txt" -W SybaseLicense.agreeToLicense=true
    RESULT=$?
    if [ ${RESULT} -ne 210 ]
    then
      if [ ${RESULT} -ne 0 ]
      then
        exit 2
      fi
    fi
    echo "Done with EBF installation"

    echo "Cleanup of EBF installation work files"
    rm ${EBF}.tar
    rm -R ${DIR}
    touch ${EBF}.tgz
  fi

  echo "Changing ownership"
  chown -R sybase:sybase ${LOC}

  echo "Done"
fi

exit 0

As you can see the script takes care of the installation in silent mode and also changes the ownership of the created files to sybase:sybase. By default, the files are owned by root. To execute the installation succesfully it is expected that a user sybase and a group called sybase are defined.

Create the metadata for the package

The directory Infofiles should contain various files to build the package.

Go to the Infofiles directory and create the following files.

cd Infofiles

pkginfo

The pkginfo file contains basic values for the package. Sample:

PKG=ASE1502-4
NAME=Sybase ASE 15.0.2 ESD 4 EBF 15651
CATEGORY=application
VERSION=1.0
VENDOR=Sybase DBA team
ARCH=sparc
BASEDIR=/sybase
CLASSES=none build
FULL_DISTRO=ase1502_solsparc64
EBF=EBF15651

Here is short description for each of the values

  • PKG – Technical name of the package, maximum length 9 characters
  • NAME – Full name
  • CATEGORY – must be set to "application"
  • VERSION – Version information
  • VENDOR – Set to the organizational name of the Sybase DBA team.
  • ARCH – set to "sparc"
  • BASEDIR – Set to "/sybase". As you can see, a prefix like /opt is missing. This makes the package relocatable. When the package is installed you can add a prefix before the basedir (pkgadd -R /opt).
  • CLASSES – set to "none build"
  • FULL_DISTRO – Set it to the name of the Sybase base installation software, but without the trailing .gz.
  • EBF – Set to the name of the EBF file to be installed on top of the base installation withou the trailing .gz. When you do not want an EBF to be installed leave the value empty.

prototype

The prototype file describes each file that should be part of the package. An example is given here:

i pkginfo
i checkinstall
i postinstall
i space

d none ASE1502-4 0755 sybase sybase
d none ASE1502-4/pkgadd_logfile 0755 sybase sybase
e build ASE1502-4/pkgadd_logfile/sybase_install 0644 sybase sybase
d none ASE1502-4/pkgadd_software 0755 sybase sybase
f none ASE1502-4/pkgadd_software/tar 0700 sybase sybase
f none ASE1502-4/pkgadd_software/ase1502_solsparc64.tgz 0644 sybase sybase
f none ASE1502-4/pkgadd_software/EBF15651.tgz 0644 sybase sybase
f none ASE1502-4/pkgadd_software/ase1502_options.txt 0644 sybase sybase
f none ASE1502-4/pkgadd_software/ase1502_ebf_options.txt 0644 sybase sybase

When you do not have an EBF to be installed, just remove the two lines related to that.

checkinstall

The checkinstall script is executed at the beginning of an installation. Here you can check for certain things. Example:

#!/bin/sh
#
# Check some basic things before continuing.

id sybase > /dev/null 2>&1
RESULT=$?

if [ ${RESULT} -eq 1 ]
then
  echo "ERROR: User sybase not found."
  exit 3
fi

RESULT=`cat /etc/group | grep "^sybase:" | wc -l`

if [ ${RESULT} -eq 0 ]
then
  echo "ERROR: Group sybase not found."
  exit 3
fi

if [ ! -d ${PKG_INSTALL_ROOT}${BASEDIR} ]
then
  echo "ERROR: Target directory ${PKG_INSTALL_ROOT}${BASEDIR} not found."
  exit 3
fi

exit 0

postinstall

The postinstall script is executed at the end of the installation. When a package is installed, all files that are described in the prototype file are added to the package database. When a package is de-installed the system knows what to remove. Since we use the silent install of Sybase, a lot of files are dynamically created. In the postinstall script these are put into a list and stored into the package database.

#
# Update the package database with files aded to the system

echo "Adding dynamically created files to the package database, please wait...."

find ${BASEDIR}/${PKGINST} | installf ${PKGINST} -

# Run installf one more time to commit to the database
installf -f ${PKGINST}

exit 0

space

The space file is used to determine if there is enough storage available on the system. The packaging system itself determines it also based on the size of the package. However, since we perform a dynamic installation we need more space.

# Reserve an extra 2 Gb disk space (4194304 512 byte blocks) and 10.000 inodes
ASE1502-4 4194304 10000

Create the package

The package can be created with these easy steps: Go to the directory where the Infofiles are stored and run pkgmk:

cd Infofiles
pkgmk –r ..

Installing / de-installing a package

Become root and install the package with this command:

pkgadd –R /opt

The pkgadd command will by default look in /var/spool/pkg for packages. Choose the package that you want to install.

To de-install the package do

pkgrm –R /opt ASE1502-4