23 February 2012

73. Gnu screen- attach to a running screen session

Follows this with minor amendments.

The issue:
You start e.g. a compile or a number-crunching job on your work computer, and go home while leaving it running. When you get home you log on to your work computer via ssh, and want to connect to the terminal in which the job is running i.e. connect to the tty.

Another use for screen is if you are working over an unstable connection -- if you get booted off the screen session continues to run, so whatever was running in it is still sound. A normal pts will die and crash.

A solution using screen:
Be aware that this can cause a potential security risk.

1. install gnu screen
sudo apt-get install screen

2. enable multi-user mode
sudo chmod +s /usr/bin/screen
sudo chmod 755 /var/run/screen

Edit /etc/screenrc and add the following lines anywhere

multiuser on
acladd me
If you want primitive scrolling (shift + page up/down)
termcapinfo xterm|xterms|xs|rxvt ti@:te@
Replace me with the local username.

3. On your work computer,
screen -S testing

4. Start whatever job you were thinking of and leave it running

5. From home ssh into your work computer then
screen -x me/testing

Another neat thing is that both terminals look the same no matter whether you are at your work computer or at your home computer. Ergo, it may be a useful way of helping people remotely with their computers too.

6. To disconnect gracefully
Hold CTRL+a+d

Do not type exit or anything like that, as it will close the screen instance completely.

For a gnu screen cheat sheet, look here:
http://www.totiso.com/2009/05/03/gnu-screen-cheat-sheet

72. Building maxima from source on Debian Testing


The version of maxima in the debian repos is the same as in the sourceforge archives. There's only one good reason to compile your own version from what I can see -- to get around the dependency of maxima on gnuplot.

Let me explain: the gnuplot version in the debian repos has problems handling small numbers (<10**(-9)). Uninstalling gnuplot and replacing it with your a version you've compiled yourself removes maxima.

Luckily it's easy to build:

wget http://sourceforge.net/projects/maxima/files/latest/download?source=files
mv download\?source\=files maxima-5.26.0.tar.gz
./configure
make -j5

where 5 is the number of cores +1 (I have four cores). Change as needed.

sudo checkinstall

Checkinstall may or may not exit successfully if you have compiled your own version of gnuplot -- see below. Chances are that it built the package correctly.

or 

sudo make install


Error:
If you get
dpkg: error processing maxima_5.26.0-1_amd64.deb (--install):
trying to overwrite '/usr/local/share/info/dir', which is also in package gnuplot 4.4.4-1
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)

Solution: 
sudo dpkg --force-overwrite -i maxima_5.26.0-1_amd64.deb

You can see that the dir file is ok (GNUPlot is still referred to):

This is the file .../info/dir, which contains the
topmost node of the Info hierarchy, called (dir)Top.
The first time you invoke Info you start off looking at this node.

File: dir, Node: Top This is the top of the INFO tree
  This (the Directory node) gives a menu of major topics.
  Typing "q" exits, "?" lists all Info commands, "d" returns here,
  "h" gives a primer for first-timers,
  "mEmacs<Return>" visits the Emacs manual, etc.
  In Emacs, you can click mouse button 2 on a menu item or cross reference
  to select it.
* Menu:
Emacs
* Imaxima: (imaxima).           Image support for the computer algebra system
                                  Maxima. Interactive math minor mode.
Math
* GNUPLOT: (gnuplot).           An Interactive Plotting Program
* Maxima: (maxima).             A computer algebra system.
* Xmaxima: (xmaxima).           Graphical interface for Maxima.

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