Ticket #11021: trac_11021-sage-spkg-cleanup-v2-rebased_to_4.7.1.alpha4.patch

File trac_11021-sage-spkg-cleanup-v2-rebased_to_4.7.1.alpha4.patch, 16.0 KB (added by leif, 8 years ago)

SCRIPTS repo. Version 2 simply rebased to Sage 4.7.1.alpha4.

  • sage-spkg

    # HG changeset patch
    # User Leif Leonhardy <not.really@online.de>
    # Date 1309990019 -7200
    # Node ID eb463c4f45e2afcc6d083d0df24e5e5d7166661f
    # Parent  5f763124e6a490173838c9920203e67e2af72659
    #11021 Clean up sage-spkg, dump SPKG.txt rather than SAGE.txt upon "-info" ("sage -info ..."), rebased to Sage 4.7.1.alpha4
    
    diff -r 5f763124e6a4 -r eb463c4f45e2 sage-spkg
    a b  
    22
    33# William Stein, 2005-12-20 -- removed "m" option from tar,
    44# which was seriously confusing the build process on some
    5 # (too fast?) machines, especially for mpfr. 
     5# (too fast?) machines, especially for mpfr.
    66
    77#######################################################
    88#  Install a Sage package.  This script is
    99#  typically invoked by giving the command
    1010#      sage -i <package name>
    1111#
    12 #  A package may assume that the following environment 
     12#  A package may assume that the following environment
    1313#  variables are defined:
    1414#
    1515#      SAGE_ROOT   -- root directory of sage install
     
    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
    4336        echo "no version"
    4437    fi
    4538}
     39
     40print_separator()
     41{
     42    echo "*************************************************************"
     43}
     44
    4645# The following sets environment variables for building
    4746# packages.  (Using dot suggested by W. Cheung.)
    4847
     
    6059    exit 0
    6160fi
    6261
     62cd "$SAGE_PACKAGES"
     63mkdir -p "$BUILD"
     64mkdir -p installed
     65cd "$BUILD"
     66mkdir -p old
    6367
    64 cd "$SAGE_PACKAGES"
    65 mymkdir "$BUILD"
    66 mymkdir installed
    67 cd "$BUILD"
    68 mymkdir old
    69 
    70 # the following two options are mutually exclusive -- i.e., you
    71 # can give only one.
     68# The following two options are mutually exclusive -- i.e., you
     69# can give only one.
    7270
    7371INFO=0
    74 if [ $1 = '-info' ]; then
     72if [ "$1" = '-info' ]; then
    7573    INFO=1
    7674    shift
    7775fi
    7876
    7977FORCE=0
    80 if [ $1 = '-f' ]; then
     78if [ "$1" = '-f' ]; then
    8179    FORCE=1
    8280    shift
    8381fi
    8482export FORCE
    8583
    8684DELETE_TMP=1
    87 if [ $1 = '-s' -o $1 = '-m' ]; then
     85if [ "$1" = '-s' -o "$1" = '-m' ]; then
    8886    DELETE_TMP=0
    8987    shift
    9088fi
     
    9593PKG_SRC="$1"
    9694PKG_BASE=`echo "$PKG_NAME" | sed -e "s/-.*//"`
    9795
    98 # check if noclobber is set and warn about it
    99 if [ $PKG_SRC == "noclobber" ]; then
     96# Check if noclobber is set and warn about it:
     97if [ "$PKG_SRC" == "noclobber" ]; then
    10098    echo "***********************************************************"
    10199    echo "* WARNING WARNING WARNING WARNING WARNING WARNING WARNING *"
    102100    echo "*                                                         *"
     
    141139
    142140if [ $INFO -ne 0 ]; then
    143141    if [ ! -f "$PKG_SRC" ]; then
    144         echo "Package $PKG_NAME not found"
     142        echo "Package $PKG_NAME not found" >&2
     143        exit 1
    145144    fi
    146     bunzip2 -c "$PKG_SRC" 2>/dev/null | tar Ofx${UNTAR_VERBOSE} - $PKG_NAME/SAGE.txt 2>/dev/null
     145    bunzip2 -c "$PKG_SRC" 2>/dev/null | tar Ofx${UNTAR_VERBOSE} - "$PKG_NAME/SPKG.txt" 2>/dev/null
    147146    if [ $? -ne 0 ]; then
    148         tar Ofx${UNTAR_VERBOSE} "$PKG_SRC" "$PKG_NAME/SAGE.txt" 2>/dev/null
     147        tar Ofx${UNTAR_VERBOSE} "$PKG_SRC" "$PKG_NAME/SPKG.txt" 2>/dev/null
    149148    fi
    150     echo ""
    151149    if [ $? -ne 0 ]; then
    152         echo "No file SAGE.txt in $PKG_NAME"
     150        echo "No file SPKG.txt in package $PKG_NAME" >&2
    153151        exit 1
    154152    fi
    155153    exit 0
     
    166164    exit 0
    167165fi
    168166
    169 cd "$SAGE_PACKAGES/build"
     167cd "$SAGE_PACKAGES/$BUILD"
    170168
    171169if [ $DELETE_TMP -eq 1 ]; then
    172170    echo "Deleting directories from past builds of previous/current versions of $PKG_NAME"
    173     # Make triply sure that we are in the build directory before doing 
     171    # Make triply sure that we are in the build directory before doing
    174172    # a scary "rm -rf".
    175     cd "$SAGE_PACKAGES/build"
    176     if [ $? -ne 0 ]; then 
    177         echo "Unable to find build directory."
     173    cd "$SAGE_PACKAGES/$BUILD"
     174    if [ $? -ne 0 ]; then
     175        echo "Unable to find build directory." >&2
    178176    else
    179         rm -rf "$PKG_BASE-"* 
    180     fi 
     177        rm -rf "$PKG_BASE-"*
     178    fi
    181179else
    182180    echo "Moving directories from past builds of previous/current versions of $PKG_NAME to build/old"
    183181    mv -f "$PKG_BASE-"* old/  2>/dev/null
     
    185183
    186184if [ ! -f "$PKG_SRC" ]; then
    187185
    188     echo "$0: file $PKG_NAME does not exist" 
     186    echo "$0: file $PKG_NAME does not exist"
    189187    echo "Attempting to download it."
    190188    CUR=`pwd`
    191189    cd "$SAGE_PACKAGES"
     
    193191        mkdir optional
    194192    fi
    195193    cd optional
    196    
     194
    197195    FOUND_VERSION=''
    198196    if [ -n "`no_version "$PKG_NAME"`" ]; then
     197        # No version was given on the command line.
    199198        echo "Searching for latest version of $PKG_NAME"
    200199        PKG_NAME=`sage-latest-online-package "$PKG_NAME"`
    201200        if [ $? -eq 0 ]; then
    202201            echo "Found package $PKG_NAME"
    203             FOUND_VERSION='1'
     202            FOUND_VERSION='1'
    204203        else
    205204            echo "$PKG_NAME"
    206205            exit 1
     
    227226    # download the package specified by $1, since it either already
    228227    # contains the version number or is a URL.
    229228    if [ "x$FOUND_VERSION" = "x" ]; then
    230         sage-download_package "$1"
     229        sage-download_package "$1"
    231230    else
    232         sage-download_package "$PKG_NAME"
     231        sage-download_package "$PKG_NAME"
    233232    fi
    234     if [ ! -f "$PKG_NAME.spkg" ]; then 
    235             echo "sage: Failed to download package $PKG_NAME from $SAGE_SERVER"
    236             exit 1
     233    if [ ! -f "$PKG_NAME.spkg" ]; then
     234        echo "sage: Failed to download package $PKG_NAME from $SAGE_SERVER" >&2
     235        exit 1
    237236    fi
    238237    PKG_SRC="`pwd`/$PKG_NAME.spkg"
    239238    cd "$CUR"
    240239fi
    241240
    242 # * The -i option below to ignore checksum errors, since
     241# * The -i option below is to ignore checksum errors, since
    243242#   I've had problems with this on Solaris.
    244 # * The m option avoids clock skew problems.   
     243# * The m option avoids clock skew problems.
    245244
    246245echo "Extracting package $PKG_SRC ..."
    247246ls -l "$PKG_SRC"
     
    251250    rm -rf "$PKG_NAME"
    252251fi
    253252
    254 bunzip2 -c "$PKG_SRC" 2>/dev/null | tar fx${UNTAR_VERBOSE} -  2>/dev/null
     253bunzip2 -c "$PKG_SRC" 2>/dev/null | tar fx${UNTAR_VERBOSE} - 2>/dev/null
    255254if [ ! -d "$PKG_NAME" ]; then
     255    # Maybe the spkg wasn't compressed, so retry with plain 'tar':
    256256    tar fx${UNTAR_VERBOSE} "$PKG_SRC"
    257257fi
    258258echo "Finished extraction"
     
    273273    fi
    274274    sage-download_package "$PKG_NAME"
    275275    echo `pwd`
    276     bunzip2 -c "$PKG_NAME.spkg"  | tar fx${UNTAR_VERBOSE} -
     276    bunzip2 -c "$PKG_NAME.spkg" | tar fx${UNTAR_VERBOSE} -
    277277    if [ ! -d "$PKG_NAME.spkg" ]; then
     278        # Maybe the spkg wasn't compressed, so retry with plain 'tar':
    278279        tar fx${UNTAR_VERBOSE} "$PKG_NAME.spkg"
    279280    fi
    280281    if [ ! -d "$PKG_NAME" ]; then
    281         echo "Second download resulted in a corrupted package."
     282        echo "Second download resulted in a corrupted package." >&2
    282283        exit 1
    283284    fi
    284285fi
     
    291292        echo "python setup.py install" >> spkg-install
    292293    else
    293294        if [ -f configure ]; then
    294             echo "./configure --prefix=\$SAGE_ROOT/local/" >> spkg-install
     295            echo "./configure --prefix=\"\$SAGE_ROOT/local/\"" >> spkg-install
    295296            echo "make" >> spkg-install
    296             echo "make install" >> spkg-install 
     297            echo "make install" >> spkg-install
    297298        else
    298             echo "There is no spkg-install script, no setup.py, and no configure script,"
    299             echo "so I do not know how to install $PKG_SRC."
     299            echo "There is no spkg-install script, no setup.py, and no configure script," >&2
     300            echo "so I do not know how to install $PKG_SRC." >&2
    300301            exit 1
    301302        fi
    302303    fi
     
    308309#echo "TOUCHING"
    309310#touch * */* */*/* */*/*/* 1>/dev/null 2>/dev/null
    310311
    311 echo "****************************************************"
     312print_separator
    312313echo "Host system"
    313314echo "uname -a:"
    314315uname -a
    315316if [ $? -ne 0 ]; then
    316     echo "Unable to determine host system information."
     317    echo "Warning: Unable to determine host system information." >&2
    317318fi
    318 echo "****************************************************"
     319print_separator
    319320
    320 echo "****************************************************"
     321print_separator
    321322echo "CC Version"
    322 echo "$CC -v"
     323echo "$CC -v:"
    323324$CC -v
    324325if [ $? -ne 0 ]; then
    325     echo "Unable to determine C compiler version."
     326    echo "Warning: Unable to determine C compiler version." >&2
    326327fi
    327 echo "****************************************************"
     328print_separator
    328329
    329330
    330331##################################################################
    331332# If spkg-install is a Python script, verify that the Sage Python
    332333# has already been installed.
    333334##################################################################
    334 # Check the first line of the file for the string "python".
     335# Check the first line of the file for the string "python":
    335336head -1 spkg-install | grep python > /dev/null
    336 if [ $? -eq 0 ]; then   # if it is found, then the exit code will be 0
    337     if [ ! -f "$SAGE_LOCAL"/bin/python ]; then   # now check if the python program is in local/bin/
    338          # if so, exit with an error. 
    339          echo "The spkg-install script depends on the Sage Python package,"
    340          echo "but the Sage Python package is not yet installed.  This may be"
    341          echo "a bug in the Sage build system dependency file.  Please"
    342          echo "update the $SAGE_ROOT/spkg/standard/deps makefile."
     337if [ $? -eq 0 ]; then   # If it is found, then the exit code will be 0.
     338    # Now check if Sage's python program is already installed:
     339    if [ ! -f "$SAGE_LOCAL"/bin/python ]; then
     340         # If not, exit with an error:
     341         echo "Error: The spkg-install script depends on the Sage Python package," >&2
     342         echo "but the Sage Python package is not yet installed.  This may be" >&2
     343         echo "a bug in the Sage build system dependency file.  Please" >&2
     344         echo "update the '$SAGE_ROOT/spkg/standard/deps' makefile." >&2
    343345         exit 1
    344     fi 
     346    fi
    345347fi
    346348
    347349BASEDIR=`pwd`
    348350if [ -n "$DEBIAN_RELEASE" ]; then
    349351    SAGE_CHECK=''
    350352    if [ -e ./spkg-debian ]; then
    351             time ./spkg-debian
     353        time ./spkg-debian
    352354    else
    353             time sage-build-debian $BASEDIR
     355        time sage-build-debian "$BASEDIR"
    354356    fi
    355357else
    356358    time ./spkg-install
    357359fi
    358360
    359361if [ $? -eq 0 ]; then
    360     cd $INSTALLED
     362    cd "$INSTALLED"
    361363    # TURNED OFF: Remove all old packages with the same name up to the first "-":
    362364    # rm -f $PKG_BASE-*
    363365
    364     # Mark that the new package has been installed. 
     366    # Mark that the new package has been installed.
    365367    # This file will eventually be a certificate like in OS X.
    366368    echo "PACKAGE NAME: $PKG_NAME" > "$PKG_NAME"
    367369    echo "INSTALL DATE: `date`" >> "$PKG_NAME"
    368370    echo "UNAME: `uname -a`" >> "$PKG_NAME"
    369371    if [ -f "$SAGE_ROOT"/VERSION.txt ]; then
    370         cat "$SAGE_ROOT"/VERSION.txt >> "$PKG_NAME"
     372        cat "$SAGE_ROOT"/VERSION.txt >> "$PKG_NAME"
    371373    fi
    372374    echo "Successfully installed $PKG_NAME"
    373375
    374     cd $BASEDIR
     376    cd "$BASEDIR"
    375377    if [ "x$SAGE_CHECK" = "xyes" -a -f spkg-check ]; then
     378        # TODO: Allow e.g. also SAGE_CHECK="ignore" to run the test suites
     379        #       without making errors fatal, which would be convenient for
     380        #       the Python package (whose test suite fails on almost all
     381        #       Linux systems and some others) and also porting.
    376382        echo "Running the test suite."
    377383        chmod +x spkg-check
    378384        ./spkg-check
    379385        if [ $? -ne 0 ]; then
    380             echo "*************************************"
    381             echo "Error testing package ** $PKG_NAME **"
    382             echo "*************************************"
    383             rm -f $SAGE_ROOT/spkg/installed/$PKG_NAME
    384             echo "sage: An error occurred while testing $PKG_NAME"
    385             echo "Please email sage-devel http://groups.google.com/group/sage-devel"
    386             echo "explaining the problem and send the relevant part of"
    387             echo "of $SAGE_ROOT/install.log.  Describe your computer, operating system, etc."
    388             echo "If you want to try to fix the problem yourself, *don't* just cd to"
    389             echo "`pwd` and type 'make check' or whatever is appropriate."
    390             echo "Instead, the following commands setup all environment variables"
    391             echo "correctly and load a subshell for you to debug the error:"
    392             echo "(cd '`pwd`' && '$SAGE_ROOT/sage' -sh)"
    393             echo "When you are done debugging, you can type \"exit\" to leave the"
    394             echo "subshell."
     386            print_separator >&2
     387
     388            echo "Error testing package $PKG_NAME." >&2
     389
     390            print_separator >&2
     391            rm -f "$SAGE_ROOT/spkg/installed/$PKG_NAME"
     392            echo "sage: An error occurred while testing $PKG_NAME" >&2
     393            echo "Please email sage-devel http://groups.google.com/group/sage-devel" >&2
     394            echo "explaining the problem and send the relevant part of" >&2
     395            echo "of $SAGE_ROOT/install.log.  Describe your computer, operating system, etc." >&2
     396            echo "If you want to try to fix the problem yourself, *don't* just cd to" >&2
     397            echo "`pwd` and type 'make check' or whatever is appropriate." >&2
     398            echo "Instead, the following commands setup all environment variables" >&2
     399            echo "correctly and load a subshell for you to debug the error:" >&2
     400            echo "(cd '`pwd`' && '$SAGE_ROOT/sage' -sh)" >&2
     401            echo "When you are done debugging, you can type \"exit\" to leave the" >&2
     402            echo "subshell." >&2
    395403            exit 1
    396         else 
     404        else
    397405            echo "TEST SUITE: passed" >> "$INSTALLED/$PKG_NAME"
    398406        fi
    399407    fi
     
    401409
    402410    # Delete the temporary build directory if required.
    403411    if [ $DELETE_TMP -eq 1 ]; then
    404         echo "Now cleaning up tmp files."
     412        echo "Now cleaning up temporary files."
    405413        if [ -d "$SAGE_PACKAGES/build/$PKG_NAME" ]; then
    406            # the if is there only to avoid the possibility of a weird bug.
    407             cd "$SAGE_PACKAGES/build/"
     414           # The if is there only to avoid the possibility of a weird bug.
    408415            rm -rf "$SAGE_PACKAGES/build/$PKG_NAME"
    409416        fi
    410417    else
     
    413420    fi
    414421
    415422else
    416     echo "sage: An error occurred while installing $PKG_NAME"
    417     echo "Please email sage-devel http://groups.google.com/group/sage-devel"
    418     echo "explaining the problem and send the relevant part of"
    419     echo "of $SAGE_ROOT/install.log.  Describe your computer, operating system, etc."
    420     echo "If you want to try to fix the problem yourself, *don't* just cd to"
    421     echo "`pwd` and type 'make check' or whatever is appropriate."
    422     echo "Instead, the following commands setup all environment variables"
    423     echo "correctly and load a subshell for you to debug the error:"
    424     echo "(cd '`pwd`' && '$SAGE_ROOT/sage' -sh)"
    425     echo "When you are done debugging, you can type \"exit\" to leave the"
    426     echo "subshell."
     423    # 'spkg-install' returned non-zero exit code:
     424    print_separator >&2
     425
     426    echo "Error installing package $PKG_NAME." >&2
     427
     428    print_separator >&2
     429    echo "sage: An error occurred while installing $PKG_NAME" >&2
     430    echo "Please email sage-devel http://groups.google.com/group/sage-devel" >&2
     431    echo "explaining the problem and send the relevant part of" >&2
     432    echo "of $SAGE_ROOT/install.log.  Describe your computer, operating system, etc." >&2
     433    echo "If you want to try to fix the problem yourself, *don't* just cd to" >&2
     434    echo "`pwd` and type 'make check' or whatever is appropriate." >&2
     435    echo "Instead, the following commands setup all environment variables" >&2
     436    echo "correctly and load a subshell for you to debug the error:" >&2
     437    echo "(cd '`pwd`' && '$SAGE_ROOT/sage' -sh)" >&2
     438    echo "When you are done debugging, you can type \"exit\" to leave the" >&2
     439    echo "subshell." >&2
    427440    exit 1
    428441fi
    429442
     
    433446cd "$SAGE_LOCAL"/bin
    434447./sage-make_relative
    435448
    436 echo "Finished installing $PKG_NAME.spkg" 
     449echo "Finished installing $PKG_NAME.spkg"
    437450
    438451# It's OK if the above fails -- in fact it will until Python
    439 # itself gets installed. That's fine. 
    440 exit 0   
     452# itself gets installed. That's fine.
     453exit 0