wiki:PackagingInstructionsforLinux
close Warning:

A script for packaging Linux distribution is available:

#!/bin/sh

# user configs - please adjust for your installation:

# the root directory of ultrascan-3:
US3=/export/home/user/demeler/ultrascan3
US2=/export/home/user/demeler/us/ultrascan

# the root directory for the QT4 distribution: 
QT4=/usr/local/Trolltech/Qt-4.7.3

# the library directory for the qt4 version of qwt:
QWT4=/opt/qwt/lib

# the library directory for the qt4 version of the qwtplot3d library:
QWT3D4=/export/home/user/demeler/ultrascan3/lib

# the mysql, crypt(o), png and jpg libraries linked to your distribution:
MYSQL=/export/home/user/demeler/ultrascan3/lib/libmysqlclient.so.16
CRYPTO=/lib/libcrypto.so.0*
CRYPT=/lib/libcrypt[-.]*
PNG=/usr/lib/libpng14.so.14*
JPG=/usr/X11R6/lib/libjpeg.so.*
SSL=/lib/libssl.so.0*

# a temporary directory for building the distribution:
TMP=/tmp

# the version to be built:
VER=2.0

# 32 or 64 bit:
ARCH=32

#############################################################
OS=Linux
REV=`cut -d\" -f2  programs/us/us_revision.h | cut -d ' ' -f2`
FILE=ultrascan-$OS$ARCH-$VER-rev$REV
BUILD=$TMP/$FILE

echo "Cleaning up previous UltraScan-3 build if it exists..."
rm -rf $BUILD
mkdir $BUILD

echo "Copying UltraScan-3 and QT4 binaries..."
cp -a $US3/bin $BUILD/.
cp $QT4/bin/assistant $BUILD/bin/.

echo "Copying UltraScan-3 libraries..."
cp -a $US3/lib $BUILD/.

echo "Copying UltraScan-3 etc..."
cp -a $US3/etc $BUILD/.

echo "Copying UltraScan-3 QT4 libraries..."
for x in libQtCLucene.so.4 libQtCore.so.4 libQtDBus.so.4 libQtGui.so.4 \
   libQtHelp.so.4 libQtNetwork.so.4 libQtOpenGL.so.4 libQtSql.so.4 \
   libQtSvg.so.4 libQtWebKit.so.4 libQtXml.so.4 libphonon.so.4 libQt3Support.so.4; do
   cp -d $QT4/lib/$x* $BUILD/lib/.
done

