Mi blog lah! Το ιστολόγιό μου

22Jun/090

From new user to kernel compilation to upstream fix

It is quite exciting when helping new users solve issues while migrating to the Linux operating system, and Ubuntu Linux in this case.

A couple of weeks ago, a new member at the Ubuntu-gr forum posted a question about a sound problem in an Ubuntu Linux installation.

Alsa Mixer

Alsa Mixer

Here is the timeline

  1. An initial post was made with the relevant hardware information.
  2. More information was gathered that led to the PCI ID and subsystem ID of the sound card, which further led to the source of a patch for a quirk.
  3. The advice to recompile the full kernel (with the patch) was given. This process required over 10GB, which caused the distribution to crash. The user was fine to reinstall.
  4. A subsequent route was taken to simply compile Alsa (not the full kernel) and add the patch.
  5. This route was successful and the sound was now working.
  6. We want to post this patch upstream so that newer versions of the kernel contain the fix. In addition, all distributions will benefit as well.
  7. A bug report was submitted to the Alsa bugtracking #0004561. We now wait.
  8. Days are passing with no progress. A question at #alsa (Freenode) shows that the Alsa bugtracking is probably not used, so there is need to contact the developers through the mailing list.
  9. An e-mail is sent to the Alsa mailing list with the patch. The Alsa developer takes the patch and applies to his tree. We missed by several days the release of Linux 2.6.30; the patch should appear in 2.6.31.

The whole process took ten days. It is amazing how rewarding it is to follow the open-source processes and contribute the personal time to help make open-source better.

The patch was evidently elemental, however it required new testing to make sure it works, and that it applies to the current state of Alsa. There are many areas that you can contribute some of your time to make open-source better.

I would like to thank Theodora for going through the process, locating and verifying the patch, so that now it is pending inclusion in Linux 2.6.31.

Update 22Apr 2010: The change has been added to the Linux kernel :-) . It’s a tiny small change that anyone can do.

http://upload.wikimedia.org/wikipedia/commons/thumb/7/78/Alsa_v1.0.14_ubuntu7.1_en.png/220px-Alsa_v1.0.14_ubuntu7.1_en.png
15Mar/080

How to easily modify a program in Ubuntu (updated)?

Some time ago we talked about how to modify easily a program in Ubuntu. We gave as an example the modification of gucharmap; we got the deb source package, made the change, compiled, created new .deb files and installed them.

We go the same (well, similar) route here, by modifying the gtk+ library (!!!). The purpose of the modification is to allow us to type, by default, all sort of interesting Unicode characters, including ⓣⓗⓘⓢ , ᾅᾷ, ṩ, and many more.

The result of this exercise is to create replacement .deb packages for the gtk+ library that we are going to install in place of the system libraries. Because these new libraries will not be original Ubuntu packages, the update manager will be pestering us to rollback to the official gtk+ packages. This is actually good in case you want to switch back; you will have the enhanced functionality for as long as you postpone that update.

There is a chance we might screw up our system, so please make backups, or have a few drinks first and come back. I take no responsibility if something bad happens on your system. If you are having any second thoughts, do not follow the next steps; use the safer alternative procedure. You may try however this guide just for the kicks; up to the dpkg command below, no changes are being made to your system.

We use Ubuntu 7.10 here. This should work in other versions, though your mileage may vary.

The compilation procedure takes time (about 30 minutes) and space. Make sure you use a partition with >2GB of free space. We are not going to use up 2GB (a bit less than 1GB), but it’s nice not to fill up partitions.

We are going to use the generic instructions on how to recompile a debian package by ducea.

First of all, install the development packages,

sudo apt-get install devscripts build-essential

Next, we use the apt-get source command to get the source code of the GTK+ 2 library,

cd /home/ubuntu/bigpartition_over2GB/
apt-get source libgtk2.0-0

We then pull in any dependencies that GTK+ may require. They are normally about a dozen packages, but we do not have to worry for the details.

apt-get build-dep libgtk2.0-0

