<div dir="ltr">Hi Brad,<div><br></div><div>With another week over, I have the following updates to share. </div><div>







<p class="gmail-p1"><b><br></b></p><p class="gmail-p1"><b>GSoC Week #7 (13 Jul - 19 Jul)</b></p><p class="gmail-p1">I moved the things to migrate action instead of 'restore' since 'restore' looks a subset of 'migrate', so can be dealt easily once migrate is over.</p><p class="gmail-p1"><br></p><p class="gmail-p1">Agenda for last week:<br></p><p class="gmail-p1">The migrate action consisted of three parts, creating a new snapshot, uninstall installed ports, re-installing them for the last snapshot.</p><p class="gmail-p1">1. Creating a new snapshot was over before, though some refactoring is still left.</p><p class="gmail-p1">2. Regarding uninstalling installed ports, I took the help of reclaim.tcl which works with the migrate action now. It uses sort_portlist_by_dependendents procedure. So, all in all, it uses "registry_uninstall::uninstall".<br></p><p class="gmail-p1">3. Re-installing the ports from the portlist. I took the help of restore_ports.tcl here, which works when called migrate. It uses <font color="#000000"><span style="white-space:pre-wrap">sort_ports [1] function. </span></font></p><p class="gmail-p1"><font color="#000000"><span style="white-space:pre-wrap"><br></span></font></p><p class="gmail-p1"><font color="#000000"><span style="white-space:pre-wrap">When we install, is it fine to use [mportexec $workername $install_target] from migrate.tcl?</span></font></p><p class="gmail-p1"><font color="#000000"><span style="white-space:pre-wrap">What took time is that these two functions at present take the port list in different formats. So, I tried debugging by simply printing on console method to know the formats of the two. </span></font></p><p class="gmail-p1"><font color="#000000"><span style="white-space:pre-wrap">I want to use the sorting function for dependencies only once instead of calling it twice while uninstalling and then re-installing. I'm still working on it and actually, close to solve this but thought, better send the weekly update first.</span></font></p><p class="gmail-p1"><br></p><p class="gmail-p1">For the next one week:<br></p>
<ol class="gmail-ol1">
<li class="gmail-li3">make appropriate changes to procedures according to<span class="gmail-Apple-converted-space"> one format.</span></li>
<li class="gmail-li3">write for “SELECT PORTS FROM SNAPSHOT ..”, i.e. connect it with the new tables we have.</li><li class="gmail-li3">try finishing the migrate action asap?</li></ol><p class="gmail-p3"><br></p><p class="gmail-p3">Points:</p><p class="gmail-p3">Since migrate action creates a snapshot within and then uses it to redo the whole state, I feel creating a snapshot here explicitly is redundant. </p><p class="gmail-p3">Internally snapshot also uses the same registry C functions to get the information first and then save to database as [registry::entry imaged] does, so instead of first retrieving from [registry::entry imaged], saving it in sqlite and then again fetching all the info using the snapshot-id we just got, can't we directly use [registry::entry imaged] here? Am I missing something?</p><p class="gmail-p3">Regarding "selected" snapshot for 'restore', it looks fine.</p><p class="gmail-p3"><br></p>
<p class="gmail-p3">New points which I made during pondering to save for the end:</p>
<ol class="gmail-ol1">
<li class="gmail-li3">Add ui_debug statements</li>
<li class="gmail-li3">Catch some error-prone areas.</li>
<li class="gmail-li3">Remove the useless/structure comments and add actual doc-strings.</li>
<li class="gmail-li3">Add copyright notices</li>
<li class="gmail-li3">Using ui_msg instead of puts and else. Should probably add that.</li></ol><p class="gmail-p3"><br></p><p class="gmail-p3">Also, here's my view of restore_ports.tcl of what it does:</p>
<ul class="gmail-ul1">
<li class="gmail-li3">macports prefix configs</li>
<li class="gmail-li3">umask 022</li>
<li class="gmail-li3">set portList [read_portlist $filename] - reads the portlist from file supplied or stdin</li>
<li class="gmail-li3">set operationList [sort_ports $portList]</li>
<ul class="gmail-ul1">
<li class="gmail-li3">sort_ports $portList</li>
<ul class="gmail-ul1">
<li class="gmail-li3">extracts name, version, variants, active for a port</li>
<li class="gmail-li3">sets it 1 in port_in_list if not there, else increments the count for that port</li>
<li class="gmail-li3">if port dependencies for the combination (port_name, its variants) doesn’t exist already, fetches them using dependenciesForPort(port_name, its variants), kind of recursively.</li>
</ul>
<li class="gmail-li3">dependenciesForPort $port_name $variants</li>
</ul>
<li class="gmail-li3">install_ports $operationList</li>
<ul class="gmail-ul1">
<li class="gmail-li3">checks $active for a port and use it to decide install_target</li>
<li class="gmail-li3">uses mportexec for installing</li></ul></ul>
<p class="gmail-p4"><br></p><p class="gmail-p4">Please find the work log here [2]. It is largely in work-in-progress state.<br></p><p class="gmail-p4"><br></p><p class="gmail-p4">[1]: <a href="https://github.com/macports/macports-contrib/blob/master/restore_ports/restore_ports.tcl#L52">https://github.com/macports/macports-contrib/blob/master/restore_ports/restore_ports.tcl#L52</a></p><p class="gmail-p4">[2]: <a href="https://github.com/macports/macports-base/commits/gsoc17-migrate">https://github.com/macports/macports-base/commits/gsoc17-migrate</a></p><p class="gmail-p4"><br></p><p class="gmail-p4">Best Regards,</p><p class="gmail-p4">Umesh Singla</p></div></div>