Tuesday, September 27, 2011

RIT Remix Hosting and Interactive Timeline

The spin remix is now hosted. Thank you Ralph Bean for tossing that up! I hope that I'll have a chance to tinker with it in the future and make some improvements to it later. For now, there's a different task at hand.

One of the key things that is missing from the FOSS Box @ RIT is a slick timeline that can show the world what we've been up to - something that's polished and comprehensive. Remy Decausemaker's forked version of MIT's Simile Exhibit project fit the bill perfectly. The project uses a whole bunch of javascript magic to render its visuals, but at its source, generates its content from a single contributors file.

Adding entries to the timeline is trivial. It's just a matter of going from this and this to a series of formatted entries:


{    "type" :                  "Event",
     "label" :                 "ImagineRIT 2010",
     "discipline" :            "Event",
     "date" :                  "2010-05-01",
     "relationship" :          "Event",
     "relationship-detail" :   "ImagineRIT 2010",
     "imageURL" :              "Event.png",
     "url" :                   "http://www.rit.edu/imagine/"
},

Not a difficult process, but a time-consuming one. One that I'm not so willing to do in the future, so I decided to create a pretty simply html form that would let me enter entires. The form is simple HTML and creates a little something like this. After creating the form, I whipped up a simple CGI script in python, which has a module that makes form handling easy. Lastly, this form launches a simple script that appends entries to the contributor.js file.

This should save a lot of hassle in the future. Of course, I wasn't able to host this simple web service on my CS webspace, given the restricted permissions that disallowed me to create any sort of .htaccess file without a headache. Gives me a good opportunity to check out openshift which has been getting a lot of buzz lately.

Tuesday, September 20, 2011

wxWoof

Rochester's getting colder. Autumn is here. I like that.

This past Saturday was the big Software Freedom event. I had a few people ask me about the spin, grab copies, so I pointed them to the public repo and showed them what went on in creating it (my previous post was editing for some more details regarding the process). It was good fun. And so was the hackathon. I didn't really go in with any particular project in mind, so I decided to get started on working on something that I've been meaning to work on for quite some time.

Ever hear of woof?

It's a nifty python (2.7) script that turns your computer into a single-file distribution server. Or, should you want, archive directories for you, and host the archive. It's pretty simple, but really useful. Need to toss a file over on your other box, and don't have a USB drive with you? No problem, just run the script on the file. By default, the script hosts it on port 8080. All you need to do to grab the file is open up your browser of choice, and connect at the host's ip (displayed if you don't know off hand), and selected port. Easy. (If you want -really- impressive speeds, try sharing a network connection from the host, and connecting the two via ethernet. That's some nice file transfer speeds.)

Some of my friends saw me using it, and really loved the script, but aren't familiar with the command line at all, or even the concept of a directory path. The script could also use a little python 3 makeover. So, I took the opportunity to start looking into some gui libraries to put a simple front-end on the script.

There were a few options. If you can recall, I already messed around with pygtk2, which was very simple and powerful. It is, however, getting it to work in OSX 10.5 and later is annoying. I then looked into something more current and robust, and stumbled upon PyQt, based on the mammoth Qt framework by Nokia. In the end I decided to just use the tried and true wxPython libraries.

This wasn't without it's issues, either, though, as wxPython hasn't been updated to work properly with Python 64 bit installs. I actually had to create a little launcher that appropriately ran my ui correctly. This was accomplished by using the following script:

#! /usr/bin/env python

import subprocess

subprocess.call(["arch", "-i386", "python", "window.py"])



You can check out my very simple gui at the public repo if you're interested. Right now, I got something that works, but I'll continue to add to and improve the UI (as well as clean up the script) over time and post more about it in the near future. Chances are I'll take a look at wxDesigner and wxGlade.

Wednesday, September 14, 2011

Creating a Fedora RIT Spin

The full process.

Up until now, I've only given snippets of the steps it took to create an RIT Live CD Spin of Fedora 15, so this time I'll detail every step (and issue) I took along the way, along with some of the issues I ran into. To start, there are Live CD creation tools provided to you for creating Fedora Live CDs that are pretty much automated, but setting up the configuration of the Live CD is what can be tricky. Before we can really begin, we need to install the tools needed for creating our spin. You can get these tools by grabbing the following packages.

sudo yum -y install spin-kickstarts livecd-tools


Next, we need our own kickstart file. We can start with a basic kickstart file as shown below.

%include /usr/share/spin-kickstarts/fedora-live-desktop.ks
%include /usr/share/spin-kickstarts/fedora-live-minimization.ks

%packages
%end

%post
%end



This is pretty much the most basic of kickstart files that can be used. These kickstart files effectively define how the Live CD will be created, and are the tool you use for customizing your spin. First, the %include statement is used to pull in other made kickstart files. A basic spin can get nearly all of the groundwork done by just pulling in the two kickstart files shown above, provided that you don't mind the default Live CD environment.

The next step is defining the applications you want in your spin. Add every desired package in the %packages section. For example, no RIT student can live without emacs and pidgin, so I'll toss those packages in.

%packages
emacs
pidgin
%end


Because the creation process creates a filesystem to be put on a non-rewritable media, it's important to get all your customization done in the kickstart file. There is a useful area of the file, the %post section, that allows you to run commands to customize the environment before the creation process runs mksquashfs to make things final, stuffing it all into a nice iso package. For the RIT spin, we wanted a few little features, such as having default RIT bookmarks for Firefox, and some nice RIT default wallpaper.

