Ticket #4949: trac_4949-root.patch

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

root repo

  • spkg/bin/sage-spkg

    # HG changeset patch
    # User J. H. Palmieri <palmieri@math.washington.edu>
    # Date 1327299042 28800
    # Node ID f21cebc416e527dcf890c44d2610734c0bddfcff
    # Parent  2f08f66e547fe1ad4328b5a296fc087c1ef1dfd7
    #4949: implement SAGE_BUILD_TMPDIR and SAGE_KEEP_BUILT_SPKGS.
    
    diff --git a/spkg/bin/sage-spkg b/spkg/bin/sage-spkg
    a b if [ $# -eq 0 ]; then 
    9696    exit 0
    9797fi
    9898
    99 
    100 cd "$SAGE_PACKAGES"
    101 mymkdir "$BUILD"
    102 mymkdir installed
    103 cd "$BUILD"
    104 mymkdir old
    105 
    10699# the following two options are mutually exclusive -- i.e., you
    107100# can give only one.
    108101
    if [ $1 = '-s' -o $1 = '-m' ]; then 
    125118    shift
    126119fi
    127120
     121if [ "x$SAGE_KEEP_BUILT_SPKGS" = "xyes" ]; then
     122    DELETE_TMP=0
     123fi
     124
    128125INSTALLED="$SAGE_PACKAGES/installed/"
    129126PKG_NAME=`echo "$1" | sed -e "s/\.spkg$//"`
    130127PKG_NAME=`basename "$PKG_NAME"`
    if [ -f "$INSTALLED/$PKG_NAME" -a $FORCE 
    202199    exit 0
    203200fi
    204201
    205 cd "$SAGE_PACKAGES/build"
     202if [ -n "$SAGE_BUILD_TMPDIR" ]; then
     203    if [ -d "$SAGE_BUILD_TMPDIR" ]; then
     204        BUILD_DIR=$SAGE_BUILD_TMPDIR
     205        echo "Building in $BUILD_DIR."
     206    else
     207        echo "The variable \$SAGE_BUILD_TMPDIR is set to \"$SAGE_BUILD_TMPDIR\","
     208        echo "which is not an existing directory. Exiting."
     209        exit 1
     210    fi
     211else
     212    BUILD_DIR=$SAGE_PACKAGES
     213fi
     214 
     215cd "$SAGE_PACKAGES"
     216mymkdir installed
     217
     218cd "$BUILD_DIR"
     219mymkdir "$BUILD"
     220cd "$BUILD"
     221mymkdir old
     222
     223cd "$BUILD_DIR/$BUILD"
    206224
    207225if [ $DELETE_TMP -eq 1 ]; then
    208226    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 
     227    # Make triply sure that we are in the build directory before doing
    210228    # a scary "rm -rf".
    211     cd "$SAGE_PACKAGES/build"
    212     if [ $? -ne 0 ]; then 
     229    cd "$BUILD_DIR/$BUILD"
     230    if [ $? -ne 0 ]; then
    213231        echo "Unable to find build directory."
    214232    else
    215         rm -rf "$PKG_BASE-"* 
    216     fi 
     233        rm -rf "$PKG_BASE-"*
     234    fi
    217235else
    218236    echo "Moving directories from past builds of previous/current versions of $PKG_NAME to build/old"
    219237    mv -f "$PKG_BASE-"* old/  2>/dev/null
    if [ ! -f "$PKG_SRC" ]; then 
    224242    echo "$0: file $PKG_NAME does not exist"
    225243    echo "Attempting to download it."
    226244    CUR=`pwd`
    227     cd "$SAGE_PACKAGES"
     245    cd "$BUILD_DIR"
    228246    if [ ! -d optional ]; then
    229247        mkdir optional
    230248    fi
    if [ $? -eq 0 ]; then 
    421439    # Delete the temporary build directory if required.
    422440    if [ $DELETE_TMP -eq 1 ]; then
    423441        echo "Now cleaning up tmp files."
    424         if [ -d "$SAGE_PACKAGES/build/$PKG_NAME" ]; then
     442        if [ -d "$BUILD_DIR/$BUILD/$PKG_NAME" ]; then
    425443            # 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"
     444            cd "$BUILD_DIR/$BUILD/"
     445            rm -rf "$BUILD_DIR/$BUILD/$PKG_NAME"
    428446        fi
    429447    else
    430448        echo "You can safely delete the temporary build directory"
    431         echo "$SAGE_PACKAGES/build/$PKG_NAME"
     449        echo "$BUILD_DIR/$BUILD/$PKG_NAME"
    432450    fi
    433451
    434452else