GSoC#6: Project and pre-second evaluation period

Unlike the previous one, this was a more productive period. There were some important discoveries I made about how the port command works and how the macports-base is written to serve the Tcl and registry APIs for non-core modules.

I'll finally update you on the three phases of my project in a more formal way.
  1. A snapshot is a list of all commands that created the current installed state.
  2. Restoring a snapshot deactivates the active ports and reproduce the install commands for the selected snapshot.
  3. Migrate creates a new snapshot, uninstalls installed ports and reproduces the install commands for the last snapshot.
I described the snapshot in great detail in the last post. There have been changes proposed to it when I was confused about how to get the whole snapshot action behave as a single transaction and Rainer pointed out the need to have the snapshot logic begin at a higher level, probably using Tcl wrappers.

Second Phase: In all, the action `migrate` aims to create a new snapshot, uninstalls all ports, upgrades the port command for the new architecture and finally restores the last snapshot which involves installing all ports from the snapshot we created before uninstalling. Till now, I have finished the following procedures.

  • uninstall_installed to uninstall all the currently installed ports.
  • recover_ports_state to install and activate (according to the snapshot) the ports to bring out the state as close to before migrating.
  • sort_portlist_by_dependents and port_dependencies to get the dependents and dependencies in the topologically sorted order in order to avoid installation of broken ports.
There is a great deal of project left for the next phase. At a higher level, I still haven't written for fetching the snapshot from the database, needs rigorous testing and error handling. From the previous phase, the above-proposed changes are still left.

The next phase will include finishing the migrate action, connecting it to the snapshot action but majorly, the implementation of restore action. I'll very likely need to take the help of my mentor in the coming phase.

In this period, I have also tried to improve on updates for the community with all the issues, leftovers and other points separately laid out. This helped to bring out the best in the discussion.

Find the work log here.


GSoC#5: A few words on Tcl (and an advice!)

After spending a couple of hours reddit-ing and other articles, I found some really interesting insights about Tcl which otherwise you might not never know about a programming language. So the following are some of the facts about Tcl which I found interesting and just stating them here:

To quote Philip Greenspun, as a software developer, you're unlikely to get rich. So you might as well try to get through your life in such a way that you make a difference to the world (like every startup shouts "make the world a better place"). Tcl illustrates one way:
  • make something that is simple enough for almost everyone to understand,
  • give away your source code
  • explain how to "weave" your source code in with other systems
Looks something we can do? Yesss. But do we? Noo.

Tcl rocks! Well, everything IS a string, like in a fundamental way. Just look at the tape from a Turing Machine which is just an infinite mutable string. This is really, really true. Like, when you do something like a for loop, you're basically running a "for" command and passing it four strings.
 for {set x 0} {$x<10} {incr x} {  
   puts "hey"  
 }  
is equivalent to:
 for "set x 0" {$x<10} "incr x" "puts \"hey\""  
:o :o

Numbers and strings being interchangeable actually works. Everything being a string, is damn powerful but takes a while to get into the mindset that you are not just coding the solution up but programming the programming to the solution. 

Oh, and the "uplevel". "uplevel" is a terrifying and baffling feature. It gives you access to the local variables of any function that called you.. Say, whaaat?

Tcl : scripting languages :: C : compiled languages.

 As jaymaj21 comments on reddit, "simple small footprint, least hairy implementation." One of the most efficiently parsed scripting languages, Tcl is simple and way easy to implement. You can just write up your own Tcl interpreter very quick. You can write a Tcl program that pokes around the run-time environment, for example, using "info exists x".

A language that is not powerful by itself can become powerful if a procedure can invoke the interpreter, that is, if a program can write a program and then ask to have it evaluated. In Tcl, you do this by calling eval!

Tcl is more of "Tcl, C Library" because you can access about everything from C in a way that's pleasant to use. 

God was I lucky to get a Tcl project for my GSoC. Finger lickin' good!