#!/bin/bash ulimit -s unlimited shopt -s extglob # nodejs.SlackBuild # Heavily based on the original Slackware build scripts, # Modified by Stuart Winter for Slackware ARM. # # Copyright 2022 Patrick J. Volkerding, Sebeka, Minnesota, USA # All rights reserved. # # Thanks to Audrius Kažukauskas, Ryan P.C. McQuen, and Willy Sudiarto Raharjo # for the slackbuilds.org version of this script. # # This program 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 # (at your option) any later version, with the following exception: # the text of the GPL license may be omitted. # # You may have received a copy of the GNU General Public License # along with this program (most likely, a file named COPYING). If # not, see . # Record toolchain & other info for the build log: slackbuildinfo # Paths to skeleton port's source & real Slackware source tree: slackset_var_cwds # Temporary build locations: export TMPBUILD=$TMP/build-$PKGNAM export PKG=$TMP/package-$PKGNAM mkpkgdirs # Delete & re-create temporary directories then cd into $TMPBUILD # Extract source: tar xvvf $CWD/node-?$VERSION.tar.!(*sign|*asc|*sig) cd node*/ || failextract slackhousekeeping # Refresh libtool to support latest architectures: slackupdatelibtool ## 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 # Configure: slack_autotoolsprep export CFLAGS="$SLKCFLAGS" export CXXFLAGS="$SLKCFLAGS" export LDFLAGS="-Wl,--copy-dt-needed-entries" ./configure \ --prefix=/usr \ --with-intl=system-icu \ --shared-openssl \ --shared-zlib \ --shared-libuv \ --experimental-http-parser \ --shared-nghttp2 \ --shared-nghttp3 \ --shared-cares \ --shared-brotli || failconfig # Build: make $NUMJOBS || make || failmake # Install into package framework: make install DESTDIR=$PKG || failinstall # Relocate manual pages: if [ -d $PKG/usr/share/man ]; then mv -fv $PKG/usr/share/man $PKG/usr fi # Remove unneeded files: find $PKG/usr \( -name '.git*' \) -exec rm -f {} \; # Set NODE_PATH to look for globally installed modules: mkdir -p $PKG/etc/profile.d cat > $PKG/etc/profile.d/${PKGNAM}.csh << EOF #!/bin/csh setenv NODE_PATH /usr/lib${LIBDIRSUFFIX}/node_modules EOF cat > $PKG/etc/profile.d/${PKGNAM}.sh << EOF #!/bin/sh export 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/npm ; ln -sf ../../../lib${LIBDIRSUFFIX}/node_modules/npm/lib/utils/completion.sh npm ) fi # Add documentation: mkdir -vpm755 $PKG/usr/doc/$PKGNAM-$VERSION cp -fav \ AUTHORS* BUILDING* CHANGELOG* CODE_OF_CONDUCT* CONTRIBUTING* GOVERNANCE* LICENSE* README* SECURITY* \ $PKG/usr/doc/$PKGNAM-$VERSION changelogliposuction CHANGELOG $PKGNAM $VERSION # Trim down a "ChangeLog" file # Apply generic Slackware packaging policies: cd $PKG slackstripall # strip all .a archives and all ELFs #slackstriprpaths # strip rpaths slack_delete_lafiles # delete usr/lib{,64}/*.la slackgzpages -i # compress man & info pages and delete usr/info/dir slackslack # set standard Slackware file/dir permissions and ownerships slackdesc # install slack-desc and doinst.sh slackmp # run makepkg -l y -c n # Perform any final checks on the package: cd $PKG slackhlinks # search for any hard links