Archive for Free software and related beasts

On-board sound hijacking my SBLive

OK, I made a fresh install of Debian Etch on my home computer, and a sound problem appeared. My computer has a soundcard integrated in the ASUS A7N8X-E Deluxe motherboard (best piece of hardware I ever bought, this mobo), but I use a spare Sound Blaster Live! I took from my previous computer, so I want the sound to come out of the latter, not the former.

However, the kernel modules to control the on-board soundcard seem to get loaded first, and sound output defaults to it. There could be more elegant solutions, but mine was to copy the following in the /etc/rc.local file (this file gets executed after the /etc/init.d/ services started at boot time):

modprobe -r snd_intel8x0
modprobe -r snd_emu10k1
modprobe snd_emu10k1
modprobe snd_intel8x0

What these lines do is remove the module for the on-board sound (intel8x0), then the SBLive! one (emu10k1), then reload them, but the SBLive! one first.

Comments

Xgl with Xfce under Debian Etch

See http://www5.autistici.org/debian-xgl/x86-xgl-pkg/README

d/l .debs from http://www5.autistici.org/debian-xgl/debian/binary-i386/

see http://www5.autistici.org/debian-xgl/

add “/usr/share/fonts/X11/misc/” to the Xgl command in http://gentoo-wiki.com/HOWTO_XGL#Running_Xgl, otherwise it gives “could not open default font ‘fixed'”

Comments

GParted and my laptop

OK, yesterday I bought a laptop (my first ever), and I am so excited about it! It’s specs:

Fujitsu-Siemes Amilo PI1536
CPU: Intel Core 2 Duo T7200 2×2.0GHz
RAM: 2x1Gb
HD: 120Gb SATA
Display: 15.4 WXGA
Graphics: ATI Mobility Radeon X1400 (128Mb dedicated/512Mb shared)

I chose it for its high quality CPU, and half-decent graphics card. It turns out most sellers have a large Core Duo stock, but a pitifully short list of Core 2 Duo models. Hence, they want to sell their already outdated Core models, and offer little choice in Core 2s (and a bit higher prices, although Intel sells them both at similar prices). The little choice in Core 2 Duos made it difficult to me to find what I was looking for, but I finally did.

However, this post is not only dedicated to spread my happiness. I also wanted to praise the Free Software program GParted, which I just used.

As any laptop+Linux user has experienced, usually Windows is pre-installed and shipped with the computer. In my case, I wanted to have it, so no problem with that. The bad part is that, of course, the whole hard disk is usually a single partition, with Windows being in it. Since I wanted to install Linux also, I had to make partitions. Although the laptop came with CDs for all the software that comes pre-installed (Windows included), I wanted to try to resize the Windows partition, and make room for the other partitions, without destroying the Windows installation.

I downloaded an Ubuntu ISO, burned it, then restarted the laptop with it. Good thing of Ubuntu is that its CD is a Live CD, which means that can be run without installing anything in the hard disk. Ubuntu started flawlessly, and I was presented with a GNOME desktop. There, I started GParted, and a simple, yet visually pleasing, GUI opened, and I point-and-clicked all the settings, which took me from:

1x 111Gb partition under NTFS

to:

1x 15Gb (NTFS)
1x 512Mb (swap) probably wasted disk, but oh well…
3x 10Gb (ReiserFS)
1x 50Gb (ReiserFS)
1x 18Gb (NTFS)

This way, the second NTFS partition can be used to store files Windows can access (I have to try if Linux can access that. If not, I’ll reformat with FAT32), and I still have room for three Linux distro installs (10 Gb Reiserfs), and a big home/ that all Linux-es can share.

Now, the delicate part… rebooting into Windows. I held my breath while the computer rebooted, but it did so fine. Windows started without problem, it just performed a disk integrity check at startup (which finished OK), and then said it had found new hardware, which turned out to be the second NTFS partition (the E: drive now). As we are used to with the stupid Windows, I was told to reboot to have the system recognize the recently-discovered hardware. So I did, and it worked!

Now Windows is installed in the 15Gb NTFS partition (and recall I didn’t reinstall anything. What was there, is still there), and sees a second 18Gb partition. As for Linux, I am looking forward to installing Debian, Ubuntu or something…

Comments (3)

Do one thing, do it well. Part II

