ruby2.SlackBuild 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. #!/bin/sh
  2. # Copyright 2015 Brenton Earl <brent@exitstatusone.com>, Tooele, UT, USA
  3. # All rights reserved.
  4. #
  5. # Modified the Official Slackware 14.1 Slackbuild
  6. #
  7. # Copyright 2008, 2009, 2010, 2011, 2012, 2013 Patrick J. Volkerding, Sebeka, MN, USA
  8. # All rights reserved.
  9. #
  10. # Parts taken from Daniel Romero's Ruby 2.0 Slackbuild script
  11. # Copyright 2013 Daniel Romero <infoslack@gmail.com>, Fortaleza, CE, BRA
  12. # All rights reserved.
  13. #
  14. # Redistribution and use of this script, with or without modification, is
  15. # permitted provided that the following conditions are met:
  16. #
  17. # 1. Redistributions of this script must retain the above copyright
  18. # notice, this list of conditions and the following disclaimer.
  19. #
  20. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
  21. # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  22. # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  23. # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  25. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  26. # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  27. # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  28. # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  29. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. PRGNAM=ruby2
  31. SRCNAM=ruby
  32. VERSION=${VERSION:-2.2.3}
  33. BUILD=${BUILD:-1}
  34. TAG=${TAG:-_SBo}
  35. if [ -z "$ARCH" ]; then
  36. case "$( uname -m )" in
  37. i?86) ARCH=i486 ;;
  38. arm*) ARCH=arm ;;
  39. *) ARCH=$( uname -m ) ;;
  40. esac
  41. fi
  42. CWD=$(pwd)
  43. TMP=${TMP:-/tmp/SBo}
  44. PKG=$TMP/package-$PRGNAM
  45. OUTPUT=${OUTPUT:-/tmp}
  46. if [ "$ARCH" = "i486" ]; then
  47. SLKCFLAGS="-march=i486 -mtune=i686 -O3 -fno-strict-aliasing"
  48. OPTFLAGS=-O3
  49. LIBDIRSUFFIX=""
  50. elif [ "$ARCH" = "s390" ]; then
  51. SLKCFLAGS="-O3 -fno-strict-aliasing"
  52. OPTFLAGS=-O3
  53. LIBDIRSUFFIX=""
  54. elif [ "$ARCH" = "x86_64" ]; then
  55. SLKCFLAGS="-O3 -fPIC -fno-strict-aliasing"
  56. OPTFLAGS=-O3
  57. LIBDIRSUFFIX="64"
  58. fi
  59. set -e
  60. rm -rf $PKG
  61. mkdir -p $TMP $PKG $OUTPUT
  62. cd $TMP
  63. rm -rf $SRCNAM-$VERSION
  64. tar xvf $CWD/$SRCNAM-$VERSION.tar.gz
  65. cd $SRCNAM-$VERSION
  66. chown -R root:root .
  67. find -L . \
  68. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  69. -o -perm 511 \) -exec chmod 755 {} \; -o \
  70. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  71. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  72. CFLAGS="$SLKCFLAGS" \
  73. optflags=$OPTFLAGS \
  74. ./configure \
  75. --prefix=/usr \
  76. --libdir=/usr/lib${LIBDIRSUFFIX} \
  77. --mandir=/usr/man \
  78. --datadir=/usr/share \
  79. --docdir=/usr/doc/$PRGNAM-$VERSION \
  80. --enable-shared \
  81. --enable-pthread \
  82. --disable-install-capi \
  83. --build=$ARCH-slackware-linux
  84. make
  85. make install DESTDIR=$PKG
  86. # Maintaining compatibility with another version of Ruby that is already installed
  87. # Remove this block if you want to just keep this version
  88. ( cd $PKG/usr/bin
  89. mv ruby ruby2
  90. mv rake rake2
  91. sed -i '0,/ruby/{s/ruby/ruby2/}' rake2
  92. mv irb irb2
  93. sed -i '0,/ruby/{s/ruby/ruby2/}' irb2
  94. mv gem gem2
  95. sed -i '0,/ruby/{s/ruby/ruby2/}' gem2
  96. mv erb erb2
  97. sed -i '0,/ruby/{s/ruby/ruby2/}' erb2
  98. mv rdoc rdoc2
  99. sed -i '0,/ruby/{s/ruby/ruby2/}' rdoc2
  100. mv ri ri2
  101. sed -i '0,/ruby/{s/ruby/ruby2/}' ri2
  102. )
  103. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  104. cp -a BSDL CONTRIBUTING* COPYING* *GPL* ChangeLog LEGAL NEWS README* \
  105. $PKG/usr/doc/$PRGNAM-$VERSION
  106. # Remove static file so it will not overwrite Slackware's ruby
  107. rm -f $PKG/usr/lib${LIBDIRSUFFIX}/libruby-static.a
  108. find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  109. | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  110. # Rename man files so it will not overwrite Slackware's ruby man files
  111. cd $PKG/usr/man/man1
  112. mv erb.1 erb2.1
  113. mv irb.1 irb2.1
  114. mv rake.1 rake2.1
  115. mv ri.1 ri2.1
  116. mv ruby.1 ruby2.1
  117. cd $TMP/$SRCNAM-$VERSION
  118. find $PKG/usr/man -type f -exec gzip -9 {} \;
  119. for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
  120. mkdir -p $PKG/install
  121. cat $CWD/slack-desc > $PKG/install/slack-desc
  122. cd $PKG
  123. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}