[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#439121: Add a .pc file for libapt-pkt



Ah, you're right, so here is finally the right one

2017-11-07 23:44 GMT+01:00 Julian Andres Klode <jak@debian.org>:
On Tue, Nov 07, 2017 at 11:20:50PM +0100, Corentin Noël wrote:
> Here is a patch working with current master, It's now fully working. It
> contains a test to ensure that it works, I tested it with autopkgtest.

> From 44fa7251911378bb0ca16a23024b7f7ede5a8f84 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Corentin=20No=C3=ABl?= <corentin@elementary.io>
> Date: Tue, 7 Nov 2017 20:38:13 +0100
> Subject: [PATCH] Enable PkgConfig on the apt-pkg and apt-inst libraries
>
> ---
>  apt-inst/CMakeLists.txt       |  3 +++
>  apt-inst/apt-inst.pc.in       | 11 +++++++++++
>  apt-pkg/CMakeLists.txt        |  3 +++
>  apt-pkg/apt-pkg.pc.in         | 10 ++++++++++
>  debian/libapt-pkg-dev.install |  1 +
>  debian/tests/control          |  5 +++--
>  debian/tests/pkg-config-test  | 22 ++++++++++++++++++++++
>  7 files changed, 53 insertions(+), 2 deletions(-)
>  create mode 100644 apt-inst/apt-inst.pc.in
>  create mode 100644 apt-pkg/apt-pkg.pc.in
>  create mode 100644 debian/tests/pkg-config-test
>
> diff --git a/apt-inst/CMakeLists.txt b/apt-inst/CMakeLists.txt
> index 31da115e4..063b40318 100644
> --- a/apt-inst/CMakeLists.txt
> +++ b/apt-inst/CMakeLists.txt
> @@ -12,6 +12,8 @@ set(APT_INST_MAJOR ${MAJOR} PARENT_SCOPE)
>  file(GLOB_RECURSE library "*.cc")
>  file(GLOB_RECURSE headers "*.h")
>
> +configure_file(apt-inst.pc.in ${CMAKE_CURRENT_BINARY_DIR}/apt-inst.pc @ONLY)
> +
>  # Create a library using the C++ files
>  add_library(apt-inst SHARED ${library})
>
> @@ -25,4 +27,5 @@ add_version_script(apt-inst)
>  # Install the library and the headers
>  install(TARGETS apt-inst LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
>  install(FILES ${headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/apt-pkg)
> +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/apt-inst.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
>  flatify(${PROJECT_BINARY_DIR}/include/apt-pkg/ "${headers}")
> diff --git a/apt-inst/apt-inst.pc.in b/apt-inst/apt-inst.pc.in
> new file mode 100644
> index 000000000..c752f4657
> --- /dev/null
> +++ b/apt-inst/apt-inst.pc.in
> @@ -0,0 +1,11 @@
> +prefix=@CMAKE_INSTALL_PREFIX@
> +exec_prefix=${prefix}
> +libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
> +includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@

That's wrong. If I define CMAKE_INSTALL_LIBDIR to /foo,
and prefix is /usr, you just set libdir to /usr//foo instead
of /foo.

Generally, we must not use CMAKE_INSTALL_PREFIX, and only
use CMAKE_INSTALL_FULL_LIBDIR, CMAKE_INSTALL_FULL_INCLUDEDIR,
and thus only define libdir and includedir, not prefix or
exec_prefix.

> +
> +Name: apt-inst
> +Description: deb package format runtime library
> +Version: @MAJOR@.@MINOR@
> +Libs: -L${libdir} -lapt-inst
> +Cflags: -I${includedir}/apt-pkg

The /apt-pkg should not be there.

> diff --git a/apt-pkg/apt-pkg.pc.in b/apt-pkg/apt-pkg.pc.in
> new file mode 100644
> index 000000000..97c90ce5e
> --- /dev/null
> +++ b/apt-pkg/apt-pkg.pc.in
> @@ -0,0 +1,10 @@
> +prefix=@CMAKE_INSTALL_PREFIX@
> +exec_prefix=${prefix}
> +libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
> +includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@

as above

> +
> +Name: apt-pkg
> +Description: package management runtime library
> +Version: @MAJOR@.@MINOR@
> +Libs: -L${libdir} -lapt-pkg -pthread
> +Cflags: -I${includedir}/apt-pkg

as above



--
Debian Developer - deb.li/jak | jak-linux.org - free software dev
Ubuntu Core Developer                              de, en speaker

From 19d95cdb3b1c70419ca7d7c34bafe068a7e056f3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Corentin=20No=C3=ABl?= <corentin@elementary.io>
Date: Tue, 7 Nov 2017 20:38:13 +0100
Subject: [PATCH] Enable PkgConfig on the apt-pkg and apt-inst libraries

---
 apt-inst/CMakeLists.txt       |  3 +++
 apt-inst/apt-inst.pc.in       |  9 +++++++++
 apt-pkg/CMakeLists.txt        |  3 +++
 apt-pkg/apt-pkg.pc.in         |  8 ++++++++
 debian/libapt-pkg-dev.install |  1 +
 debian/tests/control          |  5 +++--
 debian/tests/pkg-config-test  | 22 ++++++++++++++++++++++
 7 files changed, 49 insertions(+), 2 deletions(-)
 create mode 100644 apt-inst/apt-inst.pc.in
 create mode 100644 apt-pkg/apt-pkg.pc.in
 create mode 100644 debian/tests/pkg-config-test

diff --git a/apt-inst/CMakeLists.txt b/apt-inst/CMakeLists.txt
index 31da115e4..063b40318 100644
--- a/apt-inst/CMakeLists.txt
+++ b/apt-inst/CMakeLists.txt
@@ -12,6 +12,8 @@ set(APT_INST_MAJOR ${MAJOR} PARENT_SCOPE)
 file(GLOB_RECURSE library "*.cc")
 file(GLOB_RECURSE headers "*.h")
 
+configure_file(apt-inst.pc.in ${CMAKE_CURRENT_BINARY_DIR}/apt-inst.pc @ONLY)
+
 # Create a library using the C++ files
 add_library(apt-inst SHARED ${library})
 
@@ -25,4 +27,5 @@ add_version_script(apt-inst)
 # Install the library and the headers
 install(TARGETS apt-inst LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
 install(FILES ${headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/apt-pkg)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/apt-inst.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
 flatify(${PROJECT_BINARY_DIR}/include/apt-pkg/ "${headers}")
diff --git a/apt-inst/apt-inst.pc.in b/apt-inst/apt-inst.pc.in
new file mode 100644
index 000000000..723d1a7c3
--- /dev/null
+++ b/apt-inst/apt-inst.pc.in
@@ -0,0 +1,9 @@
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
+
+Name: apt-inst
+Description: deb package format runtime library
+Version: @MAJOR@.@MINOR@
+Libs: -L${libdir} -lapt-inst
+Cflags: -I${includedir}
+Requires: apt-pkg
diff --git a/apt-pkg/CMakeLists.txt b/apt-pkg/CMakeLists.txt
index 2f5ad3200..44e5fd9c7 100644
--- a/apt-pkg/CMakeLists.txt
+++ b/apt-pkg/CMakeLists.txt
@@ -29,6 +29,8 @@ execute_process(COMMAND grep "^#define APT_PKG_RELEASE"
 message(STATUS "Building libapt-pkg ${MAJOR} (release ${MINOR})")
 set(APT_PKG_MAJOR ${MAJOR} PARENT_SCOPE) # exporting for methods/CMakeLists.txt
 
+configure_file(apt-pkg.pc.in ${CMAKE_CURRENT_BINARY_DIR}/apt-pkg.pc @ONLY)
+
 # Definition of the C++ files used to build the library - note that this
 # is expanded at CMake time, so you have to rerun cmake if you add or remove
 # a file (you can just run cmake . in the build directory)
@@ -65,6 +67,7 @@ add_version_script(apt-pkg)
 # Install the library and the header files
 install(TARGETS apt-pkg LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
 install(FILES ${headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/apt-pkg)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/apt-pkg.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
 flatify(${PROJECT_BINARY_DIR}/include/apt-pkg/ "${headers}")
 
 if(CMAKE_BUILD_TYPE STREQUAL "Coverage")
diff --git a/apt-pkg/apt-pkg.pc.in b/apt-pkg/apt-pkg.pc.in
new file mode 100644
index 000000000..d0f17d7ee
--- /dev/null
+++ b/apt-pkg/apt-pkg.pc.in
@@ -0,0 +1,8 @@
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
+
+Name: apt-pkg
+Description: package management runtime library
+Version: @MAJOR@.@MINOR@
+Libs: -L${libdir} -lapt-pkg -pthread
+Cflags: -I${includedir}
diff --git a/debian/libapt-pkg-dev.install b/debian/libapt-pkg-dev.install
index 42e7c34d5..563e99909 100644
--- a/debian/libapt-pkg-dev.install
+++ b/debian/libapt-pkg-dev.install
@@ -1,3 +1,4 @@
 usr/include/apt-pkg/
 usr/lib/*/libapt-inst*.so
 usr/lib/*/libapt-pkg*.so
+usr/lib/*/pkgconfig/apt-*.pc
diff --git a/debian/tests/control b/debian/tests/control
index 85b16e062..a0234b50b 100644
--- a/debian/tests/control
+++ b/debian/tests/control
@@ -1,8 +1,9 @@
-Tests: run-tests
+Tests: run-tests, pkg-config-test
 Restrictions: allow-stderr
 Depends: @, @builddeps@, dpkg, fakeroot, wget, stunnel4, lsof, db-util,
          gnupg (>= 2) | gnupg2,
          gnupg1 | gnupg (<< 2),
          gpgv (>= 2) | gpgv2,
          gpgv1 | gpgv (<< 2),
-         libfile-fcntllock-perl, python3-apt
+         libfile-fcntllock-perl, python3-apt,
+         pkg-config
diff --git a/debian/tests/pkg-config-test b/debian/tests/pkg-config-test
new file mode 100644
index 000000000..cb8d1ffb0
--- /dev/null
+++ b/debian/tests/pkg-config-test
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+set -e
+
+WORKDIR=$(mktemp -d)
+trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
+cd $WORKDIR
+cat <<EOF > pkgconfigtest.c
+#include <apt-pkg/init.h>
+
+int main()
+{
+    printf("Apt Version: %s \n", pkgVersion);
+    return 0;
+}
+EOF
+
+g++ -o pkgconfigtest pkgconfigtest.c `pkg-config --cflags --libs apt-pkg apt-inst`
+echo "build: OK"
+[ -x pkgconfigtest ]
+./pkgconfigtest
+echo "run: OK"
-- 
2.14.1


Reply to: