[m-dev.] for review: warn about problems with `make install'
Warwick Harvey
wharvey at cs.monash.edu.au
Fri Mar 12 17:38:06 AEDT 1999
Fergus wrote:
> On 08-Mar-1999, Warwick Harvey <wharvey at cs.monash.edu.au> wrote:
> >
> > Is it worth trying to provide something better than this?
>
> That depends on who is volunteering ;-)
I think I was volunteering if it was deemed worth trying to provide
something better than this...
Agh, now my brain hurts.
> If you want to have a go at a better fix, please go ahead.
OK, here's my script. I haven't looked at an appropriate way to get it
called from the build process yet. That's the next step.
Oh, and I've put a Monash University copyright on this file, since I wrote
it from scratch myself. I don't know what the Mercury group's attitude is
with respect to the copyright of things contributed from "outside". The
reason I haven't worried about the copyright issue up to now (apart from my
contributions only being small ;-) and why I'd be willing to change the
copyright to UniMelb is that the grant that pays my salary is a joint
UniMelb/Monash grant, so I figured I could claim I was kinda a UniMelb
person anyway... Though I probably should check if there are any problems
with that at this end...
Anyway, here's the script, for review (is tools the right directory?):
Index: tools/cleanup_install
===================================================================
RCS file: cleanup_install
diff -N cleanup_install
--- /dev/null Fri Mar 12 17:03:09 1999
+++ cleanup_install Fri Mar 12 17:20:13 1999
@@ -0,0 +1,77 @@
+#! /bin/sh
+#---------------------------------------------------------------------------
#
+# Copyright (C) 1999 Monash University.
+# This file may only be copied under the terms of the GNU General
+# Public License - see the file COPYING in the Mercury distribution.
+#---------------------------------------------------------------------------
#
+#
+# cleanup_install
+#
+# Author: Warwick Harvey <wharvey at cs.monash.edu.au>
+#
+# Checks for failed/aborted installation attempts, and tries to clean up
+# after them, since simply re-starting the install may do the wrong thing.
+#
+# The main problem with restarting an install is when the install is
+# interrupted during the building of alternative grades of the library,
+# runtime, etc. When the alternative grades are being built, the versions
+# of the compiled files needed for the compiler itself (as opposed to
+# installed libraries) are moved into a `tmp_dir' subdirectory, with the
+# alternative versions being built in the old location. This means that if
+# the process is interrupted and then re-started, the build process will
+# attempt to re-build the compiler using some files with the wrong grade.
+#
+# This script checks for the presence of second-level directories named
+# `tmp_dir', and if it finds them, assumes that an install process has
+# failed and needs to be cleaned up. Cleaning up the failed install
+# consists simply of moving all the files in each `tmp_dir' back to where
+# they came from, overwriting any alternative grade versions that may be
+# there, and deleting the temporary directories.
+#
+# If there is an error while doing the clean-up, a more aggressive approach
+# is used. An "mmake clean" is run on the directory in question, and then
+# the `tmp_dir' is deleted completely. Note that for some directories (e.g.
+# `library' and `browser'), this deletes some C files, which require a
+# working version of Mercury to rebuild. However, if the installation got
+# as far as building the different grades of the library, then the compiler
+# (plus its default grade) has already been installed. The build scripts
+# are smart enough to find and use this installed version even if it's not
+# in the user's path, so the "mmake clean" is safe even if there is no
+# existing Mercury installation (e.g. if the user is building it from
+# release sources).
+
+cleanup_failed_dirs=
+
+for tmp in */tmp_dir ; do
+ if [ "$tmp" != "*/tmp_dir" ] ; then
+ dir=`dirname $tmp`
+ echo "Cleaning up from apparent failed install in \`$dir'..."
+ if ( cd $dir && mv -f tmp_dir/* . && rmdir tmp_dir ) ; then
+ echo "Done."
+ else
+ echo "Failed. Trying a more aggressive approach..."
+ if ( cd $dir && ../scripts/mmake clean && rm -rf tmp_dir ) ; then
+ echo "Succeeded."
+ else
+ echo "Failed again. :-("
+ cleanup_failed_dirs="$cleanup_failed_dirs $dir"
+ fi
+ fi
+ fi
+done
+
+if [ -n "$cleanup_failed_dirs" ] ; then
+ cat <<END
+
+Clean-up failed in the following directories:
+
+$cleanup_failed_dirs
+
+Either fix these directories by hand, or start over from scratch.
+
+END
+ exit 1
+fi
+
+exit 0
+
More information about the developers
mailing list