Ever found yourself in the situation where you’d like to ignore or edit a postinst or preinst script of a Debian package?
As Debian froze Wheezy I decided it would be a good time for me to upgrade my home server, to help catching bugs and because it’s Sandy Bridge based not well supported regarding its sensors by Squeeze’s kernel. Unfortunately, I had weird stuff regarding EGLIBC, namely I had the 2.13 version installed from scratch, unknown to the dpkg database, while dpkg only knew about the cleanly installed 2.11. So the upgrade failed with:
A copy of the C library was found in an unexpected directory: '/lib/x86_64-linux-gnu/libc-2.13.so' It is not safe to upgrade the C library in this situation; please remove that copy of the C library or get it out of '/lib/x86_64-linux-gnu' and try again. dpkg : erreur de traitement de libc6_2.13-33_amd64.deb (--install) : le sous-processus nouveau script pre-installation a retourné une erreur de sortie d'état 1 Des erreurs ont été rencontrées pendant l'exécution : libc6_2.13-33_amd64.deb
Nasty. EGLIBC/GLIBC is a major piece of the system, you cannot simple “remove” it or “get it out” and expect the system to continue to work. Moreover, in this specific case, these files we’re not truly an issue: they were about to be replaced during the upgrade process. But dpkg does not provide any mean to ignore configure scripts (and will probably never do). So one easy workaround is to uncompressed, edit, rebuild and install the package as follows:
aptitude download libc6 dpkg-deb --extract libc6_2.13-33_amd64.deb libc dpkg-deb --control libc6_2.13-33_amd64.deb libc/DEBIAN
Then we can edit libc/DEBIAN/preinst (I commented out the exit 1 after the safety warning)
dpkg-deb --build libc dpkg -i libc.deb
Yes, it’s fast 🙂