2012-12-28

Mupen64+ con GUI en Ubuntu 12.04 y 12.10

Menuda sorpresa me he llevado cuando intenté instalar Mupen64+ en Ubuntu 12.04 y resulta que ya no tiene interfaz gráfica. Correrlo desde la consola no me preocupa lo que en realidad si me molesta es el hecho de no poder configurar el Joypad y no poder abrir ROMs que están comprimidas en archivos .zip.

Estaba seguro de que antes había visto la interfaz gráfica de Mupen64 en Ubuntu y al principio no supe si era que me faltaba un paquete o alguna otra cosa. Buscando en los foros de Ubuntu descubrí que efectivamente la interfaz gráfica había desaparecido de la versión de Mupen64+ en los repositorios de Ubuntu.

En algunas entradas del foro sugieren usar interfaces gráficas de terceros como CuteMupen (una interfaz gráfica hecha para Mupen64+ hecha en Qt). La probé pero es un lío configurarla y además tampoco me permitió configurar el "Joypad".

Al final estaba a punto de darme por vencido cuando se me ocurrió que tal vez podría instalar el mismo paquete que usaba en Natty Narwhal y dio resultado, nuevamente tengo la misma amigable interfaz gráfica de antes y puedo configurar el "Joypad" y por supuesto puedo cargar ROMs que están comprimidas en archivos .zip.

Para hacerlo fui a los repositorios de Ubuntu y busqué el paquete de Mupen64+ en la distribución Oneric, el resultado fue un solo paquete:

mupen64plus (1.5+dfsg1-16)

Lo descargué y lo instalé usando el comando:

sudo dpkg -i mupen64plus_1.5+dfsg1-16_i386.deb

Al hacerlo Ubuntu me notificó que faltaban algunas dependencias, en mi caso los paquetes `libsdl-ttf2.0-0', `libxdg-basedir1' y `liblzma2'. Los primeros dos los instalé sin problema usando apt-get install:

sudo apt-get install libsdl-ttf2.0-0
sudo apt-get install libxdg-basedir1

Sin embargo liblzma2 parece que fue removido de los repositorios de Ubuntu 12.04.

Por suerte aún está disponible en los repositorios de Oneric: liblzma2 (5.0.0-2), así que lo descargué y lo instale:

sudo dpkg -i liblzma2_5.0.0-2_i386.deb

Y ¡ya está! Mupen64+ con interfaz gráfica:

2012-08-28

PHP - File Synchronization Script

Edit

2013-01-24

The code was moved to GitHub: sergio-bobillier/php-file-sync

Also I added a new feature:

USE_CHECKSUM
It will cause the script to use a checksum to compare files. This way the script won't copy files that haven't changed even if their modification dates differ. (Can be slow in some cases).

Fron now on all changes will be posted to GitHub so check the repository there to stay up to date.



Edit

2012-11-05

Some bug fixes.

  • When deleting a whole directory each file being deleted is listed
  • Fixed a bug that caused that when removing a whole directory only the last file in the directory was listed instead of the directory itself.



In brief:


Synchronizing files between two or more computers have never been easier, now you can synchronize files between various locations using a cloud service like Dropbox as hub. However this services although useful have their limits, for me the biggest one is size, 5 GBs are not enough for my music so I decided to write a little script to keep my music in sync between my Desktop and my Laptop computer.

The script is very simple and is well documented so for those of you that just want to watch the code here it is:

PHP - File Synchronization Script on GitHub

How to use:


To use the script:

Note:
Please do not put the script in one of the folders you are going to sync, this will cause unexpected results. Put it somewhere else like in the parent folder or your home directory.

  1. Copy settings-sample.php as settings.php and edit it to fit your needs. The options you can tweak are:
  2. debug mode: This mode will cause the script to print all the actions it takes to the console so you can know what it is doing or check what it is going to do before it actually does it.
  3. simulate: This will cause the script not to take any real actions, the script wont copy, delete or overwrite any file.
  4. After you have adjusted all the settings you can run the script by typing this command in your terminal:

    $ php -f sync-files.php

