backporting-gl2ps

Discuss the issues I ran into when backporting `gl2ps` from Ubuntu Impish to Ubuntu Bionic

View on GitHub

Backporting gl2ps from Ubuntu Impish to Ubuntu Bionic

Overview

This repository discusses the issue I ran into when backporting gl2ps from Ubuntu Impish to Ubuntu Bionic by looking deep into two packages:

I looked into the source code of these two packages in order to understand the causes of the issue.

What the Issue is

debuild -us -uc will report errors of Cannot find (any matches for) "usr/lib/*/lib*.so" (tried in ., debian/tmp). See the section “Reproduce the Issue” for more details.

Reproduce the Issue

You need to meet the following prerequisites:

Follow the steps below to reproduce the issue:

Install the project...
/usr/bin/cmake -P cmake_install.cmake
-- Install configuration: "None"
-- Installing: /vagrant/backported/gl2ps/debian/tmp/usr/lib/libgl2ps.a
-- Installing: /vagrant/backported/gl2ps/debian/tmp/usr/lib/libgl2ps.so.1.4.2
-- Installing: /vagrant/backported/gl2ps/debian/tmp/usr/lib/libgl2ps.so.1.4
-- Installing: /vagrant/backported/gl2ps/debian/tmp/usr/lib/libgl2ps.so
-- Installing: /vagrant/backported/gl2ps/debian/tmp/usr/include/gl2ps.h
-- Installing: /vagrant/backported/gl2ps/debian/tmp/usr/share/doc/gl2ps/README.txt
-- Installing: /vagrant/backported/gl2ps/debian/tmp/usr/share/doc/gl2ps/COPYING.LGPL
-- Installing: /vagrant/backported/gl2ps/debian/tmp/usr/share/doc/gl2ps/COPYING.GL2PS
-- Installing: /vagrant/backported/gl2ps/debian/tmp/usr/share/doc/gl2ps/gl2psTest.c
-- Installing: /vagrant/backported/gl2ps/debian/tmp/usr/share/doc/gl2ps/gl2psTestSimple.c
-- Installing: /vagrant/backported/gl2ps/debian/tmp/usr/share/doc/gl2ps/gl2ps.pdf
make[1]: Leaving directory '/vagrant/backported/gl2ps/obj-x86_64-linux-gnu'
   dh_install -O--buildsystem=cmake
dh_install: The use of "debhelper-compat (= 11)" is experimental and may change (or be retired) without notice
dh_install: Cannot find (any matches for) "usr/lib/*/lib*.so" (tried in ., debian/tmp)

dh_install: libgl2ps-dev missing files: usr/lib/*/lib*.so
dh_install: Cannot find (any matches for) "usr/lib/*/lib*.so.*" (tried in ., debian/tmp)

dh_install: libgl2ps1.4 missing files: usr/lib/*/lib*.so.*
dh_install: missing files, aborting
debian/rules:8: recipe for target 'binary' failed
make: *** [binary] Error 25
dpkg-buildpackage: error: debian/rules binary subprocess returned exit status 2
debuild: fatal error at line 1152:
dpkg-buildpackage -rfakeroot -us -uc -ui failed

The built files were all under the path usr/lib/lib*.so which doesn’t match the pattern usr/lib/*/lib*.so, hence the error.

Understand the Issue

The cause of the build errors about usr/lib/*/ has something to do with the debian/patches. To be more exact, it is about where the CMake statement INCLUDE(GNUInstallDirs) in inserted into CMakeLists.txt:

project(gl2ps C)
...
INCLUDE(GNUInstallDirs)
INCLUDE(GNUInstallDirs)
...
project(gl2ps C)
set(_LIBDIR_DEFAULT "lib")
if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$"
      AND NOT CMAKE_CROSSCOMPILING)
  # CMake code that forms the `x86-64_linux-gnu` part.
endif()
sub configure {
        if (is_cross_compiling()) {
           ...
        }
        push(@flags, "-DCMAKE_INSTALL_LIBDIR=lib/" . dpkg_architecture_value("DEB_HOST_MULTIARCH"));
}
sub configure {
        if (is_cross_compiling()) {
                ...
                push(@flags, "-DCMAKE_INSTALL_LIBDIR=lib/" . dpkg_architecture_value("DEB_HOST_MULTIARCH"));
        }
}