Control: tags -1 + patch

Hi Andrej,

On Wed, Dec 13, 2023 at 06:19:25PM +0100, Andrej Shadura wrote:
> Yes, I think short-term generating pkgconf.pc/pkg-config.pc instead of using 
> the in-built ones would be good. Long-term this should be fixed upstream, and 
> the upstream agreed.

I looked into this and have something that seems to work even though I'm
not totally happy with it.

Downsides:
 * pkgconf_builtin_pkg_get is a C-API function. It continues to exist,
   but it'll now always return NULL. Any user of it, will now break.
 * pkgconf_builtin_pkg_get also is pretty much unfixable as an API. It
   returns a "pkgconf_pkg_t *" with undefined lifetime. This was fine
   earlier as it was returning const data, but once we make this
   dependent on the personality, it wants to return dynamic data and the
   only way it can do that now is leak that data, which is bad. There is
   no reasonable way to fix this API.
 * The generated pkgconf.pc and pkg-config.pc very much now duplicate
   the personality files. This violates DRY and may pose future
   consistency issues.
 * It also causes lintian to notice multilibs and complain with an
   error. The thing that lintian complains about was that way earlier
   it's just that it now notices. You may want to add an override.

That said, the patch fixes the output and that's what this bug is a
bout, right?

I also note that the patch intentionally removes the builtin values such
that any future modification makes the patch fail to apply and you
notice required updates to the patch.

What do you think?

Helmut
diff --minimal -Nru pkgconf-1.8.1/debian/changelog 
pkgconf-1.8.1/debian/changelog
--- pkgconf-1.8.1/debian/changelog      2023-01-22 12:06:42.000000000 +0100
+++ pkgconf-1.8.1/debian/changelog      2023-12-14 07:43:18.000000000 +0100
@@ -1,3 +1,11 @@
+pkgconf (1.8.1-1.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Let virtual pc files pkgconf and pkg-config emit personality-dependent
+    values. (Closes: #-1)
+
+ -- Helmut Grohne <hel...@subdivi.de>  Thu, 14 Dec 2023 07:43:18 +0100
+
 pkgconf (1.8.1-1) unstable; urgency=high
 
   * New upstream release.
diff --minimal -Nru 
pkgconf-1.8.1/debian/patches/architecture_dependent_builtins.patch 
pkgconf-1.8.1/debian/patches/architecture_dependent_builtins.patch
--- pkgconf-1.8.1/debian/patches/architecture_dependent_builtins.patch  
1970-01-01 01:00:00.000000000 +0100
+++ pkgconf-1.8.1/debian/patches/architecture_dependent_builtins.patch  
2023-12-14 07:43:18.000000000 +0100
@@ -0,0 +1,151 @@
+--- pkgconf-1.8.1.orig/libpkgconf/pkg.c
++++ pkgconf-1.8.1/libpkgconf/pkg.c
+@@ -921,83 +921,6 @@
+       return 1;
+ }
+ 
+-static pkgconf_pkg_t pkg_config_virtual = {
+-      .id = "pkg-config",
+-      .realname = "pkg-config",
+-      .description = "virtual package defining pkg-config API version 
supported",
+-      .url = PACKAGE_BUGREPORT,
+-      .version = PACKAGE_VERSION,
+-      .flags = PKGCONF_PKG_PROPF_STATIC,
+-      .vars = {
+-              .head = &(pkgconf_node_t){
+-                      .next = &(pkgconf_node_t){
+-                              .next = &(pkgconf_node_t){
+-                                      .data = &(pkgconf_tuple_t){
+-                                              .key = "pc_system_libdirs",
+-                                              .value = SYSTEM_LIBDIR,
+-                                      }
+-                              },
+-                              .data = &(pkgconf_tuple_t){
+-                                      .key = "pc_system_includedirs",
+-                                      .value = SYSTEM_INCLUDEDIR,
+-                              }
+-                      },
+-                      .data = &(pkgconf_tuple_t){
+-                              .key = "pc_path",
+-                              .value = PKG_DEFAULT_PATH,
+-                      },
+-              },
+-              .tail = NULL,
+-      }
+-};
+-
+-static pkgconf_pkg_t pkgconf_virtual = {
+-      .id = "pkgconf",
+-      .realname = "pkgconf",
+-      .description = "virtual package defining pkgconf API version supported",
+-      .url = PACKAGE_BUGREPORT,
+-      .version = PACKAGE_VERSION,
+-      .flags = PKGCONF_PKG_PROPF_STATIC,
+-      .vars = {
+-              .head = &(pkgconf_node_t){
+-                      .next = &(pkgconf_node_t){
+-                              .next = &(pkgconf_node_t){
+-                                      .data = &(pkgconf_tuple_t){
+-                                              .key = "pc_system_libdirs",
+-                                              .value = SYSTEM_LIBDIR,
+-                                      }
+-                              },
+-                              .data = &(pkgconf_tuple_t){
+-                                      .key = "pc_system_includedirs",
+-                                      .value = SYSTEM_INCLUDEDIR,
+-                              }
+-                      },
+-                      .data = &(pkgconf_tuple_t){
+-                              .key = "pc_path",
+-                              .value = PKG_DEFAULT_PATH,
+-                      },
+-              },
+-              .tail = NULL,
+-      },
+-};
+-
+-typedef struct {
+-      const char *name;
+-      pkgconf_pkg_t *pkg;
+-} pkgconf_builtin_pkg_pair_t;
+-
+-/* keep these in alphabetical order */
+-static const pkgconf_builtin_pkg_pair_t pkgconf_builtin_pkg_pair_set[] = {
+-      {"pkg-config", &pkg_config_virtual},
+-      {"pkgconf", &pkgconf_virtual},
+-};
+-
+-static int pkgconf_builtin_pkg_pair_cmp(const void *key, const void *ptr)
+-{
+-      const pkgconf_builtin_pkg_pair_t *pair = ptr;
+-      return strcasecmp(key, pair->name);
+-}
+-
+ /*
+  * !doc
+  *
+@@ -1012,11 +935,7 @@
+ pkgconf_pkg_t *
+ pkgconf_builtin_pkg_get(const char *name)
+ {
+-      const pkgconf_builtin_pkg_pair_t *pair = bsearch(name, 
pkgconf_builtin_pkg_pair_set,
+-              PKGCONF_ARRAY_SIZE(pkgconf_builtin_pkg_pair_set), 
sizeof(pkgconf_builtin_pkg_pair_t),
+-              pkgconf_builtin_pkg_pair_cmp);
+-
+-      return (pair != NULL) ? pair->pkg : NULL;
++      return NULL;
+ }
+ 
+ typedef bool (*pkgconf_vercmp_res_func_t)(const char *a, const char *b);
+--- pkgconf-1.8.1.orig/Makefile.am
++++ pkgconf-1.8.1/Makefile.am
+@@ -7,7 +7,7 @@
+ pkg_default_dir        = @PKG_DEFAULT_PATH@
+ personality_dir        = @PERSONALITY_PATH@
+ pkgconfigdir           = $(libdir)/pkgconfig
+-nodist_pkgconfig_DATA  = libpkgconf.pc
++nodist_pkgconfig_DATA  = libpkgconf.pc pkgconf.pc pkg-config.pc
+ 
+ AM_CFLAGS = -DPERSONALITY_PATH=\"$(personality_dir)\" 
-DPKG_DEFAULT_PATH=\"$(pkg_default_dir)\" 
-DSYSTEM_INCLUDEDIR=\"$(system_includedir)\" 
-DSYSTEM_LIBDIR=\"$(system_libdir)\"
+ 
+--- pkgconf-1.8.1.orig/configure.ac
++++ pkgconf-1.8.1/configure.ac
+@@ -60,5 +60,5 @@
+ AC_PROG_INSTALL
+ AC_PROG_LN_S
+ 
+-AC_CONFIG_FILES([Makefile Kyuafile libpkgconf.pc tests/Kyuafile 
tests/test_env.sh])
++AC_CONFIG_FILES([Makefile Kyuafile libpkgconf.pc pkgconf.pc pkg-config.pc 
tests/Kyuafile tests/test_env.sh])
+ AC_OUTPUT
+--- /dev/null
++++ pkgconf-1.8.1/pkg-config.pc.in
+@@ -0,0 +1,8 @@
++pc_system_libdirs=@SYSTEM_LIBDIR@
++pc_system_includedirs=@SYSTEM_INCLUDEDIR@
++pc_path=@PKG_DEFAULT_PATH@
++
++Name: pkg-config
++Description: virtual package defining pkg-config API version supported
++URL: @PACKAGE_BUGREPORT@
++Version: @PACKAGE_VERSION@
+--- /dev/null
++++ pkgconf-1.8.1/pkgconf.pc.in
+@@ -0,0 +1,8 @@
++pc_system_libdirs=@SYSTEM_LIBDIR@
++pc_system_includedirs=@SYSTEM_INCLUDEDIR@
++pc_path=@PKG_DEFAULT_PATH@
++
++Name: pkgconf
++Description: virtual package defining pkgconf API version supported
++URL: @PACKAGE_BUGREPORT@
++Version: @PACKAGE_VERSION@
+--- pkgconf-1.8.1.orig/tests/regress.sh
++++ pkgconf-1.8.1/tests/regress.sh
+@@ -211,6 +211,7 @@
+ 
+ virtual_variable_body()
+ {
++      export PKG_CONFIG_PATH="${selfdir}/.."
+       atf_check -s exit:0 \
+               pkgconf --exists pkg-config
+       atf_check -s exit:0 \
diff --minimal -Nru pkgconf-1.8.1/debian/patches/series 
pkgconf-1.8.1/debian/patches/series
--- pkgconf-1.8.1/debian/patches/series 2023-01-22 12:06:42.000000000 +0100
+++ pkgconf-1.8.1/debian/patches/series 2023-12-14 07:43:10.000000000 +0100
@@ -3,3 +3,4 @@
 pkg.m4/0003-trivial-sync-of-pkg.m4-from-freedesktop.patch
 fix-exists-print-errors.patch
 regenerate-docs-for-libpkgconf.patch
+architecture_dependent_builtins.patch
diff --minimal -Nru pkgconf-1.8.1/debian/pkgconf.install 
pkgconf-1.8.1/debian/pkgconf.install
--- pkgconf-1.8.1/debian/pkgconf.install        2023-01-22 12:06:42.000000000 
+0100
+++ pkgconf-1.8.1/debian/pkgconf.install        2023-12-14 07:43:18.000000000 
+0100
@@ -1,2 +1,3 @@
 usr/share/aclocal
 usr/share/man
+usr/lib/*/pkgconfig/pkg*.pc

Reply via email to