This post is the continuation of a previous one. In that first part I mentioned the “bells and whistles” of most Windows programs being even counterproductive, and getting in the way of the user. Here I will elaborate on that.

Most GNU and Free Software applications for GNU/Linux and other Unix-like systems have the possibility of being called from the command line, appart from any GUI they may have.

One would think that no-one in his right mind would use an ugly CLI, where a visual point-and-click GUI exists. However, CLIs give a substantial flexibility, and I will illustrate this with an example.

Suppose you want your computer to remind you of the upcoming birthdays of your friends. Suppose you use Windows. Then, you have to find a program like Birthday Reminder Plus 2006, or whatever, which does it. Maybe you want to be reminded by e-mail… but you will have to make do with what the options in the BRP2006 GUI give you. If BRP2006 has a menu with: “Remind with a beep” and “Remind with a pop-up”, you will have to choose one, and that’s it. Windows programs don’t expect you to think or develop. They expect you to use Google, eMule and so on to download a pirated copy of a monolithic program that fits your needs. If BRP2006 has not an option for reminding you via e-mail, then you have to drop it alltogether, and keep searching for Birthday MegaReminder for PowerUsers 2007, which has such an option.

With GNU/Linux, maybe there is such a program, and you are free to use it. However, there are far better solutions, which you can tailor to your needs. The following is what I actually do to be reminded of birthdays:

First, I need a kind of “database” of birthdays, and a program that, reading this database, can extract the upcoming ones (the ones for which a given amount of days or less, are left). There are probably many of them, but I use one called simply Birthday. I haven’t found the Home Page of this program (to give it here), but I use the Debian package, mantained by Alexander Neumann. The “database” consists in a file called .birthdays that we have to place in our home/ directory. This file will contain lines like:

Bill Gates=30/09/666

Then, when called from the command line, it will output:

Bart[~]: birthday
Bill Gates is 1340 years old in 4 days' time.

If no option is given, birthdays in the following 21 days will be printed out. If you want to see birthdays in the following X days, just issue birthday -W X.

Second, this output is ugly. For example, the use of “is” is wrong, and “days’ time” could be shortened to “days”. To do so, we can pipe it through sed (another GNU utility):

Bart[~]: birthday | sed -e "s/ is / will be /;s/'.*//g"
Bill Gates will be 1340 years old in 4 days

