8585
8686# error_msg(header, command)
8787# This is for printing an error message if something went wrong.
88- # The first argument is the header to print, the second argument should
89- # be some proposed command to run in the subshell, e.g. "make".
88+ # The first argument is the header to print. If given, the second
89+ # argument should be some proposed command to run in the subshell
90+ # such as "make".
9091error_msg ()
9192{
9293cat >&2 << MESSAGE
9394************************************************************************
9495$1
9596************************************************************************
9697Please email sage-devel (http://groups.google.com/group/sage-devel)
97- explaining the problem and including the relevant part of the log file
98+ explaining the problem and including the log file
9899 $SAGE_LOGS /$PKG_NAME .log
99100Describe your computer, operating system, etc.
101+ MESSAGE
102+
103+ if [ -n " $2 " ]; then
104+ cat >&2 << MESSAGE
100105If you want to try to fix the problem yourself, *don't* just cd to
101106` pwd` and type '$2 ' or whatever is appropriate.
102107Instead, the following commands setup all environment variables
103108correctly and load a subshell for you to debug the error:
104109 (cd '` pwd` ' && '$SAGE_ROOT /sage' --sh)
105110When you are done debugging, you can type "exit" to leave the subshell.
111+ MESSAGE
112+ fi
113+
114+ cat >&2 << MESSAGE
106115************************************************************************
107116MESSAGE
108117}
145154. sage-env
146155
147156if [ $? -ne 0 ]; then
148- echo >&2 " Error setting environment variables by sourcing sage-env."
149- echo >&2 " possibly contact sage-devel (see http://groups.google.com/group/sage-devel)."
157+ error_msg " Error setting environment variables by sourcing sage-env"
150158 exit 1
151159fi
152160
156164
157165mkdir -p " $SAGE_SPKG_INST "
158166if [ $? -ne 0 ]; then
159- echo >&2 " Error creating directory $SAGE_SPKG_INST . "
167+ error_msg " Error creating directory $SAGE_SPKG_INST "
160168 exit 1
161169fi
162170
348356if [ ! -f " $PKG_SRC " ]; then
349357 if [ -n " $PKG_NAME_UPSTREAM " ]; then
350358 # This is the new-style package way of downloading the tarball
351- sage-download-file $PKG_NAME_UPSTREAM || exit $?
359+ if ! sage-download-file " $PKG_NAME_UPSTREAM " ; then
360+ error_msg " Error downloading $PKG_NAME_UPSTREAM "
361+ exit 1
362+ fi
352363 PKG_SRC=" $SAGE_DISTFILES /$PKG_NAME_UPSTREAM "
353364 else
354365 # Handle all the legacy cruft. This branch can be deleted once
@@ -372,6 +383,7 @@ if [ ! -f "$PKG_SRC" ]; then
372383 # like "foo" or "foo-1.2.3".
373384 MIRROR=$( sage-download-file --print-fastest-mirror) /spkg
374385 if [ $? -ne 0 ]; then
386+ error_msg " Error downloading list of packages"
375387 exit 1
376388 fi
377389 for repo in optional experimental huge; do
@@ -382,6 +394,7 @@ if [ ! -f "$PKG_SRC" ]; then
382394 sage-download-file --quiet " $MIRROR /$repo /list" $repolist
383395 if [ $? -ne 0 ]; then
384396 rm -f $repolist
397+ error_msg " Error downloading $MIRROR /$repo /list"
385398 exit 1
386399 fi
387400
478491 # Trac #5852: check write permissions
479492 mkdir -p " $SAGE_DISTFILES "
480493 if [ ! -w " $SAGE_DISTFILES " ]; then
481- echo >&2 " Error: no write access to packages directory $SAGE_PACKAGES . "
494+ error_msg " Error: no write access to packages directory $SAGE_PACKAGES "
482495 exit 1
483496 fi
484497 cd " $SAGE_DISTFILES " || exit $?
491504 if [ $? -ne 0 ]; then
492505 # Delete failed download
493506 rm -f " $PKG_TMP "
507+ error_msg " Error downloading $PKG_URL "
494508 exit 1
495509 fi
496510
@@ -516,7 +530,7 @@ cd "$SAGE_ROOT" || exit $?
516530if [ -n " $SAGE_SPKG_COPY_UPSTREAM " ]; then
517531 mkdir -p " $SAGE_SPKG_COPY_UPSTREAM " && cp -p " $PKG_SRC " " $SAGE_SPKG_COPY_UPSTREAM "
518532 if [ $? -ne 0 ]; then
519- echo >&2 " Failed to copy upstream tarball to directory '$SAGE_SPKG_COPY_UPSTREAM '"
533+ error_msg " Error copying upstream tarball to directory '$SAGE_SPKG_COPY_UPSTREAM '"
520534 exit 1
521535 fi
522536fi
@@ -532,7 +546,7 @@ if [ $INFO -ne 0 -a -z "$USE_LOCAL_SCRIPTS" ]; then
532546 cat " $PKG_SCRIPTS /SPKG.txt"
533547 sage-uncompress-spkg " $PKG_SRC " " $PKG_NAME /SPKG.txt"
534548 if [ $? -ne 0 ]; then
535- echo >&2 " No file SPKG.txt in $PKG_NAME "
549+ error_msg " Error: no file SPKG.txt in $PKG_NAME "
536550 exit 1
537551 fi
538552 exit 0
544558
545559mkdir -p " $SAGE_BUILD_DIR "
546560if [ $? -ne 0 ]; then
547- echo >&2 " Error creating directory $SAGE_BUILD_DIR . "
561+ error_msg " Error creating directory $SAGE_BUILD_DIR "
548562 exit 1
549563fi
550564
551565# Trac #5852: check write permissions
552566if [ ! -w " $SAGE_BUILD_DIR " ]; then
553- echo >&2 " Error: no write access to build directory $SAGE_BUILD_DIR . "
567+ error_msg " Error: no write access to build directory $SAGE_BUILD_DIR "
554568 exit 1
555569fi
556570if [ ! -d " $SAGE_LOCAL " ]; then
557571 # If you just unpack Sage and run "sage -p <pkg>" then local does not yet exist
558572 mkdir " $SAGE_LOCAL "
559573fi
560574if [ ! -w " $SAGE_LOCAL " ]; then
561- echo >&2 " Error: no write access to installation directory $SAGE_LOCAL . "
575+ error_msg " Error: no write access to installation directory $SAGE_LOCAL "
562576 exit 1
563577fi
564578
577591 echo " Moving old directory $PKG_NAME to $SAGE_BUILD_DIR /old..."
578592 mkdir -p old
579593 if [ $? -ne 0 ]; then
580- echo >&2 " Error creating directory $SAGE_BUILD_DIR /old. "
594+ error_msg " Error creating directory $SAGE_BUILD_DIR /old"
581595 exit 1
582596 fi
583597 rm -rf old/" $PKG_NAME "
586600fi
587601
588602if [ -e " $PKG_NAME " ]; then
589- echo >&2 " Error (re)moving $PKG_NAME "
603+ error_msg " Error (re)moving $PKG_NAME "
590604 exit 1
591605fi
592606
@@ -602,7 +616,7 @@ if [ "$USE_LOCAL_SCRIPTS" = yes ]; then
602616
603617 sage-uncompress-spkg -d src " $PKG_SRC "
604618 if [ $? -ne 0 ]; then
605- echo >&2 " Error: failed to extract $PKG_SRC "
619+ error_msg " Error: failed to extract $PKG_SRC "
606620 exit 1
607621 fi
608622else
@@ -612,21 +626,24 @@ else
612626
613627 sage-uncompress-spkg " $PKG_SRC "
614628 if [ $? -ne 0 ]; then
615- echo >&2 " Error: failed to extract $PKG_SRC "
629+ error_msg " Error: failed to extract $PKG_SRC "
616630 exit 1
617631 fi
618632
619633 cd " $PKG_NAME "
620634 if [ $? -ne 0 ]; then
621- echo >&2 " Error: after extracting, the directory '$PKG_NAME ' does not exist"
635+ error_msg " Error: after extracting, the directory '$PKG_NAME ' does not exist"
622636 exit 1
623637 fi
624638fi
625639
626640echo " Finished extraction"
627641
628642cd src
629- sage-apply-patches || exit 1
643+ if ! sage-apply-patches; then
644+ error_msg " Error applying patches"
645+ exit 1
646+ fi
630647cd ..
631648
632649# #################################################################
@@ -706,14 +723,6 @@ export rsync_proxy=$http_proxy
706723# #################################################################
707724# Actually install
708725# #################################################################
709- if [ -r spkg-build ]; then
710- # Package has both spkg-build and spkg-install
711- if [ ! -x spkg-build ]; then
712- echo >&2 " WARNING: spkg-build is not executable, making it executable"
713- chmod +x spkg-build
714- fi
715- fi
716-
717726if [ ! -x spkg-install ]; then
718727 echo >&2 " WARNING: spkg-install is not executable, making it executable"
719728 chmod +x spkg-install
@@ -723,20 +732,20 @@ if [ -x spkg-build ]; then
723732 # Package has both spkg-build and spkg-install; execute the latter with SAGE_SUDO
724733 time ./spkg-build
725734 if [ $? -ne 0 ]; then
726- error_msg " Error building package $PKG_NAME " " make"
727- exit 1
735+ error_msg " Error building package $PKG_NAME " " make"
736+ exit 1
728737 fi
729738 time $SAGE_SUDO ./spkg-install
730739 if [ $? -ne 0 ]; then
731- error_msg " Error installing package $PKG_NAME " " make"
732- exit 1
740+ error_msg " Error installing package $PKG_NAME " " make"
741+ exit 1
733742 fi
734743else
735744 # Package only has spkg-install
736745 time ./spkg-install
737746 if [ $? -ne 0 ]; then
738- error_msg " Error installing package $PKG_NAME " " make"
739- exit 1
747+ error_msg " Error installing package $PKG_NAME " " make"
748+ exit 1
740749 fi
741750fi
742751
0 commit comments