[Libguestfs] [PATCH] inspection: deb: Seperate epoch field from version
Richard W.M. Jones
rjones at redhat.com
Tue Nov 18 20:42:41 UTC 2014
On Mon, Nov 17, 2014 at 10:48:01PM +0000, Nikos Skalkotos wrote:
> Return it in the app2_epoch field of the guestfs_application2 struct
>
> Signed-off-by: Nikos Skalkotos <skalkoto at gmail.com>
> ---
> src/inspect-apps.c | 25 +++++++++++++++++--------
> 1 file changed, 17 insertions(+), 8 deletions(-)
>
> diff --git a/src/inspect-apps.c b/src/inspect-apps.c
> index 8e645b7..bd4e6c1 100644
> --- a/src/inspect-apps.c
> +++ b/src/inspect-apps.c
> @@ -439,6 +439,7 @@ list_applications_deb (guestfs_h *g, struct inspect_fs *fs)
> FILE *fp;
> char line[1024];
> size_t len;
> + int32_t epoch = 0;
> CLEANUP_FREE char *name = NULL, *version = NULL, *release = NULL, *arch = NULL;
> int installed_flag = 0;
>
> @@ -482,23 +483,31 @@ list_applications_deb (guestfs_h *g, struct inspect_fs *fs)
> else if (STRPREFIX (line, "Version: ")) {
> free (version);
> free (release);
> - char *p = strchr (&line[9], '-');
> - if (p) {
> - *p = '\0';
> - version = safe_strdup (g, &line[9]);
> - release = safe_strdup (g, p+1);
> + char *p1, *p2;
> + p1 = strchr (&line[9], ':');
> + if (p1) {
> + *p1++ = '\0';
> + epoch = guestfs___parse_unsigned_int (g, &line[9]); /* -1 on error */
> + } else {
> + p1 = &line[9];
> + epoch = 0;
> + }
> + p2 = strchr (p1, '-');
> + if (p2) {
> + *p2++ = '\0';
> + release = safe_strdup (g, p2);
> } else {
> - version = safe_strdup (g, &line[9]);
> release = NULL;
> }
> + version = safe_strdup (g, p1);
> }
> 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 ? : "",
> + if (installed_flag && name && version && (epoch >= 0))
> + add_application (g, apps, name, "", epoch, version, release ? : "",
> arch ? : "", "", "", "", "");
> free (name);
> free (version);
Thanks - I have pushed this.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html
More information about the Libguestfs
mailing list