Ticket #4949: trac_4949-root.v3.patch

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

root repo

  • Makefile

    # HG changeset patch
    # User J. H. Palmieri <palmieri@math.washington.edu>
    # Date 1327299042 28800
    # Node ID 9ce71ceedc60fb365664ea74ec7a74d2db0ecb3d
    # Parent  7c96262ff120e88549f66794680921a3469d1e1a
    #4949: implement SAGE_BUILD_TMPDIR and SAGE_KEEP_BUILT_SPKGS.
    
    diff --git a/Makefile b/Makefile
    a b clean: 
    5959        @echo "Deleting spkg/archive..."
    6060        rm -rf spkg/archive
    6161        mkdir -p spkg/archive
     62        @if [ -n "$(SAGE_BUILD_TMPDIR)" ] && [ -d "$(SAGE_BUILD_TMPDIR)/build" ]; then \
     63            echo "Deleting \$$SAGE_BUILD_TMPDIR/build..."; \
     64            echo "rm -rf $(SAGE_BUILD_TMPDIR)/build"; \
     65            rm -rf "$(SAGE_BUILD_TMPDIR)/build"; \
     66            echo "mkdir -p $(SAGE_BUILD_TMPDIR)/build"; \
     67            mkdir -p "$(SAGE_BUILD_TMPDIR)/build"; \
     68        fi
    6269
    6370distclean: clean
    6471        @echo "Deleting all remaining traces of builds, tests etc. ..."
    distclean: clean 
    8289        rm -rf matplotlibrc
    8390        rm -rf tmp
    8491        rm -f .BUILDSTART
     92        @if [ -n "$(SAGE_BUILD_TMPDIR)" ]; then \
     93            echo "rm -rf $(SAGE_BUILD_TMPDIR)/build"; \
     94            rm -rf "$(SAGE_BUILD_TMPDIR)/build"; \
     95        fi
    8596
    8697micro_release:
    8798        . spkg/bin/sage-env && local/bin/sage-micro_release
  • spkg/bin/sage-env

    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 "Creating directory \$SAGE_BUILD_TMPDIR (=$SAGE_BUILD_TMPDIR)."
     198        mkdir -p "$SAGE_BUILD_TMPDIR"
     199    fi
     200    echo "Building in $SAGE_BUILD_TMPDIR."
     201else
     202    SAGE_BUILD_TMPDIR="$SAGE_PACKAGES"
     203fi
     204 
     205mkdir -p "$SAGE_PACKAGES/installed"
     206if [ $? -ne 0 ]; then
     207    echo >&2 "Error creating directory $SAGE_PACKAGES/installed."
     208    exit 1
     209fi
     210mkdir -p "$SAGE_BUILD_TMPDIR/build/old"
     211if [ $? -ne 0 ]; then
     212    echo >&2 "Error creating directory $SAGE_BUILD_TMPDIR/build/old."
     213    exit 1
     214fi
     215
     216SAGE_BUILD_TMPDIR="$SAGE_BUILD_TMPDIR/build/"
     217cd "$SAGE_BUILD_TMPDIR"
    206218
    207219if [ $DELETE_TMP -eq 1 ]; then
    208220    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 
     221    # Make triply sure that we are in the build directory before doing
    210222    # a scary "rm -rf".
    211     cd "$SAGE_PACKAGES/build"
    212     if [ $? -ne 0 ]; then
    213         echo "Unable to find build directory."
     223    cd "$SAGE_BUILD_TMPDIR"
     224    # The previous command should always succeed because we just
     225    # created this directory if it wasn't there already, but just in case...
     226    if [ $? -ne 0 ]; then
     227        echo >&2 "Unable to find build directory."
    214228    else
    215         rm -rf "$PKG_BASE-"* 
    216     fi 
     229        rm -rf "$PKG_BASE-"*
     230    fi
    217231else
    218232    echo "Moving directories from past builds of previous/current versions of $PKG_NAME to build/old"
    219233    mv -f "$PKG_BASE-"* old/  2>/dev/null
    220234fi
    221235
    222236if [ ! -f "$PKG_SRC" ]; then
    223 
    224237    echo "$0: file $PKG_NAME does not exist"
    225238    echo "Attempting to download it."
    226239    CUR=`pwd`
    227     cd "$SAGE_PACKAGES"
    228     if [ ! -d optional ]; then
    229         mkdir optional
    230     fi
    231     cd optional
     240    mkdir -p "$SAGE_PACKAGES/optional"
     241    cd "$SAGE_PACKAGES/optional"
    232242   
    233243    FOUND_VERSION=''
    234244    if [ -n "`no_version "$PKG_NAME"`" ]; then
    else 
    389399fi
    390400
    391401if [ $? -eq 0 ]; then
    392     cd $INSTALLED
     402    cd "$INSTALLED"
    393403    # TURNED OFF: Remove all old packages with the same name up to the first "-":
    394404    # rm -f $PKG_BASE-*
    395405
    if [ $? -eq 0 ]; then 
    403413    fi
    404414    echo "Successfully installed $PKG_NAME"
    405415
    406     cd $BASEDIR
     416    cd "$BASEDIR"
    407417    if [ "x$SAGE_CHECK" = "xyes" -a -f spkg-check ]; then
    408418        echo "Running the test suite."
    409419        chmod +x spkg-check
    if [ $? -eq 0 ]; then 
    421431    # Delete the temporary build directory if required.
    422432    if [ $DELETE_TMP -eq 1 ]; then
    423433        echo "Now cleaning up tmp files."
    424         if [ -d "$SAGE_PACKAGES/build/$PKG_NAME" ]; then
     434        if [ -d "$SAGE_BUILD_TMPDIR/$PKG_NAME" ]; then
    425435            # 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"
     436            cd "$SAGE_BUILD_TMPDIR/"
     437            rm -rf "$SAGE_BUILD_TMPDIR/$PKG_NAME"
    428438        fi
    429439    else
    430440        echo "You can safely delete the temporary build directory"
    431         echo "$SAGE_PACKAGES/build/$PKG_NAME"
     441        echo "$SAGE_BUILD_TMPDIR/$PKG_NAME"
    432442    fi
    433443
    434444else