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

Commit

Permalink
Revert sage-spkg changes from Trac #19004
Browse files Browse the repository at this point in the history
  • Loading branch information
jdemeyer committed Sep 8, 2015
1 parent e856a8e commit e105028
Showing 1 changed file with 72 additions and 5 deletions.
77 changes: 72 additions & 5 deletions build/bin/sage-spkg
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,15 @@ done
# path.
# 2a. <package>-x.y.z, i.e. the name of the package plus the package's
# version numbers.
# 2b. DELETED
# 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.
# 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 and 3 we first look locally inside spkg/* for a
# 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.
#
Expand Down Expand Up @@ -336,10 +337,76 @@ if [ ! -f "$PKG_SRC" ]; then
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
exit 1
fi
for repo in optional experimental standard huge archive; 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
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
# Warn and ask the user if downloading an
# experimental or archive package.
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
read -p "Are you sure you want to continue [Y/n]? " answer
case "$answer" in
n*|N*) exit 0;;
esac
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)"
echo >&2 "Error: could not find a package matching $PKG_NAME on $MIRROR"
exit 1
fi

Expand Down

0 comments on commit e105028

Please sign in to comment.