Tip:
You can set the script to debug mode and simulate at the same time and send all its output to a file to check what the script is going to do before running it for real. I know is hard to trust an script written by someone else specially if you are entrusting it with your precious tunes. ;)

To do it use this command:

$ php -f sync-files.php > sync-result.txt

Then check the contents of sync-reuslt.txt

When running the script for the first time the script guarantees you that after sync is done both locations will have the exact same files and folders. After the first synchronization the script will save a file called .last-sync with the timestamp of the last synchronization in the path it was run.

After the script ran for the first time and the .last-sync file is saved the script will keep the two paths synchronized in subsequent runs, this means that the script will copy any new files you create in any of the two paths to the other, if you delete a file in one of the locations it will be deleted from the other, also if you modify a file in one location the most recent version of the file will be copied to the other path and off course if you rename or move files the script will carry on this changes to the other path.

About the script


Here are some details about the script if you are interested:

What it does:


The script is very simple, what it does is basically this:

  1. It scans all files and folders in the first location, for each file it checks if the same file exists in the other path, if the file does not exists then:
    • If the file was modified after than the last synchronization it copies the file to the other location (Assuming it is a new file)
    • If it was not modified after the last synchronization the script deletes it from the current path. (Assuming it was deleted from the other path)
  2. If the same file exists in both paths then:
    • If the file is a directory then the script recursively synchronizes the directories in both paths
    • If the file is a regular file then it is copied to the other path (overwriting the other file) if it is newer than the file in the other path
  3. Then it does all this the other way around

Off course the script performs some checks to avoid going wildly overwriting and deleting files all the way but yes, this basic algorithm let the script keep the two paths in sync. Note for example that if you rename a file the script will think that the file with the old name was deleted and will delete it from the other path and will think that the file with the new name is a new file and will copy it to the other path, so that is the way it handles renaming and moving.

You can tell of course that the script is very simple and in some particular cases it wont be able to handle all the modifications well and will cause data loss, for example if the same file is changed in both locations the one that was last modified will be kept and the other will be overwritten.

How the script came to be:


As I explained above I have my music in both my Desktop and Laptop computers, at first I just copied the music from my Desktop to my Laptop, using a simple linux command it is easy to only copy files that were new or have been modified since the last time the copy was made.

The problem arises when you start adding, modifying or removing files in both locations, the cp command cannot handle that and thus you need a more elaborated tool.

So I wrote the script and started using it to keep my music in sync between my two computers. Then I realized that the script might be useful for someone else or maybe for a different purpose like keeping files in sync between two servers running a web application or something like that.

Finally


The script is very primitive, currently it is performing just fine to keep my music in sync but I know that it can be improved to better handle more complex modification to files, like merging files that were modified in both locations or warning about conflicts between files.

Also I haven't fully tested it in all particular cases so I can't guarantee that you wont lose a file or two or some modifications you made to a file in one of the locations, that is why I added the simulate and debug modes.

Any comments and suggestions are welcome, feel free to leave yours in the comment section below. Also if you want to use the script in your own application please feel free to do it, don't worry about licenses or giving credit or anything like that, sharing the knowledge is the way of the future.

2011-10-09

[English] PHP: gd library > 2.0 (2.0.1 / 2.0.34) en Ubuntu

Foreword

I noticed that some English speaking people were reading and even making comments on the original (spanish) post. My first guess is: google translator but as good as it may be it is still an automatic translated document and I think I can do better than a blunt headed computer (at least when it comes to translating), also I though it might bring more people into reading the article. So here it is the English version of it:

Introduction

Ubuntu is a very popular operating system, in the last year its popularity has grown a lot because it is a stable and reliable operating system with regular updates. Its popularity has grown not only in desktops and laptops but also in web servers, however, one must admit that from time to time Canonical has some flaws, sometimes they leave very useful software packages out of their official repositories, sometimes they make mistakes when creating packages, create them in a weird way or leave out the latest updates for some software.

This is exactly the case with the gd library for PHP. The gd library is a graphics library that provides various functionalities like scaling, rotating, trimming, among others. Some plug-ins with advanced graphical effects like ImageFlow use this library to achieve those effects, like the reflections. Some CMS, like Drupal use this plug-in to create picture galleries.

