Ticket #4949: trac_4949-root.v2.patch

File trac_4949-root.v2.patch, 4.7 KB (added by jhpalmieri, 8 years ago)

root repo

  • spkg/bin/sage-env

    # HG changeset patch
    # User J. H. Palmieri <palmieri@math.washington.edu>
    # Date 1327299042 28800
    # Node ID 060f5bc9007592a27b5a07f6202aa9ebf61c7b1c
    # Parent  2f08f66e547fe1ad4328b5a296fc087c1ef1dfd7
    #4949: implement SAGE_BUILD_TMPDIR and SAGE_KEEP_BUILT_SPKGS.
    
    diff --git a/spkg/bin/sage-env b/spkg/bin/sage-env
    a b if [ 1 = 2 ]; then 
    214214fi
    215215
    216216# Setting Sage-related location environment variables.
    217 BUILD=build
    218217SAGE_PACKAGES="$SAGE_ROOT/spkg" && export SAGE_PACKAGES
    219218SAGE_LOCAL="$SAGE_ROOT/local"   && export SAGE_LOCAL
    220219SAGE_DATA="$SAGE_ROOT/data"     && export SAGE_DATA
  • spkg/bin/sage-spkg

    diff --git a/spkg/bin/sage-spkg b/spkg/bin/sage-spkg
    a b  
    3030#
    3131#######################################################
    3232
    33 mymkdir()
    34 {
    35     if [ ! -d $1 ]; then
    36         mkdir $1
    37     fi
    38 }
    39 
    4033no_version()
    4134{
    4235    if [ -z "`echo "$1" | grep -`" ]; then
    if [ $# -eq 0 ]; then 
    9689    exit 0
    9790fi
    9891
    99 
    100 cd "$SAGE_PACKAGES"
    101 mymkdir "$BUILD"
    102 mymkdir installed
    103 cd "$BUILD"
    104 mymkdir old
    105 
    10692# the following two options are mutually exclusive -- i.e., you
    10793# can give only one.
    10894
    if [ $1 = '-s' -o $1 = '-m' ]; then 
    125111    shift
    126112fi
    127113
     114if [ "x$SAGE_KEEP_BUILT_SPKGS" = "xyes" ]; then
     115    DELETE_TMP=0
     116fi
     117
    128118INSTALLED="$SAGE_PACKAGES/installed/"
    129119PKG_NAME=`echo "$1" | sed -e "s/\.spkg$//"`
    130120PKG_NAME=`basename "$PKG_NAME"`
    if [ -f "$INSTALLED/$PKG_NAME" -a $FORCE 
    202192    exit 0
    203193fi
    204194
    205 cd "$SAGE_PACKAGES/build"
     195if [ -n "$SAGE_BUILD_TMPDIR" ]; then
     196    if [ -d "$SAGE_BUILD_TMPDIR" ]; then
     197        echo "Building in $SAGE_BUILD_TMPDIR."
     198    else
     199        echo "The variable \$SAGE_BUILD_TMPDIR is set to \"$SAGE_BUILD_TMPDIR\","
     200        echo "which is not an existing directory. Exiting."
     201        exit 1
     202    fi
     203else
     204    SAGE_BUILD_TMPDIR="$SAGE_PACKAGES"
     205fi
     206 
     207mkdir -p "$SAGE_PACKAGES/installed"
     208if [ $? -ne 0 ]; then
     209    echo >&2 "Error creating directory $SAGE_PACKAGES/installed."
     210    exit 1
     211fi
     212mkdir -p "$SAGE_BUILD_TMPDIR/build/old"
     213if [ $? -ne 0 ]; then
     214    echo >&2 "Error creating directory $SAGE_BUILD_TMPDIR/build/old."
     215    exit 1
     216fi
     217
     218SAGE_BUILD_TMPDIR="$SAGE_BUILD_TMPDIR/build/"
     219cd "$SAGE_BUILD_TMPDIR"
    206220
    207221if [ $DELETE_TMP -eq 1 ]; then
    208222    echo "Deleting directories from past builds of previous/current versions of $PKG_NAME"
    209     # Make triply sure that we are in the build directory before doing 
     223    # Make triply sure that we are in the build directory before doing
    210224    # a scary "rm -rf".
    211     cd "$SAGE_PACKAGES/build"
    212     if [ $? -ne 0 ]; then
    213         echo "Unable to find build directory."
     225    cd "$SAGE_BUILD_TMPDIR"
     226    # The previous command should always succeed because we just
     227    # created this directory if it wasn't there already, but just in case...
     228    if [ $? -ne 0 ]; then
     229        echo >&2 "Unable to find build directory."
    214230    else
    215         rm -rf "$PKG_BASE-"* 
    216     fi 
     231        rm -rf "$PKG_BASE-"*
     232    fi
    217233else
    218234    echo "Moving directories from past builds of previous/current versions of $PKG_NAME to build/old"
    219235    mv -f "$PKG_BASE-"* old/  2>/dev/null
    220236fi
    221237
    222238if [ ! -f "$PKG_SRC" ]; then
    223 
    224239    echo "$0: file $PKG_NAME does not exist"
    225240    echo "Attempting to download it."
    226241    CUR=`pwd`
    227     cd "$SAGE_PACKAGES"
    228     if [ ! -d optional ]; then
    229         mkdir optional
    230     fi
    231     cd optional
     242    mkdir -p "$SAGE_PACKAGES/optional"
     243    cd "$SAGE_PACKAGES/optional"
    232244   
    233245    FOUND_VERSION=''
    234246    if [ -n "`no_version "$PKG_NAME"`" ]; then
    else 
    389401fi
    390402
    391403if [ $? -eq 0 ]; then
    392     cd $INSTALLED
     404    cd "$INSTALLED"
    393405    # TURNED OFF: Remove all old packages with the same name up to the first "-":
    394406    # rm -f $PKG_BASE-*
    395407
    if [ $? -eq 0 ]; then 
    403415    fi
    404416    echo "Successfully installed $PKG_NAME"
    405417
    406     cd $BASEDIR
     418    cd "$BASEDIR"
    407419    if [ "x$SAGE_CHECK" = "xyes" -a -f spkg-check ]; then
    408420        echo "Running the test suite."
    409421        chmod +x spkg-check
    if [ $? -eq 0 ]; then 
    421433    # Delete the temporary build directory if required.
    422434    if [ $DELETE_TMP -eq 1 ]; then
    423435        echo "Now cleaning up tmp files."
    424         if [ -d "$SAGE_PACKAGES/build/$PKG_NAME" ]; then
     436        if [ -d "$SAGE_BUILD_TMPDIR/$PKG_NAME" ]; then
    425437            # the if is there only to avoid the possibility of a weird bug.
    426             cd "$SAGE_PACKAGES/build/"
    427             rm -rf "$SAGE_PACKAGES/build/$PKG_NAME"
     438            cd "$SAGE_BUILD_TMPDIR/"
     439            rm -rf "$SAGE_BUILD_TMPDIR/$PKG_NAME"
    428440        fi
    429441    else
    430442        echo "You can safely delete the temporary build directory"
    431         echo "$SAGE_PACKAGES/build/$PKG_NAME"
     443        echo "$SAGE_BUILD_TMPDIR/$PKG_NAME"
    432444    fi
    433445
    434446else