Some SlackBuild scripts for Slackware.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

131 lines
3.6 KiB

  1. #!/bin/bash
  2. # Build script for Slackware
  3. # Copyright (C) 2014,2015,2016,2020 Damien Goutte-Gattat
  4. #
  5. # Redistribution and use of this script, with or without modifications,
  6. # is permitted provided that the following conditions are met:
  7. #
  8. # 1. Redistributions of this script must retain the above copyright
  9. # notice, this list of conditions and the following disclaimer.
  10. #
  11. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AS IS'' AND ANY EXPRESS OR
  12. # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  13. # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  14. # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
  15. # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  16. # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  17. # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  18. # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  19. # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  20. # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  21. # POSSIBILITY OF SUCH DAMAGE.
  22. #
  23. # Contact: Damien Goutte-Gattat <dgouttegattat@incenp.org>
  24. #
  25. # Latest matplotlib sourcecode is available at: <http://matplotlib.org/>.
  26. #
  27. # Depends: l/numpy, l/python-cycler, l/python-dateutil, l/python-kiwisolver
  28. #
  29. # Note: This package (along with l/numpy) must be built with a patched
  30. # version of d/Cython. See <https://github.com/cython/cython/issues/3269>.
  31. # Source package infos
  32. NAMESRC=${NAMESRC:-matplotlib}
  33. VERSION=${VERSION:-3.2.2}
  34. ARCHIVE=${ARCHIVE:-$NAMESRC-$VERSION.tar.gz}
  35. # Build infos
  36. NAMEPKG=${NAMEPKG:-matplotlib}
  37. BUILD=${BUILD:-1GGD}
  38. ARCH=${ARCH:-$(uname -m | sed 's/^i.86$/i486/;s/^arm.*/arm/')}
  39. EXT=${EXT:-txz}
  40. # Directories
  41. TMP=${TMP:-/tmp}
  42. OUT=${OUT:-$TMP/build}
  43. PKG=${PKG:-$OUT/$NAMEPKG}
  44. CWD=$(pwd)
  45. [ $ARCH = x86_64 ] && LIBDIRSUFFIX=64 || LIBDIRSUFFIX=
  46. set -e # Quit if a command returns non-zero
  47. # Sanity checks
  48. if [ $UID -eq 0 ]; then
  49. echo "You should NOT run this script as ROOT!"
  50. exit 1
  51. fi
  52. if [ ! -d $TMP ]; then
  53. echo "$TMP does not exists or is not a directory!"
  54. exit 1
  55. fi
  56. # Compilation flags
  57. case "$ARCH" in
  58. i?86)
  59. CPUOPT="-O2 -march=$ARCH -mtune=i686"
  60. ;;
  61. x86_64)
  62. CPUOPT="-O2 -fPIC"
  63. ;;
  64. *)
  65. CPUOPT="-O2"
  66. ;;
  67. esac
  68. # Get and verify the source archive
  69. if [ ! -r $ARCHIVE ]; then
  70. pip3 download --no-binary :all: --no-deps $NAMESRC==$VERSION
  71. fi
  72. sha256sum -c $ARCHIVE.sha256
  73. NAME=$(tar ft $ARCHIVE | head -n 1 | cut -d / -f 1)
  74. # Compile
  75. cd $TMP
  76. echo "Building $ARCHIVE..."
  77. tar xf $CWD/$ARCHIVE
  78. cd $NAME
  79. CFLAGS="$CPUOPT" \
  80. CXXFLAGS="$CPUOPT" \
  81. python3 setup.py build
  82. python3 setup.py install --root=$PKG
  83. # Strip binaries
  84. find $PKG | xargs file | grep "ELF \(32\|64\)-bit LSB" | cut -d : -f 1 | \
  85. xargs strip --strip-unneeded 2> /dev/null
  86. # Install the documentation
  87. mkdir -p $PKG/usr/doc/$NAME
  88. install -m 644 README.rst $PKG/usr/doc/$NAME
  89. cp -r LICENSE $PKG/usr/doc/$NAME/LICENSE
  90. # Build HTML docs if possible
  91. export PYTHONPATH=$PKG/usr/lib$LIBDIRSUFFIX/python3.8/site-packages
  92. if sphinx-build -b html docs $PKG/usr/doc/$NAME/html ; then
  93. rm -rf $PKG/usr/doc/$NAME/html/.{buildinfo,doctrees}
  94. fi
  95. # Copy slack-desc file
  96. install -D -m 644 $CWD/slack-desc $PKG/install/slack-desc
  97. # Add dependency infos
  98. cat <<EOF > $PKG/install/slack-required
  99. numpy
  100. python-cycler
  101. python-dateutil
  102. python-kiwisolver
  103. EOF
  104. # Package the tree
  105. cd $PKG
  106. mkdir -p $OUT
  107. PACKAGING="
  108. chown root:root . -R
  109. /sbin/makepkg -l y -c n $OUT/$NAMEPKG-$VERSION-$ARCH-$BUILD.$EXT
  110. rm -rf $PKG
  111. rm -rf $TMP/$NAME
  112. "
  113. if type -p fakeroot ; then
  114. echo "$PACKAGING" | fakeroot
  115. else
  116. su -c "$PACKAGING"
  117. fi