2010-12-15

finding non-meta data in a source repository

Working with a source code repository on the command line. I want to search all files in my checkout, but not the ".dotfile" metadata from the repository mechanism. The Unix "find" command has a -prune option whose function is hard to remember. So here for the record, that's how it is used for that purpose:

find . \( -name .svn -o -name CVS \) -prune -o -type f -print

keywords: unix, linux, programming, search, find, exclude, revision control, cvs, subversion

2010-08-03

upgrade glibc

As I mentioned in an earlier post, I am a Unix person crazy enough to attempt upgrading the core C library, glibc, by hand. The first, naive attempt failed, of course: simply copying the new library files over the old ones renders the system unusable.

Here I found a helpful text by Dave Storrer which helped me navigate around the most dangerous cliffs.

Here is an outline:

  1. compile glibc (current version 2.11.2)
  2. install it into a temporary directory
  3. remove ld.so.cache
  4. rename the critical library files, i.e. those having the version number 2.11.2 in the name
  5. install everything in the final destination
  6. rename the new files back, one by one...
  7. ...immediately linking them with the command "/sbin/ldconfig -l ..."
  8. don't strip any library symbols

2010-03-31

unexpected reloc type 0x0e

  • unexpected reloc type 0x0e
  • error while loading shared libraries: libc.so.6: cannot handle TLS data

You're not going to upgrade a the libc of a running Linux system, are you?. - If you are, you know what I am talking about. In the process, you might have gotten one or more of the above error messages.

Try this simple remedy: ldconfig

Switching forth and back between glibc versions:
  • ln -sf libc-2.11.1.so libc.so.6 
  • ldconfig
  • sln libc-2.3.5.so libc.so.6 
  • ldconfig
Where sln is a statically linked version of ln.

2010-01-17

Changing the Linux console keyboard layout

The problem: you switch to a virtual console using Alt-Gr-1 in order to
quickly debug something. But the key mapping is all wrong because the person
who installed the computer was a Armenian, Swiss German or what not.
You know the solution: loadkeys

But what mapping file? More often than not, I find no keyboard layout files.
This is annoying, because I really just want to fix a few things in the console
and then switch back to X11 and forget about it.

Try:
             loadkeys -d

If this does not set the correct layout directly, it gives you at least
an idea where to look for keyboard layouts.

Permanently change the default keyboard mapping on the linux console.


For example to Swiss German (sg):

  •   login as root
  •   cd /usr/share/keymaps/i386/qwerty  (your mileage may vary)
  •   mv defkeymap.kmap.gz not_my_defkeymap.kmap.gz
  •   cd ../qwertz
  •   ln -s sg-latin1.kmap.gz defkeymap.kmap.gz
  •   loadkeys -d

The point is to create a keyboard definition called defkeymap.kmap.gz
which will be loaded by default.

display the RUNPATH/RPATH of a Unix binary

First a short explanation what RUNPATH / RPATH is and why we want to use it. You know about shared libraries and their advantages over static linking. You also encountered the "shared object xxx not found" problem. There dynamic linker looks in four places for shared objects, in this order:

  1. the environment variable LD_LIBRARY_PATH
  2. a global file /etc/ld.so.conf or its cache /etc/ld.so.cache
  3. the RPATH and RUNPATH information in the executables header
  4. some hardwired default paths like /lib and /usr/lib
Working with binaries, it is advisable to avoid the first two methods whenever possible. They should be left to sysadmins and as a last resort.

RPATH and RUNPATH information is created at link time.

This is how to extract and display RPATH and RUNPATH from a given binary files:

Solaris:
/usr/ccs/bin/dump -Lv <binary> | egrep 'RPATH|RUNPATH'

Linux:
/usr/bin/objdump -p <binary> | egrep 'RPATH|RUNPATH'