Google Summer of Code


chroot() is a useful system call available in most UNIX like operating systems. I have been using chroot to do several hacks for the past few years. Mostly people use chroot for fixing boot loader / GRUB. To fix GRUB, a live cd can be used to boot into a GNU/Linux system, then run

# chroot /mnt/root_partition

~# echo chrooted environment

Then, execute grub-install or any command to update GRUB configs.

Basically chroot makes the environment believe provided path is the root “/” of the filesystem.

We can exit from chrooted environment by pressing Ctrl-D.

chroot can be used to build chroot jail to protect server services for preventing attacker to gain complete access to the server by creating chroot jails.

Last day, I was working on my GSOC project Live Installer for Pardus. It was the first time, I was using chroot() in python. It had to execute a few statements in chroot environment and come back to prevous environment. But exiting from chroot environment found to be difficult and there were no direct methods to exit from it. So I had to do a little hack. I would like to share the hack so that you can reuse it without going for long search on how to do it.

import os
real_root = os.open("/", os.O_RDONLY)
os.chroot("/mnt/new_root")
# Chrooted environment
# Put statements to be executed as chroot here
os.fchdir(real_root)
os.chroot(".")

# Back to old root
os.close(real_root)

chroot() is provided by os module
The major player of this hack is fchdir() which can take file descriptor has argument and change to that directory as current working directory. We open our real root using real_root = os.open(”/”, os.O_RDONLY) and its file descriptor is stored in real_root. Now chroot to new file system. Execute all the required statements. After that execute fchdir() to change current directory to old_root using real_root descriptor. Then chroot to current directory to switch back to real root.

Happy Hacking :)

Being a python and? code enthusiast, The most exciting feature about Pardus project is about their designs. All the of the applications pardus teams has ever written are awesome with their beauty in their code design. When ever you look at any project’s code, they are very transparent, readable and highly modular designs.

I am hacking with YALI ( Yet Another Linux Installer) Project for developing a Live OS installer. I went through the basic code and came up with an over view of YALI architecture. Hope this would be helpful for future YALI contributors and developers also.

Working of Yali4:
Yali starts with xdm service, which runs start-yali4 shell script. It runs /usr/bin/yali4-bin using /usr/bin/xinit and runs in fullscreen mode without KDE WM environment.
It invokes the method yali4.default_runner() which is yali4.gui.runner.Runner()

Pardus has its own service scripting and management technology COMAR. xdm is a comar script to serve as service for loading X.

runner.py:
Runner class servers as the major class which runs the Yali. It imports the main widget from gui/YaliWindow.py (Widget class). Widget class is Setup_ui using Ui_YaliMain (main.ui)
Resolution and screen size is set to maximum by reading QApplication.desktop()

Yali has a configuration system to behave as per different install_type.


YALI_INSTALL,YALI_DVDINSTALL, YALI_FIRSTBOOT, YALI_OEMINSTALL, YALI_PLUGIN, YALI_PARTITIONER, YALI_RESCUE = range(7) is defined in gui/installdata.py

In Runner class, it checks which sets install_type variable according to the configuration.

gui/context.py defines many constants and context variables (yali4/constants.py) . yali4.sysutils.

checkYaliParams() is used to identify the install_type configuration,
which can be passed as argument to kernel parameter.

In Runner, it creates an installer object by passing install_type and install_option to yali4.installer.Yali(). install_option is identified by yali4.sysutils.checkYaliOptions()

installer.py:

Yali class in installer.py is the main class which handles the Yali screens. Yali4 operates with the concept of screens.? mainStack Widget in the main.ui is called screen.
We dynamically load and remove different screen widgets required for the instalallation wizard. The base fullscreen UI is setup by runner and the screen is loaded from installer.py
Yali class in installer.py defines screen list for each install_type defined. Eg: self._screens[YALI_DVDINSTALL]

All different screens as defined as seperate .py files with name prefixed with Scr in yali4/gui. Each of these screen py files consist of a QWidget class Widget.
Widget class gui/YaliWindow.py has createWidgets() method which loads the required screens for given install_type. stackMove() method is used to show each screen
at appropriate time according to user interaction.

Changes/Work for Live installer
Most of the components required for the live installer can be reuse of existing screens from Yali4 and APIs.

To make Yali work as window mode and change the window size to a required size, yali4/Ui/main.ui require some changes as well as runner.py require some changes to prevent it from
resizing to available full screen width and height.

