[m-rev.] for review: make backup of installed compiler before install
Ian MacLarty
maclarty at cs.mu.OZ.AU
Tue Feb 15 19:19:52 AEDT 2005
On Tue, Feb 15, 2005 at 06:28:15PM +1100, Zoltan Somogyi wrote:
> On 15-Feb-2005, Ian MacLarty <maclarty at cs.mu.OZ.AU> wrote:
> > Index: tools/test_mercury
> > ===================================================================
> > RCS file: /home/mercury1/repository/mercury/tools/test_mercury,v
> > retrieving revision 1.249
> > diff -u -r1.249 test_mercury
> > --- tools/test_mercury 26 Jan 2005 15:56:05 -0000 1.249
> > +++ tools/test_mercury 15 Feb 2005 06:13:03 -0000
> > @@ -728,6 +728,12 @@
> > true) cd mercury || { false; exit 1; } ;;
> > esac
> >
> > + # Make a backup copy of the current installation which we will restore
> > + # if the new installation fails.
> > +
> > + mkdir -p $INSTALL_DIR/../mercury_install_backup
> > + cp -rf $INSTALL_DIR/* $INSTALL_DIR/../mercury_install_backup
>
> You need to remove any $INSTALL_DIR/* $INSTALL_DIR/../mercury_install_backup
> first, if it exists, otherwise the cp will do the wrong thing.
>
Okay, but what exactly do you mean by "do the wrong thing"? I ran some tests
and cp seems to do the right thing even if mercury_install_backup exists.
I assume you don't mean remove $INSTALL_DIR/* - then there would be nothing to
backup.
> > # Previously we had lots of special case code here for installing on
> > # IRIX systems. We don't currently have any IRIX boxes, and this
> > # code was a bit of a pain to maintain. If we ever get an IRIX box
> > @@ -775,6 +781,8 @@
> > ;;
> > *)
> > date >> $TESTDIR/logs/install-failed."$TEST_ID"
> > + # restore the previous installation
> > + cp -rf $INSTALL_DIR/../mercury_install_backup/* $INSTALL_DIR
> > ;;
> > esac
>
> This will create a directory called mercury_install_backup inside $INSTALL_DIR.
> You need to remove $INSTALL_DIR first.
>
Not according to my tests, but okay.
Here's the output of the tests I did:
maclarty at jupiter:~/test> mkdir install_dir
maclarty at jupiter:~/test> cd install_dir/
maclarty at jupiter:~/test/install_dir> vi test1
maclarty at jupiter:~/test/install_dir> vi test2
maclarty at jupiter:~/test/install_dir> ls
test1 test2
maclarty at jupiter:~/test/install_dir> export INSTALL_DIR=`pwd`
maclarty at jupiter:~/test/install_dir> echo $INSTALL_DIR
/home/mercury/maclarty/test/install_dir
maclarty at jupiter:~/test/install_dir> mkdir dirtest
maclarty at jupiter:~/test/install_dir> cd dirtest
maclarty at jupiter:~/test/install_dir/dirtest> vi test3
maclarty at jupiter:~/test/install_dir/dirtest> vi test4
maclarty at jupiter:~/test/install_dir/dirtest> cd ..
maclarty at jupiter:~/test/install_dir> mkdir -p $INSTALL_DIR/../mercury_install_backup
maclarty at jupiter:~/test/install_dir> ls ..
install_dir mercury_install_backup
maclarty at jupiter:~/test/install_dir> cp -rf $INSTALL_DIR/* $INSTALL_DIR/../mercury_install_backup
maclarty at jupiter:~/test/install_dir> ls -R ../mercury_install_backup/
../mercury_install_backup/:
dirtest test1 test2
../mercury_install_backup/dirtest:
test3 test4
maclarty at jupiter:~/test/install_dir> cp -rf $INSTALL_DIR/../mercury_install_backup/* $INSTALL_DIR
maclarty at jupiter:~/test/install_dir> ls -l
total 1
drwx------ 2 maclarty mercury 512 2005-02-15 18:41 dirtest
-rw------- 1 maclarty mercury 0 2005-02-15 18:44 test1
-rw------- 1 maclarty mercury 0 2005-02-15 18:44 test2
maclarty at jupiter:~/test/install_dir> vi test5
maclarty at jupiter:~/test/install_dir> rm test2
maclarty at jupiter:~/test/install_dir> rm -rf dirtest
maclarty at jupiter:~/test/install_dir> cp -rf $INSTALL_DIR/../mercury_install_backup/* $INSTALL_DIR
maclarty at jupiter:~/test/install_dir> ls -R
.:
dirtest test1 test2 test5
./dirtest:
test3 test4
maclarty at jupiter:~/test/install_dir> mkdir -p $INSTALL_DIR/../mercury_install_backup
maclarty at jupiter:~/test/install_dir> ls -R ..
..:
install_dir mercury_install_backup
../install_dir:
dirtest test1 test2 test5
../install_dir/dirtest:
test3 test4
../mercury_install_backup:
dirtest test1 test2
../mercury_install_backup/dirtest:
test3 test4
maclarty at jupiter:~/test/install_dir> cp -rf $INSTALL_DIR/* $INSTALL_DIR/../mercury_install_backup
maclarty at jupiter:~/test/install_dir> ls -R ..
..:
install_dir mercury_install_backup
../install_dir:
dirtest test1 test2 test5
../install_dir/dirtest:
test3 test4
../mercury_install_backup:
dirtest test1 test2 test5
../mercury_install_backup/dirtest:
test3 test4
maclarty at jupiter:~/test/install_dir> ls -l
total 1
drwx------ 2 maclarty mercury 512 2005-02-15 18:45 dirtest
-rw------- 1 maclarty mercury 0 2005-02-15 18:45 test1
-rw------- 1 maclarty mercury 0 2005-02-15 18:45 test2
-rw------- 1 maclarty mercury 0 2005-02-15 18:44 test5
maclarty at jupiter:~/test/install_dir> cp -rf $INSTALL_DIR/../mercury_install_backup/* $INSTALL_DIR
maclarty at jupiter:~/test/install_dir> ls -Rl
.:
total 1
drwx------ 2 maclarty mercury 512 2005-02-15 18:45 dirtest
-rw------- 1 maclarty mercury 0 2005-02-15 18:47 test1
-rw------- 1 maclarty mercury 0 2005-02-15 18:47 test2
-rw------- 1 maclarty mercury 0 2005-02-15 18:47 test5
./dirtest:
total 0
-rw------- 1 maclarty mercury 0 2005-02-15 18:47 test3
-rw------- 1 maclarty mercury 0 2005-02-15 18:47 test4
maclarty at jupiter:~/test/install_dir>
and the new diff:
Index: tools/test_mercury
===================================================================
RCS file: /home/mercury1/repository/mercury/tools/test_mercury,v
retrieving revision 1.249
diff -u -r1.249 test_mercury
--- tools/test_mercury 26 Jan 2005 15:56:05 -0000 1.249
+++ tools/test_mercury 15 Feb 2005 08:11:26 -0000
@@ -728,6 +728,13 @@
true) cd mercury || { false; exit 1; } ;;
esac
+ # Make a backup copy of the current installation which we will restore
+ # if the new installation fails.
+
+ rm -rf $INSTALL_DIR/../mercury_install_backup
+ mkdir -p $INSTALL_DIR/../mercury_install_backup
+ cp -rf $INSTALL_DIR/* $INSTALL_DIR/../mercury_install_backup
+
# Previously we had lots of special case code here for installing on
# IRIX systems. We don't currently have any IRIX boxes, and this
# code was a bit of a pain to maintain. If we ever get an IRIX box
@@ -775,6 +782,9 @@
;;
*)
date >> $TESTDIR/logs/install-failed."$TEST_ID"
+ # restore the previous installation
+ rm -rf $INSTALL_DIR/*
+ cp -rf $INSTALL_DIR/../mercury_install_backup/* $INSTALL_DIR
;;
esac
esac
Ian.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list