2009-10-22

Console keyboard layout and beep

Two quite annoying bits to remember so lets blog 'hem. Under a tty the keyboard may have a bad layout, I know perfectly changing it under X with setxkbmap but I usually Google for the console. The answer is loadkeys. Running loadkeys -d will print the current map file that gives an idea where to find the maps. Switching the map works like loadkeys /lib/kbd/keymaps/.../fr-latin1.map.gz, in other words just pass the map file. Now to come to the other annoying command to remember is the ability to cut off the beep. It works with setterm -blength 0.

Update: passing the locale directly to loadkeys works (thanks Boris), neither the help output nor the man page mentions this.

2009-10-13

Fast Python debugging with Vim

So I just needed to test some lines of Gtk+ code and preferably with Python. I love the interpreter (just as well as irb) but debugging even small Gtk+ pieces is not very attractive in the end. Therefore I jumped into Vim, typed my small script, and then executed the command ":%!python -". Only problem is that after the command exits it replaces the content of the Vim buffer with the console output that contains Python debugging messages as well, a quick press on "u" reverts this but maybe there is a cleaner way.

2009-10-11

MP3 support on Moblin (part 2)

Part 1 showed the easy way. Now the hard way to get MP3 support is to provide it yourself by building plugins for GStreamer. Having an RPM build environment is a prerequesite. The earlier blog entry shows how to set it up and also has an example to build and install libmad which will be useful in this example and I won't repeat it here.

Download the gstreamer-plugins-ugly source package. Put it inside the SRPMS directory and run the rpm -i command on it to unarchive its content.

Open a text editor and edit the spec file available under SPECS. The package names vary between Moblin, Fedora and RPM Fusion and this needs to be fixed in the header. And in this example only the plugin libmad will be build so that's why many lines will be commented. In fact the only build dependencies will be libmad, libid3tag and liboil. I have put the diff on Snipt. To apply it use the patch command like patch -p0 < gstreamer-plugins-ugly.spec.diff. Don't miss the patch(1) man page to know about the -p option.

Now build binary packages with the command rpmbuild -bb SPECS/gstreamer-plugins-ugly.spec. Wait a minute and you should have a ready to install gst-plugins-ugly package within the RPMS directory.

You can more or less repeat this task for DivX and other video codecs support. For that you'll have to build the GStreamer FFmpeg plugin (gstreamer-ffmpeg source package). Of course FFmpeg depends on many many libraries and you'll have to build them at first.

Update: Regarding FFmpeg, it can be build from the RPM source package without external requirements, in fact it doesn't have any hard dependencies. Or you can even compile the gstreamer-ffmpeg plugin only with the internal FFmpeg sources since it is optionaly linked to an external FFmpeg library. In both cases the provided SPEC files have to be modified.

RPM build environment on Moblin

I once set up an RPM build environment on my netbook to build missing packages, often small tools. There are many docs to do that, for myself I browsed the Fedora project wiki. If you are looking for RPMish stuff you are in the right place there.

Preparation

The package rpmdevtools provides scripts for the packager, one of them is rpmdev-setuptree. This tool will set up automatically the build directory for keeping source packages, spec files, etc. You can run this command now. Within your home, it will create an rpmbuild directory and a hidden .rpmmacros file. You can move the rpmbuild directory where ever you want but you will have to fix the variable %_topdir in the hidden rpmmacros file.

That's already about it.

Build example

Lets take a small example to show the use of the RPM build environment. Download the source package libmad from RPM Fusion. Copy it to the subdirectory SRPMS and then unarchive it with the command rpm -i SRPMS/libmad-[version].src.rpm. And finally you can build the binary packages with the command rpmbuild -bb SPECS/libmad.spec. The rpmbuild command is provided by the rpm-build package.

By now you can install the packages within the subdirectory RPMS, libmad-[version].rpm and the -devel package, if you wish to build the source package madplay to play MP3s from command line :-)

External sources

MP3 support on Moblin (part 1)

The easiest way to add support for MP3 is by installing a pre-build RPM package. Fluendo has one available for free. The reason Moblin isn't distributing a decoder is of legal issues, however one might get them by "legal" ways where that term will vary amongst different juridictions. It clearly is an annoying topic to raise up! If you buy a laptop you can expect to have MP3 support since the sellers have ways to collect royalties. At least that's what I learned from the Moblin mailing-list.

Installing an RPM is done by running the simple command "rpm -i [package]" with the super user.