| 434 | builddocs() { |
| 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 | } |