Building a Custom Kernel (3.14) on Ubuntu (Raring, Saucy, Trusty)
apt-get install wget bzip2 kernel-package build-essential
Then go to the system source directory, download and extract the latest release. The wget link in the example refers to version 3.14, but you can simply replace the link to any desired version. Then change into the directory that was created.
cd /usr/src wget --no-check-certificate https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.14.tar.xz tar xf linux-3.14.tar.xz cd linux-3.14
Take over the configuration from the kernel which is currently installed on your system.
make oldconfig
Then it is time to build the kernel and create deb packages for the image itself, the headers and the source.
make-kpkg --initrd --append-to-version=-custom kernel_image kernel_headers kernel_source
This will take some time. After the compilation is finished .deb files are automatically created (located at /usr/src). Install them and you’re done 🙂
cd .. dpkg -i *.deb
Awesome window manager: Missing icons in Control Center
If you’re running the awesome window manager and are using the gnome-session or gnome-settings-daemon as well as the gnome-control-center you might have noticed it is missing some icons (see screenshot on the right).This is due to an entry in the “gnome*panel*.desktop” files located in “/usr/share/applications”:
OnlyShowIn=GNOME;
You can quickly fix this by changing it to:
OnlyShowIn=GNOME;Awesome;
Of course you do not have to do this by hand. Simply use this handy command:
sudo find /usr/share/applications/ -name "gnome*panel*desktop" -print | xargs sudo sed -i 's/OnlyShowIn=GNOME;/OnlyShowIn=GNOME;Awesome;/g'
Python 3.4 and Django on Ubuntu 13.10
Why bother about Python versions?
Building Python from source
The downside is, that Linux distributions do not include the latest Python release yet. Most of them still ship with Python 2.7 as default version. The next Fedora and Ubuntu releases might change that, but for now you need to compile it from source. Luckily that is not a hard task. Go to the download page and grab the latest Python release (recommended if you read the post later and a newer version was released) or past the following command into a terminal.
First make sure you have everything installed to compile Python from source.
sudo apt-get install build-essential
Before downloading create a temporary directory to make the cleanup easier. At the end you can just delete “tmpPython”.
mkdir tmpPython cd tmpPython wget --no-check-certificate https://www.python.org/ftp/python/3.4.0/Python-3.4.0.tgz tar xvf Python-3.4.0.tgz
After the archive is extracted, cd into the source directory. Create a directory to install to, then run configure, build and install.
cd Python-3.4.0 sudo mkdir /opt/Python34 ./configure --prefix=/opt/Python34 && make -j4 sudo make install
Now you have Python 3.4 installed on your system.
Add the the path containing the executable to your environment.
export PATH=/opt/Python34/bin:$PATH
Also make sure to add this line to your .bashrc file (or .zshrc if you’re using zsh).
echo "export PATH=/opt/Python3.4/bin:$PATH" >> $HOME/.bashrc
Creating a virtual environment
Go to the directory where you want to create the virtual environment. I recommend /opt if you collaborate with others within the environment (you have to create everything with sudo) or your home directory if you work alone. Then run pyvenv to create it.
pyvenv-3.4 djangoEnv source djangoEnv/bin/activate
The bash prompt changes to
(djangoEnv) mpei@earth /opt
and that means that you are now within this virtual environment.
This command shows you what you have installed:
pip freeze
Installing Django
sudo pip install django django-extensions
And you’re done! You can check the installed versions by running “pip freeze” again. Maybe another blog post on Django and databases? Or the first steps in Django? We’ll see… bye bye!
Organizing C/C++ includes
After starting my new job programming in a big software project I spent some thought on organizing includes and give a recommendation. Here’s what I’ve come up with. As always, some things are obvious, some are not…
- You should only include what is necessary to compile the source code. Adding unnecessary
includes means a longer compilation time, especially in large projects. - Each header and corresponding source file should compile cleanly on its own. That
means, if you have a source file that includes only the corresponding header, it
should compile without errors. The header file should include not more
than what is necessary for that. - Try to use forward declarations as much as possible. If you’re using a
class, but the header file only deals with pointers/references to
objects of that class, then there’s no need to include the definition of
the class. That is what forward declarations are designed for!// Forward declaration
class MyClass;
- Note that some system headers might include others. But apart from a few
exceptions, there is no requirement. So if you need both
<iostream> and <string> include both, even if you can
compile only with one of them. - To prevent multiple-inclusions, with loops and all such attendant horrors is having an #ifndef guard.
#ifndef _FOO_H
#define _FOO_H
…contents of header file…
#endif - The order in which the includes appear (system includes and user includes) is up to the coding standard you follow.
- If you have the choice of picking a coding standard regarding the order at the beginning of a new project, I recommend to go from local to global, each
subsection in alphabetical order. That way you can avoid introducing
hidden dependencies. If you reverse the order and i.e. myclass.cpp
includes <string> then <myclass.h>, there is no way to catch
at build time that myclass.h may itself depend on string. So if later someone includes myclass.h but does not need string, he’ll
get an error that needs to be fixed either in the cpp or in the header
itself. - So the recommended order would be:
- header file corresponding to its .cpp file
- headers from the same component
- headers from other components
- system headers
If you use the Eclipse IDE (which I highly recommend), you can use a very nice feature that helps you organizing includes (“Source -> Organize Includes”).
5 Steps: Build a custom kernel in Debian Wheezy (…including NVIDIA drivers)
Here are five easy steps to build a custom kernel on a debian system including NVIDIA kernel module. There may be way better tutorials on building a custom kernel out there, I just want to give you the essential steps that I use…
1. Download the full source code from kernel.org and extract it to /usr/src:
$ cd /usr/src/
2. Take the configuration of your current kernel by running:
3. Edit the kernel configuration
This will bring up a GUI that makes it easy to edit the kernel configuration.
4. Build the kernel, install the modules and install the kernel
Then reboot the system. Boot the new kernel you installed by selecting it from the GRUB boot menu. The system will not boot to graphical desktop unless you have configured X to use the nouveau driver. So the last step is installing the NVIDIA driver.
5. Install the NVIDIA driver
Log in as root and run the module assistant to compile and install the NVIDIA kernel module.
$ m-a auto-install nvidia-kernel
After the installation is finished reboot the system and you’re done 🙂

