Blog

  • Nerd-friendly blogging

    I’ve been promising myself to write about my blog setup for a while now. As I explained earlier, I use Jekyll – ‘a simple, blog aware, static site generator’. Every time jekyll generates html, it gets dumped to the _site folder. I have my local nginx pointing to the _site folder, so every time I start write blog posts, I open a terminal, go to my blog’s root folder, and run jekyll --auto and hit my nginx install from the browser. This way, every time I save, I get to see what it looks like. I found this much faster than doing jekyll --auto --server and using the server with Jekyll. I version control the whole folder minus the _site folder with git and I’ve set up a bare repo on my server to which this will get pushed too.

    Jekyll also runs on my server because I want to be able to blog from any machine from which I have SSH access to my server. I’ve set up the following commit hook on the bare git repo that regenerates the HTML files on every push.

    GIT_REPO=$HOME/blog.git TMP_GIT_CLONE=/tmp/blog PUBLIC_WWW=$HOME/blog-www  git clone $GIT_REPO $TMP_GIT_CLONE jekyll --no-auto $TMP_GIT_CLONE $PUBLIC_WWW rm -Rf $TMP_GIT_CLONE exit 

    Its a pretty rad setup. For comments, I’ve setup Disqus, which was quite easy. I set up askimet with them, so that the spam gets filtered, yet to get spammed though (knocks on wood). Overall, the setup has been quite nice and yes very nerd friendly. I can write in my text editor of choice and commit to git with complete rollback history if I want to. Not having an admin panel from which things can be changed is a great benefit!

  • Git and Bash Love

    I’ve recently been working with git a lot, more specifically with branches. I love git’s branching and its fairly awesome. However, its also easy to forget which branch you’re currently working on (especially awful to find that the commits you did were to master :/). Sometime back I did some extensive searching to fix that situation and finally stumbled upon a neat way to fix it. I modified the PS1 variable to show the current branch! Here’s what I added to the .bashrc file in Ubuntu 🙂

    function parse_git_branch {     ref=$(git symbolic-ref HEAD 2> /dev/null) || return     echo "("${ref#refs/heads/}")" }  RED="[33[0;31m]" YELLOW="[33[0;33m]" GREEN="[33[0;32m]"  PS1="$PS1$RED$(date +{13371f13f0bf161e7595c2ac5df92e005bed3de1d132ef646d0a44f3a1a9ee62}H:{13371f13f0bf161e7595c2ac5df92e005bed3de1d132ef646d0a44f3a1a9ee62}M) w$YELLOW $(parse_git_branch)$GREEN$[33[0m] " 
  • Fix FTBFS Jam

    As of me writing this post, there are about 428 packages that have failed to build from source (FTBFS)]. We’re doing a FTBFS jam this Wednesday (29 June, 2011). If you’re interested in helping out, drop by in #ubuntu-motu) and just generally say that you want to help fix FTBFS and someone will be able to guide you. We have a list of packages that are potential targets to be fixed.

    While we won’t try to fix everything, we’ll be focusing on specifc failures, the ones caused by toolchain changes. Ubuntu is changing the way it handles shared library linking. Similar changes are also happening in Debian.

    Before I get into spare details of the reason for these build failures, I’d like to emphasise that the failures that we’re targetting to fix are quite easy and just needs some tinkering with make files. I recently fixed a build failure in the redis package. Take a look at the build log of the failure, the patch that fixed it, and the build log after the fix.

    Cause of the failure

    For more information on fixing these failures, please see the Ubuntu wiki page and the Debian wiki page.

    Previously, the linker (ld) would allow indirect linking of shared library symbols. For example, if you had a function spin in the library libwheel, and the library libcar used libwheel, then a program that used libcar would have the ability to call spin even though it never directly used libwheel. This kind of indirect linking leads to fragile code; when the dependency chain of a shared library changes, it can break the program that used it.

    ld now runs with the --no-copy-dt-needed-entries option enabled by default. This option is also sometimes called --no-add-needed. This means that, in the example above, the spin function would only be available when libwheel was directly linked by adding -lwheel to the command-line compiler flags, and not available indirectly through libcar. Also, ld runs with the --as-needed option enabled by default. This means that, in the example above, if no symbols from libwheel were needed by racetrack, then libwheel would not be linked even if it was explicitly included in the command-line compiler flags.

    The solution to a build error caused by indirect linking, is to directly link all needed libraries in the compiler flags on the command-line. For example, if you were previously linking with -lcar -ltruck, you would now need to explicitly add -lwheel. For example:

    gcc -Wall racetrack.c -lcar -ltruck -lwheel -o racetrack 

    The --as-needed option also makes the linker sensitive to the ordering of libraries on the command-line. You may need to move some libraries later in the command-line, so they come after other libraries or files that require symbols from them. For example, the following link line is wrong, and needs to be changed so that libraries come after objects that use them:

    gcc -Wall -lwheel -lcar -ltruck -o racetrack racetrack.c 

    When problems result from the --no-copy-dt-needed-entries option, the linker will always give you a hint at the right fix in the error message, for example ‘try adding it to the linker command line’.

  • Hacking on Ubuntu Single Sign-On

    As most of you, who’ve used community projects like Loco Team Portal and Summit know, we use login.launchpad.net as our open id provider. I believe the future is to use login.ubuntu.com. It is more consitent in terms of design, and is the exact same code as login.launchpad.net but with different configuration and theme.

    We have bugs for both the projects to switch to login.ubuntu.com, but it isn’t really easy because login.ubuntu.com configuration is actually more stricter. We can’t login from it locally, i.e., it will not pass on my credentials back to my app if I’m running my app on 127.0.0.1. The ISD team suggested that I just run SSO locally and do my testing. After running Launchpad, what could be so hard right? Famous last words 😉

    I fetched the source of SSO and started the bootstrap as the instructions said. It failed because some of the configs were in a private branch. With much hair-pulling, head-desking, and lots of help from David and Ricardo, I finally got it running last week. One of the main problems of doing this was the configuration for SSO are not stored in the ‘django way’ of things. It’s stored as .cfg files with some configglue magic. Configglue wasn’t originally open-sourced and thus the configs were private. The other problem was my inexperience with postgres 🙂

    After configglue was open-sourced, the configs still sat in a private branch because nobody got around to fixing the bootstrap process, until last week. On Friday, Ricardo finally gave me the good news!. The bootstrap process is now fixed so that community members can actually run SSO without hair pulling. We can now easily work on doing the transition from login.launchpad.net to login.ubuntu.com

  • Landing with tarmac

    I heard about Tarmac a few weeks ago when Shane mentioned it in one of his intern diary blog posts. At that point I didn’t actually look into it much since I thought it was something that’s internal to Canonical. Last week, Michael Hall told me about Tarmac again and how they use it to land branches. This time though, I could grasp what it was since it sounded to provide a functionality Launchpad’s PQM. Every time Tarmac is run, it checks for approved branches that are ready to land. If it finds that they satisfy the conditions (optional) that are defined in its config, it lands them. (It can do more, please read the documentation for that).

    I’m now running Tarmac for both Loco Team Portal project and the Summit project The really cool commitmessage plugin allowed me to define how each commit should look. I’ve formatted it in a way easy to figure out how did the review and who authored the change, and which bugs it fixed. If you want to see how it looks like, checkout the last few commits for summit. I did find a bug in tarmac documentation for which I now submitted a merge request 🙂