Ticket #11073: 11073_scripts.patch

File 11073_scripts.patch, 8.9 KB (added by jdemeyer, 5 years ago)
  • sage-bdist

    # HG changeset patch
    # User Volker Braun <vbraun@stp.dias.ie>
    # Date 1306783826 14400
    # Node ID bd2472ebcfa92d7e5ae64d312038e029b541b741
    # Parent  969ab8fb7a8c76e950ce80898e5ebdc78adef342
    Fix and simplify sage-sdist, move various scripts to spkg/bin
    
    diff --git a/sage-bdist b/sage-bdist
    a b  
    22
    33########################################################
    44# Build Sage *binary* distribution
    5 # This script should be called by the sage-sage script
     5# This script should be called by the spkg/bin/sage script
    66#
    77# Released under the GNU GPL-v2+ -- (c) William Stein
    88########################################################
     
    7070   cd sage
    7171   # Delete cython hash, so that "sage -br" works the first time.
    7272   rm -f .cython_hash
    73    cd "$TMP"/local/lib/python/site-packages
     73   cd "$TMP"/local/lib/python/site-packages && \
    7474   rm -rf sage
    7575   ln -sf ../../../../devel/sage/build/sage .
    7676fi
  • sage-make_devel_packages

    diff --git a/sage-make_devel_packages b/sage-make_devel_packages
    a b  
    11#!/usr/bin/env bash
    22
    33########################################################
    4 # Rebuild SAGE packages related to development, e.g.,
    5 #    sage_scripts, sage, doc, extcode
    6 # This script should be called by the SAGE script
     4# Rebuild Sage packages related to development, e.g.,
     5#    sage_scripts, sage, sage_root, extcode
     6# This script should be called by the sage-sdist script
    77########################################################
    88
    99if [ $# -ne 2 -a $# -ne 3 ]; then
     
    2020
    2121# REMOVE OLD PACKAGES
    2222cd "$SAGE_ROOT"/spkg/standard/
    23 rm doc-*.spkg
    24 rm examples-*.spkg
    2523rm extcode-*.spkg
    2624rm sage-*.spkg
    2725rm sage_scripts-*.spkg
     
    4947   hg tag "$SAGE_VERSION"
    5048   hg commit -m "$SAGE_VERSION"
    5149   #./sage-push
    52    chmod +x spkg-dist
    5350   ./spkg-dist "$SAGE_VERSION" "$SAGE_ROOT"
    5451   if [ $? -ne 0 ]; then
    5552       echo "Error building the Sage source code package"
     
    7370   hg commit -m "$SAGE_VERSION"
    7471 
    7572   #./sage-push
    76    chmod +x spkg-dist
    7773   ./spkg-dist "$SAGE_VERSION" "$SAGE_ROOT"
    7874   if [ $? -ne 0 ]; then
    7975       echo "Error building the extcode package"
     
    110106
    111107rm -rf "$SCRIPTS"
    112108mkdir "$SCRIPTS"
    113 chmod +x sage-*
    114 chmod -x sage-README-osx.txt sage-banner sage-env sage-gdb-commands
    115 chmod -x sage-maxima.lisp sage-verify-pyc
    116109rm sage-*~
    117110
    118111cp -pr sage-* .hg* ipy_profile_sage.py "$SCRIPTS"/
     
    148141hg clone --pull "$SAGE_ROOT" .
    149142
    150143if [ $? -ne 0 ]; then
    151     echo "Error copying Sage root repository."
     144    echo >&2 "Error cloning Sage root repository."
    152145    exit 1
    153146fi
    154147
     148# Copy spkg-install
     149cp -p "$SAGE_ROOT"/spkg/root-spkg-install spkg-install
     150chmod +x spkg-install
     151
    155152rm .hg/hgrc
    156 cd "$SAGE_ROOT"
    157 
    158 cp -p "$SAGE_ROOT"/spkg/root-spkg-install "$ROOT_REPO"/spkg-install
    159 chmod +x "$ROOT_REPO"/spkg-install
    160153
    161154echo "Done copying root repository."
    162155
     156cd "$SAGE_ROOT"
    163157tar -jcf "$ROOT_REPO".spkg "$ROOT_REPO"
    164158mv "$ROOT_REPO".spkg "$DESTINATION"/
    165159rm -rf "$ROOT_REPO"
  • sage-preparse

    diff --git a/sage-preparse b/sage-preparse
    a b  
    1111
    1212import os, sys, re
    1313
    14 # The sage-sage script that calls sage-preparse passes the current
     14# The spkg/bin/sage script that calls sage-preparse passes the current
    1515# directory in as the first argument.
    1616os.chdir(sys.argv[1])
    1717
  • new file sage-sage

    diff --git a/sage-sage b/sage-sage
    new file mode 100755
    - +  
     1#!/usr/bin/env bash
     2
     3# This script exists to handle the following situation:
     4# - In the past, a sysadmin created a script /usr/local/bin/sage
     5#   by copying /usr/local/sage-4.8/sage (say) and changing the
     6#   SAGE_ROOT line.
     7# - That sysadmin just installed sage-5.x (possibly by upgrading) and
     8#   he edited the SAGE_ROOT line in /usr/local/bin/sage, like he is
     9#   used to doing.
     10# - The old /usr/local/bin/sage script will try to execute
     11#   $SAGE_ROOT/local/bin/sage-sage
     12#   which is *this* script.
     13# - Since sage-sage isn't used anymore in sage-5.x, we print a warning
     14#   with a nice explanation and run spkg/bin/sage instead
     15#
     16# AUTHOR: Jeroen Demeyer (Trac #11073)
     17#
     18
     19# Where is sage installed?
     20whichsage=`which sage 2>/dev/null`
     21
     22if [ -n "$whichsage" ]; then
     23    guesssage="(this is probably '$whichsage')"
     24else
     25    guesssage="(this could be '/usr/local/bin/sage' for example)"
     26fi
     27
     28
     29# If this doesn't exist, probably our user ran Sage with an explicit
     30# path or is using a shell alias.
     31
     32
     33# Print a nice warning
     34cat >&2 <<EOF
     35Warning: you are using an old "sage" script to run Sage. This old
     36script calls sage-sage which is deprecated since sage-5.0.
     37The best solution is to delete this old "sage" script
     38$guesssage
     39and replace it with a symbolic link to "$SAGE_ROOT/sage".
     40You might need sysadmin privileges for this.
     41
     42For more information, consult the Sage Installation Guide:
     43$SAGE_ROOT/devel/sage/doc/output/html/en/installation/source.html#installation-in-a-multiuser-environment
     44or online at:
     45http://sagemath.org/doc/installation/source.html#installation-in-a-multiuser-environment
     46
     47For now, Sage will continue to work with the current setup, but this
     48might change in future versions.
     49**********************************************************************
     50EOF
     51
     52# The $SAGE_ROOT/sage scripts of all Sage versions since at least
     53# sage-4.5 change directory to "$SAGE_ROOT" before running sage-sage.
     54# So, it is safe to assume that the current directory is "$SAGE_ROOT".
     55exec spkg/bin/sage "$@"
  • sage-sdist

    diff --git a/sage-sdist b/sage-sdist
    a b  
    22
    33########################################################
    44# Build Sage source distribution
    5 # This script should be called by the sage-sage script
     5# This script should be called by the spkg/bin/sage script
    66########################################################
    77
    8 PKGDIR=spkg
    9 
    108if [ $# -ne 2 ]; then
    119   echo "Usage: $0 <SAGE_VERSION> <SAGE_ROOT>"
    1210   exit 1
     
    6462
    6563cd "$CUR"
    6664
    67 cp "$SAGE_ROOT"/local/bin/sage-spkg "$PKGDIR"/base/
    68 cp "$SAGE_ROOT"/local/bin/sage-env "$PKGDIR"/base/
    69 cp "$SAGE_ROOT"/local/bin/sage-make_relative "$PKGDIR"/base/
    70 
    71 TMP="/tmp/$TARGET"
    72 
    73 rm -rf "$TMP"
    74 mkdir "$TMP"
    75 
    76 # copy sage root repo over.  Cloning needs to be done in an empty
    77 # directory, so we do this now.  The other sage repositories are dealt
    78 # with later.
     65# Copy sage root directory.  Cloning needs to be done in an empty
     66# directory, so we do this now.  Creating the sage_root spkg is done
     67# in sage-make_devel_packagess below.
    7968cd "$SAGE_ROOT"
    8069
    8170hg diff
     
    8372hg tag "$SAGE_VERSION"
    8473hg commit -m "$SAGE_VERSION"
    8574
    86 echo "Copying root repository..."
    87 hg clone --pull . "$TMP"
    88 
    89 if [ $? -ne 0 ]; then
    90     echo "Error copying Sage root repository."
    91     exit 1
    92 fi
    93 
    94 rm "$TMP"/.hg/hgrc
    95 echo "Done copying root repository."
    96 
    97 STD=standard
    98 # Put VERSION.txt in a directory available for download during the
    99 # update process.  (See sage-update.)
    100 cp -p VERSION.txt $TMP/$PKGDIR/$STD/
    101 cp -pr "$PKGDIR"/base "$TMP/$PKGDIR/"
    102 
    103 "$SAGE_ROOT"/local/bin/sage-make_devel_packages "$SAGE_VERSION" "$SAGE_ROOT" "$TMP"/devel
     75# Create new sage_root, sage_scripts,... packages
     76./local/bin/sage-make_devel_packages "$SAGE_VERSION" "$SAGE_ROOT"
    10477
    10578if [ $? -ne 0 ]; then
    10679    echo "Error building the Sage packages."
    10780    exit 1
    10881fi
    10982
    110 cp "$TMP"/devel/*.spkg "$SAGE_ROOT/$PKGDIR/$STD/"
     83# Create new sage source distribution in $TMP
     84TMP="/tmp/$TARGET"
    11185
    112 cp -p "$PKGDIR/$STD"/*.spkg "$TMP/$PKGDIR/$STD/"
     86ROOT_REPO="sage_root-$SAGE_VERSION"
    11387
    114 cd "$TMP/$PKGDIR/$STD"
    115 rm -rf doc-* sage-* extcode-* sage_scripts-* examples-*
    116 mv "$TMP"/devel/*.spkg .
    117 rmdir "$TMP"/devel
     88# Extract the SAGE_ROOT repository to /tmp/$ROOT_REPO, then rename to
     89# $TMP.  This will become the root directory of the source tarball.
     90cd /tmp
     91rm -rf "$ROOT_REPO" "$TMP"
     92tar xjf "$SAGE_ROOT/spkg/standard/${ROOT_REPO}.spkg"
     93mv "$ROOT_REPO" "$TMP"
     94cd "$TMP"
    11895
    119 cd /tmp
     96# Remove spkg-install which is only needed in the spkg
     97rm spkg-install
     98
     99# Copy all base and standard packages
     100cp -p "$SAGE_ROOT"/spkg/base/*.tar* spkg/base
     101cp -p "$SAGE_ROOT"/spkg/standard/*.spkg spkg/standard
     102
     103# Put VERSION.txt in the new tarball root and also in spkg/standard,
     104# a directory available for download during the update process.
     105# (See sage-update)
     106cp -p "$SAGE_ROOT/VERSION.txt" .
     107cp -p "$SAGE_ROOT/VERSION.txt" spkg/standard
     108
     109
     110# Package the sdist repository
     111cd "$TMP/.."
    120112tar cf "$TARGET".tar "$TARGET"
    121113
    122114mkdir -p "$SAGE_ROOT"/dist
  • sage-update

    diff --git a/sage-update b/sage-update
    a b  
    418418if __name__ == '__main__':
    419419    # Make sure the SAGE_ROOT variable is set.  This should always be
    420420    # set because sage-update is only supposed to be called by
    421     # sage-upgrade, which is called only by sage-sage, after sage-env.
     421    # sage-upgrade, which is called only by spkg/bin/sage, after
     422    # sourcing sage-env.
    422423    if 'SAGE_ROOT' not in os.environ:
    423424        raise RuntimeError("The environment variable SAGE_ROOT must be set.")
    424425    SAGE_ROOT = os.environ["SAGE_ROOT"]