At this stage we need to touch up the source code of GTK+ before we go into the compilation phase. Visit the bug report #321896 – Synch gdkkeysyms.h/gtkimcontextsimple.c with X.org 6.9/7.0 and download the patch (look under the Attachment section). You should get a file named gtk-compose-update.patch. If you have a look at the patch, you will notice that it expects to find the source of gtk+ in a directory called gtk+. Making a link solves the problem,

ln -s libgtk2.0-0 gtk+

We then attempt to apply the patch (perform a dry run), just in case.

patch -p0 --dry-run < /tmp/gtk-compose-update.patch

If this does not show an error message, you can the command again without the –dry-run.

patch -p0 < /tmp/gtk-compose-update.patch

Finally, we are ready to build our fresh GTK+ library.

cd libgtk2.0-0
debuild -us -uc

This will take time to complete, so go and do some healthy cooking.

At the end of the compilation, if all went OK, you should have about a dozen .deb files created. These are one directory higher (do a “cd ..“). To install, use dpkg,

dpkg -i *.deb

If you have any other deb files in this directory, it’s good to move them away before running the command. If all went ok, the .deb files should install without a hitch.

The final step is to restart your system. To test the new support, see the last section at this post. Use Firefox and OpenOffice.org to type those Unicode characters.

If you managed to wade through all these steps, I would appreciate it if you could post a comment.

Good luck!

23Jul/071

Important MO file optimisation for en_* locales, and partly others

During GUADEC, Tomas Frydrych gave a talk on exmap-console, a cut-down version of exmap that can work well on mobile devices.

During the presentation, Tomas showed how to use the tool to find the culprits in memory (ab)use on the GNOME desktop. One issue that came up was that the MO files taking up space though the desktop showed English. Why would the MO translation files loaded in memory be so big in size?

gtk20.mo                             : VM   61440  B, M   61440  B, S   61440  B

atk10.mo                      	     : VM    8192  B, M    8192  B, S    8192  B

libgnome-2.0.mo			: VM   28672  B, M   24576  B, S   24576  B

glib20.mo			     : VM   20480  B, M   16384  B, S   16384  B

gtk20-properties.mo           : VM     128 KB, M     116 KB, S     116 KB

launchpad-integration.mo  : VM    4096  B, M    4096  B, S    4096  B

A translation file looks like

msgid “File”

msgstr “”

When translated to Greek it is

msgid “File”

msgstr “Αρχείο”

In the English UK translation it would be

msgid “File”

msgstr “File”

This actually is not necessary because if you leave those messags untranslated, the system will use the original messages that are embedded in the executable file.

However, for the purposes of the English UK, English Canadian, etc teams, it makes sense to copy the same messages in the translated field because it would be an indication that the message was examined by the translation. Any new messages would appear as untranslated and the same process would continue.

Now, the problem is that the gettext tools are not smart enough when they compile such translation files; they replicate without need those messages occupying space in the generated MO file.

Apart from the English variants, this issue is also present in other languages when the message looks like

msgid “GConf”

msgstr “GConf”

Here, it does not make much sense to translate the message in the locale language. However, the generated MO file contains now more than 10 bytes (5+5) , plus some space for the index.

Therefore, what’s the solution for this issue?

One solution is to add to msgattrib the option to preprocess a PO file and remove those unneeded copies. Here is a patch,

— src.ORIGINAL/msgattrib.c 2007-07-18 17:17:08.000000000 +0100
+++ src/msgattrib.c 2007-07-23 01:20:35.000000000 +0100
@@ -61,7 +61,8 @@
REMOVE_FUZZY = 1 << 2,
REMOVE_NONFUZZY = 1 << 3,
REMOVE_OBSOLETE = 1 << 4,
- REMOVE_NONOBSOLETE = 1 << 5
+ REMOVE_NONOBSOLETE = 1 << 5,
+ REMOVE_COPIED = 1 << 6
};
static int to_remove;