ImageFlow in particular needs gd library version 2.0.1 to work and when it doesn't find it, it doesn't work at all, instead of images we get an error message like this one:

ImageFlow requires GD 2.0.1 or higher (2.0.28 recommended)

The problem is that in the Ubuntu systems, even in the last version (11.04) the gd library version that gets installed when you install the php5-gd package is 2.0 and no matter how many times you run apt-get update you never get an updated version of the library since Canonical (or the community member who maintains the package to be precise) haven't updated the library.

When searching through the network there is a lot of people asking how can they solve this issue, not only in Ubuntu forums but in other sites. There is, among the proposed solutions, one which consists in adding the Debian repositories to the sources.list file and then install php5-gd from there. The problem with this solution is that the dependencies in Debian repositories are not the same that in Ubuntu repositories and some times doing this results in things that stop working like the Plesk control panel, because when installing php5-gd other packages get changed too.

Also when trying to install from the Debian repositories some times another problem arise:

Dependency error:
 php5-gd depends on libjpeg > 15b but 15bubuntu1 will be installed
E: Broken packages

Obviously we have the right library version but the problem is that dpkg fails to compare the versions and so the installation can simply fail, and although we could force the installation from apt-get this could leave us to other problems. We could damage the local repositories or even end with a PHP installation that doesn't work at all.

I have found another solution that worked really well for me and I wanted to share it with the Ubuntu community. I really hope that It will work for you as good as it did for me, so, here we go:

Updating the gd library


Uninstalling the current version of php5-gd

The first thing we have to do is uninstall the current version of php5-gd, if we have one installed, that is, to check if there is a version currently installed we use this command:

dpkg --get-selections | grep php5-gd

We will get something like:

php5-gd      install

If the previous command doesn't show any output it means that there is no version of php5-gd installed so you can just go ahead with the following step "Installing Alien". If the library is installed you must remove it completely first, to do so use this command:

sudo apt-get --purge remove php5-gd

When uninstalling the library the system may tell you that there are some packages that were installed with it and that are no longer needed and will suggest you to use apt-get autoremove to get rid of them. PLEASE DON'T DO IT, leave the packages installed because in any case we are going to install another version of the gd library and so the packages will probably be needed again.

Installing Alien

Alien is an special utility that can be installed in the linux systems that use packages and lets you convert .deb (Debian Packages) to .rpm (RedHat and SuSe Packages) and vice versa. We are going to use this utility in the next step so we install it like so:

sudo apt-get install alien

Once we have Alien installed we are ready to go and search for an updated gd library

Get an updated version of the gd library

The CentOS operating system is a RedHat branch and it has the updated version of the gd library and so we are going to use this operating system's packages to bring an updated version of the library to our Ubuntu system. The fist thing we will need is the exact version of PHP we have installed, to get this information we execute this command:

sergio@fate:~$ php --version
PHP 5.3.2-1ubuntu4.8 with Suhosin-Patch (cli) (built: Apr 27 2011 05:07:22) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
sergio@fate:~$

We see here that the installed version of PHP is 5.3.2, now we are going to pay a visit to CentOS' Repositories and we are going to search for the correct gd library for our PHP 5 installation. We use the search to locate the right php5-gd package for our PHP version and architecture (32 or 64 bits) and we are going to download it, in my case that would be:

wget ftp://ftp.icm.edu.pl/vol/rzm1/linux-opensuse/distribution/11.3/repo/oss/suse/i586/php5-gd-5.3.2-1.31.i586.rpm

What we are going to get is a .rpm package. Now we have to use Alien to convert it to a .deb package, so we do:

sudo alien -d php5-gd-5.3.2-1.31.i586.rpm

Alien will process the package and convert it to a .deb package that we can install:

php5-gd_5.3.2-2.31_i386.deb generated

Now we have to install it like we do with any other Debian package:

sudo dpkg -i php5-gd_5.3.2-2.31_i386.deb

