Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Trac #17222: Merge #17220
Browse files Browse the repository at this point in the history
  • Loading branch information
cheuberg committed Nov 28, 2015
2 parents c79211e + 867803f commit 4f62231
Show file tree
Hide file tree
Showing 1,363 changed files with 96,510 additions and 21,924 deletions.
1 change: 1 addition & 0 deletions COPYING.txt
Expand Up @@ -28,6 +28,7 @@ the licenses of the components of Sage are included below as well.

SOFTWARE LICENSE
-----------------------------------------------------------------------
arb GPLv2+
atlas Modified BSD
boehm_gc MIT-like license (see below)
backports_ssl_match_hostname Python License
Expand Down
31 changes: 23 additions & 8 deletions Makefile
Expand Up @@ -13,13 +13,28 @@ build: all-build

# Defer unknown targets to build/make/Makefile
%::
$(MAKE) configure logs
+cd build/make && ./pipestatus \
"./install '$@' 2>&1" \
"tee -a ../../logs/install.log"

logs:
mkdir -p $@
$(MAKE) build/make/Makefile
+build/bin/sage-logger \
"cd build/make && ./install '$@'" logs/install.log

# If configure was run before, rerun it with the old arguments.
# Otherwise, run configure with argument $PREREQ_OPTIONS.
build/make/Makefile: configure
rm -f config.log
mkdir -p logs/pkgs
ln -s logs/pkgs/config.log config.log
@if [ -x config.status ]; then \
./config.status --recheck && ./config.status; \
else \
./configure $$PREREQ_OPTIONS; \
fi || ( \
if [ "x$$SAGE_PORT" = x ]; then \
echo "If you would like to try to build Sage anyway (to help porting),"; \
echo "export the variable 'SAGE_PORT' to something non-empty."; \
exit 1; \
else \
echo "Since 'SAGE_PORT' is set, we will try to build anyway."; \
fi; )

# Preemptively download all standard upstream source tarballs.
download:
Expand Down Expand Up @@ -62,7 +77,7 @@ bootstrap-clean:
maintainer-clean: distclean bootstrap-clean
rm -rf upstream

micro_release: bdist-clean lib-clean
micro_release: bdist-clean sagelib-clean
@echo "Stripping binaries ..."
LC_ALL=C find local/lib local/bin -type f -exec strip '{}' ';' 2>&1 | grep -v "File format not recognized" | grep -v "File truncated" || true

Expand Down
2 changes: 1 addition & 1 deletion VERSION.txt
@@ -1 +1 @@
Sage version 6.9.beta0, released 2015-07-29
Sage version 6.10.beta2, released 2015-10-28
40 changes: 40 additions & 0 deletions build/bin/sage-logger
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
#
# sage-logger COMMAND LOGFILE
#
# Evaluate shell command COMMAND while logging stdout and stderr to
# LOGFILE. If either the command or the logging failed, return a
# non-zero exit status.
#
# AUTHOR:
#
# - Jeroen Demeyer (2015-07-26): initial version based on old pipestatus
# script (#18953)
#
#*****************************************************************************
# Copyright (C) 2015 Jeroen Demeyer <jdemeyer@cage.ugent.be>
#
# Distributed under the terms of the GNU General Public License (GPL)
# as published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
# http://www.gnu.org/licenses/
#*****************************************************************************

cmd="$1"
logfile="$2"
logdir=`dirname "$logfile"`

mkdir -p "$logdir"

# Redirect stdout and stderr to a subprocess running tee.
# We trap SIGINT such that SIGINT interrupts the main process being
# run, not the logging.
( exec 2>&1; eval "$cmd" ) | ( trap '' SIGINT; tee -a "$logfile" )

pipestatus=(${PIPESTATUS[*]})

if [ ${pipestatus[1]} -ne 0 ]; then
exit ${pipestatus[1]}
else
exit ${pipestatus[0]}
fi
158 changes: 75 additions & 83 deletions build/bin/sage-spkg
Expand Up @@ -6,7 +6,6 @@
# sage -i <options> <package name>...
#
# Options can be:
# -f: install a package even if the same version is already installed
# -s: do not delete temporary build directory
# -c: after installing, run the test suite for the spkg. This should
# override the settings of SAGE_CHECK and SAGE_CHECK_PACKAGES.
Expand Down Expand Up @@ -57,6 +56,24 @@
# Avoid surprises with character ranges [a-z] in regular expressions
export LC_ALL=C

usage()
{
cat <<EOF
Usage: sage -p <options> <package name>
If <package name> is a URL, download and install it. If it is a file
name, install it. Otherwise, search Sage's list of packages (see
'sage --package list') for a matching package, and if a match is
found, install it.
Options:
-s: do not delete the temporary build directory
-c: after installing, run the test suite for the package
-d: only download the package
EOF
}

