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

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

root repo; implement "make spkg-doc" from SAGE_ROOT

  • Makefile

    # HG changeset patch
    # User J. H. Palmieri <palmieri@math.washington.edu>
    # Date 1302915896 25200
    # Node ID 7b4c05fec5866d76c552e5e62c3a99a020e1e5b8
    # Parent  ba2d33f4528541eac15c6e2e79fb66cf924e0a62
    #11197:	look for spkg-install-docs in each spkg,
    add target 'spkg-doc' to the top-level Makefile
    
    diff --git a/Makefile b/Makefile
    a b  
    11# Main Makefile for Sage.
    22
    3 # The default target ("all") builds Sage and the whole (HTML) documentation.
     3# The default target ("make" or "make all") builds Sage and the whole
     4# (HTML) documentation.
    45#
    5 # Target "build" just builds Sage.
     6# "make build" just builds Sage.
     7#
     8# "make doc" builds the documentation in html format; note that this
     9# requires building Sage first.  As noted above, this is built when
     10# you type "make".
     11#
     12# "make spkg-doc" builds documentation for some of the component parts
     13# of Sage.
    614#
    715# See below for targets to build the documentation in other formats,
    816# to run various types of test suites, and to remove parts of the build etc.
    doc-clean: 
    6068        @echo "Deleting devel/sage/doc/output..."
    6169        rm -rf devel/sage/doc/output
    6270
     71spkg-doc: build # (already) indirectly depends on $(PIPE)
     72        cd spkg && "../$(PIPE)" "./install-spkg-docs 2>&1" "tee -a ../install-spkg-docs.log"
     73
    6374clean:
    6475        @echo "Deleting spkg/build..."
    6576        rm -rf spkg/build
  • new file spkg/install-spkg-docs

    diff --git a/spkg/install-spkg-docs b/spkg/install-spkg-docs
    new file mode 100755
    - +  
     1#!/usr/bin/env bash
     2
     3# This script installs documentation for spkgs; it is run by
     4# "make spkg-doc" in the top-level directory.  It searches through the
     5# spkgs, looking for a script called 'spkg-install-docs', and if that
     6# script is there, executing it.
     7
     8CUR=`pwd`
     9cd ..
     10SAGE_ROOT=`pwd`
     11# Storing the start time of the build process. The time is stored in
     12# seconds since 1970-01-01 in a hidden file called
     13# "SAGE_ROOT/.BUILDSTART". See ticket #6744.
     14echo `date -u "+%s"` > .BUILDSTART
     15cd "$CUR"
     16SAGE_LOCAL="$SAGE_ROOT/local"
     17SAGE_LOGS="$SAGE_ROOT/spkg/logs"
     18PATH="$SAGE_ROOT:$SAGE_LOCAL/bin:$PATH"
     19PYTHONPATH="$SAGE_LOCAL"
     20PKGDIR=standard
     21export PATH SAGE_ROOT SAGE_LOCAL SAGE_LOGS PYTHONPATH
     22
     23# In case we want to change the name of the script:
     24SPKG_INSTALL_SCRIPT=spkg-install-docs
     25INSTALL="$SAGE_ROOT/spkg/pipestatus"
     26# INSTALLED=list of packages for which documentation is installed
     27INSTALLED=""
     28FAILED=""
     29
     30. "$SAGE_ROOT/local/bin/sage-env"
     31if [ $? -ne 0 ]; then
     32    echo >&2 "Error running sage-env"
     33    exit 1
     34fi
     35echo "Building documentation for spkg files."
     36echo -ne "Searching for documentation..."
     37cd standard
     38for PKG in *.spkg
     39do
     40    PKG=`echo "$PKG" | sed 's/\(.(*\).spkg/\1/'`
     41    found=`tar jtf "$SAGE_ROOT/spkg/standard/$PKG.spkg" | grep $SPKG_INSTALL_SCRIPT`
     42    # $installed_file is a placeholder file which should only
     43    # exist if the docs for $PKG have been successfully built
     44    # and installed.  If present, don't rebuild the docs.
     45    installed_file="$SAGE_ROOT/spkg/installed/$PKG-docs"
     46    if [ $? -eq 0 ] && [ -n "$found" ] && [ ! -f $installed_file ]; then
     47        echo
     48        echo "**************************************************"
     49        echo "Building documentation for $PKG."
     50        cd "$SAGE_ROOT/spkg/build/"
     51        tar jxf "$SAGE_ROOT/spkg/standard/$PKG.spkg" 2>/dev/null
     52        cd "$PKG" && "$INSTALL" ". $SPKG_INSTALL_SCRIPT 2>&1" "tee -a $SAGE_LOGS/$PKG-docs.log"
     53        if [ $? -ne 0 ]; then
     54            echo "Warning: Error building documentation for $PKG."
     55            echo "Warning: Error building documentation for $PKG."  >> "$SAGE_LOGS/$PKG-docs.log"
     56            if [ -z "$FAILED" ]; then
     57                FAILED="$PKG"
     58            else
     59                FAILED="$FAILED, $PKG"
     60            fi
     61        else
     62            rm -rf "$SAGE_ROOT/spkg/build/$PKG/"
     63            echo "PACKAGE NAME: $PKG documentation" > "$installed_file"
     64            echo "INSTALL DATE: `date`" >> "$installed_file"
     65            echo "UNAME: `uname -a`" >> "$installed_file"
     66            if [ -f "$SAGE_ROOT"/VERSION.txt ]; then
     67                cat "$SAGE_ROOT"/VERSION.txt >> "$installed_file"
     68            fi
     69            echo "Successfully built and installed documentation for $PKG."
     70            if [ -z "$INSTALLED" ]; then
     71                INSTALLED="$PKG"
     72            else
     73                INSTALLED="$INSTALLED, $PKG"
     74            fi
     75        fi
     76        echo "**************************************************"
     77        echo -ne "Searching for documentation..."
     78    else
     79        echo -ne "."
     80    fi
     81done
     82echo
     83echo "**************************************************"
     84echo
     85if [ -n "$INSTALLED" ]; then
     86    echo "Documentation installed for $INSTALLED."
     87fi
     88if [ -n "$FAILED" ]; then
     89    echo "Building documentation failed for $FAILED."
     90fi
     91echo