Situation
Last time we prepared the chroot
-environment with debootstrap
. This time we continue inside the chroot environment.
chroot /mnt
Inside the chroot we create an user shimps and install aptitude for the other packages' installation process. YMMV.
user="shimps" addgroup --gid 1000 ${user} adduser --gid 1000 --uid 1000 --disabled-password --gecos ${user},13,23,42,666 ${user} apt-get update apt-get install aptitude
Packages I: General
Next we do some basic preparation of the chroot, independent from the GnuPG build process later.
aptitude install perl aptitude install libfile-fcntllock-perl aptitude install bzip2 aptitude install xz-utils aptitude install libdpkg-perl aptitude install bash-completion aptitude install git aptitude install libldap-common aptitude install libsasl2-modules aptitude install publicsuffix aptitude install openssl aptitude install ca-certificates aptitude install openssh-client aptitude install xauth aptitude install patch aptitude install etckeeper aptitude install vim update-alternatives --config editor select-editor aptitude install systemd-sysv- sysvinit-core aptitude install psmisc aptitude remove systemd aptitude install libsystemd0- libelogind0 aptitude install lsof aptitude install colordiff aptitude install wget aptitude install curl aptitude install rsync aptitude install gnupg
Packages II: Build Process
Now we install packages required for compiling GnuPG.
aptitude install gcc aptitude install libc6-dev aptitude install libc-devtools aptitude install manpages aptitude install manpages-dev aptitude install make aptitude install zlib1g-dev aptitude install libldap-dev aptitude install libreadline-dev aptitude install libsqlite3-dev aptitude install pkgconf aptitude install gawk aptitude install libbz2-dev aptitude install bzip2-doc aptitude install gpgrt-tools aptitude install libgnutls28-dev aptitude install libtasn1-doc
Drop Privileges
Now we switch to a normal user, root privileges aren't needed anymore.
su - ${user}
Clone Repository
As user shimps we clone the diy-gnupg repository from Codeberg and prepare the source code for compilation:
mkdir -p codeberg/fmg cd codeberg/fmg git clone https://codeberg.org/fmg/diy-gnupg.git diy-gnupg/self-compile/bin/fetch-source.sh diy-gnupg/self-compile/bin/unpack-source.sh mkdir -p /tmp/canary/install
Compile Libraries
Now things are almost straightforward, similar to what was described earlier in Compiling GnuPG VIII: Dependencies I, but the order has changed.
cd /tmp/canary/compile/npth-1.8 ./configure --prefix="/tmp/canary/install" make make install cd ../libgpg-error-1.51 ./configure --prefix="/tmp/canary/install" make make install cd ../libassuan-3.0.2 ./configure --prefix="/tmp/canary/install" make make install cd ../libksba-1.6.7 ./configure --prefix="/tmp/canary/install" make make install cd ../libgcrypt-1.11.0 ./configure --prefix="/tmp/canary/install" make make install
Compile GnuPG
Now we are close to run into problems with yat2m. This didn't happen before when the package pkgconf wasn't installed, but without this package it wasn't possible to build GnuPG with Sqlite3 support either. The solution is adjusting the PATH variable and to use the new compiled version of yat2m.
PATH="/tmp/canary/install/bin:${PATH}" cd ../gnupg-2.5.5 ./configure --prefix="/tmp/canary/install" make make install LD_LIBRARY_PATH="/tmp/canary/install/lib" gpg --version
Comparison
Original
$ ldd /usr/bin/gpg linux-vdso.so.1 (...) libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (...) libbz2.so.1.0 => /lib/x86_64-linux-gnu/libbz2.so.1.0 (...) libgcrypt.so.20 => /lib/x86_64-linux-gnu/libgcrypt.so.20 (...) libsqlite3.so.0 => /lib/x86_64-linux-gnu/libsqlite3.so.0 (...) libreadline.so.8 => /lib/x86_64-linux-gnu/libreadline.so.8 (...) libassuan.so.0 => /lib/x86_64-linux-gnu/libassuan.so.0 (...) libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (...) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (...) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (...) libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (...) /lib64/ld-linux-x86-64.so.2 (...)
Self Compiled
$ LD_LIBRARY_PATH="/tmp/canary/install/lib" ldd /tmp/canary/install/bin/gpg linux-vdso.so.1 (...) libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (...) libbz2.so.1.0 => /lib/x86_64-linux-gnu/libbz2.so.1.0 (...) libsqlite3.so.0 => /lib/x86_64-linux-gnu/libsqlite3.so.0 (...) libgcrypt.so.20 => /tmp/canary/install/lib/libgcrypt.so.20 (...) libreadline.so.8 => /lib/x86_64-linux-gnu/libreadline.so.8 (...) libassuan.so.9 => /tmp/canary/install/lib/libassuan.so.9 (...) libnpth.so.0 => /tmp/canary/install/lib/libnpth.so.0 (...) libgpg-error.so.0 => /tmp/canary/install/lib/libgpg-error.so.0 (...) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (...) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (...) libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (...) /lib64/ld-linux-x86-64.so.2 (...)
Thanks
Many thanks to Andreas for pointing me to the missing pkgconf package problem on the gnupg-devel mailing list.
To be continued...