# error_msg(header, command)
# This is for printing an error message if something went wrong.
# The first argument is the header to print, the second argument should
Expand Down Expand Up @@ -152,42 +169,31 @@ fi
# Handle special command-line options
##################################################################
if [ $# -eq 0 ]; then
echo "Currently installed packages:"
exec ls -1 "$SAGE_SPKG_INST"
usage
exit 0
fi

# Options have to come in a specific order,
# this is ensured by spkg/bin/sage.
# Parse options
INFO=0
if [ "$1" = '--info' ]; then
INFO=1
shift
fi

FORCE=0
if [ "$1" = '-f' ]; then
FORCE=1
shift
fi

DOWNLOAD_ONLY=0
if [ "$1" = '-d' ]; then
DOWNLOAD_ONLY=1
while true; do
case "$1" in
--info)
INFO=1;;
-d)
SAGE_INSTALL_FETCH_ONLY=1;;
-s)
export SAGE_KEEP_BUILT_SPKGS=yes;;
-c|--check)
SAGE_CHECK_PACKAGES=x # nonempty, so not set to '!python2' later
export SAGE_CHECK=yes;;
-*)
echo >&2 "Error: unknown option '$1'"
exit 2;;
*) break;;
esac
shift
elif [ -n "$SAGE_INSTALL_FETCH_ONLY" ]; then
DOWNLOAD_ONLY=1
fi
done

if [ "$1" = '-s' ]; then
export SAGE_KEEP_BUILT_SPKGS=yes
shift
fi

if [ "$1" = '-c' ]; then
export SAGE_CHECK=yes
SAGE_CHECK_PACKAGES=x # nonempty, so not set to '!python' later
shift
fi

##################################################################
# Figure out the package filename, download it if needed.
Expand All @@ -207,8 +213,6 @@ fi
# 3. <package>, i.e. the name of the package without a version number.
# 4. <URL>/<package>-x.y.z.spkg, i.e. the full URL where the package
# is hosted. Any local packages matching <package> are ignored.
# The package is only downloaded if it has not yet been installed
# (unless -f is given, then it's always downloaded and installed).
#
# In cases 2a, 2b and 3 we first look locally inside spkg/* for a
# matching package. Otherwise, we try to download it. In all cases,
Expand All @@ -225,7 +229,7 @@ fi
# PKG_NAME is the last path component without .spkg
# This already reduces case 2b to case 2a.
PKG_NAME=`basename "$PKG_SRC" | sed 's/\.spkg$//'`
PKG_BASE=`echo "$PKG_NAME" | sed 's/-[0-9].*//'`
PKG_BASE=`echo "$PKG_NAME" | sed 's/-.*//'`

# USE_LOCAL_SCRIPTS is a flag that if non-empty will cause
# this script to try to install the package using local metadata
Expand Down Expand Up @@ -262,7 +266,6 @@ elif [ -z "$PKG_HAS_PATH" ]; then

# Warning for experimental packages
if [ x`cat "$PKG_SCRIPTS/type"` = x"experimental" ]; then
echo # The following message appears twice in this file
echo "=========================== WARNING ==========================="
echo "You are about to download and install an experimental package."
echo "This probably won't work at all for you! There is no guarantee"
Expand Down Expand Up @@ -294,18 +297,6 @@ if [ $INFO -ne 0 -a "$USE_LOCAL_SCRIPTS" = yes ]; then
exit 0
fi

# Check whether the package is already installed. We do this before
# we download the package. We do a second check later, in case the
# user didn't supply a version number and we don't find a local
# matching package (case 3 above).
if [ $INFO -eq 0 -a $FORCE -eq 0 -a -f "$SAGE_SPKG_INST/$PKG_NAME" ]; then
echo "Package $PKG_NAME is already installed."
echo "Use 'sage -f $PKG_BASE' to force a reinstallation."
# Touch installed file such that "make" considers it up-to-date.
touch "$SAGE_SPKG_INST/$PKG_NAME"
exit 0
fi

