Ticket #11197: trac_11197-spkg-install-docs.patch

File trac_11197-spkg-install-docs.patch, 3.1 KB (added by jhpalmieri, 8 years ago)

root repo

  • spkg/install

    # HG changeset patch
    # User J. H. Palmieri <palmieri@math.washington.edu>
    # Date 1302818784 25200
    # Node ID 3f34746f9561c9c1c2cc4c3c4b81a595baf022b6
    # Parent  7d65e0c65ba059155300f13325b39cfcac60f042
    #11197:	look for spkg-install-docs in each spkg,
    and run it if environment variable SAGE_SPKG_INSTALL_DOCS is yes.
    
    diff --git a/spkg/install b/spkg/install
    a b export ZODB 
    431431ZNPOLY=`$newest zn_poly`
    432432export ZNPOLY
    433433
     434builddocs() {
     435    if [ "$SAGE_SPKG_INSTALL_DOCS" = "yes" ]; then
     436        # In case we want to change the name of the script:
     437        SPKG_INSTALL_SCRIPT=spkg-install-docs
     438        INSTALL="$SAGE_ROOT/spkg/pipestatus"
     439        . "$SAGE_ROOT/local/bin/sage-env"
     440        if [ $? -ne 0 ]; then
     441            echo >&2 "Error running sage-env"
     442            exit 1
     443        fi
     444        echo "Building documentation for spkg files."
     445        echo -ne "Searching for documentation..."
     446        cd standard
     447        for PKG in *.spkg
     448        do
     449            PKG=`echo "$PKG" | sed 's/\(.(*\).spkg/\1/'`
     450            found=`tar jtf "$SAGE_ROOT/spkg/standard/$PKG.spkg" | grep $SPKG_INSTALL_SCRIPT`
     451            # $installed_file is a placeholder file which should only
     452            # exist if the docs for $PKG have been successfully built
     453            # and installed.  If present, don't rebuild the docs.
     454            installed_file="$SAGE_ROOT/spkg/installed/$PKG-docs"
     455            if [ $? -eq 0 ] && [ -n "$found" ] && [ ! -f $installed_file ]; then
     456                echo
     457                echo "**************************************************"
     458                echo "Building documentation for $PKG."
     459                cd "$SAGE_ROOT/spkg/build/"
     460                tar jxf "$SAGE_ROOT/spkg/standard/$PKG.spkg" 2>/dev/null
     461                cd "$PKG" && "$INSTALL" ". $SPKG_INSTALL_SCRIPT 2>&1" "tee -a $SAGE_LOGS/$PKG-docs.log"
     462                if [ $? -ne 0 ]; then
     463                    echo "Warning: Error building documentation for $PKG."
     464                    echo "Warning: Error building documentation for $PKG."  >> "$SAGE_LOGS/$PKG-docs.log"
     465                else
     466                    rm -rf "$SAGE_ROOT/spkg/build/$PKG/"
     467                    echo "PACKAGE NAME: $PKG documentation" > "$installed_file"
     468                    echo "INSTALL DATE: `date`" >> "$installed_file"
     469                    echo "UNAME: `uname -a`" >> "$installed_file"
     470                    if [ -f "$SAGE_ROOT"/VERSION.txt ]; then
     471                        cat "$SAGE_ROOT"/VERSION.txt >> "$installed_file"
     472                    fi
     473                    echo "Successfully built and installed documentation for $PKG."
     474                fi
     475                echo "**************************************************"
     476                echo -ne "Searching for documentation..."
     477            else
     478                echo -ne "."
     479            fi
     480        done
     481        echo
     482        echo
     483    fi
     484}
    434485
    435 # Skip the rest if nothing to do (i.e., to [re]build):
     486# Skip everything (except building the spkg docs) if nothing to do
     487# (i.e., to [re]build):
    436488# Note that we should use $MAKE here, but we currently don't use
    437489# it further below either unless SAGE_PARALLEL_SPKG_BUILD=yes, which
    438490# I consider a "bug". -- Leif Leonhardy
    export ZNPOLY 
    440492# non-zero status which is not a problem.
    441493if make -q -f standard/deps $1; then
    442494    echo "Nothing to (re)build / all up-to-date."
     495    builddocs
    443496    exit 0
    444497fi
    445498
    446 
    447499# Dump environment for debugging purposes:
    448500echo "*** ALL ENVIRONMENT VARIABLES BEFORE BUILD: ***"
    449501env
    if [ $? -ne 0 ]; then 
    465517    exit 1
    466518fi
    467519
     520builddocs
     521
    468522cd "$SAGE_ROOT"
    469523
    470524# Rename makefile to Makefile (see #10156)