23 February 2012

71. Building Thunderbird 10.0.2 on debian testing

I use evolution for email, contacts and calendar because it integrates well with gnome and because it looks a whole lot prettier than the version of Thunderbird (i.e. Icedove) in the debian repos (3.1.16-1).

Well, sometimes you've got to check out the alternatives. Here's how to build thunderbird 10.0.2 from source.

-- START HERE --

sudo apt-get install libdbus-glib-1-dev gir1.2-notify-0.7 libnotify-dev  yasm checkinstall libzip-dev zip

cd ~/tmp
wget ftp://ftp.mozilla.org/pub/mozilla.org/thunderbird/releases/10.0.2/source/thunderbird-10.0.2.source.tar.bz2

tar -xvf thunderbird-10.0.2.source.tar.bz2 

cd comm-release/

./configure --disable-necko-wifi
..
updating cache ../../.././config.cache
creating ./config.status
creating Makefile
creating config/Makefile
creating config/autoconf.mk
creating ldap/Makefile
creating ldap/clients/tools/Makefile
creating ldap/include/Makefile
creating ldap/libraries/Makefile
creating ldap/libraries/libldap/Makefile
creating ldap/libraries/libprldap/Makefile
creating ldap/libraries/libldif/Makefile
creating ldap/libraries/liblber/Makefile
creating ldap/libraries/libiutil/Makefile
creating ldap/libraries/libssldap/Makefile
creating ldap/libraries/libutil/Makefile

make -jN

...
make[4]: Leaving directory `/home/me/tmp/comm-release/mail/test/mozmill'
make[3]: Leaving directory `/home/me/tmp/comm-release/mail'
make[2]: Leaving directory `/home/me/tmp/comm-release'
make[1]: Leaving directory `/home/me/tmp/comm-release'
if test -d ./mozilla/dist/bin ; then touch ./mozilla/dist/bin/.purgecaches ; fi


where N is the number of cores +1 -- in my case it's 7 since I have a six-core CPU. Be aware that building does take a while.

sudo make install

(sudo checkinstall ended with segfault for some reason)

You are now done.

Make sure that /usr/local/bin is in your PATH

me@beryllium:~/tmp/comm-release$ which thunderbird
/usr/local/bin/thunderbird


Interesting observation:
while thunderbird starts thunderbird the home-built version seems to be referred to as earlybird:



What's ugly or not is subjective, but you may want to use this add-on:
https://addons.mozilla.org/en-US/thunderbird/addon/gnome-linux-integration/?src=search



Troubleshooting:
Error:
checking MOZ_PANGO_CFLAGS... -pthread -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/freetype2
checking MOZ_PANGO_LIBS... -pthread -lpangoft2-1.0 -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0
checking for gnome-vfs-2.0 >= 2.0 gnome-vfs-module-2.0 >= 2.0... checking for gconf-2.0 >= 1.2.1 gobject-2.0 ... checking for dbus-glib-1 >= 0.60... Package dbus-glib-1 was not found in the pkg-config search path. Perhaps you should add the directory containing `dbus-glib-1.pc' to the PKG_CONFIG_PATH environment variable No package 'dbus-glib-1' found
configure: error: Library requirements (dbus-glib-1 >= 0.60) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.

Solution:
sudo apt-get install libdbus-glib-1-dev

Error:

checking MOZ_PANGO_LIBS... -pthread -lpangoft2-1.0 -lfreetype -lfontconfig -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0
checking for gnome-vfs-2.0 >= 2.0 gnome-vfs-module-2.0 >= 2.0... checking for gconf-2.0 >= 1.2.1 gobject-2.0 ... checking for libnotify >= 0.4... Package libnotify was not found in the pkg-config search path. Perhaps you should add the directory containing `libnotify.pc' to the PKG_CONFIG_PATH environment variable No package 'libnotify' found
configure: error: Library requirements (libnotify >= 0.4) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them

Solution:
sudo apt-get install gir1.2-notify-0.7 libnotify-dev

Error:

checking MOZ_DBUS_GLIB_LIBS... -pthread -ldbus-glib-1 -ldbus-1 -lpthread -lgobject-2.0 -lgthread-2.0 -lrt -lglib-2.0
checking __attribute__ ((aligned ())) support... trying 64
64
configure: error: yasm is a required build tool for this architecture when webm is enabled. You may either install yasm or --disable-webm (which disables the WebM video format). See https://developer.mozilla.org/en/YASM for more details.
configure: error: ./configure failed for mozilla

Solution:
sudo apt-get install yasm

20 February 2012

70. Installing Debian on a USB stick -- live usb vs a true and full installation

Update 17 March 2013: See this post for a faster, better way of creating a full install if you're already running Debian.

