[darwinbuild-changes] [755] branches/PR-7593824/darwinup

source_changes at macosforge.org source_changes at macosforge.org
Tue Mar 9 16:29:10 PST 2010


Revision: 755
          http://trac.macosforge.org/projects/darwinbuild/changeset/755
Author:   wsiegrist at apple.com
Date:     2010-03-09 16:29:07 -0800 (Tue, 09 Mar 2010)
Log Message:
-----------
Add message and require force option for mismatched builds during uninstall

Modified Paths:
--------------
    branches/PR-7593824/darwinup/Depot.cpp
    branches/PR-7593824/darwinup/Utils.cpp

Modified: branches/PR-7593824/darwinup/Depot.cpp
===================================================================
--- branches/PR-7593824/darwinup/Depot.cpp	2010-03-09 23:56:11 UTC (rev 754)
+++ branches/PR-7593824/darwinup/Depot.cpp	2010-03-10 00:29:07 UTC (rev 755)
@@ -844,6 +844,7 @@
 
 int Depot::uninstall(Archive* archive) {
 	extern uint32_t verbosity;
+	extern uint32_t force;
 	int res = 0;
 
 	assert(archive != NULL);
@@ -859,6 +860,25 @@
 		return -1;
 	}
 
+	/** 
+	 * require -f to force uninstalling an archive installed on top of an older
+	 * base system since the rollback archive we'll use will potentially damage
+	 * the base system.
+	 */
+	if (!force && (strcmp(this->m_build, archive->build()) != 0)) {
+		fprintf(stderr, 
+				"-------------------------------------------------------------------------------\n"
+				"The %s root was installed on a different base OS build (%s). The current    \n"
+				"OS build is %s. Uninstalling a root that was installed on a different OS     \n"
+				"build has the potential to damage your OS install due to the fact that the   \n"
+				"rollback data is from the wrong OS version.\n\n"
+				" You must use the force (-f) option to make this potentially unsafe operation  \n"
+				"happen.\n"
+				"-------------------------------------------------------------------------------\n",
+				archive->name(), archive->build(), m_build);
+		return 9999;
+	}
+	
 	res = this->lock(LOCK_EX);
 	if (res != 0) return res;
 

Modified: branches/PR-7593824/darwinup/Utils.cpp
===================================================================
--- branches/PR-7593824/darwinup/Utils.cpp	2010-03-09 23:56:11 UTC (rev 754)
+++ branches/PR-7593824/darwinup/Utils.cpp	2010-03-10 00:29:07 UTC (rev 755)
@@ -316,10 +316,10 @@
 	
 	// read from the pipe
 	close(pfd[1]);
-	*build = (char*)malloc(16);
+	*build = (char*)calloc(1, 16);
 	res = 1;
-	while (res > 0 && res < 16) {
-		res = read(pfd[0], *build, 16);
+	while (res > 0 && res < 15) {
+		res = read(pfd[0], *build, 15);
 		// strip newline
 		if (res > 1 && (*build)[res-1] == '\n') (*build)[res-1] = '\0';
 	}
@@ -356,4 +356,3 @@
 	fprintf(stdout, "=============================================="
 			"=======================================\n");	
 }
-
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/darwinbuild-changes/attachments/20100309/6343f0c0/attachment.html>


More information about the darwinbuild-changes mailing list