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

Commit

Permalink
build/bin/sage-spkg, src/bin/sage: Remove support for installing old-…
Browse files Browse the repository at this point in the history
…style SPKGs
  • Loading branch information
Matthias Koeppe committed Jun 16, 2020
1 parent e2dcdee commit e0b6112
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 241 deletions.
202 changes: 11 additions & 191 deletions build/bin/sage-spkg
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,10 @@ export LC_ALL=C
usage()
{
cat <<EOF
Usage: sage -p <options> <package name>
Usage: sage -i <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.
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
Expand Down Expand Up @@ -249,32 +247,13 @@ done
# Figure out the package filename, download it if needed.
##################################################################
# One should be able to install a package using
# sage -i <package-name> where <package-name> can be any of the
# following values:
#
# 1a. /path/to/<package>-x.y.z.spkg, i.e. the package is found somewhere
# in your file system and you're giving an absolute path.
# 1b. relative/path/to/<package>-x.y.z.spkg, the same with a relative
# path.
# 2a. <package>-x.y.z, i.e. the name of the package plus the package's
# version numbers.
# 2b. <package>-x.y.z.spkg, i.e. the name of the package in addition to
# the version numbers and the ".spkg" extension.
# 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.
#
# 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,
# we reduce to case 1a.
#
# See #7544 and #12602.
#
# sage -i <package-name>

PKG_SRC="$1"
# Does PKG_SRC contain a slash?
if echo "$PKG_SRC" | grep / >/dev/null; then
PKG_HAS_PATH=yes
echo >&2 "Error: Installing old-style SPKGs is no longer supported"
exit 1
fi
# PKG_NAME is the last path component without .spkg
# This already reduces case 2b to case 2a.
Expand Down Expand Up @@ -374,154 +353,8 @@ if [ ! -f "$PKG_SRC" ]; then
fi
PKG_SRC="$SAGE_DISTFILES/$PKG_NAME_UPSTREAM"
else
# Handle all the legacy cruft. This branch can be deleted once
# we get rid of old-style spkgs
if [ $YES = -1 ]; then
# User provided -n option, so don't even try to download the package"
echo "Old-style packages disabled by use of '-n' option"
exit 1
fi
if [ $INFO -eq 0 ]; then
echo "Attempting to download package $PKG_NAME"
else
echo "Attempting to get on-line info for package $PKG_NAME"
fi

# Reduce everything to case 4: full URL.
if [ -n "$PKG_HAS_PATH" ]; then
PKG_URL="$PKG_SRC"
else
# Handle cases 2a and 3, where the package name is something
# like "foo" or "foo-1.2.3".
MIRROR=$(sage-download-file --print-fastest-mirror)/spkg
if [ $? -ne 0 ]; then
error_msg "Error downloading list of packages"
exit 1
fi
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
repolist="${DOT_SAGE}/${repo}.list"
sage-download-file --quiet "$MIRROR/$repo/list" $repolist
if [ $? -ne 0 ]; then
rm -f $repolist
error_msg "Error downloading $MIRROR/$repo/list"
exit 1
fi

# The contrived sed commands print out either ${PKG_NAME} if
# it appears as a complete line or some string starting with
# ${PKG_NAME}- whichever occurs first.
# Tested with GNU sed, BSD sed (on OS X) and Solaris sed.
pkg=`sed -n -f <( echo "/^${PKG_NAME}\$/{p;q;}" && echo "/^${PKG_NAME}-/{p;q;}" ) $repolist`
rm -f $repolist
if [ -n "$pkg" ]; then
echo ">>> Found $pkg"
PKG_NAME=$pkg

# If INFO is set, try downloading only the .txt file
if [ $INFO -eq 1 ]; then
PKG_URL="$MIRROR/$repo/$pkg.txt"
sage-download-file --quiet "$PKG_URL" && exit 0
# If the download failed (for whatever reason),
# fall through and use the .spkg file.
else
if [ $YES != 1 ]; then
# Warn and ask the user if downloading an
# experimental package.
# Add a deprecation note for other packages,
# since old-style packages are deprecated.
if [ $repo = experimental ]; then
write_to_tty <<EOF
================================ WARNING =================================
You are about to download and install an unmaintained experimental
package. This probably won't work at all for you! There is no guarantee
that it will build correctly, or behave as expected. Use at your own risk!
This package will be removed in future versions of SageMath. If you care
about this package, you should make a proper new-style package instead.
For more information about making Sage packages, see
http://doc.sagemath.org/html/en/developer/packaging.html
==========================================================================
EOF
if [ $? -ne 0 ]; then
echo "Terminal not available for prompting. Use 'sage -i -y $PKG_BASE'"
echo "to install experimental packages in non-interactive mode."
YES=-1
fi
if [ $YES != -1 ]; then
read -p "Are you sure you want to continue [Y/n]? " answer < /dev/tty > /dev/tty 2>&1
else
answer=n
fi
case "$answer" in
n*|N*) exit 1;;
esac
else
# Deprecated since Sage 6.9, Trac #19158
write_to_tty <<EOF
================================== NOTE ==================================
You are about to download and install an old-style package. While this
might still work fine, old-style packages are unmaintained and deprecated.
This package will be removed in future versions of SageMath. If you care
about this package, you should make a proper new-style package instead.
For more information about making Sage packages, see
http://doc.sagemath.org/html/en/developer/packaging.html
==========================================================================
EOF
if [ $? = 0 -a $YES != -1 ]; then
read -t 30 -p "Are you sure (automatically continuing in 30 seconds) [Y/n]? " answer < /dev/tty > /dev/tty 2>&1
elif [ $YES = -1 ]; then
answer=n
else
answer=y
fi
case "$answer" in
n*|N*) exit 1;;
esac
fi
# Confirm the user's input. (This gives important
# feedback to the user when output is redirected to a logfile.)
echo > /dev/tty "OK, installing $PKG_NAME now..."
fi
fi
PKG_URL="$MIRROR/$repo/$pkg.spkg"
break
fi
done

