diff --git a/build/bin/sage-spkg b/build/bin/sage-spkg index 3d47c0cc84b..7a9d35f8a3b 100755 --- a/build/bin/sage-spkg +++ b/build/bin/sage-spkg @@ -3,7 +3,7 @@ # sage-spkg: install a Sage package # # This script is typically invoked by giving the command -# sage -i ... +# sage {-i|-p} ... # # Options can be: # -s: do not delete temporary build directory @@ -75,12 +75,10 @@ export LC_ALL=C.UTF-8 usage() { cat < +Usage: sage {-i|-p} -If 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 @@ -251,37 +249,16 @@ done # Figure out the package filename, download it if needed. ################################################################## # One should be able to install a package using -# sage -i where can be any of the -# following values: -# -# 1a. /path/to/-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/-x.y.z.spkg, the same with a relative -# path. -# 2a. -x.y.z, i.e. the name of the package plus the package's -# version numbers. -# 2b. -x.y.z.spkg, i.e. the name of the package in addition to -# the version numbers and the ".spkg" extension. -# 3. , i.e. the name of the package without a version number. -# 4. /-x.y.z.spkg, i.e. the full URL where the package -# is hosted. Any local packages matching 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 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. -PKG_NAME=`basename "$PKG_SRC" | sed 's/\.spkg$//'` -PKG_BASE=`echo "$PKG_NAME" | sed 's/-.*//'` +PKG_NAME="$PKG_SRC" +PKG_BASE=`echo "$PKG_NAME" | sed 's/-.*//'` # strip version number # USE_LOCAL_SCRIPTS is a flag that if non-empty will cause # this script to try to install the package using local metadata @@ -289,39 +266,31 @@ PKG_BASE=`echo "$PKG_NAME" | sed 's/-.*//'` # the value of this flag is set in the next codeblock USE_LOCAL_SCRIPTS= -if [ -f "$PKG_SRC" ]; then - # PKG_SRC is a file. If it is given by a relative path, prepend `pwd` - # (reduce case 1b to 1a) - if ! echo "$PKG_SRC" | grep '^/' >/dev/null; then - PKG_SRC="`pwd`/$PKG_SRC" - fi -elif [ -z "$PKG_HAS_PATH" ]; then - # If PKG_SRC is not an existing file and doesn't contain a slash, - # we are in case 2a or 3. If version in 2a matches the version in - # build/pkgs or we are in case 3 use the local scripts, otherwise - # we try to find a package in upstream - PKG_VER="${PKG_NAME#${PKG_BASE}}" - PKG_VER="${PKG_VER#-}" - PKG_SCRIPTS="$SAGE_ROOT/build/pkgs/$PKG_BASE" - LOCAL_PKG_VER=`cat $PKG_SCRIPTS/package-version.txt 2>/dev/null` - if [ -n "$LOCAL_PKG_VER" ] && [ -z "$PKG_VER" -o "$PKG_VER" = "$LOCAL_PKG_VER" ]; then - PKG_VER="$LOCAL_PKG_VER" - if [ -z "$PKG_VER" ]; then - PKG_NAME="${PKG_BASE}" - else - PKG_NAME="${PKG_BASE}-${PKG_VER}" - fi - USE_LOCAL_SCRIPTS=yes - PKG_BASE_VER=`echo $PKG_VER | sed 's/\.p[0-9][0-9]*$//'` - PKG_NAME_UPSTREAM=`lookup_param tarball "$PKG_SCRIPTS/checksums.ini" | sed "s/VERSION/$PKG_BASE_VER/"` - echo "Found local metadata for $PKG_NAME" - - # Warning for experimental packages - if [ x`cat "$PKG_SCRIPTS/type"` = x"experimental" -a $INFO = 0 ]; then - if [ $YES != 1 ]; then - # We use /dev/tty here because our output may be redirected - # to a logfile, or line-buffered. - write_to_tty </dev/null` +PKG_VER="$LOCAL_PKG_VER" +if [ -z "$PKG_VER" ]; then + PKG_NAME="${PKG_BASE}" +else + PKG_NAME="${PKG_BASE}-${PKG_VER}" +fi +USE_LOCAL_SCRIPTS=yes +PKG_BASE_VER=`echo $PKG_VER | sed 's/\.p[0-9][0-9]*$//'` +PKG_NAME_UPSTREAM=`lookup_param tarball "$PKG_SCRIPTS/checksums.ini" | sed "s/VERSION/$PKG_BASE_VER/"` +echo "Found local metadata for $PKG_NAME" + +# Warning for experimental packages +if [ x`cat "$PKG_SCRIPTS/type"` = x"experimental" -a $INFO = 0 ]; then + if [ $YES != 1 ]; then + # We use /dev/tty here because our output may be redirected + # to a logfile, or line-buffered. + write_to_tty < /dev/tty 2>&1 - else - answer=n - fi - case "$answer" in - n*|N*) exit 1;; - esac - # 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 + 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 - - else - cd "$SAGE_DISTFILES" - for spkg in `ls -1t ${PKG_NAME}.spkg ${PKG_NAME}-*.spkg 2>/dev/null`; do - if [ -f "$spkg" ]; then - # Found a good package - echo "Found package $PKG_NAME in $SAGE_DISTFILES/$spkg" - PKG_SRC="`pwd`/$spkg" - PKG_NAME=`basename "$spkg" | sed 's/\.spkg$//'` - break - fi - done + 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 + # 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 @@ -376,154 +331,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 < /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 < /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 @@ -636,21 +445,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" @@ -1049,4 +845,4 @@ fi touch "$SAGE_LOCAL/lib/sage-force-relocate.txt" -echo "Finished installing $PKG_NAME.spkg" +echo "Finished installing $PKG_NAME" diff --git a/src/bin/sage b/src/bin/sage index 0c52aa3463c..9b3710ba223 100755 --- a/src/bin/sage +++ b/src/bin/sage @@ -167,9 +167,7 @@ usage_advanced() { 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 " checking. Options are the same as 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" @@ -390,7 +388,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" @@ -1115,7 +1113,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 diff --git a/src/doc/en/reference/repl/options.rst b/src/doc/en/reference/repl/options.rst index 3bc37ca1961..89214741c55 100644 --- a/src/doc/en/reference/repl/options.rst +++ b/src/doc/en/reference/repl/options.rst @@ -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