The location where Ubuntu stores the PHP 5 extensions is a bit weird and somewhat curious opposed to CentOS so we will have to move some files to make them available for our Ubuntu PHP 5 installation, we do so like this:

sergio@fate:~$ cd /usr/lib/php5
sergio@fate:/usr/lib/php5$ ls
20090626+lfs  extensions  libexec  maxlifetime
sergio@fate:/usr/lib/php5$ cd extensions
sergio@fate:/usr/lib/php5/extensions$ ls
gd.so
sergio@fate:/usr/lib/php5/extensions$ sudo mv gd.so ../20090626+lfs/gd.so

Basically what we are doing here is moving the library gd.so from the "extensions" directory to the "20090626+lfs" directory which is the directory where Ubuntu puts PHP extension (I told you it was weird) so that PHP can find it.

In your version of Ubuntu the name "20090626+lfs" may be a little different but you'll know which folder it is by the unusual name

Finishing the installation

Well, so we already have a recent version of the gd library, but, we are not done yet, that library is not totally functional, now we have to take care of some details that arise from using other operating system's packages

For the next step we have to make sure that PHP is logging it's error to a file that we can check, to do so we go to the /etc/php5/apache2 directory and open the php.ini file

There we search for a line like this one:

;error_log = php_errors.log

We remove the semicolon (;) at the beginning of the line and replace php_errors.log with the full path to the file we want PHP to log it's errors to, for example I used:

error_log = /var/log/php5/errors.log

We save the file, then we have to make sure that Apache can write on the PHP log file so use these commands to do so:

sergio@fate:/etc/php5/apache2$ cd /var/log
sergio@fate:/var/log$ sudo mkdir php5
sergio@fate:/var/log$ cd php5
sergio@fate:/var/log/php5$ sudo touch errors.log
sergio@fate:/var/log/php5$ sudo chmod o+w errors.log
sergio@fate:/var/log/php5$ 

Now we restart the Apache web server and check the PHP error log file:

sergio@fate:/var/log/php5$ sudo /etc/init.d/apache2 restart
 * Restarting web server apache2
 ... waiting                                                         [ OK ]

sergio@fate:/var/log/php5$ tail errors.log
[30-Apr-2011 22:19:44] PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/gd.so' -
libpng14.so.14: cannot open shared object file: No such file or directory in Unknown on line 0
sergio@fate:/var/log/php5$ 

There we see that there is an error, PHP tells us that we are missing the libpng14.so.14 library, so we are going to look for it on the CentOS' repositories. There we use the search with the option that says Search for rpms which contain given file name (1) e.g. libhistory.so to locate the package with the library we need.

Once we locate the correct package for our architecture (32 or 64 bits) we are going to download the package like we did before:

wget ftp://mirror.switch.ch/pool/1/mirror/opensuse/distribution/11.4/repo/oss/suse/i586/libpng14-14-1.4.4-2.1.i586.rpm

We get the RPM package and once again we use Alien to conver it to a Debian package:

sudo alien -d libpng14-14-1.4.4-2.1.i586.rpm
...
libpng14-14_1.4.4-3.1_i386.deb generated

Then we install the library:

sudo dpkg -i libpng14-14_1.4.4-3.1_i386.deb

After installing the library we restart the Apache Web server and check the PHP error log file once again. If we encounter another missing library we will have to repeat the previous procedure to install it from the CentOS' repositories. When you see no more errors in the PHP error log then the installation is done

Verifying the installation

Now we check that the installation is working properly using the phpinfo function and checking that the installed gd library is version 2.0.34:

GD Supportenabled
GD Versionbundled (2.0.34 compatible)
FreeType Supportenabled
FreeType Linkagewith freetype
FreeType Version2.3.12
T1Lib Supportenabled
GIF Read Supportenabled
GIF Create Supportenabled
JPEG Supportenabled
libJPEG Versionunknown
PNG Supportenabled
libPNG Version1.4.3
WBMP Supportenabled
XPM Supportenabled
XBM Supportenabled

Conclusion

Using the Android utility we managed to update the gd library for PHP. Until Canonical updates the library version in the official Ubuntu repositories this is a good way around the problem.

