#!/bin/bash # # nodejs.SlackBuild is free software; you can redistribute it and/or modify it under the # terms of the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or any later version. # # nodejs.SlackBuild is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along with # this program; if not, write to the Free Software Foundation, Inc., 59 Temple # Place - Suite 330, Boston, MA 02111-1307, USA # # default settings PACKAGE="nodejs" PACKAGE_EXT="xz" VERSION=${VERSION:=22.21.1} BUILD=${BUILD:=1} if [ -f ~/.slackbuildrc ]; then . ~/.slackbuildrc elif [ -f ../../runtime/slackbuildrc ]; then . ../../runtime/slackbuildrc fi check_required SRC="node-v$VERSION.tar.$PACKAGE_EXT" URL="https://nodejs.org/dist/v${VERSION}/${SRC}" get_source $SRC $URL unpack_source $SRC node-v$VERSION ## Fix libdir for 64-bit: sed -i "s|lib/|lib${LIBDIRSUFFIX}/|g" tools/install.py sed -i "s|'lib'|'lib${LIBDIRSUFFIX}'|g" lib/module.js sed -i "s|'lib'|'lib${LIBDIRSUFFIX}'|g" deps/npm/lib/npm.js # Not sure if this one is really needed. #sed -i "s|math.h|cmath|" src/node_crypto.cc # Work around a bug in GCC 11.2 on Slackware 15.0: cat $CWD/nodejs22_gcc11.2_bug.patch | patch -p1 --verbose # Choose a compiler (gcc/g++ or clang/clang++): export CC=${CC:-gcc} export CXX=${CXX:-g++} echo Building ... export LDFLAGS="$SLKLDFLAGS" export CXXFLAGS="$SLKCFLAGS" export CFLAGS="$SLKCFLAGS" ./configure \ --prefix=/usr \ --shared-zlib \ --experimental-http-parser \ --shared-nghttp2 \ --shared-openssl \ --shared-brotli || exit 1 export CFLAGS="$SLKCFLAGS" export CXXFLAGS="$SLKCFLAGS" export LDFLAGS="-Wl,--copy-dt-needed-entries" make -j 2 || exit 2 make DESTDIR=$PKG install # Define NODE_PATH supporting globally installed modules: mkdir -p $PKG/etc/profile.d cat < $PKG/etc/profile.d/node.sh #!/bin/sh export NODE_PATH=/usr/lib${LIBDIRSUFFIX}/node_modules EOF cat < $PKG/etc/profile.d/node.csh #!/bin/csh setenv NODE_PATH /usr/lib${LIBDIRSUFFIX}/node_modules EOF chmod 0755 $PKG/etc/profile.d/* # Symlink bash-completion if needed: mkdir -p $PKG/usr/share/bash-completion/completions if [ ! -r $PKG/usr/share/bash-completion/completions/npm -a -r $PKG/usr/lib${LIBDIRSUFFIX}/node_modules/npm/lib/utils/completion.sh ]; then ( cd $PKG/usr/share/bash-completion/completions/ ; ln -sf ../../../lib${LIBDIRSUFFIX}/node_modules/npm/lib/utils/completion.sh npm ) fi # Relocate manual pages: if [ -d $PKG/usr/share/man ]; then mv $PKG/usr/share/man $PKG/usr # Copy these, we'll link them later: rsync -lprvt $PKG/usr/lib${LIBDIRSUFFIX}/node_modules/npm/man/ $PKG/usr/man/ fi # Compress manual pages: find $PKG/usr/man $PKG/usr/lib${LIBDIRSUFFIX}/node_modules/npm/man -type f -exec gzip -9 {} \+ for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz rm $i done # Symlink npm man pages: ( cd $PKG/usr/lib${LIBDIRSUFFIX}/node_modules/npm/man for dir in man? ; do pushd $dir for file in *.gz ; do ln -sf ../../../../../man/$dir/$file . done popd done ) mkdir -p $DOCS cp -a LICENSE *.md $DOCS chmod 644 $DOCS/* fixup_package $PKG # Clean up the extra stuff: set +u if [ "$1" = "--cleanup" ]; then rm -rf $TMP/nodejs rm -rf $PKG fi