summaryrefslogtreecommitdiffstats
path: root/freenx/build/nx.SlackBuild
blob: 850d462c4cd37e41bb8382a1c33af86bc6f7726b (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
#!/bin/sh
# $Id$
# -----------------------------------------------------------------------------
#
# Slackware SlackBuild script 
# ===========================
# By:        Eric Hameleers <alien@slackware.com>
# For:       nx
# URL:       http://www.nomachine.com/
# Needs:     
# Changelog:
# 1.5.0-1:   14/Aug/2005 by Eric Hameleers <alien@sox.homeip.net>
#            * Initial build.
# 1.5.0-2:   18/Aug/2005 by Eric Hameleers <alien@sox.homeip.net>
#            * 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 <alien@slackware.com>
#            * 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.
# 
# Run 'sh SlackBuild --cleanup' to build a Slackware package.
# The package (.tgz) plus descriptive .txt file are created in /tmp .
# Install using 'installpkg'. 
#
# -----------------------------------------------------------------------------

# --- INIT ---
# Set initial variables:
CWD=`pwd`
if [ "$TMP" = "" ]; then
  TMP=/tmp
fi

PRGNAM=nx
VERSION=1.5.0
ARCH=${ARCH:-i486}
BUILD=3

if [ "$ARCH" = "i386" ]; then
  SLKCFLAGS="-O2 -march=i386 -mcpu=i686"
elif [ "$ARCH" = "i486" ]; then
  SLKCFLAGS="-O2 -march=i486 -mcpu=i686"
elif [ "$ARCH" = "s390" ]; then
  SLKCFLAGS="-O2"
elif [ "$ARCH" = "s390x" ]; then
  SLKCFLAGS="-O2"
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
fi

PKG=$TMP/package-$PRGNAM

if [ ! -d $TMP/tmp-$PRGNAM ]; then
  mkdir -p $TMP/tmp-$PRGNAM # location to build the source
fi
if [ ! -d $PKG ]; then
  mkdir -p $PKG # place for the package to be built
fi

SOURCE[0]=nxproxy-1.5.0-9.tar.gz
SOURCE[1]=nxcomp-1.5.0-65.tar.gz
SOURCE[2]=nxcompext-1.5.0-16.tar.gz
SOURCE[3]=nx-X11-1.5.0-15.tar.gz
SOURCE[4]=nxagent-1.5.0-90.tar.gz
SOURCE[5]=nxviewer-1.5.0-14.tar.gz
SOURCE[6]=nxdesktop-1.5.0-61.tar.gz
SOURCE[7]=nxscripts-1.5.0-11.tar.gz
SOURCE[8]=esound-0.2.35.tar.bz2
SOURCE[9]=nxagent
SOURCE[10]=docs.tar.bz2

PATCH[0]=NX.diff
PATCH[1]=ESPEAKER-fix.diff
PATCH[2]=fix-artsd.diff



# --- PACKAGE BUILDING ---

echo "++"
echo "|| $PRGNAM-$VERSION"
echo "++"

rm -rf $PKG/*

cd $PKG

# Explode the package framework:
if [ -f $CWD/_$PRGNAM.tar.gz ]; then
  explodepkg $CWD/_$PRGNAM.tar.gz
fi

cd $TMP/tmp-$PRGNAM


# --- TARBALL EXTRACTION,PATCH,MODIFY ---

echo "Extracting the program tarballs for $PRGNAM..."
for (( i = 0; i < 9; i++ )) ; do
  if ! [ -f ${CWD}/${SOURCE[$i]} ]; then
    echo "Missing source file ${SOURCE[$i]} !"; exit 1
  fi
  if file ${CWD}/${SOURCE[$i]} | grep -q ": gzip "; then
    tar -zxvf ${CWD}/${SOURCE[$i]}
  else
    tar -jxvf ${CWD}/${SOURCE[$i]}
  fi
done

patch -p0 < $CWD/${PATCH[0]}


chown -R root.root *
find . -perm 777 -exec chmod 755 {} \;


# --- BUILDING ---

echo Building ...

ln -s rdesktop.1 nxdesktop/doc/nxdesktop.1

cat <<-EOF >> nx-X11/config/cf/host.def
	#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
	EOF


export CFLAGS="$SLKCFLAGS"
export CXXFLAGS="$SLKCFLAGS"
sed -i -e "s|CXXFLAGS=.-O.*|CXXFLAGS=$CXXFLAGS|" */configure

CONFIGURE="./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc"

# build Compression Library and Proxy
for i in nxcomp nxproxy; do
  (cd $i; $CONFIGURE; make)
done
# build X11 Support Libraries and Agents
(cd nx-X11; make World)
# build Extended Compression Library
(cd nxcompext; $CONFIGURE; make)
# build RFB Agent
(cd nxviewer; xmkmf -a
  cp -a /usr/X11R6/lib/libXp.so* ../nx-X11/exports/lib/
  make 2> /dev/null
)
# build RDP Agent
if [ "$ARCH" = "i386" -o "$ARCH" = "i486" -o "$ARCH" = "x86_64" ]; then
  (cd nxdesktop
    ./configure --prefix=/usr --sharedir=/usr/share/NX
    make
  )
fi
# Build nxesddsp
(cd esound-0.2.35; $CONFIGURE --enable-arts; make)

#
# Install all the needed stuff to the package dir
#
mkdir -p $PKG/usr/bin
mkdir -p $PKG/usr/lib/NX/lib
mkdir -p $PKG/usr/man/man1

# install X11 Support Libraries and Agents
cp -a nx-X11/lib/X11/libX11.so.* \
  nx-X11/lib/Xext/libXext.so.* \
  nx-X11/lib/Xrender/libXrender.so.* \
  $PKG/usr/lib/NX/lib/
cp -a nx-X11/programs/Xserver/nxagent $PKG/usr/lib/NX/
chmod 755 $PKG/usr/lib/NX/nxagent 
cp -a $CWD/${SOURCE[9]} $PKG/usr/bin/

# install Compression Libraries and Proxy
cp -a nxcomp/libXcomp.so.* $PKG/usr/lib/NX/lib/
cp -a nxcompext/libXcompext.so.* $PKG/usr/lib/NX/lib/
cp -a nxproxy/nxproxy $PKG/usr/lib/NX/
chmod 755 $PKG/usr/lib/NX/nxproxy 
ln -snf nxagent $PKG/usr/bin/nxproxy

# install RFB Agent
( cd nxviewer
  make install DESTDIR=$PKG
  mv $PKG/usr/X11R6/bin/nxviewer $PKG/usr/lib/NX/
  ln -snf nxagent $PKG/usr/bin/nxviewer
  chmod 755 $PKG/usr/bin/nxviewer
  mv $PKG/usr/X11R6/bin/nxpasswd $PKG/usr/bin/
)

rmdir $PKG/usr/X11R6/bin
rmdir $PKG/usr/X11R6

# install RDP Agent
if [ "$ARCH" = "i386" -o "$ARCH" = "i486" -o "$ARCH" = "x86_64" ]; then
  (cd nxdesktop
    make install DESTDIR=$PKG
    mv $PKG/usr/bin/nxdesktop $PKG/usr/lib/NX/
    ln -snf nxagent $PKG/usr/bin/nxdesktop
    chmod 755 $PKG/usr/bin/nxdesktop
  )
fi

# Install nxesd sound wrapper
(cd esound-0.2.35
  cp -a esd $PKG/usr/lib/NX/nxesd
  cp -a esddsp $PKG/usr/lib/NX/nxesddsp
  ln -snf nxagent $PKG/usr/bin/nxesddsp
  chmod 755 $PKG/usr/bin/nxesddsp
)

# --- DOCUMENTATION ---

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION

# install scripts
cp -a nxscripts $PKG/usr/doc/$PRGNAM-$VERSION

# documentation and license
tar -jxvf $CWD/${SOURCE[10]} -C $PKG/usr/doc/$PRGNAM-$VERSION
cp nxcomp/LICENSE $PKG/usr/doc/$PRGNAM-$VERSION
cp nxcomp/README $PKG/usr/doc/$PRGNAM-$VERSION/README.nxcomp
cp nxdesktop/README $PKG/usr/doc/$PRGNAM-$VERSION/README.nxdesktop
cp -a nxdesktop/doc $PKG/usr/doc/$PRGNAM-$VERSION/nxdesktop

chmod -R a-w $PKG/usr/doc/$PRGNAM-$VERSION/*

# Compress the man page(s)
gzip -9f $PKG/usr/man/*/* 

# Strip binaries
( cd $PKG
  find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
  find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
)


# --- OWNERSHIP, RIGHTS ---

chmod -R o-w $PKG
chown root:bin $PKG/usr/bin/* $PKG/usr/sbin/* $PKG/bin/* $PKG/sbin/* \
               $PKG/usr/X11R6/bin/* $PKG/opt/kde/bin/* 2>/dev/null


# --- PACKAGE DESCRIPTION ---

mkdir -p $PKG/install
cat $CWD/${PRGNAM}.slack-desc > $PKG/install/slack-desc
if [ -f $CWD/doinst.sh ]; then
  cat $CWD/doinst.sh > $PKG/install/doinst.sh
fi


# --- BUILDING ---

# Build the package:
cd $PKG
makepkg --linkadd y --chown n $TMP/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}.tgz \
  2>&1 | tee $CWD/makepkg-${PRGNAM}.log
(cd $TMP && md5sum ${PRGNAM}-${VERSION}-${ARCH}-${BUILD}.tgz > ${PRGNAM}-${VERSION}-${ARCH}-${BUILD}.tgz.md5)
cat $CWD/${PRGNAM}.slack-desc | grep "^${PRGNAM}" > $TMP/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}.txt


# --- CLEANUP ---

# Clean up the extra stuff:
if [ "$1" = "--cleanup" ]; then
  rm -rf $TMP/tmp-$PRGNAM
  rm -rf $PKG
fi