[darwinbuild-changes] [740] trunk/darwinup
source_changes at macosforge.org
source_changes at macosforge.org
Sat Mar 6 18:39:39 PST 2010
Revision: 740
http://trac.macosforge.org/projects/darwinbuild/changeset/740
Author: wsiegrist at apple.com
Date: 2010-03-06 18:39:36 -0800 (Sat, 06 Mar 2010)
Log Message:
-----------
Add superseded keyword for archives that have been fully replaced by newer roots.
Modified Paths:
--------------
trunk/darwinup/DB.cpp
trunk/darwinup/Depot.cpp
trunk/darwinup/Depot.h
trunk/darwinup/main.cpp
Modified: trunk/darwinup/DB.cpp
===================================================================
--- trunk/darwinup/DB.cpp 2010-03-06 00:27:08 UTC (rev 739)
+++ trunk/darwinup/DB.cpp 2010-03-07 02:39:36 UTC (rev 740)
@@ -402,7 +402,7 @@
int res = this->get_all_ordered("get_archives",
data, count,
this->m_archives_table,
- this->m_archives_table->column(0), // order by path
+ this->m_archives_table->column(0), // order by serial
ORDER_BY_DESC,
1,
this->m_archives_table->column(2), // name
Modified: trunk/darwinup/Depot.cpp
===================================================================
--- trunk/darwinup/Depot.cpp 2010-03-06 00:27:08 UTC (rev 739)
+++ trunk/darwinup/Depot.cpp 2010-03-07 02:39:36 UTC (rev 740)
@@ -266,6 +266,36 @@
return list;
}
+Archive** Depot::get_superseded_archives(uint32_t* count) {
+ int res = DB_OK;
+ uint8_t** archlist;
+ res = this->m_db->get_archives(&archlist, count, false); // rollbacks cannot be superseded
+
+ Archive** list = (Archive**)malloc(sizeof(Archive*) * (*count));
+ if (!list) {
+ fprintf(stderr, "Error: ran out of memory in Depot::get_superseded_archives\n");
+ return NULL;
+ }
+
+ uint32_t i = 0;
+ uint32_t cur = i;
+ if (FOUND(res)) {
+ while (i < *count) {
+ Archive* archive = this->m_db->make_archive(archlist[i++]);
+ if (archive && this->is_superseded(archive)) {
+ list[cur++] = archive;
+ } else if (!archive) {
+ fprintf(stderr, "%s:%d: DB::make_archive returned NULL\n", __FILE__, __LINE__);
+ res = -1;
+ break;
+ }
+ }
+ }
+ // adjust count based on our is_superseded filtering
+ *count = cur;
+ return list;
+}
+
uint64_t Depot::count_archives() {
extern uint32_t verbosity;
uint64_t c = this->m_db->count_archives((bool)(verbosity & VERBOSE_DEBUG));
@@ -836,6 +866,9 @@
if (res == 0) res = prune_archives();
+ if (res == 0) fprintf(stdout, "Uninstalled archive: %llu %s \n",
+ archive->serial(), archive->name());
+
(void)this->lock(LOCK_SH);
return res;
@@ -1009,6 +1042,23 @@
int Depot::is_locked() { return m_is_locked; }
+bool Depot::is_superseded(Archive* archive) {
+ int res = DB_OK;
+ uint8_t** filelist;
+ uint8_t* data;
+ uint32_t count;
+ res = this->m_db->get_files(&filelist, &count, archive);
+ if (FOUND(res)) {
+ for (uint32_t i=0; i < count; i++) {
+ File* file = this->m_db->make_file(filelist[i]);
+ res = this->m_db->get_next_file(&data, file, FILE_SUPERSEDED);
+ // XXX: need to send data to Table to free
+ if (!FOUND(res)) return false;
+ }
+ }
+ return true;
+}
+
int Depot::lock(int operation) {
int res = 0;
if (m_lock_fd == -1) {
@@ -1133,6 +1183,8 @@
if (strncasecmp(arg, "all", 3) == 0) {
list = this->get_all_archives(&count);
+ } else if (strncasecmp(arg, "superseded", 10) == 0) {
+ list = this->get_superseded_archives(&count);
} else {
// make a list of 1 Archive
list = (Archive**)malloc(sizeof(Archive*));
Modified: trunk/darwinup/Depot.h
===================================================================
--- trunk/darwinup/Depot.h 2010-03-06 00:27:08 UTC (rev 739)
+++ trunk/darwinup/Depot.h 2010-03-07 02:39:36 UTC (rev 740)
@@ -79,6 +79,7 @@
// returns a list of Archive*. Caller must free the list.
Archive** get_all_archives(uint32_t *count);
+ Archive** get_superseded_archives(uint32_t *count);
uint64_t count_archives();
int dump();
@@ -112,6 +113,7 @@
// test if the depot is currently locked
int is_locked();
+ bool is_superseded(Archive* archive);
protected:
Modified: trunk/darwinup/main.cpp
===================================================================
--- trunk/darwinup/main.cpp 2010-03-06 00:27:08 UTC (rev 739)
+++ trunk/darwinup/main.cpp 2010-03-07 02:39:36 UTC (rev 740)
@@ -72,12 +72,14 @@
fprintf(stderr, " xar, zip \n");
fprintf(stderr, " \n");
fprintf(stderr, "<archive> is one of: \n");
- fprintf(stderr, " <serial> the Serial number \n");
- fprintf(stderr, " <uuid> the UUID \n");
- fprintf(stderr, " <name> the last root installed with that name \n");
- fprintf(stderr, " newest the newest (last) root installed \n");
- fprintf(stderr, " oldest the oldest root installed \n");
- fprintf(stderr, " all all installed roots \n");
+ fprintf(stderr, " <serial> the Serial number \n");
+ fprintf(stderr, " <uuid> the UUID \n");
+ fprintf(stderr, " <name> the last root installed with that name \n");
+ fprintf(stderr, " newest the newest (last) root installed \n");
+ fprintf(stderr, " oldest the oldest root installed \n");
+ fprintf(stderr, " superseded all roots that have been fully replaced \n");
+ fprintf(stderr, " by newer roots \n");
+ fprintf(stderr, " all all installed roots \n");
fprintf(stderr, " \n");
exit(1);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/darwinbuild-changes/attachments/20100306/803a3f61/attachment.html>
More information about the darwinbuild-changes
mailing list