Sunday, August 10, 2014

GSoC 2014, Week #12: Starting to wrap everything

Hello faithful readers!

    As the title says, things are beginning to get wrapped up nicely with a little bow and everything.

    A lot of time this week was spent on trying to get all my pull requests pushed to layman's master branch. Two notable ones (in my opinion) that got merged into the master branch were the overlay-maker tool and the portage sync plug-in. However, a few things needed to be changed to get these features up to snuff, particularly the overlay-maker.

1.) Overlay maker auto-completion improvements:

    Recall previously that I discussed that the overlay-maker has auto-completion for source URLs? Well the code for that was admittedly very horrid to go through. Not very clean, not very easily maintained.

    In order to improve upon that, I took the original concept and changed the implementation almost completely.

    Originally, if you were to give the overlay-maker the source URL of "git://git.overlays.gentoo.org/proj/layman.git" a series of string modifications were made to turn that source into two other source URLs along with the homepage and two separate feeds.

    To do this, there was a function called _set_gentoo_info() or something very similar to that. Sounds a little complex, but not really. Right? Right. I would agree with you. But imagine if you wanted to add support for another source URL for auto-completion of information? And then another? If we go under the assumption that the _set_gentoo_info() function was roughly 45-50 lines of code and we wanted to add two more source URLs for support then that's an additional 45-50 lines of code per source mirror!

    That's what we call "spaghettified code" and it's not pretty, and not always necessary.

    So for the sake of space, maintainability, and pride in your ability to code you want to take something like that down from 135-150 lines to 60 lines of code. Maintain the idea of modifying the URLs and feeds, and the homepage based on a specific URL mirror such as github, gentoo, or bitbucket. Then realize what differs from one github URL to another github URL. Those are your variables.

    After that it's as simple as creating a template constant that includes the auto-completion information for you. Once that's implemented then it's as simple as breaking up the URL into the variables you need and then perform interpolation on the template to get the correct overlay information.

   To anyone interested in seeing that concept in action then you should take a peak at: https://github.com/twitch153/layman/commit/7537f0b6216c2cbb13e2059edd9be0ed8e19a097

2.) Overlay-maker CLI interface:

    Up until now whenever a user wanted to tell the overlay-maker that they wanted to have auto-completion support for their overlay then they had to specify on every overlay creation. That can get tedious and sometimes annoying if you're working on adding a large amount of overlays to an xml. In favor of ease of use and not wanting users to curse my name at the end of their keyboard I gave users the ability to simply specify this via command line arguments.

    You can now do the following:
  • List all mirrors supported for auto-completion.
  • Tell the overlay-maker you only want the bare basics for the overlay(s) you are creating.
  • Select a mirror for auto-completion when creating your overlay.
  • Override certain checks when creating an overlay such as only saving the overlay.xml in your "overlay_defs"  location and giving an overlay a name of an overlay that already exists.
After both these changes were made to the overlay-maker then it was time that the pull-request was merged into master. It's only a matter of time before a new release is available to users (wink, wink).

3.) Merged test-suite and updated-updater:

    Both of these branches were merged to master along with the other two.

    The changes made to the test-suite were simple things like modifying what gets checked to assure that the test is working out exactly as it should.

     The changes made to updated-updater were also minimal. Now updater.py will check to see which conf_types are enabled and will then create the proper configuration files based on that.

    This brought the pull-request count down from 7 to 3! Which just shows how much closer we are to completion.

4.) Added layman-mounter tool:

    Recall in the past (we seem to do that a lot recently) that I added squashfs overlay support to layman. Well, it turns out that the method I used to add the support by unpacking the archive wasn't what my mentor had in mind (whoops!). After a little bit of discussion we came to the agreement that we wanted to add squashfs support to layman so that it would mount it read-only.

    The benefit of this is that you save space on your system. The drawback is that once you reboot your computer the overlay is no longer mounted.

   To address that drawback a utility script was created called "layman-mounter". This sounds a little...odd for a tool. What will this do? Well, it's not that odd. Really. I swear. And it does the following:
  1. lists all mountable overlays.
  2. lists the status of all mountable overlays (mounted/unmounted).
  3. Can mount overlay(s).
  4. Can unmount overlay(s).
    The beauty of that is that a user can then have layman-mounter invoked on every reboot to mount all your overlays. Or only select ones. The squashfs overlay code was also changed to reflect the behavior of being mounted instead of extracted. So look for this handy tool on the next release.

    Be aware that this method of squashfs overlay support does require you to have CONFIG_SQUASHFS enabled in your kernel though.

Goals for next week:
  •  Work on getting the last three pull-requests merged with layman's master branch.
  • Add modular configuration plug-ins.
  • Refine any code necessary in order to get a new release out before the end of the program.
As always, to anyone interested the source code and my commits can be found on git.overlays.gentoo.org/gitweb/[1] or on github.com[2] on layman's gsoc2014 branch.

  [1]http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=shortlog;h=refs/heads/gsoc2014
  [2]https://github.com/twitch153/layman/tree/gsoc2014

With regards,
    Devan Franchini (twitch153)

No comments:

Post a Comment