@@ -90,6 +91,7 @@
{ “help”, no_argument, NULL, ‘h’ },
{ “ignore-file”, required_argument, NULL, CHAR_MAX + 15 },
{ “indent”, no_argument, NULL, ‘i’ },
+ { “no-copied”, no_argument, NULL, CHAR_MAX + 19 },
{ “no-escape”, no_argument, NULL, ‘e’ },
{ “no-fuzzy”, no_argument, NULL, CHAR_MAX + 3 },
{ “no-location”, no_argument, &line_comment, 0 },
@@ -314,6 +316,10 @@
to_change |= REMOVE_PREV;
break;

+ case CHAR_MAX + 19: /* –no-copied */
+ to_remove |= REMOVE_COPIED;
+ break;
+
default:
usage (EXIT_FAILURE);
/* NOTREACHED */
@@ -436,6 +442,8 @@
–no-obsolete remove obsolete #~ messages\n”));
printf (_(“\
–only-obsolete keep obsolete #~ messages\n”));
+ printf (_(“\
+ –no-copied remove copied messages\n”));
printf (“\n”);
printf (_(“\
Attribute manipulation:\n”));
@@ -536,6 +544,21 @@
: to_remove & REMOVE_NONOBSOLETE))
return false;

+ if (to_remove & REMOVE_COPIED)
+ {
+ if (!strcmp(mp->msgid, mp->msgstr) && strlen(mp->msgstr)+1 >= mp->msgstr_len)
+ {
+ return false;
+ }
+ else if ( strlen(mp->msgstr)+1 < mp->msgstr_len )
+ {
+ if ( !strcmp(mp->msgstr + strlen(mp->msgstr)+1, mp->msgid_plural) )
+ {
+ return false;
+ }
+ }
+ }
+
return true;
}
However, if we only change msgattrib, we would need to adapt the build system for all packages.

Apparently, it would make sense to change the default behaviour of msgfmt, the program that compiles PO files into MO files.

An e-mail was sent to the email address for the development team of gettext regarding the issue. The development team does not appear to have a Bugzilla to record these issues. If you know of an alternative contact point, please notify me.

Update #1 (23Jul07): As an indication of the file size savings, the en_GB locale on Ubuntu in the installation CD occupies about 424KB where in practice it should have been 48KB.

A full installation of Ubuntu with some basic KDE packages (only for the basic libraries, i.e. KBabel – (ls k* | wc -l = 499)) occupies about 26MB of space just for the translation files. When optimising in the MO files, the translation files occupy only 7MB. This is quite important because when someone installs for example the en_CA locale, all en_?? locales are added.

The reason why the reduction is more has to do with the message types that KDE uses. For example,

msgid “”
“_: Unknown State\n”
“Unknown”
msgstr “Unknown”

I cannot see a portable way to code the gettext-tools so that they understand that the above message can be easily omitted. For the above reduction to 7MB, KDE applications (k*) occupy 3.6MB. The non-KDE applications include GNOME, XFCE and GNU traditional tools. The biggest culprits in KDE are kstars (386KB) and kgeography (345KB).

Update #2 (23Jul07): (Thanks Deniz for the comment below on gweather!) The po-locations translations (gnome-applets/gweather) of all languages are combined together to generate a big XML file that can be found at usr/share/gnome-applets/gweather/Locations.xml (~15MB).

This file is not kept in memory while the gweather applet is running.
However, the file is parsed when the user opens the properties dialog to change the location.
I would say that the main problem here is the file size (15.8MB) that can be easily reduced when stripping copied messages. This file is included in any Linux distribution, whatever the locale.

The po-locations directory currently occupies 107MB and when copied messages are eliminated it occupies 78MB (a difference of 30MB). The generated XML file is in any case smaller (15.8MB without optimisation) because it does not include repeatedly the msgid lines for each language.

I regenerated the Locations.xml file with the optimised PO files and the resulting file is 7.6MB. This is a good reduction in file space and also in packaging size.