# If we haven't found the package yet, we must download it
if [ ! -f "$PKG_SRC" ]; then
if [ -n "$PKG_NAME_UPSTREAM" ]; then
Expand All @@ -331,7 +322,7 @@ if [ ! -f "$PKG_SRC" ]; then
if [ $? -ne 0 ]; then
exit 1
fi
for repo in optional experimental standard huge archive; do
for repo in optional experimental huge; do
# Download the list of packages.
echo ">>> Checking online list of $repo packages."
# File inside DOT_SAGE should be writable
Expand Down Expand Up @@ -360,32 +351,40 @@ if [ ! -f "$PKG_SRC" ]; then
# fall through and use the .spkg file.
else
# Warn and ask the user if downloading an
# experimental or archive package.
# experimental package.
# Add a deprecation note for other packages,
# since old-style packages are deprecated.
if [ $repo = experimental ]; then
echo # The following message appears twice in this file
echo "=========================== WARNING ==========================="
echo "You are about to download and install an experimental package."
echo "This probably won't work at all for you! There is no guarantee"
echo "that it will build correctly, or behave as expected."
echo "Use at your own risk!"
echo "==============================================================="
ask_download=yes
elif [ $repo = archive ]; then
echo "=========================== WARNING ==========================="
echo "You are about to download and install an archived package."
echo "This means the package is likely to be outdated and it probably"
echo "won't work at all for you! Use at your own risk!"
echo "==============================================================="
ask_download=yes
else
ask_download=no
fi

if [ $ask_download = yes ]; then
echo "================================ WARNING ================================="
echo "You are about to download and install an unmaintained experimental"
echo "package. This probably won't work at all for you! There is no guarantee"
echo "that it will build correctly, or behave as expected. Use at your own risk!"
echo
echo "This package will be removed in future versions of SageMath. If you care"
echo "about this package, you should make a proper new-style package instead."
echo "For more information about making Sage packages, see"
echo "http://doc.sagemath.org/html/en/developer/packaging.html"
echo "=========================================================================="
read -p "Are you sure you want to continue [Y/n]? " answer
case "$answer" in
n*|N*) exit 0;;
esac
else
# Deprecated since Sage 6.9, Trac #19158
echo "================================== NOTE =================================="
echo "You are about to download and install an old-style package. While this"
echo "might still work fine, old-style packages are unmaintained and deprecated."
echo
echo "This package will be removed in future versions of SageMath. If you care"
echo "about this package, you should make a proper new-style package instead."
echo "For more information about making Sage packages, see"
echo "http://doc.sagemath.org/html/en/developer/packaging.html"
echo "=========================================================================="
echo
read -t 30 -p "Are you sure (automatically continuing in 30 seconds) [Y/n]? " answer
case "$answer" in
n*|N*) exit 0;;
esac
fi
fi
PKG_URL="$MIRROR/$repo/$pkg.spkg"
Expand All @@ -394,18 +393,11 @@ if [ ! -f "$PKG_SRC" ]; then
done

if [ -z "$PKG_URL" ]; then
echo >&2 "Error: could not find a package matching $PKG_NAME on $MIRROR"
echo >&2 "Error: could not find a package matching $PKG_NAME"
echo >&2 " Try 'sage --package list' to see the available packages"
echo >&2 " $(sage-package apropos $PKG_NAME)"
exit 1
fi

# Check a second time whether the package is already installed.
if [ $INFO -eq 0 -a $FORCE -eq 0 -a -f "$SAGE_SPKG_INST/$PKG_NAME" ]; then
echo "Package $PKG_NAME is already installed."
echo "Use 'sage -f $PKG_BASE' to force a reinstallation."
# Touch installed file such that "make" considers it up-to-date.
touch "$SAGE_SPKG_INST/$PKG_NAME"
exit 0
fi
fi

# Trac #5852: check write permissions
Expand Down Expand Up @@ -453,7 +445,7 @@ if [ -n "$SAGE_SPKG_COPY_UPSTREAM" ]; then
exit 1
fi
fi
if [ $DOWNLOAD_ONLY -ne 0 ]; then
if [ -n "$SAGE_INSTALL_FETCH_ONLY" ]; then
exit 0
fi

Expand Down Expand Up @@ -494,7 +486,7 @@ if [ ! -w "$SAGE_BUILD_DIR" ]; then
exit 1
fi
if [ ! -d "$SAGE_LOCAL" ]; then
# If you just unpack Sage and run "sage -f <pkg>" then local does not yet exist
# If you just unpack Sage and run "sage -p <pkg>" then local does not yet exist
mkdir "$SAGE_LOCAL"
fi
if [ ! -w "$SAGE_LOCAL" ]; then
Expand Down Expand Up @@ -605,7 +597,7 @@ fi
# Since Python's self-tests seem to fail on all platforms, we disable
# its test suite by default.
if [ -z "$SAGE_CHECK_PACKAGES" ]; then
SAGE_CHECK_PACKAGES='!python'
SAGE_CHECK_PACKAGES='!python2'
fi
# Allow spaces, commas, or colons as separator (the documentation suggests commas).
if echo ",$SAGE_CHECK_PACKAGES," | grep -i "[ ,:]\!$PKG_BASE[ ,:]" > /dev/null ; then
Expand Down

0 comments on commit 4f62231

Please sign in to comment.