reduce-algebra.SlackBuild 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. #!/bin/bash
  2. # Slackware build script for reduce-algebra
  3. # Copyright 2016-2020 Alexander Verbovetsky, Moscow, Russia
  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=reduce-algebra
  24. VERSION=${VERSION:-20201007svn5424}
  25. BUILD=${BUILD:-1}
  26. TAG=${TAG:-_SBo}
  27. PKGTYPE=${PKGTYPE:-tgz}
  28. SRCNAM=Reduce-${VERSION:8}-src
  29. SLACKVER=${SLACKVER:-$(cat /etc/slackware-version | tr --delete '[[:space:]]' | tr '[:upper:]' '[:lower:]')}
  30. if [ -z "$ARCH" ]; then
  31. case "$( uname -m )" in
  32. i?86) ARCH=i586 ;;
  33. arm*) ARCH=arm ;;
  34. *) ARCH=$( uname -m ) ;;
  35. esac
  36. fi
  37. # If the variable PRINT_PACKAGE_NAME is set, then this script will report what
  38. # the name of the created package would be, and then exit. This information
  39. # could be useful to other scripts.
  40. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  41. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  42. exit 0
  43. fi
  44. TMP=${TMP:-/tmp/SBo}
  45. PKG=$TMP/package-$PRGNAM
  46. OUTPUT=${OUTPUT:-/tmp}
  47. if [ "$ARCH" = "i586" ]; then
  48. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  49. LIBDIRSUFFIX=""
  50. elif [ "$ARCH" = "i686" ]; then
  51. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  52. LIBDIRSUFFIX=""
  53. elif [ "$ARCH" = "x86_64" ]; then
  54. SLKCFLAGS="-O2 -fPIC"
  55. LIBDIRSUFFIX="64"
  56. else
  57. SLKCFLAGS="-O2"
  58. LIBDIRSUFFIX=""
  59. fi
  60. set -e
  61. rm -rf $PKG
  62. mkdir -p $TMP $PKG $OUTPUT
  63. cd $TMP
  64. rm -rf $SRCNAM ${SRCNAM}-addnl
  65. mkdir -p ${SRCNAM}-addnl
  66. tar xvf $CWD/$SRCNAM.tar.gz
  67. tar xvf $CWD/reduce-common_${VERSION:11:4}_all.tgz -C ${SRCNAM}-addnl
  68. chown -R root:root ${SRCNAM}-addnl/usr/share/doc/reduce
  69. chmod -R 644 ${SRCNAM}-addnl/usr/share/doc/reduce/*
  70. cd $SRCNAM
  71. chown -R root:root .
  72. find -L . \
  73. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  74. -o -perm 511 \) -exec chmod 755 {} \; -o \
  75. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  76. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  77. sed --in-place "s/^echo\ \$os$/echo $SLACKVER/" scripts/findos.sh
  78. CFLAGS="$SLKCFLAGS" CXXFLAGS="$SLKCFLAGS" ./configure --with-csl
  79. CFLAGS="$SLKCFLAGS" CXXFLAGS="$SLKCFLAGS" ./configure --with-psl
  80. VERBOSE='' make -j1
  81. # The Makefile has no 'install' target (yet). Let's do by hand.
  82. # The below code is mainly based on debianbuild/reduce/debian/rules
  83. # create target directories
  84. mkdir -p \
  85. $PKG/usr/bin \
  86. $PKG/usr/share/reduce/{packages,fonts} \
  87. $PKG/usr/lib$LIBDIRSUFFIX/reduce/{pslbuild/{psl,red},cslbuild/csl} \
  88. $PKG/usr/doc/$PRGNAM-$VERSION/{breduce,manual-tex} \
  89. $PKG/usr/doc/$PRGNAM-$VERSION/manual-html \
  90. $PKG/usr/man/man1 \
  91. $PKG/usr/share/emacs/site-lisp/reduce
  92. # copy documentation files
  93. cp -r BUGS Contributor-Release.txt DEPENDENCY_TRACKING README README.BUILDING \
  94. csl/reduce.doc/{BINARY-LICENSE.txt,BSD-LICENSE.txt,LGPL-2.1.txt} \
  95. doc/projects.txt buglist/ contrib/ doc/primers/ doc/notes/ generic/texmacs/ \
  96. $PKG/usr/doc/$PRGNAM-$VERSION
  97. cp doc/manual/* $PKG/usr/doc/$PRGNAM-$VERSION/manual-tex/
  98. rm -f $PKG/usr/doc/$PRGNAM-$VERSION/manual-tex/manual.pdf
  99. cp generic/breduce/breduce.{tex,bbl,pdf} $PKG/usr/doc/$PRGNAM-$VERSION/breduce/
  100. cp -r doc/primers/ $PKG/usr/doc/$PRGNAM-$VERSION/
  101. cp ../${SRCNAM}-addnl/usr/share/doc/reduce/{*.html,*.png,*.css} \
  102. $PKG/usr/doc/$PRGNAM-$VERSION/manual-html
  103. zcat ../${SRCNAM}-addnl/usr/share/doc/reduce/manual.pdf.gz \
  104. > $PKG/usr/doc/$PRGNAM-$VERSION/manual.pdf
  105. chmod -R -x+X $PKG/usr/doc/$PRGNAM-$VERSION/*
  106. # copy man files
  107. cp debianbuild/reduce/debian/{redcsl.1,redpsl.1} generic/newfront/redfront.1 generic/breduce/breduce.1 $PKG/usr/man/man1
  108. chmod -x $PKG/usr/man/man1/*
  109. sed --in-place "s/\/usr\/share\/doc\/reduce-addons\/breduce.pdf/\/usr\/doc\/$PRGNAM-$VERSION\/breduce\/breduce.pdf/" $PKG/usr/man/man1/breduce.1
  110. ln -s redfront.1 $PKG/usr/man/man1/rfcsl.1
  111. ln -s redfront.1 $PKG/usr/man/man1/rfpsl.1
  112. # copy CSL files
  113. CSLBUILDDIR="cslbuild/$(scripts/findhost.sh $(./config.guess))"
  114. cp -r $CSLBUILDDIR/csl/{reduce.img,reduce,reduce.resources} $PKG/usr/lib$LIBDIRSUFFIX/reduce/cslbuild/csl
  115. RSYNC_CMD="rsync --archive --cvs-exclude --delete --delete-excluded"
  116. $RSYNC_CMD --chmod=Fa-x --exclude "/src/***" $CSLBUILDDIR/csl/reduce.fonts/ $PKG/usr/share/reduce/fonts
  117. chmod -R -x+X $PKG/usr/share/reduce/fonts/*
  118. # copy PSL files
  119. PSLBUILDDIR="pslbuild/$(scripts/findhost.sh $(./config.guess))"
  120. $RSYNC_CMD --exclude "kernel/***" --exclude "xport.*" $PSLBUILDDIR/psl/ $PKG/usr/lib$LIBDIRSUFFIX/reduce/pslbuild/psl/
  121. chmod -x $PKG/usr/lib$LIBDIRSUFFIX/reduce/pslbuild/psl/*.b
  122. $RSYNC_CMD $PSLBUILDDIR/red/ $PKG/usr/lib$LIBDIRSUFFIX/reduce/pslbuild/red/
  123. [ -s $PKG/usr/lib$LIBDIRSUFFIX/reduce/pslbuild/red/hugo ] || rm -f $PKG/usr/lib$LIBDIRSUFFIX/reduce/pslbuild/red/hugo
  124. chmod -x $PKG/usr/lib$LIBDIRSUFFIX/reduce/pslbuild/red/*
  125. psl/saveimage.sh $PSLBUILDDIR $(realpath -e $PKG/usr/lib$LIBDIRSUFFIX/reduce/pslbuild/red) /usr/lib$LIBDIRSUFFIX/reduce/pslbuild
  126. # copy common files
  127. $RSYNC_CMD --no-perms --chmod=Fa-x --exclude "/regressions/***" packages/ $PKG/usr/share/reduce/packages/
  128. chmod a+x $PKG/usr/share/reduce/packages/{gcref/gcref,redlog/regressions/make.sh}
  129. ln -fs ../../../../share/reduce/fonts $PKG/usr/lib$LIBDIRSUFFIX/reduce/cslbuild/csl/reduce.fonts
  130. ln -fs ../../../../doc/$PRGNAM-$VERSION $PKG/usr/lib$LIBDIRSUFFIX/reduce/cslbuild/csl/reduce.doc
  131. ln -fs ../../lib$LIBDIRSUFFIX/reduce/pslbuild $PKG/usr/share/reduce/pslbuild
  132. ln -fs ../../lib$LIBDIRSUFFIX/reduce/cslbuild $PKG/usr/share/reduce/cslbuild
  133. # copy shell scripts for running REDUCE
  134. cp -a debianbuild/reduce/debian/runpsl.sh $PKG/usr/bin/redpsl
  135. cp -a debianbuild/reduce/debian/runcsl.sh $PKG/usr/bin/redcsl
  136. sed --in-place "s/\/lib\/reduce\/pslbuild/\/lib$LIBDIRSUFFIX\/reduce\/pslbuild/" $PKG/usr/bin/redpsl
  137. sed --in-place "s/\/lib\/reduce\/cslbuild/\/lib$LIBDIRSUFFIX\/reduce\/cslbuild/" $PKG/usr/bin/redcsl
  138. # copy rest
  139. cp bin/{rfcsl,rfpsl} generic/breduce/breduce $PKG/usr/bin
  140. cp -r generic/emacs/* $PKG/usr/share/emacs/site-lisp/reduce
  141. find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  142. | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  143. find $PKG/usr/man -type f -exec gzip -9 {} \;
  144. for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
  145. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  146. mkdir -p $PKG/install
  147. cat $CWD/slack-desc > $PKG/install/slack-desc
  148. cd $PKG
  149. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE