alexk / rpms / rpm

Forked from rpms/rpm 2 years ago
Clone
83a7c7
From 2ec0832287bd1443ebf336f8a98293f30bfa2036 Mon Sep 17 00:00:00 2001
83a7c7
Message-Id: <2ec0832287bd1443ebf336f8a98293f30bfa2036.1554983205.git.pmatilai@redhat.com>
83a7c7
From: Panu Matilainen <pmatilai@redhat.com>
83a7c7
Date: Mon, 18 Mar 2019 15:24:54 +0200
83a7c7
Subject: [PATCH 1/3] Make rpmsign exit values more consistent with our other
83a7c7
 tools
83a7c7
83a7c7
rpmPkgSign*() return -1 for failure, which is not that helpful when
83a7c7
returned to shell and the way it was counted could easily wrap around
83a7c7
when signing multiple packages. Return number of failures similarly to
83a7c7
how rpm -q and frieds does, avoid overflows and xargs special value 255.
83a7c7
---
83a7c7
 rpmsign.c | 8 +++++---
83a7c7
 1 file changed, 5 insertions(+), 3 deletions(-)
83a7c7
83a7c7
diff --git a/rpmsign.c b/rpmsign.c
83a7c7
index ae86f666d..1a5cd59c2 100644
83a7c7
--- a/rpmsign.c
83a7c7
+++ b/rpmsign.c
83a7c7
@@ -134,7 +134,8 @@ static int doSign(poptContext optCon, struct rpmSignArgs *sargs)
83a7c7
     const char *arg;
83a7c7
     rc = 0;
83a7c7
     while ((arg = poptGetArg(optCon)) != NULL) {
83a7c7
-	rc += rpmPkgSign(arg, sargs);
83a7c7
+	if (rpmPkgSign(arg, sargs) < 0)
83a7c7
+	    rc++;
83a7c7
     }
83a7c7
 
83a7c7
 exit:
83a7c7
@@ -175,7 +176,8 @@ int main(int argc, char *argv[])
83a7c7
     case MODE_DELSIGN:
83a7c7
 	ec = 0;
83a7c7
 	while ((arg = poptGetArg(optCon)) != NULL) {
83a7c7
-	    ec += rpmPkgDelSign(arg, &sargs);
83a7c7
+	    if (rpmPkgDelSign(arg, &sargs) < 0)
83a7c7
+		ec++;
83a7c7
 	}
83a7c7
 	break;
83a7c7
     case MODE_NONE:
83a7c7
@@ -188,5 +190,5 @@ int main(int argc, char *argv[])
83a7c7
 
83a7c7
 exit:
83a7c7
     rpmcliFini(optCon);
83a7c7
-    return ec;
83a7c7
+    return RETVAL(ec);
83a7c7
 }
83a7c7
-- 
83a7c7
2.20.1
83a7c7