I certainly hope that this post was useful to you. For me it meant an entire day working trying to find a way to update the library while keeping PHP, Plesk and the rest of the software installed on the server working.

2011-09-09

Apagar el equipo y hacer una captura de pantalla unos segundos antes

Bitelia publicó el día de hoy esta entrada [Descarga del día] AudioBookSleep, cuenta atrás para el cierre del sistema, un programa Windows que permite introducir un tiempo (en minutos) después del cual el sistema se apagará pero no sin antes dejar una captura de pantalla unos instantes antes de que ocurra el cierre del sistema.

Yo me quedé pensando si no sería posible hacer lo mismo en Linux y pensé que tal vez con un script del shell se podría lograr, así que me di a la tarea y escribí un pequeño script de shell que permite apagar el sistema y hacer una captura de pantalla un segundo antes de que se lleve a cabo el cierre del sistema, aquí está:

#!/bin/bash
seconds=$[$1 * 60]
seconds_shot=$[$seconds - 2]
shutdown -P $1 &
sleep ${seconds_shot}s
shot_filename=$(date +'%Y-%m-%d %H.%M.%S').png
scrot "$shot_filename"

Basta con guardar este texto en un archivo llamado shutdown.sh, luego darle permisos de ejecución:

chmod u+x shutdown.sh

Y luego podremos usarlo así:

sudo ./shutdown.sh 60

Nota: Hay que llamar al script usando sudo por que el comando shutdown solo puede ser ejecutado por el root.

Damos el tiempo en minutos y un segundo antes de que se realice el shutdown el script del shell ejecutará el comando scrot que tomará un screenshot y lo guardará en un archivo cuyo nombre será la fecha y hora en la que fue tomado.

cool! :)

2011-05-01

PHP: gd library > 2.0 (2.0.1 / 2.0.34) en Ubuntu

Introducción

Ubuntu es un sistema operativo muy popular, en estos últimos años ha crecido muchísimo en popularidad por ser un sistema operativo estable confiable y con actualizaciones regulares. Su popularidad ha crecido mucho no solo en los sistemas de escritorios y portátiles sino también en los servidores Web, sin embargo, hay que admitir que a veces Canonical tiene algunas fallas, a veces dejan por fuera de sus repositorios software muy útil, otras veces empaquetan mal o de manera extraña y otras veces no ponen en sus repositorios las versiones más actualizadas del software.

Este es el caso de la librería gd para PHP. La librería gd es una librería gráfica que proporciona varias funciones como escalado, rotación, recortado y otras más. Algunos plug-ins con efectos especiales gráficos como el ImageFlow utilizan esta librería para lograr los efectos especiales, como el reflejo en las imágenes, adicionalmente, algunos CMS(s) como Drupal utilizan este plug-in para crear galerías fotográficas.

El ImageFlow necesita de la versión 2.0.1 de la librería gd para funcionar y cuando no la encuentra no funciona en lo absoluto, en lugar de imágenes recibimos un mensaje como este:

ImageFlow requires GD 2.0.1 or higher (2.0.28 recommended)

El problema es que en los sistemas Ubuntu, aún en la última versión (11.04) la librería gd que se instala al instalar el paquete php5-gd es la 2.0 y por más que corramos apt-get updrade nunca obtendremos una versión más actualizada de la librería ya que canonical no la ha actualizado.

Al buscar a través de la red hay un montón de personas que preguntan como pueden solucionar este problema, no solo en los foros de ubuntu sino en otros lugares. Hay por ahí algunas soluciones que consisten en agregar los repositorios de debian al sources.list e instalar php5-gd desde ahí. El problema es que las dependencias en los repositorios de debian no son iguales a las de los repositorios de ubuntu y a veces hacer eso resulta en cosas que dejan de funcionar, como el Plesk por que al instalar php5-gd se cambian otros paquetes.

Adicionalmente al instalar desde los repositorios de debian nos podemos encontrar con mensajes como este:

Problemas de dependencias:
 php5-gd depende de libjpeg > 15b pero 15bubuntu1 será instalada
E: Paquetes rotos

Obviamente tenemos una librería funcional pero el problema es que el dpkg falla al comparar las versiones y por eso la instalación puede simplemente fallar, y aunque podríamos forzar la instalación desde el apt-get esto podría llevarnos a tener problemas después. Podríamos tirarnos los repositorios o hasta terminar con un php que no funciona en absoluto.

Yo he encontrado una solución que funcionó muy bien para mi y por eso quiero compartirla con la comunidad ubuntu. Espero les funcione igual de bien que a mi, aquí vamos:

Actualizar la librería gd


 

Desinstalar la versión actual de php5-gd

Lo primero que haremos es desinstalar la versión actual de php5-gd, si ya tenemos alguna instalada, para saber si hay una instalada podemos usar este comando:

dpkg --get-selections | grep php5-gd

A lo que el sistema responderá con:

php5-gd      install

Si el comando anterior no muestra ninguna salida significa que no tienes instalada la librería php5-gd por lo que podrás continuar con el siguiente paso. Si está instalada deberás desinstalarla por completo haciendo uso del siguiente comando:

sudo apt-get --purge remove php5-gd

Cuando desinstales la librería el sistema te dirá que hay ciertos paquetes que se instalaron con ella y que ya no son necesarios y te sugerirá que corras apt-get autoremove para quitarlos, NO LO HAGAS, deja los paquetes ahí por que igual vamos a instalar luego la librería gd nuevamente así que probablemente serán necesarios.

Instalar Alien

Alien es una utilidad especial que se puede instalar en los sistemas linux que utilizan sistemas de paquetes y que permite convertir paquetes deb (de debian) a rpm (de RedHat y SuSe) y viceversa, vamos a emplear esta utilidad, así que la instalamos así:

sudo apt-get install alien

Una vez está instalado Alien estamos listos para ir a buscar la librería gd actualizada.

Obtener una versión actualizada de la librería gd:

El sistema operativo CentOS que es una ramificación de RedHat si tiene la versión actualizada de la librería gd por lo que usaremos los paquetes de este sistema operativo para traer una versión actualizada a la librería a nuestro ubuntu. Lo primero que necesitamos saber es que versión de php5 tenemos, para lo cual ejecutamos:

sergio@fate:~$ php --version
PHP 5.3.2-1ubuntu4.8 with Suhosin-Patch (cli) (built: Apr 27 2011 05:07:22) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
sergio@fate:~$

Vemos que es la 5.3.2, ahora vamos a ir a visitar el repositorio de paquetes de CentOS y vamos a buscar la librería gd adecuada para nuestra versión de php5. Usamos el search para localizar el paquete php5-gd correcto para nuestra versión de php5 y nuestra arquitectura (32 o 64 bits) y lo descargamos, en mi caso;

wget ftp://ftp.icm.edu.pl/vol/rzm1/linux-opensuse/distribution/11.3/repo/oss/suse/i586/php5-gd-5.3.2-1.31.i586.rpm

Lo que obtendremos será un paquete .rpm. Ahora debemos usar el alien para convertirlo a un paquete .deb, para lo cual:

sudo alien -d php5-gd-5.3.2-1.31.i586.rpm

Alien procesará el paquete y lo convertirá a un paquete .deb:

php5-gd_5.3.2-2.31_i386.deb generated
Ahora debemos instalarlo como cualquier paquete debian corriente:
sudo dpkg -i php5-gd_5.3.2-2.31_i386.deb

La organización de las extensiones de PHP 5 es un poco diferente entre ubuntu y CentOS, así que deberemos mover la librería al lugar correcto para que funcione con el PHP, lo hacemos así:

sergio@fate:~$ cd /usr/lib/php5
sergio@fate:/usr/lib/php5$ ls
20090626+lfs  extensions  libexec  maxlifetime
sergio@fate:/usr/lib/php5$ cd extensions
sergio@fate:/usr/lib/php5/extensions$ ls
gd.so
sergio@fate:/usr/lib/php5/extensions$ sudo mv gd.so ../20090626+lfs/gd.so