if [ -z "$PKG_URL" ]; then
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
fi

# Trac #5852: check write permissions
mkdir -p "$SAGE_DISTFILES"
if [ ! -w "$SAGE_DISTFILES" ]; then
error_msg "Error: no write access to packages directory $SAGE_PACKAGES"
exit 1
fi
cd "$SAGE_DISTFILES" || exit $?

# Download to a temporary file (such that we don't end up with a
# corrupted .spkg file).
PKG_TMP="${PKG_URL##*/}.tmp"
echo ">>> Trying to download $PKG_URL"
sage-download-file "$PKG_URL" "$PKG_TMP"
if [ $? -ne 0 ]; then
# Delete failed download
rm -f "$PKG_TMP"
error_msg "Error downloading $PKG_URL"
exit 1
fi

PKG_SRC="`pwd`/${PKG_URL##*/}"
mv -f "$PKG_TMP" "$PKG_SRC"
echo >&2 "Error: Installing old-style SPKGs is no longer supported"
exit 1
fi
fi

Expand Down Expand Up @@ -634,21 +467,8 @@ if [ "$USE_LOCAL_SCRIPTS" = yes ]; then
exit 1
fi
else
# Old-style package (deprecated)
echo "Extracting package $PKG_SRC"
ls -l "$PKG_SRC"

sage-uncompress-spkg "$PKG_SRC"
if [ $? -ne 0 ]; then
error_msg "Error: failed to extract $PKG_SRC"
exit 1
fi

cd "$PKG_NAME"
if [ $? -ne 0 ]; then
error_msg "Error: after extracting, the directory '$PKG_NAME' does not exist"
exit 1
fi
echo >&2 "Error: Installing old-style SPKGs is no longer supported."
exit 1
fi

echo "Finished extraction"
Expand Down Expand Up @@ -1047,4 +867,4 @@ fi
touch "$SAGE_LOCAL/lib/sage-force-relocate.txt"


