Perl binding for GDAL on Debian 12 (Bookworm)

The XS based binding for Perl included with the Gdal library has been dropped with the release of GDAL 3.5.0 on May of 2022. Therefore, bookworm has not more a gdal-perl package available, as in the past releases of Debian.

A new CPAN module Geo::GDAL::FFI, based on the FFI interface to external libraries is available, so the Perl developers can use the usual cpan tool to install it or eventually consider to use the Debian way to build Perl modules to install system-wide the new module, making it usable by any user.

Unfortunately, both the processes are not straightforward, so this page describes the workflow to install properly all dependencies in the right order to build Geo::GDAL::FFI.

Building your own binary packages to support Geo::GDAL::FFI

First of all install sudo and add your user to the sudo admin group. All the following operations will download source packages of CPAN modules from the net, so avoid to use dh-make-perl as a privileged user.

sudo apt install dh-make-perl build-essential cmake
sudo apt install libgdal-dev
sudo apt install libtest-harness-perl
sudo apt install libtest2-suite-perl
sudo apt install libffi-checklib-perl
sudo apt install libpkgconfig-perl 

mkdir ~/perl-stuff && cd ~/perl-stuff

dh-make-perl --build --cpan Alien::Build
sudo apt install ./libalien-build-perl_*_amd64.deb

sudo apt install libarchive-extract-perl libshell-guess-perl libshell-config-generate-perl
dh-make-perl --build --cpan Alien::Base::ModuleBuild
sudo apt install ./libalien-base-modulebuild-perl_*_all.deb

dh-make-perl --build --cpan Alien::geos::af
sudo apt install ./libalien-geos-af-perl_*_all.deb

dh-make-perl --build --cpan Mozilla::CA
sudo apt install ./libmozilla-ca-perl_*_all.deb

sudo apt install sqlite3
dh-make-perl --build --cpan Alien::sqlite
sudo apt install ./libalien-sqlite-perl_*_all.deb

dh-make-perl --build --cpan Alien::Build::Plugin::PkgConfig::PPWrapper
sudo apt install ./libalien-build-plugin-pkgconfig-ppwrapper-perl_*_all.deb

dh-make-perl --build --cpan Alien::proj
sudo apt install ./libalien-proj-perl_*_all.deb

dh-make-perl --build --cpan Alien::libtiff
sudo apt install ./libalien-libtiff-perl_*_all.deb

dh-make-perl --build --cpan Alien::GDAL
sudo apt install ./libalien-gdal-perl_*_all.deb

sudo apt install pdl libffi-platypus-perl

dh-make-perl --build --cpan FFI::Platypus::Declare
sudo apt install ./libffi-platypus-declare-perl_*_all.deb

dh-make-perl --build --cpan Geo::GDAL::FFI
sudo apt install ./libgeo-gdal-ffi-perl_*_all.deb

Installing from the unofficial repository for Bookworm

It is also possible to add an unofficial set of binaries for Bookworm (amd64 only), which sits on by running the following commands:

wget -O- | sudo tee /etc/apt/trusted.gpg.d/frankie-unofficial.asc 
echo "deb [arch=amd64] bookworm main" | sudo tee /etc/apt/sources.list.d/frankie-unofficial.list
sudo apt update
sudo apt install libgeo-gdal-ffi-perl libalien-proj-perl libalien-libtiff-perl libalien-geos-af-perl libgdal-dev

This is the preferrable way to support the GDAL binding for Perl on multiple servers. Note that the two APIs of Geo::GDAL and Geo::GDAL::FFI are different, so that does not solve the problem of migrating to the new interface for an existing code base.