Update: How to patch the custom kernel
TeX Live 2012
Last weekend, TeX Live 2012 has been released. Most Linux distributions are still stuck with TeX Live 2009. If you want to enjoy the latest versions of all TeX packages can download it from here.install-tl-* subdirectory and start the installation by running install-tl. Leave everything at default values and press “I” to start the installation.
export MANPATH=”/usr/local/texlive/2012/texmf/doc/man:$MANPATH”
export INFOPATH=”/usr/local/texlive/2012/texmf/doc/info:$INFOPATH”
export TEXMFHOME=”/usr/local/texlive/2012/texmf”
export TEXMFCNF=”/usr/local/texlive/2012/texmf/web2c”
Skype 4.0 for Linux
Since 14th of June the long awaited version 4.0 of Skype is available for download. The changes are listed by Marco in his blog.Spotify on Debian Wheezy (testing)
As I have a premium account for Spotify I was disappointed when I discovered that the client does not install on a recent Debian testing installation.After fetching the new sources with
run
to install Spotify 🙂
Ubuntu One on Debian Wheezy
PLEASE DO NOT USE THIS AT THE MOMENT. I’M WORKING ON A BETTER AND UPDATED VERSION.
I tried to update the electron repulsion integral handler libint in our
quantum chemical code AICCM. But the linking against gmp failed on my
Ubuntu 12.04 LTS. After discovering that it would build on a Debian Wheezy I
decided to install Debian on my computer. Since I am using the Ubuntu One cloud
service to sync all my data across various machines, including
smartphone and tablet, I was disappointed to find out that there are no
packages available for Debian. I did not want to abandon the service since I am a paid subscriber. It is only 29.99$ per year for 25GB.
After searching through forums and trying
several failed approaches to use the binary packages from Ubuntu 12.04 I
decided to build it from the sources.
In this blog entry I would like to give a detailed description how to build and install Ubuntu One on a Debian system. If you have any questions or comments please do not hesitate to contact me.
mkdir $HOME/UbuntuOne
cd $HOME/UbuntuOne
and install the dependencies:
apt-get install python-twisted pyqt4-dev-tools bzr python-lazr.restfulclient python-oauth python-pyinotify python-protobuf gnome-common gobject-introspection xutils-dev libnautilus-extension-dev libgconf2-dev libebook1.2-dev gnome-settings-daemon-dev python-twisted-names python-libproxy python-distutils-extra python-setuptools
There are two ways to obtain the source code (1b is recommended):
1a. From bazaar repository (latest development version)
If you are using this option you need to neglect the version numbers in the following.
1b. Download the tarball from launchpad (latest stable version)
wget https://launchpad.net/ubuntuone-storage-protocol/stable-3-0/3.0.0/+download/ubuntuone-storage-protocol-3.0.0.tar.gz
If you have downloaded the latest stable version you have to extract all downloaded archives
2. Set the $PYTHONPATH
So open the file in your favorite editor (I use vim):
And add the following lines:
# Ubuntu One PYTHONPATH
export PYTHONPATH=”$HOME/UbuntuOne/configglue-1.0.3:$PYTHONPATH”
export PYTHONPATH=”$HOME/UbuntuOne/dirspec-3.0.0:$PYTHONPATH”
export PYTHONPATH=”$HOME/UbuntuOne/ubuntuone-client-3.0.1:$PYTHONPATH”
export PYTHONPATH=”$HOME/UbuntuOne/ubuntuone-storage-protocol-3.0.0:$PYTHONPATH”
export PYTHONPATH=”$HOME/UbuntuOne/ubuntu-sso-client-1.3.3:$PYTHONPATH”
The $PATH and $LD_LIBRARY_PATH variable needs modification, too. So also add this:
# Ubuntu One PATH
export PATH=”$HOME/UbuntuOne/ubuntuone-client-3.0.1/bin:$PATH”
Then reload the settings:
3. Build the client:
The next step is to build the client. Note that you do not need to run make install and pollute your $HOME 🙂
3. Get an auth token
wget http://people.canonical.com/~roman.yepishev/us/ubuntuone-sso-login.py
python ubuntuone-sso-login.py
Ubuntu SSO Login: **your Ubuntu SSO Login** Password: **your Ubuntu SSO Password** oauth=hPQWPsH:rhOokmNiRuuoiHe...
4. Copy the configuration file and add an auth token
Create the directory and copy the config file of the server:
[__main__] oauth=hPQWPsH:rhOokmNiRuuoiHe...
This part (3. & 4.) is best described here.
5. Wrapper files
The files look like this:
u1sdtool-wrapper
#!/bin/bash
# u1sdtool wrapper for headless Ubuntu One
if [ -z “$DBUS_SESSION_BUS_ADDRESS” ]; then
ENVVAR=”DBUS_SESSION_BUS_ADDRESS”
eval $(ps xe | grep “[u]buntuone-syncdaemon.*$ENVVAR” |
sed -E “s/.*($ENVVAR=[^ ]+).*/1/g” )
if [ -z “$DBUS_SESSION_BUS_ADDRESS” ]; then
# Ubuntu One is not running and we don’t have a dbus daemon
eval `dbus-launch –sh-syntax`
fi
export DBUS_SESSION_BUS_ADDRESS
fi
exec u1sdtool “$@”
ubuntuone-syncdaemon-wrapper
#!/bin/bash
# wrapper for headless Ubuntu One
if [ -z “$DBUS_SESSION_BUS_ADDRESS” ]; then
ENVVAR=”DBUS_SESSION_BUS_ADDRESS”
eval $(ps xe | grep “[u]buntuone-syncdaemon.*$ENVVAR” |
sed -E “s/.*($ENVVAR=[^ ]+).*/1/g” )
if [ -z “$DBUS_SESSION_BUS_ADDRESS” ]; then
# Ubuntu One is not running and we don’t have a dbus daemon
eval `dbus-launch –sh-syntax`
fi
export DBUS_SESSION_BUS_ADDRESS
fi
exec ubuntuone-syncdaemon $HOME/.config/ubuntuone/syncdaemon.conf &
ubuntu-sso-login-wrapper
#!/bin/bash
# ubuntu-sso-login wrapper for headless Ubuntu One
if [ -z “$DBUS_SESSION_BUS_ADDRESS” ]; then
ENVVAR=”DBUS_SESSION_BUS_ADDRESS”
eval $(ps xe | grep “[u]buntuone-syncdaemon.*$ENVVAR” |
sed -E “s/.*($ENVVAR=[^ ]+).*/1/g” )
if [ -z “$DBUS_SESSION_BUS_ADDRESS” ]; then
# Ubuntu One is not running and we don’t have a dbus daemon
eval `dbus-launch –sh-syntax`
fi
export DBUS_SESSION_BUS_ADDRESS
fi
exec ubuntu-sso-login “$@”
6. Start the syncdeamon
7. Use the u1sdtool-wrapper
This shows you the available commands:
These might be tho ones you need the most:
u1sdtool-wrapper –list-folders
Examples:
1. Add a folder to be synched (that is already in the cloud)
Type:
Get:
Folder list:
id=2ce31368-0a79-411e-XXX subscribed=False path=/home/mpei/Xoom
Type:
u1sdtool-wrapper –subscribe-folder=2ce31368-0a79-411e-XXX
Known issues:
1. network-manager / connection: With User Not Network
fixed the problem for me 🙂





