Ticket #4949: trac_4949-scripts.patch

File trac_4949-scripts.patch, 2.7 KB (added by jhpalmieri, 8 years ago)

scripts repo

  • sage-spkg

    # HG changeset patch
    # User J. H. Palmieri <palmieri@math.washington.edu>
    # Date 1305902348 25200
    # Node ID 339095d9552152d070c227d2dc40ec6df2d64246
    # Parent  969aa8f980c89290cdc1e4d95dab0e7fabc5286a
    #4949: implement SAGE_BUILD_TMPDIR and SAGE_KEEP_BUILT_SPKGS.
    scripts repo
    
    diff --git a/sage-spkg b/sage-spkg
    a b if [ $# -eq 0 ]; then 
    6060    exit 0
    6161fi
    6262
    63 
    64 cd "$SAGE_PACKAGES"
    65 mymkdir "$BUILD"
    66 mymkdir installed
    67 cd "$BUILD"
    68 mymkdir old
    69 
    7063# the following two options are mutually exclusive -- i.e., you
    7164# can give only one.
    7265
    if [ $1 = '-s' -o $1 = '-m' ]; then 
    8982    shift
    9083fi
    9184
     85if [ "x$SAGE_KEEP_BUILT_SPKGS" = "xyes" ]; then
     86    DELETE_TMP=0
     87fi
     88
    9289INSTALLED="$SAGE_PACKAGES/installed/"
    9390PKG_NAME=`echo "$1" | sed -e "s/\.spkg$//"`
    9491PKG_NAME=`basename "$PKG_NAME"`
    if [ -f "$INSTALLED/$PKG_NAME" -a $FORCE 
    166163    exit 0
    167164fi
    168165
    169 cd "$SAGE_PACKAGES/build"
     166if [ -n "$SAGE_BUILD_TMPDIR" ]; then
     167    if [ -d "$SAGE_BUILD_TMPDIR" ]; then
     168        BUILD_DIR=$SAGE_BUILD_TMPDIR
     169        echo "Building in $BUILD_DIR."
     170    else
     171        echo "The variable \$SAGE_BUILD_TMPDIR is set to \"$SAGE_BUILD_TMPDIR\","
     172        echo "which is not an existing directory. Exiting."
     173        exit 1
     174    fi
     175else
     176    BUILD_DIR=$SAGE_PACKAGES
     177fi
     178
     179cd "$SAGE_PACKAGES"
     180mymkdir installed
     181
     182cd "$BUILD_DIR"
     183mymkdir "$BUILD"
     184cd "$BUILD"
     185mymkdir old
     186
     187cd "$BUILD_DIR/$BUILD"
    170188
    171189if [ $DELETE_TMP -eq 1 ]; then
    172190    echo "Deleting directories from past builds of previous/current versions of $PKG_NAME"
    173191    # Make triply sure that we are in the build directory before doing
    174192    # a scary "rm -rf".
    175     cd "$SAGE_PACKAGES/build"
     193    cd "$BUILD_DIR/$BUILD"
    176194    if [ $? -ne 0 ]; then
    177195        echo "Unable to find build directory."
    178196    else
    if [ ! -f "$PKG_SRC" ]; then 
    188206    echo "$0: file $PKG_NAME does not exist"
    189207    echo "Attempting to download it."
    190208    CUR=`pwd`
    191     cd "$SAGE_PACKAGES"
     209    cd "$BUILD_DIR"
    192210    if [ ! -d optional ]; then
    193211        mkdir optional
    194212    fi
    if [ $? -eq 0 ]; then 
    402420    # Delete the temporary build directory if required.
    403421    if [ $DELETE_TMP -eq 1 ]; then
    404422        echo "Now cleaning up tmp files."
    405         if [ -d "$SAGE_PACKAGES/build/$PKG_NAME" ]; then
     423        if [ -d "$BUILD_DIR/$BUILD/$PKG_NAME" ]; then
    406424           # the if is there only to avoid the possibility of a weird bug.
    407             cd "$SAGE_PACKAGES/build/"
    408             rm -rf "$SAGE_PACKAGES/build/$PKG_NAME"
     425            cd "$BUILD_DIR/$BUILD"
     426            rm -rf "$BUILD_DIR/$BUILD/$PKG_NAME"
    409427        fi
    410428    else
    411429        echo "You can safely delete the temporary build directory"
    412         echo "$SAGE_PACKAGES/build/$PKG_NAME"
     430        echo "$BUILD_DIR/$BUILD/$PKG_NAME"
    413431    fi
    414432
    415433else