John Eckersberg
2012-Nov-05 15:16 UTC
[Libguestfs] [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?
John Eckersberg
2012-Nov-05 15:16 UTC
[Libguestfs] [PATCH] lib: debian support for package arch inspection
--- 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
Richard W.M. Jones
2012-Nov-05 16:23 UTC
[Libguestfs] [PATCH 0/1] lib: debian support for package arch inspection
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
Possibly Parallel Threads
- [PATCH] inspection: deb: Seperate epoch field from version
- [PATCH 1/3] inspect: add source and summary to internal add_application
- [PATCH v2 1/3] inspect: add source and summary to internal add_application
- [PATCH v2 0/3] New inspect_list_applications2 API
- [PATCH 0/2] New inspect_list_applications2 API