Update #3 (25Jul07): Posted a patch for gettext-tools/msgattrib.c. Sent an e-mail to the kde-i18n-doc mailing list and got good response and a valid argument for the proposed changes. Specifically, there is a case when one gives custom values to the LANGUAGE variable. This happens when someone uses the LANGUAGE variable with a value such as “es:fr” which means show me messages in Spanish and if something is untranslated show me in French. If a message has msgid==msgstr for Spanish but not for French, then it would show in French if we go along with the proposed optimisation.

1May/070

Mentoring facility available in Launchpad, Ubuntu

Is there a bug report in Launchpad.net (Ubuntu) that you are confident you can help someone to fix but do not have the time to fix yourself?
Now Launchpad provides the facility for contributors to offer mentoring support to bug reports and blueprints, so that users can apply and receive mentoring. With mentoring you help someone else solve a problem. Ubuntu is benefited, and also the new user gets help in resolving bugs.

For the Greek language there is an Ubuntu team called Ubuntu Greek Testers. Users interested for the Greek language in Ubuntu can subscribe to team. Then, for any bug report that relates to the Greek language support, we subscribe the team as a member. The system is configured in such a way so that any activity on those bug reports is mailed to each member. This makes it easy to track the status of reports.

You can see the current list of pending reports for the Greek language in Ubuntu.

One of the bug reports is about the Broken context-sensitive spell check in evolution (Greek, Russian, etc) GNOME #344008.
This report has been there for around 2 years and it should be fixed soon. I am not sure what the best course of action should be. Well, the typical course of action would be to compile GNOME manually (jhbuild), locate the code in Evolution that deals with gnome-spell and put printf()s that show what’s going on when this part of the code is reached. Any takers?

Update: Just offered mentorship for https://bugs.launchpad.net/evolution/+bug/10713 :) I understand the direction to work on but do not know what exactly is going on.

9Jan/070

Creating a new locale on the OLPC

When you run the OLPC software you currently have access only to the English locales.

If you want to enable Greek support, you need to run (as root)

localedef -v -c -i /usr/share/i18n/locales/el_GR -f UTF-8 /usr/lib/locale/el_GR/

localedef -v -c -i /usr/share/i18n/locales/el_GR -f UTF-8 /usr/lib/locale/el_GR.utf8/

You will get a bunch of warnings. You can ignore them for now.

The localedef command compiles the source locale information found at /usr/share/i18n/locales/el_GR and places the resulting files at
/usr/lib/locale/el_GR/ and /usr/lib/locale/el_GR.utf8/ (both directories contain the same files, so you can also make a link from one to another). The reason we make two versions is that we can use either el_GR or el_GR.utf8 in the applications. Both use UTF-8 as the base encoding which is always nice.
For other locales, replace el_GR with the locale name of your country.

To activate the Greek locale, you need to create a file /etc/sysconfig/i18n and add the text

LANG=el_GR.utf8

LANGUAGE=el:en

Now you need to place the translated applications (.mo format) into

/usr/share/locale/el/LC_MESSAGES/

and restart your virtual machine (or laptop (hint hint)).

9Jun/061

How to easily modify a program in your Ubuntu?

Suppose we want to change the functionality of an Ubuntu application but we do not want to go into all the trouble of finding the source code, installing in /usr/local/, breaking dependencies with original versions and so on.

Let’s change Character Map (gucharmap), and specifically change the default font size from 20pt to 14pt, so that when you start it there is more space in the character window. Currently Character Map does not offer an option to save this setting.

We get the source code of Character Map,

# apt-get source gucharmap

Then,

cd gucharmap-1.4.4/

and now we edit the file gucharmap/main.c

We know what to edit because we visited the GNOME CVS Website, at http://cvs.gnome.org/viewcvs/gucharmap/

and we examined the logs for the file http://cvs.gnome.org/viewcvs/gucharmap/gucharmap/main.c?view=log

which show that for Revision 1.69, the following change took place,

Log:

2004-02-01  Noah Levitt

* gucharmap/gucharmap-table.c: Improve square size.