Thus, sed substitutes ‘ is ‘ with ‘ will be ‘, and a literal ‘ and anything behind it ('.*) with nothing (effectively deleting it).

Third, we have to send this “Bill Gates will be…” to our e-mail address. For that, we will use the mail GNU command, like this:

Bart[~/]: birthday | sed -e "s/ is / will be /;s/'.*//g" | mail -s '[BIRTHDAY]' myaddress@myisp.org

This will send an e-mail to myaddress@myisp.org, with the subject [BIRTHDAY], and the body being the Bill Gates will be 1340 years old in 4 days text above.

Fourth, we need to automate this. For that, we can make a little Perl script:

#!/usr/bin/perl -w

#
# This scripts e-mails me to remind me of
# upcoming birthdays. It needs the ‘birthday’
# package.
#

use strict;

# Test if birthday package is installed:
die “No birthday package!\n” if (`which birthday` =~ /not found/);

# Read the list of upcoming birthdays, formated with sed:
my @bulk = `birthday | sed -e “s/ is / will be /;s/’.*//g”`;

# The e-mail address:
my $u = ‘a@b.c’;

# Send e-mail, if there is any upcoming birthday:
system “echo ‘ @bulk’ | mail -s ‘[BIRTHDAY]’ $u” if @bulk;

Next, we have to set this script to run periodically. We can do it with the GNU cron utility. This is a daemon, constantly running in the background (if its service has been activated), wasting negligible resources, and executing the task the users schedule, via the crontab command, or even a GUI like Kcron.

So, I use kcron to schedule the Perl script above to run everyday, at 7:01 am, et voilà! I receive an e-mail from my system every morning, reminding me of the upcoming birthdays.

Uf, all THAT has to be done?

OK, it sounds like a lot of work, for something our Birthday MegaReminder 2007 could do with half a dozen clicks.

Now, consider. The procedure outlined here is fully modular. Any time you want to modify something, you can act on the relevant step: e.g.: if you want to add a birth date to your list, you can just add it editing the ~/.birthday file. If you want to be reminded just once a week, the crontab should be modified. If you want to be reminded 73 days in advance, just add -W 73 to the birthday command in the Perl script. If you want the reminder to be sent to a list of e-mails, instead of only to yourself, you can modify the script accordingly.

The good part is that now you have learned how to use different tools, for different tasks: You have used cron here, but you can use elsewere to schedule ANY job. You have used mail here, but you can use it elsewere to send any text by e-mail, including the contents of a file, the output of a command, or a fixed text.

Maybe the Birthday MegaReminder has scheduling capabilities (like cron), running in the background and activating itself when appropriate. That’s fine but… can its scheduling capabilities be used for other programs? Sorry, no. If you want a periodic scheduler for program X, you have to buy, or pirate, a copy of a program which not only makes X, but also has scheduling capabilities. Maybe Birthday MegaReminder has e-mailing capabilities (like mail), but… can they be used to e-mail other things? Sorry, no.

With the GNU tools (like cron, sed and mail), when I want a program to connect to the Web, retrieve my horoscope, and send a copy to my e-mail, I don’t need a program that is good at sending e-mails or scheduling actions. I need a program that is good at retrieving horoscopes from the Internet. Then, I have tools to e-mail me with the output of such a program, and/or schedule its execution periodically.

Comments

Do one thing, do it well. Part I

If one reviews the Unix philosophy, it is readily seen a huge different from Windows-land. With Windows, every single task has huge programs, with a colorful graphical interface, menues galore, icons, flashing lights and all functionality incorporated into point-and-click buttons, scrolling bars etc.

All this is advocated in the name of “user friendliness”, that is, making it easy for the user. However, there are two major drawbacks I can see (there can be others). First, in a technical aspect, each and every program is a mammoth. Second, the flexibility and usefulness of these programs actually gets degraded with this policy. I’ll address the first question in this post, the second one in another one.

The “mammoth-ness” of proprietary programs happens because, since they forbid sharing code and information among their developers, they tend (have) to be mostly self-contained. This is highly counterproductive, because instead of sharing resources, they have to be replicated.

Think of the following (silly) example: I have programs A, B and C, all of which can produce red circles. Since their source code is closed, each one of them has to implement a piece of code (library) to make “red circles”. Each time one of the three programs is installed, it carries its own redcircles library, with its bugs and problems (and hard disk and memory resource waste). See Figure 1.

bad

Figure 1: Each program has incorporated a redcircles module.

If these programs were Free, they could all share a common redcircles package, which could be developed by other people. See Figure 2. This would let the developer of each program concentrate on the particular things their program does. And also disk space would not be wasted installing that library for each new program that uses it. A new A, B or C instalation would only need the installer to know that the extra package redcircles has to be also installed (a “required” package), if it already isn’t.

good

Figure 2: All programs share an external redcircles library.

The development of the redcircles package would also be much more efficient, because developing and debugging a single package would be much easier than doing so for each program that uses it.

Comments (1)

Sudaku released

I previously posted about the sudoku fever that had attacked my family. I have found amusing solving some sudokus, but what I really thought was interesting was making a computer program to solve them automatically. Not that it would be more “challenging” (some sudokus are quite difficult), just more fun for me.

OK, so that I did, and today I have released a Perl program that (hopefully) solves any sudoku we feed to it. The program is called Sudaku (well, one sweats when solves a sudoku, doesn’t one?), and can be freely downloaded from my home page. I have licensed it under the GPLv2.

Yes, I know there are other sudoku solvers around, probably better than mine, on top of that. However, I just wanted to make it, and releasing it may help someone, or (more probably) even me, if some better programers than me out there e-mail me proposing changes/corrections.

What the heck, I just felt like releasing it! :^)

Comments

Some numbers on FLOSS

Looking at the Free Software page in the Wikipedia (to which I have contributed with the “However, direct economic benefit is hardly the main reason[…]” paragraph), I found the following link.

Although it’s about 9 months old, it is still meaningfull, and makes for a good reading. Also check this Groklaw article.

Go ahead and “get the facts”.

Comments

Convert PS to PDF

I make extensive use of ps2pdf to convert PostScript files to PDF. As most GNU/Linux tools, this is a simple and incredibly useful one.

