<pre style='margin:0'>
Clemens Lang (neverpanic) pushed a commit to branch gsoc17-migrate
in repository macports-base.
</pre>
<p><a href="https://github.com/macports/macports-base/commit/aa112e2eabf9c2f7d6810b50efe630ffd8282d41">https://github.com/macports/macports-base/commit/aa112e2eabf9c2f7d6810b50efe630ffd8282d41</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit aa112e2eabf9c2f7d6810b50efe630ffd8282d41
</span>Author: Umesh Singla <umeshksingla@macports.org>
AuthorDate: Mon Jun 26 00:10:02 2017 +0530
<span style='display:block; white-space:pre;color:#404040;'> WIP: Add function to store ports as part of the snapshot
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> Store all currently installed ports in snapshot_ports along
</span><span style='display:block; white-space:pre;color:#404040;'> with the requested flag, with a foreign key linked to a snapshot.
</span><span style='display:block; white-space:pre;color:#404040;'> This function can be moved to a different file in future.
</span>---
src/cregistry/entry.c | 58 +++++++++++++++++++++++++++++++++++++++++---
src/cregistry/entry.h | 6 +++--
src/macports1.0/snapshot.tcl | 1 -
src/registry2.0/entry.c | 9 -------
4 files changed, 58 insertions(+), 16 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/cregistry/entry.c b/src/cregistry/entry.c
</span><span style='display:block; white-space:pre;color:#808080;'>index e364992..0cc3955 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/cregistry/entry.c
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/cregistry/entry.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1313,10 +1313,6 @@ int reg_entry_depends(reg_entry* entry, char* name, reg_error* errPtr) {
</span> return result;
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>-void test_call_c() {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- printf("inside cregsitry\n");
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span> reg_entry* reg_snapshot_create(reg_registry* reg, char* note, reg_error* errPtr) {
printf("inside cregsitry sn cr\n");
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1377,6 +1373,60 @@ reg_entry* reg_snapshot_create(reg_registry* reg, char* note, reg_error* errPtr)
</span> return entry;
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+int snapshot_store_ports(reg_registry* reg, reg_entry* entry, reg_error* errPtr){
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ reg_entry** entries;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ reg_error error;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int i, entry_count;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int result = 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ entry_count = reg_entry_imaged(reg, NULL, NULL, NULL, NULL,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ &entries, &error);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ printf("entry count: %d\n", entry_count);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (entry_count >= 0) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ for ( i = 0; i < entry_count; i++){
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ char* key1 = "name";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ char* key2 = "requested";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ char* port_name;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ char* requested;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ sqlite3_stmt* stmt = NULL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if(reg_entry_propget(entries[i], key1, &port_name, &error)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ && reg_entry_propget(entries[i], key2, &requested, &error)){
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ char* query = "INSERT INTO registry.snapshot_ports (id, port_name, requested) "
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "VALUES (?, ?, ?)";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ // entry->id is snapshot's id
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if ((sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ && (sqlite3_bind_int64(stmt, 1, entry->id) == SQLITE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ && (sqlite3_bind_text(stmt, 2, port_name, -1, SQLITE_STATIC) == SQLITE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ && (sqlite3_bind_int64(stmt, 3, atoi(requested)) == SQLITE_OK)) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int r;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ do {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ r = sqlite3_step(stmt);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ switch (r) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ case SQLITE_DONE:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ // store variants for entries[i]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ printf("done with %s port\n", port_name);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ case SQLITE_BUSY:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ default:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ reg_sqlite_error(reg->db, errPtr, query);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ result = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } while (r == SQLITE_BUSY);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ reg_sqlite_error(reg->db, errPtr, query);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ result = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (stmt) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ sqlite3_finalize(stmt);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ printf("stored: %d\n", result);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return result;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> /**
* Fetches a list of all open entries.
*
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/cregistry/entry.h b/src/cregistry/entry.h
</span><span style='display:block; white-space:pre;color:#808080;'>index 55e57ce..644e269 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/cregistry/entry.h
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/cregistry/entry.h
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -94,8 +94,10 @@ int reg_entry_dependencies(reg_entry* entry, reg_entry*** dependencies,
</span> reg_error* errPtr);
int reg_entry_depends(reg_entry* entry, char* name, reg_error* errPtr);
<span style='display:block; white-space:pre;background:#ffe0e0;'>-void test_call_c();
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-reg_entry* reg_snapshot_create(reg_registry* reg, char* note, reg_error* errPtr);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+reg_entry* reg_snapshot_create(reg_registry* reg, char* note,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ reg_error* errPtr);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int snapshot_store_ports(reg_registry* reg, reg_entry* entry,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ reg_error* errPtr);
</span>
int reg_all_open_entries(reg_registry* reg, reg_entry*** entries);
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/macports1.0/snapshot.tcl b/src/macports1.0/snapshot.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index efb8cad..a77fed9 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/macports1.0/snapshot.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/macports1.0/snapshot.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -25,7 +25,6 @@ namespace eval snapshot {
</span> puts [$port name]
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- registry::entry testcall
</span> set a [registry::entry snapshot "testsnapshot"]
puts $a
puts done
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/registry2.0/entry.c b/src/registry2.0/entry.c
</span><span style='display:block; white-space:pre;color:#808080;'>index 71d1efe..54342d1 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/registry2.0/entry.c
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/registry2.0/entry.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -477,13 +477,6 @@ static int entry_owner(Tcl_Interp* interp, int objc, Tcl_Obj* CONST objv[]) {
</span> }
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>-static int test_call(){
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- printf("inside registry2.0\n");
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- test_call_c();
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- printf("done here\n");
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return TCL_OK;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span> static int snapshot_create(Tcl_Interp* interp, int objc, Tcl_Obj* CONST objv[]) {
printf("inside 2.0 entry\n");
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -526,8 +519,6 @@ static entry_cmd_type entry_cmds[] = {
</span> { "imaged", entry_imaged },
{ "installed", entry_installed },
{ "owner", entry_owner },
<span style='display:block; white-space:pre;background:#ffe0e0;'>- /* test call */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- { "testcall", test_call },
</span> { "snapshot", snapshot_create},
{ NULL, NULL }
};
</pre><pre style='margin:0'>
</pre>