Original post:
Every now and again I get posts like this one, or this one, via google news. While those posts --describing the use of unetbootin to create a 'live' USB analogue to a live CD -- may be technically correct, there's just so much more you can do.

In 1  we do the old boring bog-standard 'write live cd to a usb' thingy that you see pasted all over the web, but using cat instead of unetbootin.
In 2  we make a real, bootable installation on a usb drive.



1.  Creating a USB version of a live CD -- the boring option
With the current 'hybrid' Debian iso's it couldn't be easier.
THIS WILL WIPE YOUR USB STICK

 --- START HERE ---

a. Download the iso
Using jigdo is a good option. Downloading a business-card/netinstall iso is another, if you'll have a working internet connection available.

b. Plug in and mount your USB device and  find out the device name of your USB drive.
If it's mounted you can use
df -h
rootfs                                                   93G   36G   54G  40% /
udev                                                    3.9G     0  3.9G   0% /dev
tmpfs                                                   801M  980K  800M   1% /run
/dev/disk/by-uuid/..-10a350f85687   93G   36G   54G  40% /
tmpfs                                                   5.0M     0  5.0M   0% /run/lock
tmpfs                                                   1.6G   52K  1.6G   1% /tmp
tmpfs                                                   1.6G  816K  1.6G   1% /run/shm
/dev/sda6                                               745G  183G  525G  26% /home
/dev/sdc1                                               2.0G  434M  1.5G  23% /media/XP-KOMKU

or

mount
../dev/sdc1 on /media/XP-KOMKU type vfat (rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0077,codepage=cp437,iocharset=utf8,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks)



to list mounted devices. In my case it's an old 2 G usb stick I used to create a Windows XP installation USB device on.

If you prefer a gui tool, start palimpsest (called Disk Utility in gnome)
It will be something akin to sdb1 or sdc1 etc. That means the device name is /dev/sdb or /dev/sdc, respectively. In our case, it's sdc.

c. Unmount but don't detach the device
You don't want anything else writing to it.

me@beryllium:~/Documents/screengrabs$ umount /dev/sdc1
me@beryllium:~/Documents/screengrabs$ df -h
Filesystem                                              Size  Used Avail Use% Mounted on
rootfs                                                   93G   36G   54G  40% /
udev                                                    3.9G     0  3.9G   0% /dev
tmpfs                                                   801M  976K  800M   1% /run
/dev/disk/by-uuid/..-10a350f85687   93G   36G   54G  40% /
tmpfs                                                   5.0M     0  5.0M   0% /run/lock
tmpfs                                                   1.6G   60K  1.6G   1% /tmp
tmpfs                                                   1.6G  820K  1.6G   1% /run/shm
/dev/sda6                                               745G  183G  525G  26% /home
d. Become root and use cat to write the iso to the USB device

sudo su

And write (assuming that the device name is sdc and you are using the businesscard iso)

cat debian-6.0.3-amd64-businesscard.iso > /dev/sdc

Done.

e. boot from your USB drive and go through the same steps as for a CD.  
Plug it in, then start your computer. Hit F12 (or F10 or del or F2) during the bios start-up to select boot medium. Choose to boot from usb. Older BIOSes can't boot from USB.



2. Really INSTALLING Debian on a USB
You can use either virtualbox or quemu for this. Here I show how to use virtualbox.