However, sometimes it might give problems. For example, I have sometime converted a PS to a PDF that Evince would open fine, but Acrobat Reader would not. I fixed this problem making use of the superb alternatives system present in Debian.

The first thing to know is that most of PS and PDF manipulation (including PS-to-PDF conversion) is done by calling a backend application called Ghostscript (GS). A quick search within the Debian packages shows that most (if not all) of the GS versions mentioned in the wikipedia page are available:

Bart[~/]: aptitude search ^gs-
i   gs-afpl                     - The AFPL Ghostscript PostScript interpreter
p   gs-aladdin                  - Transitional package
p   gs-cjk-resource             - Resource files for gs-cjk, ghostscript CJK-TrueType extension
i A gs-common                   - Common files for different Ghostscript releases
i A gs-esp                      - The Ghostscript PostScript interpreter - ESP version
p   gs-gpl                      - The GPL Ghostscript PostScript interpreter
v   gs-pdfencrypt               -

It turns out I was using gs-esp:

Bart[~/]: which gs
/usr/bin/gs
Bart[~/]: ls -l /usr/bin/gs
lrwxrwxrwx 1 root root 20 Jul  4 09:00 /usr/bin/gs -> /etc/alternatives/gs*
Bart[~/]: ls -l /etc/alternatives/gs
lrwxrwxrwx 1 root root 16 Jul 27 11:26 /etc/alternatives/gs -> /usr/bin/gs-esp

I remember having used different GS versions, and AFPL being the “best”, so I installed it and made the default gs point to it, with the Debian alternatives system (as root):

Bart:~# aptitude install gs-afpl
[...]
Bart:~# update-alternatives --config gs

