HOAB

History of a bug

Relocatable postgresql

Rédigé par gorki Aucun commentaire

Problem :

I need a relocatable / portable version of postgresql.

Disclaimer : if possible, use the OS distribution, it will be more up-to-date and sure.

That thing said : 

  • I downloaded the source
  • Compile it on my computer (Debian / Trixie / Sid)
  • Package and run

Fail ! Obviously but here is why : 

  1. Shared library are related to an absolute path
  2. Glibc version on my computer is more recent than target server

Solution :

Two problems here and a few useful commands :

  • ldd <program name>
    • Will give you if the program is static or dynamic
    • If dynamic, the list of libraries and the searched path, example (libpq is a library from postgres)
 libpq.so.5 => /lib/x86_64-linux-gnu/libpq.so.5 (0x00007f29f9786000)
  • readelf -d <program name> : information on execution
0x0000000000000001 (NEEDED)             Shared library : [libpq.so.5]
0x0000000000000001 (NEEDED)             Shared library : [libm.so.6]
0x0000000000000001 (NEEDED)             Shared library : [libc.so.6]
0x000000000000001d (RUNPATH)            Library runpath :[/home/myuser/projects/packaging/postgresql/output/lib]
0x000000000000000c (INIT)               0x6000
0x000000000000000d (FINI)               0x162a0
  • objdump -T <program name> | grep GLIBC : list dependencies on GLIBC

 

Once I had this information : 

  • I compile postgresql on the target system : GLIBC 2.34, 2.33 were not available so postgresql compile without linking it
  • I change the runpath of the executables with these commands :
# extract postgres sources
./configure --prefix=/home/myuser/postgresql/output --without-icu --without-readline --without-zlib --disable-rpath
export LD_RUN_PATH='$ORIGIN/../lib'
make
make install

It generates a postgresql version in  /home/myuser/postgresql/output

The readelf commands returns : 

 0x000000000000000f (RPATH)              Library rpath: [$ORIGIN/../lib]

So I was now able to package it.

 

 

Écrire un commentaire

Quelle est le quatrième caractère du mot t68sk ?

Fil RSS des commentaires de cet article