To tackle the bookmarks, I had to poke around a bit at the guts of Firefox 6 to see how bookmarks are stored. When firefox runs, it creates a default profile for the user, and stores bookmarks in an sqlite database. While it would have been easy to set some bookmarks, and just copy the .sqlite file for later use, I noticed that Firefox computes a random hash for the user profile folder, making it pretty much impossible to be able to predict the folder of the default profile for any given user. I then looked into how these .sqlite databases are being generated.

Firefox 6 contains an archive called omni.jar, located in /usr/lib/firefox-6 that effectively has a bookmarks.html file inside, defining the bookmarks hierarchy that is used to generate the inital sqlite database for each profile. In order to change this, it is necessary to unzip the archive, swap in the bookmarks.html file (here's mine), and finally zip it back up. To do this I put my own script into the %post section of the kickstart file. The script I use to do this can be found here.

Lastly, I had to change the default wallpaper for the spin. The first step to getting this to work was to get the wallpapers on the newly created filesystem (before mksquashfs runs) to be used. While it's possible to create your own package to include, I decided it might be easier to just look for a swapping command. Because Fedora 15 runs gnome3, it was tempting to use the gsettings command to set the background, but this won't do anything. (One approach that may work is creating a startup script to do just that, but gsettings cannot be run without the user being logged in and gnome initialized. Therefore, it won't work in the %post section of the kickstart file.)

Instead, I decided to write a script that safely tuck away the default Fedora 15 backgrounds (there are three versions of it), and swap in my own wallpapers for them. It's a bit hackish, but at least the wallpaper will appear on the the default startup, and this way, I don't have to create a whole new package and tinker with the various .xml configuration files to change the default location. Note that wget is necessary to add as a package to grab the files that I had hosted (probably the easiest way to pull in file needed by the %post scripts). Furthermore, livecd users are not added to the sudoers file, so it's easiest just to run a su -c "command" to get the job done, as the background folder contents does require root permissions to alter.

Something to note as well is that Fedora 15 has 3 default wallpapers, each with different resolutions that reside in their own folders. It's a good idea to do the same with your own.

A last feature I wished to add to the spin is a prompt to ask if the user would like to run the live cd with RPM Fusion enabled. Obviously, much of the software out there that provides a user with a normal experience is proprietary, and won't be put on the spin by default. Instead, the user should have the ability to quickly fetch and enable these packages.

I created a simple pygtk2 launcher that runs a simple fetch script for RPM Fusion (Note, the prior is a python script, and the latter is a fetch script, so simply rename the extension if you pull them from my public webspace). Adding scripts to the startup routine is trivial... if you have access to the gsettings command. My first approach was to add my script to init.d, but this approach will not work. A second approach I took was to attempt to pull a customized bash_profile which launches the prompt on login, and tosses it into the user folder. However, this will not work either, because the liveusr profile will not be created at the time of %post, and therefore, it is not possible to modify its bash_profile. This feature will require a little more exploration.

Given more time for refinement, a better approach would be to make a proper package for the wallpapers, but if you have to get it done quickly (and with the long creation process), this quick-and-dirty method should get things set just fine. Overall, however, the process is fairly straight forward, and most of the difficulties come from the fact that you don't have too much wiggle room on the temporary filesystem customization.

The final kickstart file I use for the RIT spin can be found here. If you wish to contribute to the spin project, or make your own based on what I have, feel free to fork the public repo.

Monday, September 12, 2011

Setting the Background for a Fedora 15 Remix

If you're creating a Fedora Remix, you might want to give a nice customized desktop wallpaper. This can be done easily using the %post section of the kickstart file.

Firstly, make sure that you go to the directory that houses our own background images.
cd /usr/share/backgrounds/images


Next we want to fetch a background image and bring it into the created filesystem. Note that resolv.config, at the time that the post script executes, is not yet set up, so there's no DNS lookup going on. We need to use the ip. Be sure to also have wget included in the %package section of the kickstart file.


wget --header="Host: www.someplace.com/wherever/your/image/is.jpg" http://123.45.67.89/wherever/your/image/is.jpg


Finally, all that's left is to configure the background image by calling the gsettings command. Previously, in Fedora 14 and previous, you would use gconftool-2 to edit the background image schema, but gnome3 uses a slightly different command:


gsettings set org.gnome.desktop.background picture-uri "file:///usr/share/backgrounds/images/yourimage.jpg"


There are many other settings that can be altered using the gsettings command, so you have a lot of freedom in customizing the look and feel of your Fedora 15 remix.




Thursday, September 8, 2011

Fedora Kickstart Files

The past two days have been interesting, to say the least. Creating a live cd isn't really difficult given that there are many tools to create one for you with ease. What is tricky, is using the post installation scripting that the kickstart files. Since the live cd can only be written to once, and due to the natural limitations on customization of a live cd (which is, in part, the point), all customization has to be done when creating the .iso of the live cd. For example, the kickstart file I'm creating makes use of the post installation segment to change some firefox bookmark defaults. Using these scripts to change the background of your Fedora live cd is possible too, should you wish it. Hopefully today, I'll be able to figure out the post-boot problems my build has.

Monday, September 5, 2011

There is a Box of FOSS at RIT, and I am now inside it.

The calendar is marked: September 17th - Software Freedom Day. All my hours could be spent towards creating the perfect Fedora Spin for Open Source loving RIT students, but instead, VMware fusion is intent on making emulation as difficult as possible. Only after jumping through hoops thought to be long gone, could I finally get the guest OS to recognize that my computer has, in fact, a usb port. Useful. Tomorrow will be a day filled with tinkering as I explore kickstart files, something I've never done before. Hopefully, I can bundle in the right applications that covers most anything a new RIT student needs.