#!/bin/ksh # Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # This script takes as input a path to a prototype space of files that are to be # encapsulated in Solaris packages. The installation must include both 32 and # 64 bit libaries and prefixed in the correct manner. # # The steps to build are as follows using vpaths: # % cd ompi-trunk # % ./autogen.sh # % mkdir -p vpath/64 vpath/32/ vpath/proto # # (sparc build) # % cd vpath/64 # % ../../configure --enable-shared --enable-mpi-f90 \ # --with-tm=/path/to/OpenPBS --with-threads=solaris --enable-mpi-threads \ # CFLAGS="-xarch=v9" CXXFLAGS="-xarch=v9" FFLAGS="-stackvar -mt -dalign \ # -fpp -xarch=v9" FCFLAGS="-xarch=v9 -KPIC" --disable-binaries \ # --prefix=/opt/SUNWhpc/HPC7.0 --libdir=/opt/SUNWhpc/HPC7.0/lib/sparcv9 \ # --includedir=/opt/SUNWhpc/HPC7.0/include/v9 # % make DESTDIR=/path/to/ompi-trunk/vpath/proto install # % cd ../32 # % ../../configure --enable-shared --enable-mpi-f90 \ # --with-tm=/path/to/OpenPBS --with-threads=solaris --enable-mpi-threads \ # CFLAGS="" CXXFLAGS="" FFLAGS="-stackvar -mt -dalign -fpp" \ # FCFLAGS="-KPIC" --prefix=/opt/SUNWhpc/HPC7.0 \ # --libdir=/opt/SUNWhpc/HPC7.0/lib --includedir=/opt/SUNWhpc/HPC7.0/include # % make DESTDIR=/path/to/ompi-trunk/vpath/proto install # % cd ../../contrib/dist/solaris # % ./bld_solaris_pkgs -p /path/to/vpath/proto/opt/SUNWhpc/HPC7.0 # # (amd/i386 build) # % cd vpath/64 # % ../../configure --enable-shared --enable-mpi-f90 \ # --with-tm=/path/to/OpenPBS --with-threads=solaris --enable-mpi-threads \ # CFLAGS="" CXXFLAGS="" FFLAGS="-stackvar -mt -dalign \ # -fpp" FCFLAGS="-KPIC" \ # --prefix=/opt/SUNWhpc/HPC7.0 --libdir=/opt/SUNWhpc/HPC7.0/lib/amd64 \ # --includedir=/opt/SUNWhpc/HPC7.0/include/amd64 # % make DESTDIR=/path/to/ompi-trunk/vpath/proto install # % cd ../32 # % ../../configure --enable-shared --enable-mpi-f90 \ # --with-tm=/path/to/OpenPBS --with-threads=solaris --enable-mpi-threads \ # CFLAGS="" CXXFLAGS="" FFLAGS="-stackvar -mt -dalign -fpp" \ # FCFLAGS="-KPIC" --prefix=/opt/SUNWhpc/HPC7.0 \ # --libdir=/opt/SUNWhpc/HPC7.0/lib --includedir=/opt/SUNWhpc/HPC7.0/include # % make DESTDIR=/path/to/ompi-trunk/vpath/proto install # % cd ../../contrib/dist/solaris # % ./bld_solaris_pkgs -p /path/to/vpath/proto/opt/SUNWhpc/HPC7.0 # # The packages will be built into # .../ompi-trunk/contrib/dist/solaris/$PLATFORM/$ARCH/$DATE unless otherwise # specified by the -b option to bld_solaris_pkgs # # This is not the ideal case for long term use. There needs to be changes to # build dynamic packages instead of the static packages we have now. # PATH=/usr/bin/usr/sbin:${PATH} # # global variables # ARCH=`uname -p` DATE=`date +'%Y.%m.%d'` PKGNAMES="SUNWompi SUNWompimn SUNWorte SUNWortemn SUNWomsc" PLATFORM=`uname -s` PROTO= SED_PKGINFO_PROTO=sed_pkginfo_proto SPOOLDEV=`pwd`"/${PLATFORM}/${ARCH}/${DATE}" # # build_package: This function takes as input the name of the package to build # and constructs the package into ${SPOOLDEV}/${PLATFORM}/${ARCH}/${DATE} # function build_package { f_pkg_name=$1 if [ ${BASE} ] ; then SPOOLDEV=${BASE} fi if [ ! -d ${SPOOLDEV} ] ; then mkdir -p ${SPOOLDEV} fi pkgmk -b ${PROTO} -d ${SPOOLDEV} -f prototype.${f_pkg_name} if [ $? != 0 ] ; then print "Error in packaging ${f_pkg_name}" cleanup_pkginfo ${f_pkg_name} cleanup_prototype ${f_pkg_name} exit 1 fi } # # build_sed_script: This function creates the temporary sed script that is used # to process the pkginfo and prototype template files. # function build_sed_script { if [ ${ARCH} == sparc ] ; then lib_v9="sparcv9" inc_v9="v9" elif [ ${ARCH} == i386 ] ; then lib_v9="amd64" inc_v9="amd64" else lib_v9="64" inc_v9="64" fi if [ -f ${SED_PKGINFO_PROTO} ] ; then rm -f ${SED_PKGINFO_PROTO} fi cat << _EOF > ${SED_PKGINFO_PROTO} s/\/LIB_ISAV9/\/${lib_v9}/g s/\/INC_ISAV9/\/${inc_v9}/g s/\/LIB_ISA/\/${ARCH}/g s/\/INC_ISA/\/${ARCH}/g s/\/ISA/\/${ARCH}/g s/\=\"ISA\"/\=\"${ARCH}\"/g _EOF } # # cleanup_pkginfo: This function takes a single input of a package name and # removes the non-templete version of the pkginfo file after the package # has been created. # function cleanup_pkginfo { f_pkginfo_name=pkginfo.$1 if [ -f ${f_pkginfo_name} ] ; then rm -f ${f_pkginfo_name} fi } # # cleanup_prototype: This function takes a single input of a package name and # removes the non-templete version of the prototype file after the package # has been created. # function cleanup_prototype { f_proto_name=prototype.$1 if [ -f ${f_proto_name} ] ; then rm -f ${f_proto_name} fi } # # update_pkginfo: This function takes a single input of a package name and # creates the needed pkginfo file from the template and processing it # with the sed_pkginfo_proto script. # function update_pkginfo { f_pkginfo_name=pkginfo.$1 if [ -f ${f_pkginfo_name} ] ; then rm -f ${f_pkginfo_name} fi sed -f ${SED_PKGINFO_PROTO} ${f_pkginfo_name}.tmpl > ${f_pkginfo_name} } # # update_prototype: This function takes a single input of a package name and # creates the needed prototype file from the template and processing it # with the sed_pkginfo_proto script. # function update_prototype { f_proto_name=prototype.$1 if [ -f ${f_proto_name} ] ; then rm -f ${f_proto_name} fi sed -f ${SED_PKGINFO_PROTO} ${f_proto_name}.tmpl > ${f_proto_name} } # # # function usage { prog=`basename $0` print "Usage: ${prog} [-b build-base] -p proto-dir" print " -b path to place built packages" print " -p path to the prototype space of files to be packaged" } # # main # if (( $# < 1 )) ; then usage exit 1 fi while getopts b:p: a do case "$a" in b) BASE=$OPTARG;; p) PROTO=$OPTARG;; esac done if [ ! ${PROTO} ] ; then usage exit 1 fi if [ ! -d ${PROTO} ]; then print "Error: the proto space ${PROTO} does not exist." usage exit 1 fi build_sed_script for pkg in ${PKGNAMES} do update_pkginfo ${pkg} update_prototype ${pkg} build_package ${pkg} cleanup_pkginfo ${pkg} cleanup_prototype ${pkg} done rm ${SED_PKGINFO_PROTO} exit 0