nodejs.SlackBuild 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #!/bin/bash
  2. # Slackware build script for nodejs
  3. # Thanks to Audrius Kažukauskas
  4. # Ryan P.C. McQuen | Everett, WA | ryanpcmcquen@member.fsf.org
  5. # Willy Sudiarto Raharjo <willysr@slackbuilds.org>
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 2 of the License, or
  9. # (at your option) any later version, with the following exception:
  10. # the text of the GPL license may be omitted.
  11. # This program is distributed in the hope that it will be useful, but
  12. # without any warranty; without even the implied warranty of
  13. # merchantability or fitness for a particular purpose. Compiling,
  14. # interpreting, executing or merely reading the text of the program
  15. # may result in lapses of consciousness and/or very being, up to and
  16. # including the end of all existence and the Universe as we know it.
  17. # See the GNU General Public License for more details.
  18. # You may have received a copy of the GNU General Public License
  19. # along with this program (most likely, a file named COPYING). If
  20. # not, see <https://www.gnu.org/licenses/>.
  21. cd $(dirname $0) ; CWD=$(pwd)
  22. PRGNAM=nodejs
  23. SRCNAM=node
  24. VERSION=${VERSION:-17.9.0}
  25. BUILD=${BUILD:-1}
  26. TAG=${TAG:-_SBo}
  27. PKGTYPE=${PKGTYPE:-tgz}
  28. if [ -z "$ARCH" ]; then
  29. case "$( uname -m )" in
  30. i?86) ARCH=i586 ;;
  31. arm*) ARCH=arm ;;
  32. *) ARCH=$( uname -m ) ;;
  33. esac
  34. fi
  35. # If the variable PRINT_PACKAGE_NAME is set, then this script will report what
  36. # the name of the created package would be, and then exit. This information
  37. # could be useful to other scripts.
  38. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  39. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  40. exit 0
  41. fi
  42. TMP=${TMP:-/tmp/SBo}
  43. PKG=$TMP/package-$PRGNAM
  44. OUTPUT=${OUTPUT:-/tmp}
  45. if [ "$ARCH" = "i586" ]; then
  46. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  47. LIBDIRSUFFIX=""
  48. elif [ "$ARCH" = "i686" ]; then
  49. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  50. LIBDIRSUFFIX=""
  51. elif [ "$ARCH" = "x86_64" ]; then
  52. SLKCFLAGS="-O2 -fPIC"
  53. LIBDIRSUFFIX="64"
  54. else
  55. SLKCFLAGS="-O2"
  56. LIBDIRSUFFIX=""
  57. fi
  58. set -eu
  59. rm -rf $PKG
  60. mkdir -p $TMP $PKG $OUTPUT
  61. cd $TMP
  62. rm -rf $SRCNAM-v$VERSION
  63. tar xvf $CWD/$SRCNAM-v$VERSION.tar.xz
  64. cd $SRCNAM-v$VERSION
  65. chown -R root:root .
  66. find -L . \
  67. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  68. -o -perm 511 \) -exec chmod 755 {} \; -o \
  69. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  70. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  71. ## Fix man page path.
  72. sed -i 's|share/||' tools/install.py
  73. ## Fix libdir for 64-bit.
  74. sed -i "s|lib/|lib${LIBDIRSUFFIX}/|g" tools/install.py
  75. sed -i "s/'lib'/'lib${LIBDIRSUFFIX}'/" lib/module.js
  76. sed -i "s|\"lib\"|\"lib${LIBDIRSUFFIX}\"|" deps/npm/lib/npm.js
  77. sed -i "s|math.h|cmath|" src/node_crypto.cc
  78. ./configure \
  79. --prefix=/usr \
  80. --shared-zlib \
  81. --ninja
  82. make CFLAGS="$SLKCFLAGS" CXXFLAGS="$SLKCFLAGS"
  83. make install DESTDIR=$PKG
  84. find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  85. | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  86. find $PKG/usr/man -type f -exec gzip -9 {} \;
  87. for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
  88. ## Add bash completion file for npm.
  89. install -D -m 644 $CWD/npm.sh $PKG/usr/share/bash-completion/completions/npm
  90. ## Remove unneeded files.
  91. find $PKG/usr \( -name '.git*' \) -exec rm -f {} \;
  92. ## Set NODE_PATH to look for globally installed modules.
  93. mkdir -p $PKG/etc/profile.d
  94. cat > $PKG/etc/profile.d/${SRCNAM}.csh << EOF
  95. #!/bin/csh
  96. setenv NODE_PATH /usr/lib${LIBDIRSUFFIX}/node_modules
  97. EOF
  98. cat > $PKG/etc/profile.d/${SRCNAM}.sh << EOF
  99. #!/bin/sh
  100. export NODE_PATH=/usr/lib${LIBDIRSUFFIX}/node_modules
  101. EOF
  102. chmod 0755 $PKG/etc/profile.d/*
  103. # Fix some files path
  104. mv $PKG/usr/doc/node $PKG/usr/share/nodejs
  105. mv $PKG/usr/systemtap $PKG/usr/share/systemtap
  106. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  107. cp -a AUTHORS LICENSE *.md $PKG/usr/doc/$PRGNAM-$VERSION
  108. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  109. mkdir -p $PKG/install
  110. cat $CWD/slack-desc > $PKG/install/slack-desc
  111. cd $PKG
  112. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE