Ticket #11021: trac_11021-support_and_document_sage_-info_in_sage-sage.scripts.patch

File trac_11021-support_and_document_sage_-info_in_sage-sage.scripts.patch, 5.8 KB (added by leif, 8 years ago)

SCRIPTS repo. Implements/supports & documents "sage -info ..." in sage-sage; minor fixes. Based on Sage 4.7.1.alpha4.

  • sage-sage

    # HG changeset patch
    # User Leif Leonhardy <not.really@online.de>
    # 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 b  
    99    ####  |.....................--.|...................................................|
    1010    echo "Optional arguments:"
    1111    echo "  file.<sage|py|spyx> -- run given .sage, .py or .spyx files"
     12    echo "  file.spkg           -- install given .spkg file(s)"
    1213    echo "  -advanced           -- list all command line options"
    1314    echo "  -c <cmd>            -- Evaluates cmd as sage code"
    1415    echo "  -experimental       -- list all experimental packages that can be installed"
    1516    echo "  -gap [...]          -- run Sage's Gap with given arguments"
    1617    echo "  -gp [...]           -- run Sage's PARI/GP calculator with given arguments"
    1718    echo "  -h, -?              -- print this help message"
    18     echo "  -i [packages]       -- install the given Sage packages"
     19    echo "  -i, -info           -- list installed Sage packages"
     20    echo "  -i [packages]       -- install the given Sage package(s)"
     21    echo "  -info [packages]    -- list SPKG.txt of the given Sage package(s)"
    1922    echo "  -inotebook [...]    -- start the *insecure* Sage notebook"
    2023    echo "  -maxima [...]       -- run Sage's Maxima with given arguments"
    2124    echo "  -mwrank [...]       -- run Sage's mwrank with given arguments"
     
    111114    ####  |.....................--.|...................................................|
    112115    echo "Installing packages and upgrading:"
    113116    echo "  -experimental       -- list all experimental packages that can be installed"
    114     echo "  -f [packages]       -- force build of the given Sage package (even if it is"
    115     echo "                         already installed)"
     117    echo "  -f [packages]       -- force (re)installation of the given Sage package(s)"
     118    echo "                         (even if they are already installed)"
    116119    echo "  -f -s [packages]    -- like -f but do not delete the spkg/build directories"
    117     echo "  -i [packages]       -- install the given Sage packages"
    118     echo "                         if no packages given, print a list of all installed"
     120    echo "  -i, -info           -- list installed Sage packages"
     121    echo "  -i [packages]       -- install the given Sage package(s)"
    119122    echo "  -i -s [packages]    -- like -i but do not delete the spkg/build directories"
     123    echo "  -info [packages]    -- list SPKG.txt of the given Sage package(s)"
    120124    echo "  -optional           -- list all optional packages that can be installed"
    121125    echo "  -standard           -- list all standard packages that can be installed"
    122126   #echo "  -update             -- download latest non-optional Sage packages (do not build them)"
     
    171175    echo "  -docbuild [lang/]<document> <html|pdf|...> -- Build the Sage documentation"
    172176    echo "  -grep <string>      -- grep through all the Sage library code for string"
    173177    echo "  -grepdoc <string>   -- grep through all the Sage documentation for string"
     178    echo "  -info [packages]    -- list SPKG.txt of the given Sage package(s)"
    174179
    175180    echo
    176181    ####  1.......................26..................................................78
     
    786791install() {
    787792   cd "$SAGE_ROOT/spkg"
    788793   if [ $# -lt 2 ]; then
     794       # "sage -i" without further parameters => list installed packages
    789795       sage-spkg
    790796       exit $?
     797   elif [ "$1" = "-info" ]; then
     798       shift # at least one parameter remaining
     799       ok=true
     800       for PKG in "$@"; do
     801           case "$PKG" in
     802               /*)
     803                   sage-spkg -info "$PKG" || ok=false
     804                   ;;
     805               *)  sage-spkg -info "$CUR/$PKG" || ok=false
     806           esac   
     807       done
     808       exit `$ok`
    791809   fi
    792810   OPT="$1"
    793811   shift
     
    836854   exit 0
    837855fi
    838856
     857if [ "$1" = '-info' ]; then
     858   shift
     859   if [ $# -gt 0 ]; then
     860       echo "Listing SPKG.txt of $@"
     861       install -info "$@"
     862   else
     863       # List installed packages:
     864       install " " "$@"
     865   fi
     866   # install() does not return.
     867fi
     868
    839869if [ "$1" = '-i' ]; then
    840870   shift
    841    echo "Installing $@"
     871   if [ $# -gt 0 ]; then
     872       echo "Installing $@"
     873       # (Otherwise sage-spkg just lists the installed packages.)
     874   fi
    842875   install " " "$@"
    843876fi
    844877
    845878if [ "$1" = '-f' ]; then
    846879   shift
    847    echo "Force installing $@"
    848    install -f "$@"
     880   if [ $# -gt 0 ]; then
     881       echo "Force installing $@"
     882       install -f "$@"
     883   fi
     884   echo >&2 "Usage: sage -f [-s] package(s)"
     885   exit 1
    849886fi
    850887
    851888if [ "$1" = '-pkg' -o "$1" = '-spkg' -o "$1" = "--pkg" -o "$1" = "--spkg" ]; then
     
    10171054if [ $# -ge 1 ]; then
    10181055   T=`echo "$1" | sed -e "s/.*\.//"`
    10191056   if [ "$T " = "spkg " ]; then
     1057       # Some *.spkg filename given as first argument
     1058       # => try to install it (or them):
    10201059       install "" "$@"
    10211060       exit $?
    10221061   fi
     1062   # Assume first argument is a file to be run by Sage (*.sage,*.spyx,*.py).
     1063   # TODO: Note that sage-run does (currently) not take any options
     1064   # (starting with '-'), so we could catch that case already here.
    10231065   cd "$SAGE_LOCAL/bin/"
    10241066   sage-run "$CUR" "$@"
    10251067   exit $?