[darwinbuild-changes] [895] branches/PR-8488185

source_changes at macosforge.org source_changes at macosforge.org
Mon Oct 25 15:07:42 PDT 2010


Revision: 895
          http://trac.macosforge.org/projects/darwinbuild/changeset/895
Author:   wsiegrist at 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:
--------------
    branches/PR-8488185/darwinup/Depot.cpp
    branches/PR-8488185/darwinup/Depot.h
    branches/PR-8488185/testing/darwinup/run-tests.sh

Added Paths:
-----------
    branches/PR-8488185/testing/darwinup/corrupt.tgz

Modified: branches/PR-8488185/darwinup/Depot.cpp
===================================================================
--- 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
===================================================================
--- 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
===================================================================
--- 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
===================================================================
--- 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/darwinbuild-changes/attachments/20101025/0417638b/attachment-0001.html>


More information about the darwinbuild-changes mailing list