echo "Copying UltraScan-3 QWT..."
cp -d $QWT4/* $BUILD/lib/.

echo "Copying UltraScan-3 QWTPLOT3D..."
cp -d $QWT3D4/* $BUILD/lib/.

rm -f $BUILD/etc/somo*prev

echo "Removing unneeded files..."
rm -rf $BUILD/lib/*prl
rm -rf $BUILD/lib/*.la

echo "Copying miscellaneous libraries..."
cp -d $MYSQL $BUILD/lib/.
cp -d $JPG $BUILD/lib/.
cp -d $PNG $BUILD/lib/.
cp -d $CRYPT $BUILD/lib/.
cp -d $CRYPTO $BUILD/lib/.
cp -d $SSL $BUILD/lib/.

echo "Stripping debugging symbols..."
strip $BUILD/bin/*
strip $BUILD/lib/*
echo "removing SVN stuff..."
find $BUILD -name .svn | xargs rm -Rf

echo "Copying SOMO stuff..."
mkdir -p $BUILD/somo
cp -a $US2/somo/demo $BUILD/somo/.
cp -a $US3/somo/doc $BUILD/somo/.

cd $TMP
tar -cvzf $FILE.tar.gz $FILE

Locations of the 3rd party libraries should be checked carefully on the build system and replaced in this script.

An alternative script is available as well:

!/bin/sh
#     copypkg-lnx.sh  - copy ultrascan3 directories to us3pkg/PKGNAME

SRCDIR=$HOME/ultrascan3
DSTDIR=$HOME/us3pkg
ME=`whoami`
SYSTYPE=`uname -s`
if [ "${SYSTYPE}" != "Linux" ]; then
  echo "$0 requires a SYSTYPE (uname -s) of \"Linux\""
  echo "  SYSTYPE=${SYSTYPE}"
  exit 1
fi
SURL="//bcf.uthscsa.edu/ultrascan3/trunk"
REV=`svn info svn:${SURL}|grep Revision|awk '{print $2}'`
RSYNC="rsync -av --exclude=.svn"
REVL=`svn info ${SRCDIR}|grep Revision|awk '{print $2}'`
VERS="1.0"

if [ "${REV}" != "${REVL}" ]; then
  # Abort if source is not latest revision
  echo "Rev from ${SURL}:   ${REV}"
  echo "Rev from ${SRCDIR}:   ${REVL}"
  echo "  Do 'svn update' and build, then re-run this script"
  exit 1
fi

QTLIBS=" \
 libQtCore.so.4
 libQtDBus.so.4
 libQtGui.so.4
 libQtHelp.so.4
 libQtNetwork.so.4
 libQtOpenGL.so.4
 libQtSql.so.4
 libQtSvg.so.4
 libQtWebKit.so.4
 libQtXml.so.4
 libQtCLucene.so.4
 libQt3Support.so.4
 libphonon.so.4
 "
QTBINS="assistant"

# Determine if this is 32-bit or 64-bit
TEMP=`which gcc`
TEMP=`file ${TEMP} | egrep -ci '64-bit|x86-64'`
if [ ${TEMP} -ne 0 ]; then
  PKGNAME=ultrascan-Linux64-${VERS}-rev${REV}
else
  PKGNAME=ultrascan-Linux32-${VERS}-rev${REV}
fi
PKGDIR=${DSTDIR}/${PKGNAME}

# Insure we have a package base directory
cd $HOME
if [ ! -d us3pkg ]; then
  mkdir us3pkg
fi
cd ${DSTDIR}
if [ ! -d ${PKGNAME} ]; then
  mkdir ${PKGNAME};
fi
echo "PKGDIR=${PKGDIR}"

# Copy the US3 directories
(cd ${PKGDIR};mkdir etc bin lib)
for D in etc bin lib us3-update.sh; do
  SDIR=${SRCDIR}/${D}
  DDIR=${PKGDIR}
  echo "${RSYNC} ${SDIR} ${DDIR}"
  ${RSYNC} ${SDIR} ${DDIR}
done
 Remove the SOMO bins
US3BINS=`(cd ${SRCDIR}/somo/bin;ls)`
for F in ${US3BINS}; do
  echo "/bin/rm -f ${PKGDIR}/bin/${F}"
  /bin/rm -f ${PKGDIR}/bin/${F}
done

# Leave only *.new files in etc/somo
for F in ${PKGDIR}/etc/somo*; do
  if [ `echo ${F} | grep -ic '.new$'` -eq 0 ]; then
    # Remove any etc/somo* that does not end in '.new'
    /bin/rm -f ${F}
  fi
done

# Copy the SOMO directories
SDIR=${SRCDIR}/somo/lib
DDIR=${PKGDIR}
echo "${RSYNC} ${SDIR} ${DDIR}"
${RSYNC} ${SDIR} ${DDIR}
SDIR=${SRCDIR}/somo/bin
DDIR=${PKGDIR}
echo "${RSYNC} ${SDIR} ${DDIR}"
${RSYNC} ${SDIR} ${DDIR}
(cd ${PKGDIR};mkdir somo somo/doc somo/demo somo/test);
SDIR=${SRCDIR}/somo/doc
DDIR=${PKGDIR}/somo
echo "${RSYNC} ${SDIR} ${DDIR}"
${RSYNC} ${SDIR} ${DDIR}

SOMODIR=$HOME/ultrascan/somo
if [ -d ${SOMODIR} -a -d ${SOMODIR}/demo ]; then
  # Clear out somo/demo so only present contents are copied
  /bin/rm -rf ${PKGDIR}/somo/demo/*
  # Copy somo demo,test contents
  for D in demo test; do
    SDIR=${SOMODIR}/${D}
    DDIR=${PKGDIR}/somo
    echo "${RSYNC} ${SDIR} ${DDIR}"
    ${RSYNC} ${SDIR} ${DDIR}
  done
fi

# Copy special library files
CPYCMD='cp -d --preserve=timestamps'
cd ${PKGDIR}
MYSQL=`ldd bin/u* lib/*|grep -i mysql|sed -n 1p`
      echo "MYSQL=${MYSQL}"
if [ ! -z "${MYSQL}" ]; then
  MYSQL=`echo ${MYSQL} | awk '{print $3}' | sed -e 's/sqlclient.so.*$/sqlclient.so/'`
      echo "MYSQL=${MYSQL}"
  ${CPYCMD} ${MYSQL}*  ${PKGDIR}/lib/.
fi
JPEG=`ldd bin/u* lib/*|grep -i jpeg|sed -n 1p`
      echo "JPEG=${JPEG}"
if [ ! -z "${JPEG}" ]; then
  JPEG=`echo ${JPEG} | awk '{print $3}' | sed -e 's/jpeg.so.*$/jpeg.so/'`
      echo "JPEG=${JPEG}"
  ${CPYCMD} ${JPEG}*  ${PKGDIR}/lib/.
fi
PNG=`ldd bin/u* lib/*|grep -i png|sed -n 1p`
      echo "PNG=${PNG}"
if [ ! -z "${PNG}" ]; then
  PNG=`echo ${PNG} | awk '{print $3}' | sed -e 's/png.so.*$/png.so/'`
      echo "PNG=${PNG}"
  ${CPYCMD} ${PNG}*  ${PKGDIR}/lib/.
fi
CRYPT=`ldd bin/u* lib/*|grep -i libcrypt|sed -n 1p`
      echo "CRYPT=${CRYPT}"
if [ ! -z "${CRYPT}" ]; then
  CRYPT=`echo ${CRYPT} | awk '{print $3}' | sed -e 's/libcrypt.*$/libcrypt/'`
      echo "CRYPT=${CRYPT}"
  ${CPYCMD} ${CRYPT}*  ${PKGDIR}/lib/.
fi
SSL=`ldd bin/u* lib/*|grep -i ssl|sed -n 1p`
      echo "SSL=${SSL}"
if [ ! -z "${SSL}" ]; then
  SSL=`echo ${SSL} | awk '{print $3}' | sed -e 's/ssl.so.*$/ssl.so/'`
      echo "SSL=${SSL}"
  ${CPYCMD} ${SSL}*  ${PKGDIR}/lib/.
fi

      echo "QTDIR=${QTDIR}"
if [ ! -z "${QTDIR}" ]; then
  for x in ${QTLIBS}; do
    ${CPYCMD} ${QTDIR}/lib/${x}* ${PKGDIR}/lib
  done
  for x in ${QTBINS}; do
    ${CPYCMD} ${QTDIR}/bin/${x}* ${PKGDIR}/bin
  done
fi
      echo "QWTDIR=${QWTDIR}"
if [ -z "${QWTDIR}" ]; then
  QWTDIR=`ldd bin/u* lib/*|grep -i qwt.so|sed -n 1p`
  QWTDIR=`echo ${QWTDIR} | awk '{print $3}' | sed -e 's@lib/libqwt.*$@@'`
fi
      echo "QWTDIR=${QWTDIR}"
if [ ! -z "${QWTDIR}" ]; then
  ${CPYCMD} ${QWTDIR}/lib/libqwt.so* ${PKGDIR}/lib/.
fi

# Strip libs and bins
echo "Stripping debugging symbols..."
strip ${PKGDIR}/bin/u*
strip ${PKGDIR}/lib/lib*

# Remove .svn
cd ${PKGDIR}
find ./ -name '.svn' | xargs rm -Rf
ls -lF

# Create the package archive and display it
cd ${DSTDIR}
tar -cvzf ${PKGNAME}.tar.gz ${PKGNAME}
pwd
ls -lF
cd ${PKGDIR}
pwd
ls -lF

Last modified 6 years ago Last modified on Oct 31, 2012 4:41:21 PM