[NOTE: there's a leaner, faster, better way described here: http://verahill.blogspot.com/2013/03/361-installing-debian-on-usb-stick-from.html ]

  •  Note that a tiny 2 Gb USB stick isn't suitable for a full Debian + Gnome installation. It may, however, work well with e.g. openbox and xmonad. Or just work in the terminal -- use mutt for email, mcabber for chat, elinks for http/www etc.
  • Here I show how to install using the businesscard iso, but I've done this with the regular Debian DVD version in the past.
  • Also, few USB devices operate at 480 Mbps -- so be prepared that installation via virtualbox onto a USB device will take considerably longer than a regular installation.
  • Solid state devices degrade with I/O, so use your USB stick for back-up use during e.g. travel etc. Don't trust the integrity of it. 


There are a few good reasons for installing a full linux version on a thumb drive or a regular but external harddrive:
*  a thumb drive will allow you too carry an independent OS with you, allowing you to e.g. temporarily borrow a computer from a friend but running your own system. An installation, as opposed to a 'live cd', allows you to customise the setup and install programs. USB 2 is quite slow, and many thumb drives are slower than that, so you're probably better off running a light system than a full on gnome-shell desktop. That's not so say that you can't -- I have.
* installing onto a usb-connected harddrive will allow you to setup and prepare headless boxes or systems without a direct internet connection.

First you need to install virtualbox, which is available in the debian repos (sudo apt-get install virtualbox virtualbox-guest-additions), and -- in order to enable USB 2 support --  the "VirtualBox 4.1.8 Oracle VM VirtualBox Extension Pack" from https://www.virtualbox.org/wiki/Downloads
Start virtualbox and go to  File/Preferences/Extensions to install the extension pack you downloaded.

 --- START HERE ---

Installing debian (or any os) on an external USB stick/drive using virtualbox
a. Start virtualbox and click on New.

b. Click through the Name, Operating System and Version questions, Select a memory size which is reasonable for the intended use and target machine. Give it at least 256 Mb. Don't fret about this step -- on each boot your system will autodetect the amount of available RAM. The next question is the key to the whole undertaking: DO NOT SET A START-UP DISK (or any virtual harddisk)

In the next dialogue box you'll be asked if you want to continue or go back - yes, you want to continue.

c. Your new machine is now ready to be set up. Select it and click on settings; Got to storage, IDE controller and choose a virtual CD/DVD disk file. Select the debian installation iso.

d. Next click on USB, enable USB 2 controller, and add a filter for your device by e.g. hitting alt+insert and selecting it from the list.


e. You're ready to install! Start the virtual machine, and the installation should start without you having to select boot device. Most of the setting are the same as in any normal install. Pay attention when you come to the Partition Disk dialogue though. Make sure that you're not doing something silly and accidentally deleting something you shouldn't be a-deleting, even though the risks of that are very slim.

Delete the existing partitions and create a new one. I added a tiny swap space too, hoping that this will make the difference between a freeze and a slow crawl on underpowered systems.
f. Continue with the installation as normal.



g. Postscript:
* /dev/sda1 vs UUID. Once you're done with the installation  and have shut down your virtualbox, mount the USB drive as a normal thumb drive and have a look at fstab in particular -- if you're using relative paths (e.g. sda) instead of absolute paths using UUID, you may run into problems at some point.




In the screengrab you see that

# / was on /dev/sda1 during installation
UUID=8c0c9c98-e73f-4f5a-b7d7-f91f95c9d8ca /               ext4    errors=remount-ro 0       1

Which means we're good.

You may want to comment out
/dev/sda1       /media/usb0     auto    rw,user,noauto  0       0
/dev/sda2       /media/usb1     auto    rw,user,noauto  0       0
/dev/sda5       /media/usb2     auto    rw,user,noauto  0       0

But I haven't in the past and all has been good.

* network interfaces -- you may find that no network interface is configured for you and that no interface shows up when you use ifconfig. Use ip addr to get a list over interfaces. If the interface is e.g. eth2, you may  want to edit /etc/network/interfaces and add

auto eth2
iface eth2 inet dhcp

or (the ip's are just examples)

auto eth2
iface eth2 inet static
address 192.168.1.100
gateway 192.168.1.1
netmask 255.255.255.0

And then run sudo service networking restart

That's it. You now have a full installation on either a 'removable' drive or on an HDD which you can install in a desktop/laptop.


Links to this page:
http://vk.com/topic-50603_27808581
http://forum.debian.org.tr/arsiv-konu-391.0-debian-live-usb.html
http://alsamixer.wordpress.com/2012/10/07/installing-debian/
http://cv.uoc.edu/app/phpBB3/viewtopic.php?f=3511&t=20897
http://www.computerbase.de/forum/showthread.php?t=1208228&p=13936928

17 February 2012

70. Bug in Debian version of Gnuplot 4.4.0

The symptom:

Gnuplot 4.4.0-1.1 (the current Debian version) can't handle numbers smaller than 10**(-9) properly
e.g.
me@beryllium:~/Dropbox$ gnuplot
G N U P L O T
Version 4.4 patchlevel 0
last modified March 2010
System: Linux 3.2.0-1-amd64
Copyright (C) 1986-1993, 1998, 2004, 2007-2010
Thomas Williams, Colin Kelley and many others
gnuplot home:     http://www.gnuplot.info
faq, bugs, etc:   type "help seeking-assistance"
immediate help:   type "help"
plot window:      hit 'h'
Terminal type set to 'wxt'
gnuplot> print 10**(-9)
1e-09
gnuplot> print 10**(-10)
7.09186959928599e-10
gnuplot> print 10**(-11)
8.22536045240377e-10

It's not related to set zero.

gnuplot> set zero 1e-20
gnuplot> print 10**(-11)
8.22536045240377e-10
gnuplot> print 10**(-10)
7.09186959928599e-10
gnuplot> print 10**(-9)
1e-09
gnuplot> 

Currently, I'm using version 4.4.0-1.1 -- which is used in all versions of Debian.


me@beryllium:~$ apt-cache showpkg gnuplot
Package: gnuplot
Versions:
4.4.0-1.1 (/var/lib/apt/lists/ftp.au.debian.org_debian_dists_testing_main_binary-amd64_Packages) (/var/lib/apt/lists/ftp.au.debian.org_debian_dists_stable_main_binary-amd64_Packages) (/var/lib/apt/lists/ftp.au.debian.org_debian_dists_unstable_main_binary-amd64_Packages) (/var/lib/dpkg/status)
..
Dependencies:
4.4.0-1.1 - gnuplot-nox (2 4.4.0-1.1) gnuplot-x11 (2 4.4.0-1.1) gnuplot-doc (2 4.4.0-1.1)
Provides:
4.4.0-1.1 -
Reverse Provides: 

The bug affects the output from the print statement as well as the internal handling of numbers:




gnuplot> plot 10**(-11)
Warning: empty y range [8.22536e-10:8.22536e-10], adjusting to [8.14311e-10:8.30761e-10]



gnuplot> plot 10**(-12)
Warning: empty y range [-1.3748e-09:-1.3748e-09], adjusting to [-1.36105e-09:-1.38855e-09]
gnuplot> plot 10**(-12)/10**(-10)
Warning: empty y range [-1.93855:-1.93855], adjusting to [-1.91917:-1.95794]





gnuplot> set xrange [10**(-9):10**(-12)]
gnuplot> plot x 



The bug is similar to this: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=360087

Integer overflows are not reported. A hint could be printed that real
(float) numbers should (could) be used to avaid this problem.
gnuplot> print 1000000*100000
1215752192
gnuplot> print 1000000**2
-727379968
gnuplot> print 100000**2
1410065408
gnuplot> a=2000000**2
gnuplot> print a
1385447424
gnuplot> print 10000**2 # OK
100000000
which ended up with "Added tag(s) wontfix. "
Ergo, if you're using debian and you are using gnuplot for serious purposes (research, work), compile your own version of gnuplot as per below.


ANNOYING: there are packages such as maxima which depend on gnuplot. Remove the debian version of gnuplot using apt-get and you lose maxima too. Octave, which one would think would be a heavier user of gnuplot, does not depend on gnuplot but merely recommends it.


Package: maxima                        
State: not installed
Version: 5.26.0-3
Priority: optional
Section: math
Maintainer: Camm Maguire <camm@debian.org>
Uncompressed Size: 47.8 M
Depends: libc6 (>= 2.3), libgmp10, libreadline6 (>= 6.0), libx11-6, gnuplot-x11
Maybe time to build your own maxima.deb? In the end you will end up with a very inelegant system with mixed packages.


Upstreams:
I've compiled and checked the current upstreams version:

me@beryllium:~$ sudo apt-get autoremove gnuplot gnuplot-nox
cd ~/temp
wget http://downloads.sourceforge.net/project/gnuplot/gnuplot/4.4.4/gnuplot-4.4.4.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fgnuplot%2Ffiles%2F&ts=1329439455&use_mirror=aarnet
 mv gnuplot-4.4.4.tar.gz\?r\=http\:%2F%2Fsourceforge.net%2Fprojects%2Fgnuplot%2Ffiles%2F gnuplot-4.4.4.tar.gz
tar -xvf gnuplot-4.4.4.tar.gz
./configure
make 
sudo checkinstall


me@beryllium:~/temp/gnuplot-4.4.4$ sudo dpkg -i gnuplot_4.4.4-1_amd64.deb
(Reading database ... 446323 files and directories currently installed.)
Preparing to replace gnuplot 4.4.4-1 (using gnuplot_4.4.4-1_amd64.deb) ...
Unpacking replacement gnuplot ...
Setting up gnuplot (4.4.4-1) ...
Processing triggers for man-db ...
me@beryllium:~/temp/gnuplot-4.4.4$ gnuplot
G N U P L O T
Version 4.4 patchlevel 4
last modified November 2011
System: Linux 3.2.0-1-amd64
Copyright (C) 1986-1993, 1998, 2004, 2007-2011
Thomas Williams, Colin Kelley and many others
gnuplot home:     http://www.gnuplot.info
faq, bugs, etc:   type "help seeking-assistance"
immediate help:   type "help"
plot window:      hit 'h'
Terminal type set to 'x11'
gnuplot> print 10**(-9)
1e-09
gnuplot> print 10**(-10)
1e-10
gnuplot> print 10**(-11)
1e-11
gnuplot> print 3.14*10**(-10)
3.14e-10
gnuplot> print 3.14*10**(-20)
3.14e-20
gnuplot> print 3.14*10**(-21)
3.14e-21
gnuplot> print 3*10**(-12)/(4*10**(-14))
75.0
gnuplot> 

Ergo, upstreams v 4.4.4 works.

Update: Here's my bug report:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=660299