# $Id$ PNAME="nxserver-freenx" PVER="0.7.3" PBUILD="r6" PCAT="net-misc" DESCRIPTION="A free NX server implementation." HOMEPAGE="http://freenx.berlios.de/" # binutils is only needed for the strings binary! DEPEND=">= net-misc/nxcomp-3.5 >= net-misc/nxcompsh-3.5 >= net-misc/nxcompshad-3.5 >= net-misc/nxcompext-3.5 >= net-misc/nxlibs-3.5 >= net-misc/nxagent-3.5 >= net-misc/openssh-6 >= dev-util/expect-5.43 >= sys-apps/gawk-1.3.5 >= net-misc/netcat-0.7.1 >= net-misc/rdesktop-1 >= virtual/vnc-client >= x11-apps/sessreg-1 >= x11-apps/xauth-1 >= x11-apps/xdm-1 >= x11-apps/xrdb-1 >= x11-apps/xmessage-1 >= media-fonts/font-misc-misc-1 >= media-fonts/font-cursor-misc-1 >= sys-dev/binutils-2.18 >= sys-apps/coreutils-8 >= sys-apps/util-linux-2.23" SDEPEND=">= virtual/sed >= x11-misc/imake-1 >= x11-misc/gccmakedep-1" PROVIDE="virtual/nxprint virtual/nxnode virtual/nxserver" SRCFILE="freenx-server-${PVER}.tar.gz" SRCDIR="${BUILDDIR}/freenx-server-${PVER}" sminclude mtools systemd SRC_URI=( http://download.berlios.de/freenx/${SRCFILE} mirror://${PNAME}/${SRCFILE} mirror://${PNAME}/${PNAME}-${PVER}-lp-fixes.patch mirror://${PNAME}/${PNAME}-${PVER}-nxredir.patch mirror://${PNAME}/${PNAME}-${PVER}-generate-ssh-keys.patch mirror://${PNAME}/${PNAME}-${PVER}-nxdialog.patch mirror://${PNAME}/${PNAME}-${PVER}-nxipp.patch mirror://${PNAME}/${PNAME}-${PVER}-nxpath.patch mirror://${PNAME}/${PNAME}-${PVER}-dpi.patch mirror://${PNAME}/${PNAME}-${PVER}-agent-version.patch mirror://${PNAME}/${PNAME}-${PVER}-prefer-xmessage.patch mirror://${PNAME}/${PNAME}-${PVER}-increase-base-ports.patch mirror://${PNAME}/${PNAME}-${PVER}-nxprint-warnings.patch mirror://${PNAME}/${PNAME}-${PVER}-ignore-system-nxloadconfig.patch mirror://${PNAME}/${PNAME}-${PVER}-agent-startup.patch mirror://${PNAME}/nxclient-wrapper mirror://${PNAME}/freenx.service mirror://${PNAME}/freenx.logrotate mirror://${PNAME}/freenx-check-setup.sh ) UP2DATE="updatecmd_berlios freenx freenx-server" src_prepare() { munpack ${SRCFILE} || die cd ${SRCDIR} # upstream patches from launchpad mpatch ${PNAME}-${PVER}-lp-fixes.patch || die # fix installation of nxredir mpatch ${PNAME}-${PVER}-nxredir.patch || die # auto generate missing ssh keys mpatch ${PNAME}-${PVER}-generate-ssh-keys.patch || die # only use dialog when xterm is installed mpatch ${PNAME}-${PVER}-nxdialog.patch || die # fix ipp handling mpatch ${PNAME}-${PVER}-nxipp.patch || die # fix path handling with symlinks mpatch ${PNAME}-${PVER}-nxpath.patch || die # make the default DPI configurable through node.conf mpatch ${PNAME}-${PVER}-dpi.patch || die # allow agents up to version 3.5 mpatch ${PNAME}-${PVER}-agent-version.patch || die # prefer xmessage instead of dialog mpatch ${PNAME}-${PVER}-prefer-xmessage.patch || die # change DISPLAY_BASE to 2000 to avoid conflicts with nasd, cupsd and smbd mpatch ${PNAME}-${PVER}-increase-base-ports.patch || die # do not read from non-existent dirs to fix warnings mpatch ${PNAME}-${PVER}-nxprint-warnings.patch || die # do not load systemwide nxloadconfig mpatch ${PNAME}-${PVER}-ignore-system-nxloadconfig.patch # wait until nxagent has completed startup mpatch ${PNAME}-${PVER}-agent-startup.patch || die # fixup pathes and honor multilib systems sed -i "s:/usr/lib:/usr/$(mlibdir):g" nxloadconfig node.conf.sample || die sed -i "s:^\(NX_DIR=\).*:\1\"/usr/NX\":" nxloadconfig || die sed -i "s:^\(NX_ETC_DIR=\).*:\1\"\$NX_DIR/etc\":" nxloadconfig || die sed -i "s:^\(NX_SESS_DIR=\).*:\1\"\$NX_DIR/var/db\":" nxloadconfig || die sed -i "s:^\(NX_HOME_DIR=\).*:\1\"\$NX_DIR/home/nx\":" nxloadconfig || die sed -i "s:^\(#\{,1\}NOMACHINE_NX_HOME_DIR=\).*:\1\"/usr/NX/home/nx\":" nxloadconfig node.conf.sample || die # fixed authorized keys file sed -i 's:authorized_keys2:authorized_keys:g' nxloadconfig || die # no more X11R6 sed -i 's:/usr/X11R6/bin/xauth:/usr/bin/xauth:g' nxloadconfig || die sed -i 's:/usr/X11R6/bin/xmessage:/usr/bin/xmessage:g' nxdialog || die # fix foomatic path sed -i "s:^\(#\{,1\}COMMAND_FOOMATIC=\).*:\1\"/usr/bin/foomatic-ppdfile\":" nxloadconfig node.conf.sample || die # do not require openssl for md5sum sed -i "s:^\(#\{,1\}COMMAND_MD5SUM=\).*:\1\"md5sum\":" nxloadconfig node.conf.sample || die # fix xkb, font and rgb pathes sed -i "s:^\(#\{,1\}AGENT_EXTRA_OPTIONS_X=\).*:\1\"-nolisten tcp -co /usr/share/X11/rgb.txt -fp /usr/share/fonts/misc,/usr/share/fonts/75dpi,/usr/share/fonts/100dpi,/usr/share/fonts/TTF,/usr/share/fonts/Type1 -xkbdir /usr/share/X11/xkb\":" nxloadconfig node.conf.sample || die # no more nx-1.4 version sed -i "s:^\(#\{,1\}ENABLE_AUTORECONNECT_BEFORE_140=\).*:\1\"0\":" nxloadconfig node.conf.sample || die # fix so-lib versions and pathes sed -i 's:libXcomp.so:libXcomp.so.3:g' nxloadconfig || die sed -i 's:libXcompext.so:libXcompext.so.3:g' nxloadconfig || die sed -i 's:libXrender.so.1.2:libXrender.so.1.2.2\:$APPLICATION_LIBRARY_PATH/libXcompsh.so.3\:$APPLICATION_LIBRARY_PATH/libXcompshad.so.3:g' nxloadconfig || die # automatically generate keys sed -i "s:^\(AUTOMATIC=\).*:\1\"yes\":" nxsetup || die # fix path to Xession file sed -i "s:^\(#\{,1\}DEFAULT_X_SESSION=\).*:\1\"/usr/$(mlibdir)/X11/xdm/Xsession\":" nxloadconfig node.conf.sample || die # use 75dpi as default sed -i "s:^\(#\{,1\}DEFAULT_XDPI=\).*:\1\"75\":" nxloadconfig node.conf.sample || die } src_compile() { cd ${SRCDIR} mmake || die } src_install() { local i cd ${SRCDIR} mmake DESTDIR=${BINDIR} install || die # install wrappers for essential binaries minstalldir /usr/bin || die for i in nxdialog nxkeygen nxnode nxpasswd \ nxprint nxredir nxserver nxsetup do minstallexec -s nxclient-wrapper /usr/bin/${i} || die done # nxloadconfig gets sourced in all scripts, so symlink this file and do *not* wrap it mlink /usr/NX/bin/nxloadconfig /usr/bin/nxloadconfig || die # create needed empty directories and files to ghost-own them minstalldir /usr/NX/etc || die for i in passwords{,.orig} server.id_dsa.pub.key users.id_dsa{,.pub} client.id_dsa.key do memptyfile /usr/NX/etc/${i} || die mchmod 0600 /usr/NX/etc/${i} || die done # install the default config file minstallfile node.conf.sample /usr/NX/etc/node.conf || die minstalldir /usr/NX/home/nx/.ssh || die mchown -R nx.nx /usr/NX/home/nx || die for i in running closed failed do mkeepdir /usr/NX/var/db/${i} || die mchmod 0700 /usr/NX/var/db/${i} || die done minstallunit freenx.service || die minstalllog freenx.logrotate freenx || die minstallexec -s freenx-check-setup.sh /usr/NX/bin/freenx-check-setup || die } preinstall() { # block if nomachine nxprint is installed if [[ -n $(magequery -n nxprint) ]] then echo echo "You have 'net-misc/nxprint' installed on your system." echo echo "Both 'net-misc/nxserver-freenx' and 'net-misc/nxprint'" echo "cannot be installed at the same time. Please uninstall nxprint first!" echo die "net-misc/nxprint found." fi # block if nomachine nxnode is installed if [[ -n $(magequery -n nxnode) ]] then echo echo "You have 'net-misc/nxnode' installed on your system." echo echo "Both 'net-misc/nxserver-freenx' and 'net-misc/nxnode'" echo "cannot be installed at the same time. Please uninstall nxnode first!" echo die "net-misc/nxnode found." fi # block if nx free-edition is installed if [[ -n $(magequery -n nxserver-freeedition) ]] then echo echo "You have 'net-misc/nxserver-freeedition' installed on your system." echo echo "Both 'net-misc/nxserver-freenx' and 'net-misc/nxserver-freeedition'" echo "cannot be installed at the same time. Please uninstall nxserver-freeedition first!" echo die "net-misc/nxserver-freeedition found." fi ${MLIBDIR}/mgroupadd nx ${MLIBDIR}/museradd -o "-g nx -s /usr/NX/bin/nxserver -d /usr/NX/home/nx" nx } postinstall() { # autoscramble nx system-user password if none was set if [[ -n $(passwd -S nx | grep '[[:space:]][N|L][P| ]') ]] then usermod -p $(openssl passwd -1 $(mktemp -u | cut -d. -f2)) nx fi if [[ ! -d /usr/NX/home/nx ]] then install /usr/NX/home/nx fi chown -R nx:root /usr/NX/home/nx chmod 0700 /usr/NX/home/nx echo "Running freenx's setup script" ${MROOT}/usr/NX/bin/nxsetup --setup-nomachine-key --install mstartunit freenx.service nxserver # echo # echo "You must run 'nxsetup --setup-nomachine-key --install' to complete the installation." # echo "You also need to set a password for the user nx or pam permits ssh logins." # echo "To add a NX user run 'nxserver --adduser [username]'" # echo "and set a password with 'nxserver --passwd [username]'." # echo } post_remove() { mstopunit freenx.service }