[PATCH 0/1] lib: debian support for package arch inspection
This adds package arch inspection for deb-based systems. The patch returns package arch as given by dpkg, which means that it returns 'amd64' instead of 'x86_64', for example. Whether or not we should standardize this to match rpm output is up for debate. I see other places such as guestfs_file_architecture that use the rpm-style arch. I can understand though where a user of guestfs inspecting deb-based hosts would rather get back the "native" strings. Thoughts?
--- src/inspect-apps.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/inspect-apps.c b/src/inspect-apps.c index 9307eb2..ce4756d 100644 --- a/src/inspect-apps.c +++ b/src/inspect-apps.c @@ -402,7 +402,7 @@ list_applications_deb (guestfs_h *g, struct inspect_fs *fs) FILE *fp = NULL; char line[1024]; size_t len; - char *name = NULL, *version = NULL, *release = NULL; + char *name = NULL, *version = NULL, *release = NULL, *arch = NULL; int installed_flag = 0; fp = fopen (status, "r"); @@ -450,14 +450,19 @@ list_applications_deb (guestfs_h *g, struct inspect_fs *fs) release = NULL; } } + else if (STRPREFIX (line, "Architecture: ")) { + free (arch); + arch = safe_strdup (g, &line[14]); + } else if (STREQ (line, "")) { if (installed_flag && name && version) add_application (g, apps, name, "", 0, version, release ? : "", - "", "", "", "", ""); + arch ? : "", "", "", "", ""); free (name); free (version); free (release); - name = version = release = NULL; + free (arch); + name = version = release = arch = NULL; installed_flag = 0; } } -- 1.7.11.7
On Mon, Nov 05, 2012 at 10:16:35AM -0500, John Eckersberg wrote:
This adds package arch inspection for deb-based systems. The patch returns package arch as given by dpkg, which means that it returns 'amd64' instead of 'x86_64', for example. Whether or not we should standardize this to match rpm output is up for debate. I see other places such as guestfs_file_architecture that use the rpm-style arch. I can understand though where a user of guestfs inspecting deb-based hosts would rather get back the "native" strings.
Thanks, ACKed and pushed. I tend to agree with your decision to keep the native string, for the following reasons: - any attempt by libguestfs to rewrite these arch strings is prone to go wrong for unexpected reasons - avoids losing information - the strings are not well-standardized anyway (eg. i386 vs i686) so the caller may still want to do their own canonicalization Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v
participants (2)
-
John Eckersberg -
Richard W.M. Jones