sage-bin.SlackBuild 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. #!/bin/bash
  2. # Slackware build script for sage-bin
  3. # Copyright 2018 Duncan Roe, Melbourne, Australia
  4. # All rights reserved.
  5. #
  6. # Redistribution and use of this script, with or without modification, is
  7. # permitted provided that the following conditions are met:
  8. #
  9. # 1. Redistributions of this script must retain the above copyright
  10. # notice, this list of conditions and the following disclaimer.
  11. #
  12. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
  13. # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  15. # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  16. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  17. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  18. # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  19. # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  20. # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  21. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. cd $(dirname $0) ; CWD=$(pwd)
  23. PRGNAM=sage-bin
  24. VERSION=${VERSION:-9.4}
  25. DEBVERSION=${DEBVERSION:-11}
  26. BUILD=${BUILD:-1}
  27. TAG=${TAG:-_SBo}
  28. PKGTYPE=${PKGTYPE:-tgz}
  29. SLK_VERSION=${SLK_VERSION:-$(cat /etc/slackware-version|cut -d' ' -f2)}
  30. [ $SLK_VERSION = 14.2 ] && PYTHON=python || PYTHON=python2
  31. if [ -z "$ARCH" ]; then
  32. case "$( uname -m )" in
  33. i?86) ARCH=i686 ;;
  34. arm*) ARCH=arm ;;
  35. *) ARCH=$( uname -m ) ;;
  36. esac
  37. fi
  38. # If the variable PRINT_PACKAGE_NAME is set, then this script will report what
  39. # the name of the created package would be, and then exit. This information
  40. # could be useful to other scripts.
  41. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  42. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  43. exit 0
  44. fi
  45. TMP=${TMP:-/tmp/SBo}
  46. PKG=$TMP/package-$PRGNAM
  47. OUTPUT=${OUTPUT:-/tmp}
  48. if [ "$ARCH" != "x86_64" ] && [ "$ARCH" != "i686" ]; then
  49. echo "Architecture $ARCH is not supported" >&2
  50. exit 1
  51. fi
  52. set -e
  53. rm -rf $PKG
  54. mkdir -p $TMP $PKG $OUTPUT
  55. cd $PKG
  56. mkdir root proc opt
  57. tar xvf $CWD/sage-$VERSION-Debian_GNU_Linux_$DEBVERSION-$ARCH.tar.bz2 -C $PKG/opt
  58. [ ! -r $CWD/$VERSION.patch ] || patch -p0 < $CWD/$VERSION.patch
  59. [ ! -r $CWD/${VERSION}_sh ] || . $CWD/${VERSION}_sh
  60. chown -R root:root .
  61. find -L . \
  62. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  63. -o -perm 511 \) -exec chmod 755 {} \; -o \
  64. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  65. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  66. mkchroot .
  67. addchroot . $PYTHON sed util-linux
  68. chroot . <<////
  69. export SAGE_BANNER=bare
  70. mount -t proc proc proc
  71. opt/SageMath/sage < /dev/null # Run sage patch system
  72. umount proc
  73. exit
  74. ////
  75. # Remove mkchroot leftovers
  76. rm -rf Tools bin dev etc lib64 proc root sbin usr
  77. # and other junk
  78. rm -rf $PKG/opt/SageMath/.git
  79. mkdir -p $PKG/etc/profile.d
  80. install -D -m0755 $CWD/profile.d/sage.sh $PKG/etc/profile.d
  81. install -D -m0755 $CWD/profile.d/sage.csh $PKG/etc/profile.d
  82. mkdir -p $PKG/usr/share/texmf/tex/latex
  83. ln -sf /opt/SageMath/local/share/texmf/tex/latex/sagetex $PKG/usr/share/texmf/tex/latex
  84. mkdir -p $PKG/usr/share/applications
  85. for d in $PKG/opt/SageMath/local/share/applications/*.desktop ; do
  86. ln -sf /opt/SageMath/local/share/applications/$(basename $d) $PKG/usr/share/applications
  87. done
  88. for res in 16x16 32x32 64x64 128x128 ; do
  89. mkdir -p $PKG/usr/share/icons/hicolor/$res/{apps,mimetypes}
  90. ln -sf /opt/SageMath/local/share/icons/hicolor/$res/xcas.png \
  91. $PKG/usr/share/icons/hicolor/$res/apps
  92. ln -sf /opt/SageMath/local/share/icons/hicolor/$res/application-x-xcas.png \
  93. $PKG/usr/share/icons/hicolor/$res/mimetypes
  94. done
  95. # Some man pages and their symlinks are already gzipped
  96. find $PKG/opt/SageMath/local/share/man -type f ! -name '*.gz' -exec gzip -9 {} \;
  97. for i in $( find $PKG/opt/SageMath/local/share/man -type l ! -name '*.gz' ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
  98. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  99. cp -a opt/SageMath/*.{md,txt} $PKG/usr/doc/$PRGNAM-$VERSION
  100. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  101. mkdir -p $PKG/install
  102. cat $CWD/slack-desc > $PKG/install/slack-desc
  103. cat $CWD/doinst.sh > $PKG/install/doinst.sh
  104. cd $PKG
  105. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE