Source: deets
Source-Version: 0.2-3
Severity: wishlist
Tags: patch

Hi!

Here's a patch series with some fixes and an update for the upcoming
changes in the libdpkg 1.17.10 API. Some enum value names have
changed, but the switch to the pkg_status_name() function will shield
the code from that now and in the future, and will reduce code
duplication.

Thanks,
Guillem
From 14f596d035e15eb07f17218f8c7aeaddbf558b0b Mon Sep 17 00:00:00 2001
From: Guillem Jover <guil...@hadrons.org>
Date: Wed, 4 Jun 2014 02:43:33 +0200
Subject: [PATCH 1/3] Ignore stamp-h1

---
 .gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitignore b/.gitignore
index feccf6c..fadec6b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@ config.*
 config-aux/
 configure
 luau
+stamp-h1
-- 
2.0.0

From 7abc9b44121e022eaf70fe5d9cfe81dd2ec7b7c6 Mon Sep 17 00:00:00 2001
From: Guillem Jover <guil...@hadrons.org>
Date: Wed, 4 Jun 2014 02:44:03 +0200
Subject: [PATCH 2/3] Use AC_CHECK_LIB instead of AC_CHECK_FUNCS

The AC_CHECK_FUNCS macro only checks if the function is defined by the
libc, which was not triggering in this case as the function is exported
by libdpkg.
---
 configure.ac | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 0957c9e..65b48d8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -10,7 +10,9 @@ PKG_CHECK_MODULES(Lua, lua5.1)
 
 PKG_CHECK_MODULES([LIBDPKG], [libdpkg])
 
-AC_CHECK_FUNCS(dpkg_set_progname)
+AC_CHECK_LIB([dpkg], [dpkg_set_progname],
+             [AC_DEFINE(HAVE_DPKG_SET_PROGNAME, [1],
+                        [libdpkg provides dpkg_set_progname])])
 
 AC_CONFIG_FILES(Makefile)
 AC_OUTPUT
-- 
2.0.0

From 6bd1a3fe20c43626fd17946505e29960f57347a3 Mon Sep 17 00:00:00 2001
From: Guillem Jover <guil...@hadrons.org>
Date: Wed, 4 Jun 2014 02:45:58 +0200
Subject: [PATCH 3/3] Use new libdpkg pkg_status_name() function

This function is present since libdpkg 1.17.10, and avoids having to
keep the code up-to-date regarding the package states.
---
 configure.ac | 3 +++
 luau.c       | 4 ++++
 2 files changed, 7 insertions(+)

diff --git a/configure.ac b/configure.ac
index 65b48d8..e718d2a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -13,6 +13,9 @@ PKG_CHECK_MODULES([LIBDPKG], [libdpkg])
 AC_CHECK_LIB([dpkg], [dpkg_set_progname],
              [AC_DEFINE(HAVE_DPKG_SET_PROGNAME, [1],
                         [libdpkg provides dpkg_set_progname])])
+AC_CHECK_LIB([dpkg], [pkg_status_name],
+             [AC_DEFINE(HAVE_PKG_STATUS_NAME, [1],
+                        [libdpkg provides pkg_status_name])])
 
 AC_CONFIG_FILES(Makefile)
 AC_OUTPUT
diff --git a/luau.c b/luau.c
index c91dfb4..c6363ed 100644
--- a/luau.c
+++ b/luau.c
@@ -80,6 +80,9 @@ dpkg_status (lua_State * L)
 	  lua_error (L);
 	}
 
+#ifdef HAVE_PKG_STATUS_NAME
+      lua_pushstring (L, pkg_status_name (p));
+#else
       switch (p->status)
 	{
 	case stat_notinstalled:
@@ -109,6 +112,7 @@ dpkg_status (lua_State * L)
 	default:
 	  lua_pushinteger (L, p->status);
 	}
+#endif
       j++;
     }
   return j;
-- 
2.0.0

Reply via email to