# HG changeset patch # User Leif Leonhardy # Date 1310013856 -7200 # Node ID 6d670e9222541fc657de996919b8e57f6cec5f80 # Parent 7be38304209ccf0ccb32ee5bb1782f00abc9c05a #11021 Implement/support and document "sage -info [packages]" which apparently got broken. "sage-spkg -info ..." prints SPKG.txt (previously the now deprecated SAGE.txt), but there's meanwhile been no way to tell sage-sage (or simply sage) to call sage-spkg with that option, i.e., sage rejected that option. "sage -i ..." and "sage -f ..." now check whether any spkg parameters have been given and act accordingly (i.e., either suppressing the "Installing" message or giving an error message if no package names have been specified on the command line). Some clarifying comments added. diff -r 7be38304209c -r 6d670e922254 sage-sage --- a/sage-sage Thu Jul 07 06:18:34 2011 +0200 +++ b/sage-sage Thu Jul 07 06:44:16 2011 +0200 @@ -9,13 +9,16 @@ #### |.....................--.|...................................................| echo "Optional arguments:" echo " file. -- run given .sage, .py or .spyx files" + echo " file.spkg -- install given .spkg file(s)" echo " -advanced -- list all command line options" echo " -c -- Evaluates cmd as sage code" echo " -experimental -- list all experimental packages that can be installed" echo " -gap [...] -- run Sage's Gap with given arguments" echo " -gp [...] -- run Sage's PARI/GP calculator with given arguments" echo " -h, -? -- print this help message" - echo " -i [packages] -- install the given Sage packages" + echo " -i, -info -- list installed Sage packages" + echo " -i [packages] -- install the given Sage package(s)" + echo " -info [packages] -- list SPKG.txt of the given Sage package(s)" echo " -inotebook [...] -- start the *insecure* Sage notebook" echo " -maxima [...] -- run Sage's Maxima with given arguments" echo " -mwrank [...] -- run Sage's mwrank with given arguments" @@ -111,12 +114,13 @@ #### |.....................--.|...................................................| echo "Installing packages and upgrading:" echo " -experimental -- list all experimental packages that can be installed" - echo " -f [packages] -- force build of the given Sage package (even if it is" - echo " already installed)" + echo " -f [packages] -- force (re)installation of the given Sage package(s)" + echo " (even if they are already installed)" echo " -f -s [packages] -- like -f but do not delete the spkg/build directories" - echo " -i [packages] -- install the given Sage packages" - echo " if no packages given, print a list of all installed" + echo " -i, -info -- list installed Sage packages" + echo " -i [packages] -- install the given Sage package(s)" echo " -i -s [packages] -- like -i but do not delete the spkg/build directories" + echo " -info [packages] -- list SPKG.txt of the given Sage package(s)" echo " -optional -- list all optional packages that can be installed" echo " -standard -- list all standard packages that can be installed" #echo " -update -- download latest non-optional Sage packages (do not build them)" @@ -171,6 +175,7 @@ echo " -docbuild [lang/] -- Build the Sage documentation" echo " -grep -- grep through all the Sage library code for string" echo " -grepdoc -- grep through all the Sage documentation for string" + echo " -info [packages] -- list SPKG.txt of the given Sage package(s)" echo #### 1.......................26..................................................78 @@ -786,8 +791,21 @@ install() { cd "$SAGE_ROOT/spkg" if [ $# -lt 2 ]; then + # "sage -i" without further parameters => list installed packages sage-spkg exit $? + elif [ "$1" = "-info" ]; then + shift # at least one parameter remaining + ok=true + for PKG in "$@"; do + case "$PKG" in + /*) + sage-spkg -info "$PKG" || ok=false + ;; + *) sage-spkg -info "$CUR/$PKG" || ok=false + esac + done + exit `$ok` fi OPT="$1" shift @@ -836,16 +854,35 @@ exit 0 fi +if [ "$1" = '-info' ]; then + shift + if [ $# -gt 0 ]; then + echo "Listing SPKG.txt of $@" + install -info "$@" + else + # List installed packages: + install " " "$@" + fi + # install() does not return. +fi + if [ "$1" = '-i' ]; then shift - echo "Installing $@" + if [ $# -gt 0 ]; then + echo "Installing $@" + # (Otherwise sage-spkg just lists the installed packages.) + fi install " " "$@" fi if [ "$1" = '-f' ]; then shift - echo "Force installing $@" - install -f "$@" + if [ $# -gt 0 ]; then + echo "Force installing $@" + install -f "$@" + fi + echo >&2 "Usage: sage -f [-s] package(s)" + exit 1 fi if [ "$1" = '-pkg' -o "$1" = '-spkg' -o "$1" = "--pkg" -o "$1" = "--spkg" ]; then @@ -1017,9 +1054,14 @@ if [ $# -ge 1 ]; then T=`echo "$1" | sed -e "s/.*\.//"` if [ "$T " = "spkg " ]; then + # Some *.spkg filename given as first argument + # => try to install it (or them): install "" "$@" exit $? fi + # Assume first argument is a file to be run by Sage (*.sage,*.spyx,*.py). + # TODO: Note that sage-run does (currently) not take any options + # (starting with '-'), so we could catch that case already here. cd "$SAGE_LOCAL/bin/" sage-run "$CUR" "$@" exit $?