[darwinbuild-changes] [797] branches/PR-7798586/darwinup

source_changes at macosforge.org source_changes at macosforge.org
Sat Mar 27 19:36:15 PDT 2010


Revision: 797
          http://trac.macosforge.org/projects/darwinbuild/changeset/797
Author:   wsiegrist at apple.com
Date:     2010-03-27 19:36:15 -0700 (Sat, 27 Mar 2010)
Log Message:
-----------
Do not require -f to uninstall a superseded archive

Modified Paths:
--------------
    branches/PR-7798586/darwinup/Archive.cpp
    branches/PR-7798586/darwinup/Archive.h
    branches/PR-7798586/darwinup/Depot.cpp

Modified: branches/PR-7798586/darwinup/Archive.cpp
===================================================================
--- branches/PR-7798586/darwinup/Archive.cpp	2010-03-28 02:24:35 UTC (rev 796)
+++ branches/PR-7798586/darwinup/Archive.cpp	2010-03-28 02:36:15 UTC (rev 797)
@@ -51,6 +51,7 @@
 	m_name = strdup(basename(m_path));
 	m_info = 0;
 	m_date_installed = time(NULL);
+	m_is_superseded = -1;  // unknown
 }
 
 Archive::Archive(uint64_t serial, uuid_t uuid, const char* name, const char* path, 
@@ -62,6 +63,7 @@
 	m_build = build ? strdup(build) : NULL;
 	m_info = info;
 	m_date_installed = date_installed;
+	m_is_superseded = -1; // unknown
 }
 
 

Modified: branches/PR-7798586/darwinup/Archive.h
===================================================================
--- branches/PR-7798586/darwinup/Archive.h	2010-03-28 02:24:35 UTC (rev 796)
+++ branches/PR-7798586/darwinup/Archive.h	2010-03-28 02:36:15 UTC (rev 797)
@@ -106,7 +106,7 @@
 	// The epoch seconds when the archive was installed.
 	virtual time_t date_installed();
 	
-	
+		
 	////
 	//  Member functions
 	////
@@ -146,6 +146,9 @@
 	uint64_t	m_info;
 	time_t		m_date_installed;
 	
+	// -1 unknown, 0 false, 1 true
+	int       m_is_superseded;
+	
 	friend struct Depot;
 	friend struct DarwinupDatabase;
 };

Modified: branches/PR-7798586/darwinup/Depot.cpp
===================================================================
--- branches/PR-7798586/darwinup/Depot.cpp	2010-03-28 02:24:35 UTC (rev 796)
+++ branches/PR-7798586/darwinup/Depot.cpp	2010-03-28 02:36:15 UTC (rev 797)
@@ -929,7 +929,9 @@
 	if (!force && 
 		this->m_build &&
 		archive->build() &&
-		(strcmp(this->m_build, archive->build()) != 0)) {
+		(strcmp(this->m_build, archive->build()) != 0) &&
+		!this->is_superseded(archive)
+		) {
 		fprintf(stderr, 
 				"-------------------------------------------------------------------------------\n"
 				"The %s root was installed on a different base OS build (%s). The current    \n"
@@ -1195,6 +1197,12 @@
 int Depot::is_locked() { return m_is_locked; }
 
 bool Depot::is_superseded(Archive* archive) {
+	// return early if already known
+	if (archive->m_is_superseded != -1) { 
+		return (archive->m_is_superseded == 1);
+	}
+	
+	// need to find out if superseded
 	int res = DB_OK;
 	uint8_t** filelist;
 	uint8_t* data;
@@ -1218,12 +1226,16 @@
 
 			// not found in database and no changes on disk, 
 			// so file is the current version of actual
-			if (flags == FILE_INFO_IDENTICAL) return false;
+			if (flags == FILE_INFO_IDENTICAL) {
+				archive->m_is_superseded = 0;
+				return false;
+			}
 			 
 			// something external changed contents of actual,
 			// so we consider this file superseded (by OS upgrade?)
 		}
 	}
+	archive->m_is_superseded = 1;
 	return true;			
 }
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/darwinbuild-changes/attachments/20100327/f8296272/attachment-0001.html>


More information about the darwinbuild-changes mailing list