echo "Finished installing $PKG_NAME.spkg"
echo "Finished installing $PKG_NAME"
52 changes: 5 additions & 47 deletions src/bin/sage
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,6 @@ usage_advanced() {
echo " build correctly; use at your own risk"
echo " -n -- reply no to prompts about experimental"
echo " and old-style packages"
echo " -p [opts] [packages]-- install the given Sage packages, without dependency"
echo " checking and with support for old-style spkgs."
echo " Options are -c, -d and -s with the same meaning as"
echo " for the -i command"
echo " -info [packages] -- print the SPKG.txt or SPKG.rst of the given packages,"
echo " and some additional information."
echo " --location -- if needed, fix paths to make Sage relocatable"
Expand Down Expand Up @@ -385,7 +381,7 @@ if [ "$1" = '-i' ]; then
# See https://trac.sagemath.org/ticket/25078
if ! echo "$ALL_TARGETS" | grep "^${PKG}$" >/dev/null; then
echo >&2 "Error: package '$PKG' not found"
echo >&2 "Note: if it is an old-style package, use -p instead of -i to install it"
echo >&2 "Note: if it is an old-style package, installing these is no longer supported"
exit 1
fi
$MAKE SAGE_SPKG="sage-spkg $INSTALL_OPTIONS" "$PKG"
Expand Down Expand Up @@ -942,41 +938,6 @@ if [ "$1" = '--location' ]; then
exit 0
fi


install() {
maybe_sage_location

for PKG in "$@"
do
# Check for options
case "$PKG" in
-*)
INSTALL_OPTIONS="$INSTALL_OPTIONS $PKG"
continue;;
esac

PKG_NAME=`echo "$PKG" | sed -e "s/\.spkg$//"`
PKG_NAME=`basename "$PKG_NAME"`

sage-logger \
"sage-spkg $INSTALL_OPTIONS '$PKG'" "$SAGE_LOGS/$PKG_NAME.log"
# Do not try to install further packages if one failed
if [ $? -ne 0 ]; then
exit 1
fi
done
# Display a message if we actually installed something (using this
# file, generated by sage-spkg, is a bit of a hack though)
if [ -f "$SAGE_LOCAL/lib/sage-force-relocate.txt" ]; then
echo
echo "Warning: it might be needed to update the Sage library before"
echo "installed packages work: you should run 'make' from \$SAGE_ROOT"
echo "before running Sage."
fi
exit 0
}


if [ "$1" = '-package' -o "$1" = "--package" ]; then
shift
exec sage-package $@
Expand All @@ -1003,12 +964,8 @@ if [ "$1" = '-installed' -o "$1" = "--installed" ]; then
fi

if [ "$1" = '-p' ]; then
shift
# If there are no further arguments, display usage help.
if [ $# -eq 0 ]; then
exec sage-spkg
fi
install "$@"
echo "Error: Installing old-style SPKGs is no longer supported."
exit 1
fi

if [ "$1" = '-info' -o "$1" = '--info' ]; then
Expand Down Expand Up @@ -1110,7 +1067,8 @@ fi
if [ $# -ge 1 ]; then
T=`echo "$1" | sed -e "s/.*\.//"`
if [ "$T" = "spkg" ]; then
install "$@"
echo "Error: Installing old-style SPKGs is no longer supported."
exit 1
fi
sage_setup
unset TERM # See Trac #12263
Expand Down
3 changes: 0 additions & 3 deletions src/doc/en/reference/repl/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,6 @@ Command-line options for Sage

.. rubric:: Making Sage packages or distributions

- ``--pkg dir`` -- create the Sage package ``dir.spkg`` from the
directory ``dir``
- ``--pkg_nc dir`` -- as ``--pkg``, but do not compress the package
- ``--merge`` -- run Sage's automatic merge and test script
- ``--sdist`` -- build a source distribution of Sage

Expand Down

0 comments on commit e0b6112

Please sign in to comment.