Revision
895
Author
wsiegrist@apple.com
Date
2010-10-25 15:07:40 -0700 (Mon, 25 Oct 2010)

Log Message

Do not try to rollback transactions or archive installations when early failures occur, since there is nothing to rollback.

Modified Paths

Added Paths

Diff

Modified: branches/PR-8488185/darwinup/Depot.cpp (894 => 895)


--- branches/PR-8488185/darwinup/Depot.cpp	2010-10-25 22:06:35 UTC (rev 894)
+++ branches/PR-8488185/darwinup/Depot.cpp	2010-10-25 22:07:40 UTC (rev 895)
@@ -688,8 +688,9 @@
 			fprintf(stdout, "%s\n", uuid);
 		} else {
 			fprintf(stderr, "Error: Install failed.\n");				
-			if (res != DEPOT_OBJ_CHANGE) {
+			if (res != DEPOT_OBJ_CHANGE && res != DEPOT_PREINSTALL_ERR) {
 				// object change errors come from analyze stage,
+				// and pre-install errors happen early,
 				// so there is no installation to roll back
 				fprintf(stderr, "Rolling back installation.\n");
 				res = this->uninstall(archive);
@@ -763,6 +764,10 @@
 		remove_directory(rollback_path);
 		free(rollback_path);
 		free(archive_path);
+		if (!dryrun && res) {
+			this->rollback_transaction();
+			return DEPOT_PREINSTALL_ERR;
+		}
 		return res;
 	}
 	

Modified: branches/PR-8488185/darwinup/Depot.h (894 => 895)


--- branches/PR-8488185/darwinup/Depot.h	2010-10-25 22:06:35 UTC (rev 894)
+++ branches/PR-8488185/darwinup/Depot.h	2010-10-25 22:07:40 UTC (rev 895)
@@ -46,6 +46,7 @@
 #define DEPOT_OBJ_CHANGE     -4
 #define DEPOT_BUILD_MISMATCH -5
 #define DEPOT_USAGE_ERROR    -6
+#define DEPOT_PREINSTALL_ERR -7
 
 
 struct Archive;

Added: branches/PR-8488185/testing/darwinup/corrupt.tgz (0 => 895)


--- branches/PR-8488185/testing/darwinup/corrupt.tgz	                        (rev 0)
+++ branches/PR-8488185/testing/darwinup/corrupt.tgz	2010-10-25 22:07:40 UTC (rev 895)
@@ -0,0 +1,2 @@
+This is a text file. Darwinup will see the .tgz extension and try to use tar on it.
+This will fail, which allows us to test early failures from external tools (like ditto and tar).

Modified: branches/PR-8488185/testing/darwinup/run-tests.sh (894 => 895)


--- branches/PR-8488185/testing/darwinup/run-tests.sh	2010-10-25 22:06:35 UTC (rev 894)
+++ branches/PR-8488185/testing/darwinup/run-tests.sh	2010-10-25 22:07:40 UTC (rev 895)
@@ -62,6 +62,8 @@
 	cp $R $PREFIX/
 done;
 
+cp corrupt.tgz $PREFIX/
+
 mkdir -p $ORIG
 cp -R $DEST/* $ORIG/
 
@@ -426,6 +428,17 @@
 echo "========== Expected Failures =========="
 set +e
 
+echo "========== TEST: testing early ditto failure ==========";
+
+$DARWINUP install $PREFIX/corrupt.tgz | tee $PREFIX/corrupt.log
+C=$(grep -c 'Rolling back' $PREFIX/corrupt.log)
+test $C -eq 0
+if [ $? -ne 0 ]; then exit 1; fi
+echo "DIFF: diffing original test files to dest (should be no diffs) ..."
+$DIFF $ORIG $DEST 2>&1
+if [ $? -ne 0 ]; then exit 1; fi
+
+
 echo "========== TEST: Try replacing File with Directory =========="
 $DARWINUP install $PREFIX/rep_file_dir
 if [ $? -ne 255 ]; then exit 1; fi