There are 2 alternatives which provide `gs'.

  Selection    Alternative
  -----------------------------------------------
  * +   1        /usr/bin/gs-esp
        2        /usr/bin/gs-afpl

Press enter to keep the default[*], or type selection number:

There, I just pressed “2”, et voilà! Now my default GS is gs-afpl, and ps2pdf makes use of it. Any other GS version one could want to use, the procedure to change it would be the same.

Comments

SATA HD plus IDE CD under 2.6 kernel

You can read in my troubleshooting page what problems I had with my CD unit in a computer with a SATA hard disk (under Linux kernel 2.6, not 2.4).

Basically it boils down to: if / is mounted on a SATA HD, the libata kernel module must be loaded at boot time. When libata is loaded, it “hijacks” not only the SATA interfaces, but also the IDE interfaces. When, later on, ide-generic and other IDE kernel modules are loaded, they don’t see the IDE ports, so the CDs/DVDs or other IDE HDs, are not found! Moreover, they can’t ever be found.

This can be overcome by loading some IDE modules before libata is loaded, as I outline in my “Troubleshooting” page. However, I recently discovered (with kernel 2.6.15), that an IDE module (precisely ide-generic would, conversely, hijack the SATA ports, making libata not find any SATA interface, and generating a kernel panic at boot time, because / could not be mounted.

Now, it seemed like I had no way to fix it, because if I loaded ide-generic first, I would get a kernel panic, whereas if I loaded libata first, I would have to make do without access to the CD. Luckily, I tried to find out how to load one of the modules without having it hijack the interface that it shouldn’t hijack. To do so, I used the modinfo utility:

Bart:~# modinfo libata
filename: /lib/modules/2.6.15-1-686-smp/kernel/drivers/scsi/libata.ko
author: Jeff Garzik
description: Library module for ATA devices
license: GPL
version: 1.20
vermagic: 2.6.15-1-686-smp SMP 686 gcc-4.0
depends: scsi_mod
srcversion: 54ECB7B28C0FB6028983484
parm: atapi_enabled:Enable discovery of ATAPI devices (0=off, 1=on) (int)

Then I tried to load libata (“load” means to put it in /etc/mkinitrd/modules), then running mkinitrd -o /boot/initrd.img-2.6.15-1-686-smp.custom 2.6.15-1-686-smp, then rebooting) with the atapi_enabled=0 parameter, so that it wouldn’t hijack the IDE, and it failed again :^(

They say that if you can’t beat an enemy you should join her, and that I did: I tried libata atapi_enabled=1 with the intention of having libata handle the IDE device properly (if I couldn’t make it ignore it), and it worked! The CD is emulated as a SCSI device (a /dev/sga0 device was generated), but it works.

Comments

Post a Kriptópolis

Como tantas otras veces en muchos sitios, he mandado un comentario kilométrico a Kriptópolis, y me ha apetecido copiarlo aquí (para vanagloriarme de los listo que soy, y alimentar mi ego, sí. Si tienes un problema con ello, monta tu propio blog, jejeje).

El post es una respuesta a otro comentario, cuyos “argumentos” también cito (En cursiva):

“[…] mil ojos no tienen porque ver más que dos […] eso es como decir que por decir mil personas que una pared es negra, tienen más razón que yo, que digo que es blanca.”

Si mil personas dicen que una pared es negra, y tú dices que es blanca, pero yo NO he visto la pared… lo siento, pero me fío más de 1000 desconocidos que de uno. Presuponer que los 1000 tienen que equivocarse es mucho suponer, ¿no?.

Es más, tienes razón: ni me fío de ti, ni me fío de los 1000 (malditos mentirosos). Quiero ver la pared yo. ¿Puedo?. Si la pared es libre sí. Si es privativa, no.

“Además lo que se hizo con Linux, gcc etc lo puede hacer cualquier empresa de software, se llama auditar software y no hace falta que sea software libre, pagas y ellos te lo revisan”

Dime a qué empresa pago para que me audite el código de Windows. ¡Ah, perdona, no puedo! Va a ser que es ILEGAL acceder a ese código… Te refieres a que Microsoft pida la auditoría… ya, ya. Me quedo más tranquilo.

“y para eso ningún loco se va a mirar el código entero, vamos el que se crea que de verdad se han mirado todo el código fuente vive en el mundo de yupi. Lo que se utiliza es la regla 80-20 (o 20-80 da igual), que viene a decir que el 80% de los fallos se concentran en el 20% de los módulos, y eso es lo que miran, el 20% del código, obviamente siguiendo ciertos criterios para seleccionar los módulos más propensos a errores.”

Perdona, pero tú sí que vives en los mundos de Yupi. El 80% de los errores estará en el 20% del código, pero NADIE sabe en qué 20%. Si se supiera no serían errores. Por eso hay que mirar TODO.

¡Pero claro que nadie se mira todo! Pero sí que es cierto que ENTRE TODOS MIRAMOS TODO. Es exáctamente igual que en las publicaciones científicas: nadie se lee ni un 0.01% de las revistas que salen (ni siquiera las de su campo), pero intenta colar una mentirijilla y ya verás como hay algún cabrito en Wisconsin o Kuala Lumpur que te pilla (suponiendo que la mentira pasara el filtro de los referees y sea publicada).

“Lo de que da más seguridad, más confianza, es indiscutible, pero que por eso sea más seguro es perfectamente discutible.”

Estás confundiendo causa con efecto: da más confianza porque es más seguro, no al revés. ¿Ves cómo la frase así tiene más sentido?

“También es verdad que al ser abierto es más fácil encontrar los bugs, para bien y para mal (no todos son buenos samaritanos que informan inmediatamente del bug al equipo de desarrolladores o directamente proporcionan un parche, habrá quien se lo calle y se dedique a explotarlo) como dice UnAlien.”

Esto es una tontería. Por cada persona que se guarde para sí el error que encuentre habrá 10 que lo reporten, y otros 10 que estarán dispuestos a arreglarlo. Si no hay dispuestos 10 a arreglarlo, es que a nadie le interesa. Aunque fuera al revés, y hubiera 10 descubridores maliciosos por cada “buen samaritano” (que NO es así), ese buen samaritano sería suficiente, con tal de que el software sea libre, y el samaritano pueda 1) encontrar la solución, porque puede leer el código, 2) corregir el error, porque puede cambiar el código y 3) distribuir las correcciones, porque la licencia lo permite.

“Si se encuentran más bugs en IExplorer es porque compensa más dedicarle esfuerzo pues tiene más cuota de mercado, igual que a Window$. Aunque no dudo que de disponer del código podría ser terrible.”

Si se encuentran más bugs en IE es porque los tiene (en primer lugar), y porque sólo los desarrolladores pueden corregirlos, si les da la gana y cuando les dé la gana, con lo cual la vida de los bugs es larga y fructífera.

Y también vale esto para los virus. Nadie se dedica a hacer un virus para una pieza de software que otras 1000 personas van a tardar 2 días en parchear. Simplemente no merece la pena. Para cuando “sacas” tu virus, el programa ya ha cambiado. Un desarrollador de virus necesita una plataforma estática que atacar, que sepa que va a ser vulnerable suficiente tiempo para que el virus haga algo (e incluso le dé tiempo a él a programarlo). Es curioso que creamos que los 5 niñatos que andan haciendo virus por diversión sí tienen capacidades superhumanas para leerse TODO el código y programar virus al instante, mientras que entre los 100000 usuarios de ese programa, a los cuales les parece vital su seguridad, no son capaces de leerlo y arreglarlo.

“JMG, no te engañes, esos cientos de programadores si ven el código es porque trabajan en alguna parte de él, sino olvidate, te puedo asegurar que si algo odia un programador es revisar y probar código, hacerlo sin que te paguen molesta, pero es que tener que ver código de otro eso ya es un castigo. Por eso, entre otras cosas, se intentan seguir metodologías de forma extricta, porque si esperas que un programador lo haga por gusto vas bueno.”

Correcto. Tienes mucha razón, depurar código jode mogollón. Pero no más que tener que usar un programa defectuoso que sabes cómo arreglar, pero su estúpida licencia te lo impide.

Te falla una cosa: en el software libre no hay esa distinción artificial entre programador y usuario. El programador no es un pringao que se lo curra para otros… El programador es él mismo un usuario, que quiere que el programa funcione, y como otro no lo arregla (o aunque también otro lo arregle), lo intenta arreglar él. Además puede elegir a qué proyectos contribuye, y de qué manera, cosa que ayuda muchísimo a la motivación.

“Asociar calidad o seguridad con software libre es totalmente incorrecto, el software es bueno si se hace bien”

Asociar seguridad con conducir sobrio es totalmente incorrecto; una conducción es segura cuando se conduce bien, independientemente de que vayas ebrio.

“y auditar software lo puede hacer cualquiera,”

¿Cómo? Software Libre lo puede auditar cualquiera, pero el propietario NO. ¿Sabes eso, no?

“Y esto no es que lo diga yo, es que también he asistido a una conferencia larguilla de Stallman, y he leido algunas entrevistas y articulos suyos y JAMÁS dice que el software libre sea mejor o más seguro que el privativo,”

Pues hablaremos de otro Stallman, porque yo también he asistido a una conferencia suya (podéis ver la entrada en mi blog), y dijo cosas muy interesantes sobre el tema, como por ejemplo relato en mi blog bajo los títulos “Funcionalidades malas” y “Errores”.

Claro que igual tú no defines “libre de malware” como “mejor”.

“simplemente que es “mejor para el usuario” en el sentido de que es libre, que te dá libertad, y es lo normal, ese tio sabe de informática y afirmar que tiene mayor calidad simplemente por licenciarlo bajo GPL, BSD etc sería mentirse a sí mismo, una licencia es una licencia, ¡nada más! Esto ya parece una religión, demasiada fé ciega.”

Cierto, Stallman da énfasis a la libertad (independientemente de la calidad).

Pero tu postura de decir que “afirmar que tiene mayor calidad simplemente por licenciarlo bajo GPL es estúpido” es un argumento de hombre de paja. Criticas una bufonada que atribuyes a gente que no la ha dicho. La licencia no cambia nada de la seguridad ni calidad del programa. Directamente. ¡Pero indirectamente claro que lo hace! Te estamos diciendo los mecanismos que ciertas licencias libres permiten, y gracias a los cuales el SL puede ser mejor, y sigues sin captarlo. Es como decir que dar periódicos grátis puede ayudar a que la gente esté mejor informada, y tú digas que igualmente la gente puede decidir seguir sin leer las noticias.

“el saber nos hace libres”

No es del todo cierto. El saber y el poder actuar según ese conocimiento, sin coacciones ni imposiciones. De nada me vale saber cómo arreglar un bug del IE, si su licencia no me permite que lo haga.

Comments

« Previous Page« Previous entries « Previous Page · Next Page » Next entries »Next Page »