sage.SlackBuild 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. #!/bin/bash
  2. # Slackware build script for sage
  3. # Written by Jack Maddox <jack@auburn.edu>
  4. # Currently maintained by Christopher L Duston <christopher.duston@protonmail.com>
  5. # Last update Jan 2022.
  6. #
  7. # All rights reserved.
  8. #
  9. # Redistribution and use of this script, with or without modification, is
  10. # permitted provided that the following conditions are met:
  11. #
  12. # 1. Redistributions of this script must retain the above copyright
  13. # notice, this list of conditions and the following disclaimer.
  14. #
  15. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
  16. # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  17. # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  18. # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  19. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  20. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  21. # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  22. # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  23. # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  24. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. cd $(dirname $0) ; CWD=$(pwd)
  26. PRGNAM=sage
  27. VERSION=${VERSION:-9.4}
  28. BUILD=${BUILD:-1}
  29. TAG=${TAG:-_SBo}
  30. PKGTYPE=${PKGTYPE:-tgz}
  31. if [ -z "$ARCH" ]; then
  32. case "$( uname -m )" in
  33. i?86) export ARCH=i586 ;;
  34. arm*) export ARCH=arm ;;
  35. *) export ARCH=$( uname -m ) ;;
  36. esac
  37. fi
  38. #### These lines are to ensure the build can happen on multilib systems.
  39. if [ "$ARCH" = "i586" ]; then
  40. LIBDIRSUFFIX=""
  41. elif [ "$ARCH" = "x86_64" ]; then
  42. LIBDIRSUFFIX="64"
  43. else
  44. LIBDIRSUFFIX=""
  45. fi
  46. ####
  47. # SAGE_ROOT/bin/sage points to the build directory, which can't be
  48. # in the /tmp folder if we want it to remain after installation.
  49. # So we'll put it in /var/tmp. Maybe just sticking it in /usr is better.
  50. # If the variable PRINT_PACKAGE_NAME is set, then this script will report what
  51. # the name of the created package would be, and then exit. This information
  52. # could be useful to other scripts.
  53. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  54. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  55. exit 0
  56. fi
  57. TMP=${TMP:-/var/tmp/SBo}
  58. PKG=$TMP/package-$PRGNAM
  59. OUTPUT=${OUTPUT:-/tmp}
  60. SAGEROOT=${SAGEROOT:-/opt/sage}
  61. set -e
  62. rm -rf $PKG
  63. mkdir -p $TMP $PKG $OUTPUT
  64. cd $TMP
  65. rm -rf $PRGNAM-$VERSION
  66. tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
  67. cd $PRGNAM-$VERSION
  68. chown -R root:root .
  69. find -L . \
  70. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  71. -o -perm 511 \) -exec chmod 755 {} \; -o \
  72. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  73. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  74. mkdir -p $PKG/$SAGEROOT $PKG/usr/share/{applications,pixmaps} \
  75. $PKG/usr/doc/$PRGNAM-$VERSION $PKG/etc/profile.d
  76. # The docs do not build correctly, so instead of make, do the following:
  77. LDFLAGS="-L/usr/lib${LIBDIRSUFFIX}" \
  78. ./configure \
  79. --enable-build-as-root
  80. make build
  81. # test all examples in the documentation (over 93,000 line of input)
  82. [ "${TEST:-no}" = "yes" ] && make test
  83. # build the pdf version of the documentation
  84. # (Note: this requires a LaTeX installation)
  85. if [ "${PDFDOC:-no}" = "yes" ]; then
  86. ./sage -docbuild all pdf
  87. cp -av devel/sage/doc/output/pdf $PKG/usr/doc/$PRGNAM-$VERSION
  88. fi
  89. # install optional packages as defined by the OPTIONALSPKG flag
  90. OPTIONALSPKG=${OPTIONALSPKG:-no}
  91. if [ "$OPTIONALSPKG" != "no" ]; then
  92. for i in ${OPTIONALSPKG}; do
  93. ./sage -i $(./sage -optional | grep ${i})
  94. done
  95. fi
  96. cp -av * $PKG/$SAGEROOT
  97. rm -rf $PKG/$SAGEROOT/{upstream,logs}
  98. find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  99. | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  100. # Add profile scripts
  101. sed "s%SAGEROOT%${SAGEROOT}%" $CWD/profile.d/sage.sh > $PKG/etc/profile.d/sage.sh
  102. sed "s%SAGEROOT%${SAGEROOT}%" $CWD/profile.d/sage.csh > $PKG/etc/profile.d/sage.csh
  103. chmod 0755 $PKG/etc/profile.d/*
  104. # install scripts to SAGEROOT/bin that allow the internal sage versions of: gap,
  105. # gp, singular, maxima, M2, kash, mwrank, ipython, hg, and R to be run independently
  106. # and add SAGEROOT/bin to the PATH
  107. if [ "${INSTALLSCRIPTS:-no}" = "yes" ]; then
  108. mkdir $PKG$SAGEROOT/bin
  109. echo "install_scripts('$PKG$SAGEROOT/bin')" | ./sage
  110. sed -i 's%$PATH:${SAGE_ROOT}%$PATH:${SAGE_ROOT}:${SAGE_ROOT}/bin%' $PKG/etc/profile.d/sage.sh
  111. sed -i 's%$path ${SAGE_ROOT}%$path ${SAGE_ROOT} ${SAGE_ROOT}/bin%' $PKG/etc/profile.d/sage.csh
  112. fi
  113. sed "s%SAGEROOT%${SAGEROOT}%" $CWD/$PRGNAM-notebook.desktop > $PKG/usr/share/applications/$PRGNAM-notebook.desktop
  114. cp src/doc/common/themes/sage/static/sageicon.png $PKG/usr/share/pixmaps/
  115. # Put a line here which *actually* adds sage to the path
  116. # install sagetex to a location that is accessible to the system TeX installation
  117. cp -a local/share/texmf $PKG/usr/share
  118. cp -a COPYING.txt README.md $PKG/usr/doc/$PRGNAM-$VERSION
  119. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  120. mkdir -p $PKG/install
  121. cat $CWD/slack-desc > $PKG/install/slack-desc
  122. sed "s%SAGEROOT%${SAGEROOT}%" $CWD/doinst.sh > $PKG/install/doinst.sh
  123. cd $PKG
  124. /sbin/makepkg -p -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE