#!/bin/sh # $Id$ # Copyright (c) 2008,2009,2010 Eric Hameleers, Eindhoven, The Netherlands # All rights reserved. # # Permission to use, copy, modify, and distribute this software for # any purpose with or without fee is hereby granted, provided that # the above copyright notice and this permission notice appear in all # copies. # # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # ----------------------------------------------------------------------------- # # Slackware SlackBuild script # =========================== # By: Eric Hameleers # For: nx # Descr: a proxy system for X Window # URL: http://www.nomachine.com/ # Needs: # Changelog: # 1.5.0-1: 14/Aug/2005 by Eric Hameleers # * Initial build. # 1.5.0-2: 18/Aug/2005 by Eric Hameleers # * Updated to first maintenance release; added patched version of # esd to get sound in the Windows/Mac client # (the default esd is broken). # If you want sound in KDE, use "UNIX/Custom" in nxclient and the # command line is "nxesddsp startkde". Then, configure KDE to use # the ESD and enable networked sound. # 1.5.0-3: 01/Sep/2005 by Eric Hameleers # * Updated nxdesktop. Also, freenx is patched so that it runs # "nxesddsp" automatically for KDE sessions, so sound should work # with the default client configuration for KDE. # 1.5.0-4: 03/Sep/2005 by Eric Hameleers # This time, nxesddsp should really work :-/ Forgot to use the # patches, *and* forgot to copy the patched libs. # 3.2.0-1: 16/Nov/2008 by Eric Hameleers # * Update to 3.2.0. # 3.3.0-1: 30/dec/2008 by Eric Hameleers # * Update to 3.3.0. # 3.3.0-2: 27/jan/2009 by Eric Hameleers # * 3.3.0 service release by NoMachine updates several components # (nxcompext, nx-X11, nxagent, nxcompshad). # 3.4.0-1: 18/dec/2009 by Eric Hameleers # * 3.4.0 service release by NoMachine updates several components # 3.4.0-2: 04/jun/2010 by Eric Hameleers # * 3.4.0 service release by NoMachine updates several components # # Run 'sh nx.SlackBuild' to build a Slackware package. # The package (.tgz) plus descriptive .txt file are created in /tmp . # Install using 'installpkg'. # # ----------------------------------------------------------------------------- # Set initial variables: PRGNAM=nx VERSION=${VERSION:-3.4.0} BUILD=${BUILD:-2} TAG=${TAG:-alien} # Where do we look for sources? SRCDIR=$(cd $(dirname $0); pwd) # Place to build (TMP) package (PKG) and output (OUTPUT) the program: TMP=${TMP:-/tmp/build} PKG=$TMP/package-$PRGNAM OUTPUT=${OUTPUT:-/tmp} SOURCE[0]="$SRCDIR/nxproxy-${VERSION}-2.tar.gz" SRCURL[0]="http://64.34.161.181/download/${VERSION}/sources/nxproxy-${VERSION}-2.tar.gz" SOURCE[1]="$SRCDIR/nxcomp-${VERSION}-7.tar.gz" SRCURL[1]="http://64.34.161.181/download/${VERSION}/sources/nxcomp-${VERSION}-7.tar.gz" SOURCE[2]="$SRCDIR/nxcompext-${VERSION}-1.tar.gz" SRCURL[2]="http://64.34.161.181/download/${VERSION}/sources/nxcompext-${VERSION}-1.tar.gz" SOURCE[3]="$SRCDIR/nxssh-${VERSION}-2.tar.gz" SRCURL[3]="http://64.34.161.181/download/${VERSION}/sources/nxssh-${VERSION}-2.tar.gz" SOURCE[4]="$SRCDIR/nx-X11-${VERSION}-3.tar.gz" SRCURL[4]="http://64.34.161.181/download/${VERSION}/sources/nx-X11-${VERSION}-3.tar.gz" SOURCE[5]="$SRCDIR/nxwin-${VERSION}-5.tar.gz" SRCURL[5]="http://64.34.161.181/download/${VERSION}/sources/nxwin-${VERSION}-5.tar.gz" SOURCE[6]="$SRCDIR/nxauth-${VERSION}-3.tar.gz" SRCURL[6]="http://64.34.161.181/download/${VERSION}/sources/nxauth-${VERSION}-3.tar.gz" SOURCE[7]="$SRCDIR/nxagent-${VERSION}-5.tar.gz" SRCURL[7]="http://64.34.161.181/download/${VERSION}/sources/nxagent-${VERSION}-5.tar.gz" SOURCE[8]="$SRCDIR/nxesd-${VERSION}-2.tar.gz" SRCURL[8]="http://64.34.161.181/download/${VERSION}/sources/nxesd-${VERSION}-2.tar.gz" SOURCE[9]="$SRCDIR/nxcompshad-${VERSION}-3.tar.gz" SRCURL[9]="http://64.34.161.181/download/${VERSION}/sources/nxcompshad-${VERSION}-3.tar.gz" SOURCE[10]="$SRCDIR/nxscripts-${VERSION}-1.tar.gz" SRCURL[10]="http://64.34.161.181/download/${VERSION}/sources/nxscripts-${VERSION}-1.tar.gz" SOURCE[11]="$SRCDIR/nxspool-${VERSION}-2.tar.gz" SRCURL[11]="http://64.34.161.181/download/${VERSION}/sources/nxspool-${VERSION}-2.tar.gz" ## ## --- with a little luck, you won't have to edit below this point --- ## ## # Automatically determine the architecture we're building on: if [ -z "$ARCH" ]; then case "$( uname -m )" in i?86) export ARCH=i486 ;; arm*) export ARCH=arm ;; # Unless $ARCH is already set, use uname -m for all other archs: *) export ARCH=$( uname -m ) ;; esac fi case "$ARCH" in i486) SLKCFLAGS="-O2 -march=i486 -mtune=i686" SLKLDFLAGS=""; LIBDIRSUFFIX="" ;; x86_64) SLKCFLAGS="-O2 -fPIC" SLKLDFLAGS="-L/usr/lib64"; LIBDIRSUFFIX="64" ;; *) SLKCFLAGS="-O2" SLKLDFLAGS=""; LIBDIRSUFFIX="" ;; esac # Exit the script on errors: set -e trap 'echo "$0 FAILED at line ${LINENO}" | tee $OUTPUT/error-${PRGNAM}.log' ERR # Catch unitialized variables: set -u P1=${1:-1} # Save old umask and set to 0022: _UMASK_=$(umask) umask 0022 # Create working directories: mkdir -p $OUTPUT # place for the package to be saved mkdir -p $TMP/tmp-$PRGNAM # location to build the source mkdir -p $PKG # place for the package to be built rm -rf $PKG/* # always erase old package's contents rm -rf $TMP/tmp-$PRGNAM/* # remove the remnants of previous build # Source file availability: for (( i = 0; i < ${#SOURCE[*]}; i++ )) ; do if ! [ -f ${SOURCE[$i]} ]; then if ! [ "x${SRCURL[$i]}" == "x" ]; then # Check if the $SRCDIR is writable at all - if not, download to $OUTPUT [ -w "$SRCDIR" ] || SOURCE[$i]="$OUTPUT/$(basename ${SOURCE[$i]})" echo "Source '$(basename ${SOURCE[$i]})' not available yet..." echo "Will download file to $(dirname $SOURCE[$i])" wget -nv -T 20 -O "${SOURCE[$i]}" "${SRCURL[$i]}" || true if [ $? -ne 0 -o ! -s "${SOURCE[$i]}" ]; then echo "Downloading '$(basename ${SOURCE[$i]})' failed, aborting the build." mv -f "${SOURCE[$i]}" "${SOURCE[$i]}".FAIL exit 1 fi else echo "File '$(basename ${SOURCE[$i]})' not available, aborting the build." exit 1 fi fi done if [ "$P1" == "--download" ]; then echo "Download complete." exit 0 fi # --- PACKAGE BUILDING --- echo "++" echo "|| $PRGNAM-$VERSION" echo "++" cd $TMP/tmp-$PRGNAM echo "Extracting the source archive(s) for $PRGNAM..." for (( i = 0; i < ${#SOURCE[*]}; i++ )) ; do tar -xvf ${SOURCE[$i]} done chown -R root:root * chmod -R u+w,go+r-w,a+X-s * echo Building ... export LDFLAGS="$SLKLDFLAGS" export CXXFLAGS="$SLKCFLAGS" export CFLAGS="$SLKCFLAGS" cat >> nx-X11/config/cf/host.def << EOF #ifdef i386Architecture #undef DefaultGcc2i386Opt #define DefaultGcc2i386Opt $SLKCFLAGS -fno-strict-aliasing #endif #ifdef MipsArchitecture #undef DefaultGcc2MipsOpt #define DefaultGcc2MipsOpt $SLKCFLAGS -fno-strict-aliasing #endif #ifdef s390xArchitecture #undef OptimizedCDebugFlags #define OptimizedCDebugFlags $SLKCFLAGS -fno-strict-aliasing #endif #ifdef AMD64Architecture #undef DefaultGcc2AMD64Opt #define DefaultGcc2AMD64Opt $SLKCFLAGS -fno-strict-aliasing #endif EOF sed -i -e "s|CXXFLAGS=.-O.*|CXXFLAGS=\"$CXXFLAGS\"|" */configure # Build Compression Library and Proxy for i in nxcomp nxproxy nxcompshad; do cd $i echo "** $i" ./configure --prefix=/usr \ --libdir=/usr/lib${LIBDIRSUFFIX} \ --localstatedir=/var \ --sysconfdir=/etc make cd - done # Build X11 Support Libraries and Agents cd nx-X11 echo "** nx-X11" make World cd - # Build Extended Compression Library cd nxcompext echo "** nxcompext" ./configure --prefix=/usr \ --libdir=/usr/lib${LIBDIRSUFFIX} \ --localstatedir=/var \ --sysconfdir=/etc make cd - # Build nxssh cd nxssh echo "** nxssh" ./configure --prefix=/usr \ --libdir=/usr/lib${LIBDIRSUFFIX} \ --localstatedir=/var \ --sysconfdir=/etc \ --without-zlib-version-check make cd - # Build nxspool cd nxspool/source echo "** nxspool" ./configure --prefix=/usr \ --libdir=/usr/lib${LIBDIRSUFFIX} \ --localstatedir=/var \ --sysconfdir=/etc \ --without-ldap \ --without-krb5 make cd - # Build nxesd cd nxesd echo "** nxesd" ./configure --prefix=/usr \ --libdir=/usr/lib${LIBDIRSUFFIX} \ --localstatedir=/var \ --sysconfdir=/etc make cd - # Install all the needed stuff to the package dir mkdir -p $PKG/usr/bin mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}/NX/lib cp -a nx-X11/lib/X11/libX11.so.* \ nx-X11/lib/Xext/libXext.so.* \ nx-X11/lib/Xrender/libXrender.so.* \ $PKG/usr/lib${LIBDIRSUFFIX}/NX/lib install -m 755 nx-X11/programs/Xserver/nxagent \ $PKG/usr/lib${LIBDIRSUFFIX}/NX cat < $PKG/usr/bin/nxagent #!/bin/sh NXCOMMAND=\$(basename \$0) export LD_LIBRARY_PATH=/usr/lib${LIBDIRSUFFIX}/NX/lib:\$LD_LIBRARY_PATH exec /usr/lib${LIBDIRSUFFIX}/NX/\$NXCOMMAND \${1+"\$@"} EOT chmod 755 $PKG/usr/bin/nxagent cp -a nxcomp/libXcomp.so.* $PKG/usr/lib${LIBDIRSUFFIX}/NX/lib cp -a nxcompext/libXcompext.so.* $PKG/usr/lib${LIBDIRSUFFIX}/NX/lib cp -a nxcompshad/libXcompshad.so.* $PKG/usr/lib${LIBDIRSUFFIX}/NX/lib install -m 755 nxproxy/nxproxy $PKG/usr/lib${LIBDIRSUFFIX}/NX ln -snf nxagent $PKG/usr/bin/nxproxy cp -a nxssh/nxssh $PKG/usr/lib${LIBDIRSUFFIX}/NX ln -snf nxagent $PKG/usr/bin/nxssh chmod 755 $PKG/usr/bin/nxssh cp -a nxspool/source/bin/nxspool $PKG/usr/lib${LIBDIRSUFFIX}/NX ln -snf nxagent $PKG/usr/bin/nxspool chmod 755 $PKG/usr/bin/nxspool cp -a nxesd/nxesd $PKG/usr/lib${LIBDIRSUFFIX}/NX ln -snf nxagent $PKG/usr/bin/nxesd chmod 755 $PKG/usr/bin/nxesd # Add documentation: mkdir -p \ $PKG/usr/doc/$PRGNAM-$VERSION/{nx-X11,nxcomp,nxcompext,nxesd,nxproxy,nxservice,nxspool,nxssh} cd nx-X11 cp -a \ BUILD CHANGELOG* COPYING ChangeLog.X.org LABEL LICENSE README* RELNOTES \ $PKG/usr/doc/$PRGNAM-$VERSION/nx-X11 cd - cd nxcomp cp -a \ COPYING LICENSE README* VERSION \ $PKG/usr/doc/$PRGNAM-$VERSION/nxcomp cd - cd nxcompext cp -a \ CHANGELOG COPYING LICENSE README* VERSION \ $PKG/usr/doc/$PRGNAM-$VERSION/nxcompext cd - cd nxesd cp -a \ AUTHORS CHANGELOG COPYING COPYRIGHT ChangeLog.ESD.original \ LICENSE MAINTAINERS NEWS README TIPS TODO \ $PKG/usr/doc/$PRGNAM-$VERSION/nxesd cd - cd nxproxy cp -a \ CHANGELOG COPYING LICENSE README* VERSION \ $PKG/usr/doc/$PRGNAM-$VERSION/nxproxy cd - cd nxspool cp -a \ CHANGELOG COPYING MAINTAINERS Manifest README* REVISION \ Read-Manifest-Now Roadmap WHATSNEW.txt \ $PKG/usr/doc/$PRGNAM-$VERSION/nxspool cd - cd nxssh cp -a \ CHANGELOG* CREDITS ChangeLog.SSH.orginal \ LICENCE OVERVIEW README* RFC.nroff TODO WARNING.RNG \ $PKG/usr/doc/$PRGNAM-$VERSION/nxssh cd - cp -r nxscripts $PKG/usr/doc/$PRGNAM-$VERSION cp -a $SRCDIR/$(basename $0) $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild chown -R root:root $PKG/usr/doc/$PRGNAM-$VERSION find $PKG/usr/doc -type f -exec chmod 644 {} \; # Strip binaries: find $PKG | xargs file | grep -e "executable" -e "shared object" \ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null # Add a package description: mkdir -p $PKG/install cat $SRCDIR/slack-desc.${PRGNAM} > $PKG/install/slack-desc # Build the package: cd $PKG makepkg --linkadd y --chown n $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.tgz 2>&1 | tee $OUTPUT/makepkg-${PRGNAM}.log cd $OUTPUT md5sum ${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.tgz > ${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.tgz.md5 cd - cat $PKG/install/slack-desc | grep "^${PRGNAM}" > $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.txt # Restore the original umask: umask ${_UMASK_}