* gucharmap/main.c: Increase default font size.

When we click on the link Diff to previous 1.68 of the above page, we pinpoint the change,

version 1.68, Sun Feb 1 03:46:21 2004 UTC version 1.69, Mon Feb 2 00:48:05 2004 UTC
Line 93 main (gint argc, gchar **argv)
Line 93 main (gint argc, gchar **argv)

gint default_size = PANGO_PIXELS (1.5 * pango_font_description_get_size (window->style->font_desc));

gint default_size = PANGO_PIXELS (2.0 * pango_font_description_get_size (window->style->font_desc));

The change in the multiplier (from 1.5 to 2.0) changes the font size from 15pt to 20pt.

20pt is too big for us, therefore we edit the file gucharmap/main.c and change the 2.0 to 1.4 (14pt).
At this point we can compile the package using the command line

$ dpkg-buildpackage -rfakeroot -uc -b

dpkg-buildpackage: source package is gucharmap
dpkg-buildpackage: source version is 1:1.4.4-1ubuntu1
dpkg-buildpackage: source changed by Sebastien Bacher
dpkg-buildpackage: host architecture i386
fakeroot debian/rules clean

……….

At this point it is possible that you will get an error that an essential package is missing. The above command line will name the missing files, therefore you can simply install by

# apt-get install package-name

In case you do not have the basic compiler packages, you would need to install the build-essential meta-package. Do

# apt-get install build-essential

Finally, after the dpkg-buildpackage command completes, it will create one or more .deb packages in the directory above gucharmap.

# cd ..

# ls -l *.deb

gucharmap_1.4.4-1ubuntu1_i386.deb

libgucharmap4_1.4.4-1ubuntu1_i386.deb

libgucharmap4-dev_1.4.4-1ubuntu1_i386.deb
#

You can now install them (over the original packages) by running

# dpkg -i gucharmap_1.4.4-1ubuntu1_i386.deb libgucharmap4_1.4.4-1ubuntu1_i386.deb libgucharmap4-dev_1.4.4-1ubuntu1_i386.deb

Now we start the Character Map from Applications/Accessories/ and we get the default character size of 14pt!

Is there something we should pay attention on top of this? Yes, we should investigate the GNOME Bugzilla in case there is relevant work on this issue. We visit

http://bugzilla.gnome.org/

and specifically we click on the link Browse.

There, we select the package gucharmap (how do we know that Character Map is gucharmap? We either click on Help/About in Character Map which shows the internal name, or we run ps ax at a Applications/Accessories/Terminal while Character Map is running; the name gucharmap will pop up at the end of the long list.).

gucharmap is under the Desktop heading in the Browse list; or click on this direct link of bug reports on gucharmap.
If you start perusing the gucharmap bugs list, you will notice Bug #140414, titled remember settings. This report describes a superset of the problem we tried to solve above. That is, the bug report asks to enable Character Map to use the GNOME configuration database (gconf) so that it saves/remembers the user settings. However, this specific bug report is still pending.

The correct way to solve the configuration settings issue of gucharmap is to implement what is described in Bug #140414. If you have Ubuntu 6.06, you most likely have a very recent version of the source code of gucharmap. Therefore, the differences would be rather minimal. You can give it a go and try to get the gconf functionality in place.

You compile, install and test. If it works, you can make a patch of your changes; visit another directory and download a fresh copy of the source code using the apt-get source packagename command. Rename gucharmap-1.4.4 to gucharmap-1.4.4.ORIGINAL

# mv gucharmap-1.4.4 gucharmap-1.4.4.ORIGINAL

and make sure you clean the original gucharmap-1.4.4/ directory from compiled files (enter the directory were you did the source code changes and run make clean).

Finally, create a diff file,

# diff -ur ~/tmp/gucharmap-1.4.4.ORIGINAL ~/gucharmap-1.4.4/ > remember-settings.patch

