Ticket #10286: trac_10286_fix_sage-native-execute.patch

File trac_10286_fix_sage-native-execute.patch, 3.7 KB (added by Volker Braun, 12 years ago)

apply to SAGE_LOCAL/bin

  • sage-env

    # HG changeset patch
    # User Volker Braun <vbraun@stp.dias.ie>
    # Date 1290031800 18000
    # Node ID 6142b25d71551c4efa4184d45390d4ff030835cd
    # Parent  6f1a75750df41564e077dc801163fe4ce660adff
    Trac 10286: sage-native-execute does not unset path etc.
    
    The sage-native-execute script unsets the LD_LIBRARY_PATH but not the PATH, and then executes the argument. So it essentially breaks execution of all programs that are shipped with sage since they can't find their libraries any more, unless you are lucky and the system libraries have the same version.
    
    diff -r 6f1a75750df4 -r 6142b25d7155 sage-env
    a b  
    2222#
    2323##########################################################################
    2424
     25# first, save paths so we can unset them when calling external programs
     26if [ -z "${SAGE_ORIG_PATH_SET}" ]; then
     27    SAGE_ORIG_PATH=$PATH && export SAGE_ORIG_PATH
     28    SAGE_ORIG_PATH_SET=True && export SAGE_ORIG_PATH_SET
     29fi
     30
     31if [ -z "${SAGE_ORIG_LD_LIBRARY_PATH_SET}" ]; then
     32    SAGE_ORIG_LD_LIBRARY_PATH=$LD_LIBRARY_PATH && export SAGE_ORIG_LD_LIBRARY_PATH
     33    SAGE_ORIG_LD_LIBRARY_PATH_SET=True && export SAGE_ORIG_LD_LIBRARY_PATH_SET
     34fi
     35
     36if [ `uname` = "Darwin" ]; then
     37    if [ -z "${SAGE_ORIG_DYLD_LIBRARY_PATH_SET}" ]; then
     38        SAGE_ORIG_DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH && export SAGE_ORIG_DYLD_LIBRARY_PATH
     39        SAGE_ORIG_DYLD_LIBRARY_PATH_SET=True && export SAGE_ORIG_DYLD_LIBRARY_PATH_SET
     40    fi
     41fi
     42
    2543# GUESS SAGE_ROOT from pwd
    2644SAVEDIR="`pwd`"
    2745if [ -f sage -a -d spkg ]; then
     
    173191    PYTHONHOME="$SAGE_ROOT/local" && export PYTHONHOME
    174192fi
    175193
    176 if [ -z "${SAGE_ORIG_LD_LIBRARY_PATH_SET}" ]; then
    177     SAGE_ORIG_LD_LIBRARY_PATH=$LD_LIBRARY_PATH && export SAGE_ORIG_LD_LIBRARY_PATH
    178     SAGE_ORIG_LD_LIBRARY_PATH_SET=True && export SAGE_ORIG_LD_LIBRARY_PATH_SET
    179 fi
    180 
    181194if [ -z "$SAGE_TESTDIR" ]; then
    182195    SAGE_TESTDIR="$DOT_SAGE"/tmp && export SAGE_TESTDIR
    183196fi
     
    214227# The following is needed for OS X (especially for the
    215228# Singular install).
    216229if [ `uname` = "Darwin" ]; then
    217     if [ -z "${SAGE_ORIG_DYLD_LIBRARY_PATH_SET}" ]; then
    218         SAGE_ORIG_DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH && export SAGE_ORIG_DYLD_LIBRARY_PATH
    219         SAGE_ORIG_DYLD_LIBRARY_PATH_SET=True && export SAGE_ORIG_DYLD_LIBRARY_PATH_SET
    220     fi
    221230    DYLD_LIBRARY_PATH="$LD_LIBRARY_PATH:$DYLD_LIBRARY_PATH:$SAGE_LOCAL/lib/R/lib" && export DYLD_LIBRARY_PATH
    222231fi
    223232
  • sage-native-execute

    diff -r 6f1a75750df4 -r 6142b25d7155 sage-native-execute
    a b  
    11#!/bin/sh
    22
    3 LD_LIBRARY_PATH=$SAGE_ORIG_LD_LIBRARY_PATH; export LD_LIBRARY_PATH
    4 if [ `uname` = 'Darwin' ]; then
    5   DYLD_LIBRARY_PATH=$SAGE_ORIG_DYLD_LIBRARY_PATH
     3# This script is used to run non-Sage programs such as opening an
     4# image viewer, magma, matlab, latex, etc.
     5
     6# The PATH and LD_LIBRARY_PATH will be reverted to what they were
     7# before Sage was run, allowing external programs to run. You can not
     8# use this script to run programs that are shipped with Sage, as they
     9# and their libraries will no longer be in the search path.
     10
     11
     12# revert all relevant paths
     13if [ "x$SAGE_ORIG_PATH_SET" = "xTrue" ]; then
     14    PATH=$SAGE_ORIG_PATH
     15    export PATH
    616fi
    717
     18if [ "x$SAGE_ORIG_LD_LIBRARY_PATH_SET" = "xTrue" ]; then
     19    LD_LIBRARY_PATH=$SAGE_ORIG_LD_LIBRARY_PATH
     20    export LD_LIBRARY_PATH
     21fi
     22
     23if [ "x$SAGE_ORIG_DYLD_LIBRARY_PATH" = "xTrue" ]; then
     24    DYLD_LIBRARY_PATH=$SAGE_ORIG_DYLD_LIBRARY_PATH
     25    export DYLD_LIBRARY_PATH
     26fi
     27
     28unset PYTHONPATH && export PYTHONPATH
     29unset PYTHONHOME && export PYTHONHOME
     30
    831"$@"
    932