On Thu, 2011-09-15 at 15:29:43 +0000, Clint Adams wrote: > On Wed, Sep 14, 2011 at 05:19:07PM -0700, Steve Langasek wrote: > > It's premature to apply this in Debian of course since dpkg 1.16.0 does not > > include the multiarch changes, and it's even possible that there will be > > further API changes before this finally lands in Debian; but I figure it's > > better to forward the patch on than let it languish in the Ubuntu archive, > > at any rate. > > Thanks!
Here's an untested patch against the current API, which should make deets multiarch-aware. regards, guillem
>From 9b8e57a2015b8fa940937155eecd473cdaf05ba3 Mon Sep 17 00:00:00 2001 From: Guillem Jover <[email protected]> Date: Mon, 19 Mar 2012 18:38:24 +0100 Subject: [PATCH] Switch to new libdpkg 1.16.2 API --- luau.c | 23 +++++++++++++++++++---- 1 files changed, 19 insertions(+), 4 deletions(-) diff --git a/luau.c b/luau.c index c536f7a..8ef0e22 100644 --- a/luau.c +++ b/luau.c @@ -38,6 +38,7 @@ #define LIBDPKG_VOLATILE_API 1 #include <dpkg/dpkg.h> #include <dpkg/dpkg-db.h> +#include <dpkg/pkg-spec.h> #define LUA_LIB 1 #include <lua.h> @@ -60,6 +61,7 @@ const char thisname[] = "luau"; static int dpkg_status (lua_State * L) { + struct dpkg_error e; struct pkginfo *p; int j = 0; int n = lua_gettop (L); @@ -72,7 +74,13 @@ dpkg_status (lua_State * L) lua_error (L); } - p = pkg_db_find (lua_tostring (L, i)); + p = pkg_spec_parse_pkg (lua_tostring (L, i), &e); + if (!p) + { + lua_pushstring (L, e.str); + lua_error (L); + } + switch (p->status) { case stat_notinstalled: @@ -116,10 +124,10 @@ dpkg_pkglist (lua_State * L) lua_newtable (L); - for (iter = pkg_db_iter_new (); (pkg = pkg_db_iter_next (iter));) + for (iter = pkg_db_iter_new (); (pkg = pkg_db_iter_next_pkg (iter));) { lua_pushnumber (L, ++i); - lua_pushstring (L, pkg->name); + lua_pushstring (L, pkg_name(pkg, pnaw_nonambig)); lua_rawset (L, -3); } pkg_db_iter_free (iter); @@ -130,6 +138,7 @@ dpkg_pkglist (lua_State * L) static int dpkg_conffilelist (lua_State * L) { + struct dpkg_error e; struct pkginfo *p; struct conffile *c; int n = lua_gettop (L); @@ -141,7 +150,13 @@ dpkg_conffilelist (lua_State * L) lua_error (L); } - p = pkg_db_find (lua_tostring (L, 1)); + p = pkg_spec_parse_pkg (lua_tostring (L, 1), &e); + if (!p) + { + lua_pushstring (L, e.str); + lua_error (L); + } + if (!(c = p->installed.conffiles)) { lua_pushnil (L); -- 1.7.9.1

