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

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



Here is the right version of the patch.

I'm unable to test it because I'm on Ubuntu 16.04, and even when installing the backported autopkgtest, it fails with "erroneous package: Test dependencies are unsatisfiable."

On Fri, 30 Dec 2016 21:42:38 +0100 David Kalnischkies <david@kalnischkies.de> wrote:
> Hi,

> On Wed, Dec 28, 2016 at 12:24:41AM +0100, Corentin Noël wrote:
> > Please note that I haven't been able to test the new test in the debian
> > package.

> Feel free to ask specifics as this is supposed to be easyâ„¢ and more and
> more packages use this, so knowing how to run them should be useful for
> other packages as well.

> The actual invokation depends on your system/preferences, but the
> manpage 'autopkgtest' does a reasonable job of explaining them.
> Something like that should work:

> 0) [do once] setup sbuild + a (s)chroot "unstable-amd64-sbuild"
>    see https://wiki.debian.org/sbuild
> 1) autopkgtest /path/to/source/apt -- schroot unstable-amd64-sbuild

> That will built the packages first and then run all tests.


> >  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 +++--
> >  6 files changed, 31 insertions(+), 2 deletions(-)
> >  create mode 100644 apt-inst/apt-inst.pc.in
> >  create mode 100644 apt-pkg/apt-pkg.pc.in

> Looks like the test you refer to isn't included in the diff. :)


> > diff --git a/debian/tests/control b/debian/tests/control
> […]
> > -Tests: run-tests
> > +Tests: run-tests, autopkgtest

> Please don't name the new test like the tool running all these tests as
> that would be quite confusing (something can be said about having the
> other test named 'run-tests' â€¦).


> Best regards

> David Kalnischkies
>From 5e0f05ca69edda1a7d27a19c5c2e8ebcc2b2fe12 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Corentin=20No=C3=ABl?= <corentin@elementary.io>
Date: Sat, 29 Oct 2016 16:07:24 +0200
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/control                |  2 +-
 debian/libapt-pkg-dev.install |  1 +
 debian/tests/control          |  5 +++--
 debian/tests/pkg-config-test  | 22 ++++++++++++++++++++++
 8 files changed, 54 insertions(+), 3 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 f757823..d11111a 100644
--- a/apt-inst/CMakeLists.txt
+++ b/apt-inst/CMakeLists.txt
@@ -10,6 +10,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})
 
@@ -23,4 +25,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 0000000..c752f46
--- /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@
+
+Name: apt-inst
+Description: deb package format runtime library
+Version: @MAJOR@.@MINOR@
+Libs: -L${libdir} -lapt-inst
+Cflags: -I${includedir}/apt-pkg
+Requires: apt-pkg
diff --git a/apt-pkg/CMakeLists.txt b/apt-pkg/CMakeLists.txt
index 25ed13e..3d58235 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
 file(GLOB_RECURSE library "*.cc"  "${CMAKE_CURRENT_BINARY_DIR}/tagfile-keys.cc")
 file(GLOB_RECURSE headers "*.h")
@@ -62,6 +64,7 @@ add_version_script(apt-pkg)
 install(TARGETS apt-pkg LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
 install(FILES ${headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/apt-pkg)
 flatify(${PROJECT_BINARY_DIR}/include/apt-pkg/ "${headers}")
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/apt-pkg.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
 
 if(CMAKE_BUILD_TYPE STREQUAL "Coverage")
   target_link_libraries(apt-pkg PUBLIC noprofile)
diff --git a/apt-pkg/apt-pkg.pc.in b/apt-pkg/apt-pkg.pc.in
new file mode 100644
index 0000000..ea762f6
--- /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@
+
+Name: apt-pkg
+Description: package management runtime library
+Version: @MAJOR@.@MINOR@
+Libs: -L${libdir} -lapt-pkg
+Cflags: -I${includedir}/apt-pkg
diff --git a/debian/control b/debian/control
index 96bbef3..5cee1c2 100644
--- a/debian/control
+++ b/debian/control
@@ -7,7 +7,7 @@ Uploaders: Michael Vogt <mvo@debian.org>,
            David Kalnischkies <donkult@debian.org>
 Standards-Version: 3.9.8
 Build-Depends: cmake (>= 3.4),
-               debhelper (>= 9.20160709~),
+               debhelper (>= 9.2016~),
                dh-systemd,
                docbook-xml,
                docbook-xsl,
diff --git a/debian/libapt-pkg-dev.install b/debian/libapt-pkg-dev.install
index 42e7c34..563e999 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 a282584..eaa1c6d 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@, 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 0000000..a6da5f4
--- /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
+
+gcc -o pkgconfigtest pkgconfigtest.c `pkg-config --cflags --libs apt-pkg apt-inst`
+echo "build: OK"
+[ -x pkgconfigtest ]
+./pkgconfigtest
+echo "run: OK"
-- 
2.7.4


Reply to: