[Slackbuilds-users] package for grab: sage

Philip Lacroix slackph at posteo.de
Wed Mar 30 13:22:45 UTC 2016


Am 28.03.2016 16:40 schrieb Willy Sudiarto Raharjo:
>> I tried to upgrade the SlackBuild to sage 7.1 but failed. I just don't
>> understand the build process of sage well enough to patch this 
>> together.
>> But let me know if you need testers! I'm a regular Sage user.
> 
> yes, it failed on pynac, which is strange since it was the same problem
> as in 7.0, but it built perfectly on 7.0, but eventually not in 7.1

Hello Willy and all

I had some problems building Sage 7.1 as well (because of pynac) but 
eventually
I could build and package it successfully, after tracking down and 
removing the
following patch:

build/pkgs/python2/patches/sys_path_security.patch

The patch is explicitly related to this bug report to upstream:

http://trac.sagemath.org/ticket/13579

I'm not sure about the actual security implications (if any) of not 
using the
patch in our SBo context, but this is the error I had when I applied it 
and the
build of pynac failed:

"not adding directory ' ' to sys.path since it's not owned by a trusted 
user."

Apparently, the patched python2 which is included in Sage didn't want to 
add
the current directory to sys.path, in order to prevent the execution of 
python
scripts from /tmp (even if I actually pointed TMP to my home directory).

Anyway, Sage 7.1 seems to be working fine here.

This is what I have done so far to the script itself, basing on the 
current
version (some of the other files were also modified - meanwhile I'll do 
some
more tests):


#-----------------------------------------------#

#!/bin/sh

# Slackware build script for sage

# Originally written by Jack Maddox <jack at auburn.edu>
# Currently maintained by Willy Sudiarto Raharjo 
<willysr at slackbuilds.org>
#
# (03.2016) Reviewed and updated by Philip Lacroix <slackph at posteo.de>
#
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, 
is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR 
IMPLIED
#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  
IN NO
#  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 
INCIDENTAL,
#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
LIMITED TO,
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
PROFITS;
#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
LIABILITY,
#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
OR
#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 
IF
#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

PRGNAM=sage
VERSION=${VERSION:-7.1}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}

if [ -z "$ARCH" ]; then
   case "$( uname -m )" in
     i?86) export ARCH=i486 ;;
     arm*) export ARCH=arm ;;
        *) export ARCH=$( uname -m ) ;;
   esac
fi

CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

SAGEROOT=${SAGEROOT:-/opt/sage}

set -e

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
cd $PRGNAM-$VERSION
chown -R root:root .
find -L . \
  \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  -o -perm 511 \) -exec chmod 755 {} \; -o \
  \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;

PRGBIN=$PKG/$SAGEROOT/bin
PRGSHR=$PKG/usr/share
PRGPFL=$PKG/etc/profile.d
PRGDOC=$PKG/usr/doc/$PRGNAM-$VERSION

mkdir -p $PKG/$SAGEROOT $PRGSHR/{applications,pixmaps} $PRGDOC $PRGPFL

# Apply FreeBSD patch to build as root (thanks to Heinz for pointing to 
it).
patch -p0 < $CWD/sage-pynac.patch

# Apply another patch to build as root.
patch -p1 < $CWD/sage-build-root.patch

# Remove problematic patch to the included python2.
rm -f build/pkgs/python2/patches/sys_path_security.patch

make

# Test all examples in the documentation (over 93,000 line of input).
[ "${TEST:-no}" = "yes" ] && make test

# Build the pdf version of the documentation (this requires LaTeX).
if [ "${PDFDOC:-no}" = "yes" ]; then
   ./sage -docbuild all pdf
   cp -av devel/sage/doc/output/pdf $PRGDOC/
fi

# Install optional packages as defined by the OPTIONALSPKG flag.
OPTIONALSPKG=${OPTIONALSPKG:-no}
if [ "$OPTIONALSPKG" != "no" ]; then
     for i in ${OPTIONALSPKG}; do
         ./sage -i $(./sage -optional | grep ${i})
     done
fi

cp -av build local sage $PKG/$SAGEROOT/

find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared 
object" \
   | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null 
|| true

# Add profile scripts.
sed "s%SAGEROOT%${SAGEROOT}%" $CWD/profile.d/sage.sh > 
$PRGPFL/$PRGNAM.sh
sed "s%SAGEROOT%${SAGEROOT}%" $CWD/profile.d/sage.csh > 
$PRGPFL/$PRGNAM.csh
chmod 0755 $PRGPFL/*

# Install scripts to SAGEROOT/bin that allow the internal sage versions 
of
# gap, gp, singular, maxima, M2, kash, mwrank, ipython, hg, and R to be 
run
# independently. Also add SAGEROOT/bin to PATH.
if [ "${INSTALLSCRIPTS:-no}" = "yes" ]; then
   mkdir $PRGBIN
   echo "install_scripts('$PRGBIN')" | ./sage
   sed -i 's%$PATH:${SAGE_ROOT}%$PATH:${SAGE_ROOT}:${SAGE_ROOT}/bin%' \
     $PRGPFL/$PRGNAM.sh
   sed -i 's%$path ${SAGE_ROOT}%$path ${SAGE_ROOT} ${SAGE_ROOT}/bin%' \
     $PRGPFL/$PRGNAM.csh
fi

# Install sagetex to a location accessible to the system TeX 
installation.
cp -a local/share/texmf $PRGSHR/

# Install desktop file, icon and logo. Symlink icon.
desktop=sage-notebook.desktop
sed "s%SAGEROOT%${SAGEROOT}%" $CWD/$desktop > 
$PRGSHR/applications/$desktop
cp -a src/doc/common/themes/sage/static/sage{icon,logo}.png 
$PRGSHR/pixmaps/
icondir=$PRGSHR/icons/hicolor/16x16/apps/ ; mkdir -p $icondir
ln -sf /opt/$PRGNAM/usr/share/pixmaps/sageicon.png $icondir/

# Install documentation.
cp -a COPYING.txt README.md VERSION.txt $PRGDOC/
cat $CWD/$PRGNAM.SlackBuild > $PRGDOC/$PRGNAM.SlackBuild

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
sed "s%SAGEROOT%${SAGEROOT}%" $CWD/doinst.sh > $PKG/install/doinst.sh

cd $PKG
/sbin/makepkg -p -l y -c n 
$OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}

#-----------------------------------------------#

Cheers
Philip


More information about the SlackBuilds-users mailing list