In ideal terms, it is preferable if you could produce a patch for the latest version of gucharmap. That is, the version of gucharmap you get from http://cvs.gnome.org/viewcvs/gucharmap/. By doing so, the developers will love you because they will be able to simply apply the patch and limit the burden of adding the feature. Indeed, if it is too much effort to get a build system running, you can start off with simple patches and if you feel you are doing well with it, make the extra mile to have a build system. More on this in a future post.

16Feb/061

Ανατομία ενός γράμματος

Με ενδιαφέρον είδα μια συζήτηση (τίτλος upgrade σε ubuntu 5.10 = προβλήματα με τα ελληνικά) στη λίστα συνδρομητών Linux-greek-users για το θέμα της υποστήριξης γραφής ελληνικών σε ελεύθερο λογισμικό.
Ωστόσο, μετά από λίγα γράμματα, στάλθηκε

17May/04Off

Ασύρματα δίκτυα 802.11[abg] και Linux

Πριν αγοράσετε εξοπλισμό για ασύρματα δίκτυα, καλό είναι να ψάξετε αν υπάρχει υποστήριξη για Linux.

Γενικά υπάρχουν κάρτες οι οποίες είναι πλήρως συμβατές με Linux και προσφέρουν και δυνατότητες που ένας χρήστης Windows δε μπορεί να διανοηθεί!

Για παράδειγμα, μια κάρτα είναι δυνατόν να υποστηρίζει τη “κατάσταση Host AP/AccessPoint” που σημαίνει ότι με ειδικό λογισμικό κάποιος μπορεί να μετατρέψει το συμβατό υπολογιστή του/της σε “Access Point” χωρίς να χρειάζεται επιπλέον υλικό (hardware). Με αυτό το τρόπο, μπορείτε να δεχθείτε πολλαπλές συνδέσεις στον υπολογιστή σας. Δείτε “access point” μέσω λογισμικού (κατάσταση Host AP) για περισσότερα.

Επιπλέον, στην προτίμηση μιας κάρτας 802.11[abg] είναι θετικό να υπάρχει δυνατότητα σύνδεσης νέας κεραίας, σε περίπτωση που θέλετε να έχετε μεγαλύτερη εμβέλεια. Σε αρκετές περιπτώση όμως δεν είναι πολύ σημαντικό.

Μια άλλη κατάσταση που μπορεί να υποστηρίζει μια κάρτα είναι η κατάσταση rfmon, με την οποία κάποιος μπορεί να χρησιμοποιήσει εφαρμογές όπως το Netstumbler (Windows) για την ανίχνευση διαθέσιμων δικτύων. Για Linux υπάρχει το πρόγραμμα kismet που θεωρείτε και καλύτερο από το Netstumbler.

Γενικά όταν αγοράζει κάποιος μια κάρτα ασύρματου δικτύου, είναι δύσκολο να ξέρει τι “chipset” περιέχει (που δείχνει και αν υπάρχει υποστήριξη). Η σελίδα WLAN Adapter Chipset Directory compiled by AbsoluteValue Systems, Inc. είναι πολύ βοηθητική. Φυσικά υπάρχουν κάρτες όπως αναφέρεις που διαφορετικά “revision” έχουν διαφορετικά chipset. Πριν αγοράσετε, ζητήστε “συμβατότητα με Linux”.

Το chipset της Intersil Prism είναι αρκετά ενδιαφέρον. Αν μπορείτε, προτιμήστε το. Δείτε prism54.

Για το Atheros δείτε MADWIFI.

Υπάρχουν δικτυακοί τόποι για ασύρματα δίκτυα σε μεγάλες πόλεις (Αθήνα, Θεσσαλονίκη, Πάρτα, Λάρισσα) και μικρές (Μυτιλήνη). Γενικότερα δείτε NodeDB.com : Europe : Greece .

Τέλος, κοίταξε στο forum του awmn.gr για ενδιαφέροντες συνδέσμους (ομαδική αγορά, συμβατότητα, άλλοι χρήστες, κτλ).

   

Switch to our mobile site