[Pkg-libvirt-commits] [libguestfs] 79/116: inspection: deb: Seperate epoch field from version

Hilko Bengen bengen at moszumanska.debian.org
Wed Nov 26 22:05:20 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to annotated tag debian/1%1.29.10-1
in repository libguestfs.

commit 6aaff1fffaa7d62bf75d55cd99ed291d7a143ed3
Author: Nikos Skalkotos <skalkoto at gmail.com>
Date:   Mon Nov 17 22:48:01 2014 +0000

    inspection: deb: Seperate epoch field from version
    
    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);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list