We need to add a new a new install_type YALI_LIVEINSTALL in gui/installdata.py

Instead of yali4/gui/ScrInstall.py, which handles installation for real pardus install medias. we have to write a new screen, ScrLiveinstall.py which can handle
installation from Live media.

yali4/installer.py will require an entry for YALI_LIVEINSTALL,


self._screens[YALI_LIVEINSTALL] = [                                  # Numbers can be used with -s paramter
                                       yali4.gui.ScrKahyaCheck,          # 00
                                       yali4.gui.ScrWelcome,             # 01
                                       yali4.gui.ScrCheckCD,             # 02
                                       yali4.gui.ScrKeyboard,            # 03
                                       yali4.gui.ScrDateTime,            # 04
                                       yali4.gui.ScrUsers,               # 05
                                       yali4.gui.ScrAdmin,               # 06
                                       yali4.gui.ScrPartitionAuto,       # 07
                                       yali4.gui.ScrPartitionManual,     # 08
                                       yali4.gui.ScrBootloader,          # 09
                                       yali4.gui.ScrSummary,             # 10
                                       yali4.gui.ScrLiveinstall,         # 11
                                       yali4.gui.ScrGoodbye              # 12
                                      ]

Above changes are required to bring a minimal Live installer.

I have written a basic command line minimal Pardus Live installer,? http://web.sarathlakshman.info/gsoc/pardus/installer.py. Most of the required logic appears in its code.

Finally this year’s Google Summer of Code 2010 students are announced. Glad to announce, I am one of them :)

This is my third year of participation with Google Summer of Code programs. It was fun working with different project and mentors along the recent years. This year’s selection procedures gave me a lot of input and support while talking to some of new mentors from different organisations Gentoo and Meego. I am with the Pardus due to my Pardus love. I enjoy it. But I missed other projects since I can work only on one project. I am thinking of working on the project I had proposed (not in gsoc context.) for fun.

This time I will be developing Live OS installer for Pardus. Also I will be developing Live CD creator from a Pardus installation. Optionally I have some more ideas out of gsoc context with Pardus, being a pardus developer. I will be writing a pisi-offline tool which is similar to Apt-On-CD on Ubuntu. But the one I am developing will be much better than Apt-On-CD which works based on package cache. But pisi-offline will not rely on cache. But the real installed applications.

My assigned mentor for the project is Mete Alpaslan, who is the author of Yali4 installer for Pardus :)

Project link: http://socghop.appspot.com/gsoc/student_project/show/google/gsoc2010/pardus/t127230768169

There is more glad news from my College, there is one more student from my College. Narayanan K, who would be working with OAR suite. His project url :http://socghop.appspot.com/gsoc/student_project/show/google/gsoc2010/oar/t127230761183

Congrats to all students :)

I am getting more busy these days with lots of work which ranges from coding to college and hostel life and as a result I am getting more and more lazier to blog :P

I have successfully completed my Google Summer of Code 2009? programs with Pardus project. The Pardusman is now ready to build custom pardus distros through web. Some of the work remaining is to? setup the server configuration files at pardus server. I will be looking forward to setup it in a couple of weeks. Once it is setup, it would be able to build distros through the web interface at http://pardusman.pardus.org.tr. Waiting for the official Summer of Code T-Shirt to be shipped. :P

The ExcelX, the 10th edition of our college techfest is coming soon during Oct 9-11th of 2009. I am one of the co-ordinators and I have been working on it. Had a good time coding in Google Appengine. It is cool web framework to work with. Hats off to Google. I would come up with a Online Shell Scripting contest web application within 5 days of coding. Feels awesome.

appengineGoogle appengine is a mix of several web frameworks bitten by python. it derives most of the things from Django 0.96. Django 1.0 is the latest release and I have been working on it. Hence backward compatibility was an issue while coding. Some features are missing. It eated up some of my time finding out what the issue is.

Suppose you are guy who is familiar with Django 1.0 and never used 0.96, I might be trapped tracing the issue while coding. So I suggest you to verify whether that feature is available in Django 0.96 while coding with Google Appengine.

An example,

In template system, we cant use dictionary traversal in the following manner

{% for key,val in dictionary.items %}

<!-- some html tags -->

{{ key }} : {{ val }}

{% endfor %}

instead you have to use 0.96 style,

{% for item in dictionary %}

{{ item.0 }} : {{ item.1 }}

{% endfor %}

Try out. Have a good time with GAE :)

Next Page »