Básicamente, aquí lo que hemos hecho es mover la librería gd.so del directorio extensions al directorio 20090626+lfs que es donde ubuntu almacena las extensiones de php5

Terminar la instalación

Bien, ya tenemos instalada una versión reciente de la librería gd, pero aún no es totalmente funcional, ahora debemos encargarnos de algunos detalles que surgen como resultado de usar paquetes de otro sistema operativo.

Para el siguiente paso debemos asegurarnos de que PHP esté registrando los errores en un archivo de registro que podamos consultar, para ello, vamos a /etc/php5/apache2 y abrimos el archivo php.ini

Allí buscamos una línea como esta:
;error_log = php_errors.log
Le retiramos el punto y coma (;) al inicio de la línea y colocar allí la ruta a un archivo donde se escribirá el registro de los errores de PHP, por ejemplo:
error_log = /var/log/php5/errors.log

Guardamos el archivo, luego debemos asegurarnos de que el Apache pueda escribir en el archivo que hemos elegido:

sergio@fate:/etc/php5/apache2$ cd /var/log
sergio@fate:/var/log$ sudo mkdir php5
sergio@fate:/var/log$ cd php5
sergio@fate:/var/log/php5$ sudo touch errors.log
sergio@fate:/var/log/php5$ sudo chmod o+w errors.log
sergio@fate:/var/log/php5$ 

Ahora reiniciamos el apache y consultamos el archivo de registro de errores:

sergio@fate:/var/log/php5$ sudo /etc/init.d/apache2 restart
 * Restarting web server apache2
 ... waiting 
                                                                                                                                                                           [ OK ]

sergio@fate:/var/log/php5$ tail errors.log
[30-Apr-2011 22:19:44] PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/gd.so' - libpng14.so.14: cannot open shared object file: No such file or directory in Unknown on line 0
sergio@fate:/var/log/php5$ 

Allí vemos que hay un error, nos dice que nos hace falta la librería libpng14.so.14, vamos a ir a buscarla al repositorio de CentOS. Allí usamos el search con la opción Search for rpms which contain given file name (1) e.g. libhistory.so para localizar el paquete con la librería que necesitamos.

Una vez lo ubiquemos seleccionamos el paquete correcto para nuestra arquitectura (32 o 64 bits) y descargamos el paquete como antes:

wget ftp://mirror.switch.ch/pool/1/mirror/opensuse/distribution/11.4/repo/oss/suse/i586/libpng14-14-1.4.4-2.1.i586.rpm

Obtendremos el RPM y nuevamente usamos el Alien para convertirlo a un paquete de debian:

sudo alien -d libpng14-14-1.4.4-2.1.i586.rpm
...
libpng14-14_1.4.4-3.1_i386.deb generated
Luego instalamos la librería:
sudo dpkg -i libpng14-14_1.4.4-3.1_i386.deb

Luego de esto reiniciamos el apache y comprobamos nuevamente el archivo de errores del PHP. Si encontramos otra librería que haga falta tendremos que repetir el procedimiento anterior para instalarla. Cuando el PHP no presente más errores habremos terminado con la instalación.

Comprobar la instalación:

Ahora comprobamos la instalación usando la función phpinfo y verificamos que la librería gd instalada sea la 2.0.34:

GD Supportenabled
GD Versionbundled (2.0.34 compatible)
FreeType Supportenabled
FreeType Linkagewith freetype
FreeType Version2.3.12
T1Lib Supportenabled
GIF Read Supportenabled
GIF Create Supportenabled
JPEG Supportenabled
libJPEG Versionunknown
PNG Supportenabled
libPNG Version1.4.3
WBMP Supportenabled
XPM Supportenabled
XBM Supportenabled

 

Conclusión

Usando la utilidad Alien hemos logrado actualizar la librería gd para php. Hasta que canonical actualice la versión de los repositorios de ubuntu esta es una buena forma de quitarnos el problema de encima.

Espero que esta entrada les haya sido de mucha utilidad. Para mi significó un día entero de trabajo buscando la manera de actualizar la librería.