RPM Community Forums

Mailing List Message of <rpm-devel>

Changing /usr/bin/rpm exit codes

From: Jeff Johnson <n3npq@mac.com>
Date: Sat 30 Aug 2008 - 16:52:32 CEST
Message-id: <FF1FD8DA-A31E-42F8-9EF1-1085E6D773FF@mac.com>
I think its time to change the exit code conventions for rpm  

Traditionally, rpm attempts to return the "number of failed items" where
an item is usually a package.

There are several problems with that that convention:

1) a status return is 8 bits
	The status code wraps when > 255 (with other secret sauce
          hackery for xargs deficiencies) (from rpmqv.c:1064):

              /* XXX don't overflow single byte exit status */
              /* XXX status 255 is special to xargs(1) */
              if (ec > 254) ec = 254;

2) the "number of failed items" is rather uninformative
            First of all "items" is usually, but not always,  
identical to packages.

            And the fundamental flaw is that applications want/need  
to know
            "why" rpm failed, not how many items failed.

Enumerating all possible failures of rpm execution in order to map into
an exit code would quickly exceed 8 bits as well.

(aside) IMHO there's no point in trying to represent each and every  
failure point in rpm
with an explicit identifier, details about errors should be returned  
through other means,
using informative strings, rather than attempting some ever  
increasing silly enumeration
of failure points.

However, rpm internally tries to use rpmRC codes as much as possible  
is a retrofit to pre-existing code so not used everywhere. I  
routinely try to use
these return codes in all new development as much as possible):

/** \ingroup rpmio
  * RPM return codes.
typedef enum rpmRC_e {
     RPMRC_OK            = 0,    /*!< Generic success code */
     RPMRC_NOTFOUND      = 1,    /*!< Generic not found code. */
     RPMRC_FAIL          = 2,    /*!< Generic failure code. */
     RPMRC_NOTTRUSTED    = 3,    /*!< Signature is OK, but key is not  
trusted. */
     RPMRC_NOKEY         = 4     /*!< Public key is unavailable. */
} rpmRC;

So as a starting point, I'd like to see rpm executables start to  
follow the same convention
as rpmRC uses.

Other opinions?

73 de Jeff
Received on Sat Aug 30 18:04:11 2008
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.