RPM Community Forums

Mailing List Message of <rpm-cvs>

[CVS] RPM: rpm/ CHANGES rpm/rpmio/ macro.c

From: Ralf S. Engelschall <rse@rpm5.org>
Date: Fri 01 Feb 2008 - 14:51:24 CET
Message-Id: <20080201135124.C7861348474@rpm5.org>
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Ralf S. Engelschall
  Root:   /v/rpm/cvs                       Email:  rse@rpm5.org
  Module: rpm                              Date:   01-Feb-2008 14:51:24
  Branch: HEAD                             Handle: 2008020113512301

  Modified files:
    rpm                     CHANGES
    rpm/rpmio               macro.c

  Log:
    Add new RPM macro "%{uuid:[<version>[, <ns>, <data>]]}" for generating
    UUIDs of version 1, 3, 4 or 5. This allows one to generate UUIDs
    directly from within RPM macros files or from .spec files.
    
    Examples:
    
    $ ./rpm --eval '%{uuid}' | uuid -d -
    encode: STR:     78ed984e-d0cc-11dc-926c-0019d13dcdc5
            SIV:     160741023020338677322047218926661520837
    decode: variant: DCE 1.1, ISO/IEC 11578:1996
            version: 1 (time and node based)
            content: time:  2008-02-01 13:49:13.501499.0 UTC
                     clock: 4716 (usually random)
                     node:  00:19:d1:3d:cd:c5 (global unicast)
    
    $ ./rpm --eval '%{uuid:3 ns:URL http://rpm5.org/}' | uuid -d -
    encode: STR:     d74931ab-be1d-3b9f-8798-01a0fe9ce9e1
            SIV:     286164064209353816239503491618855250401
    decode: variant: DCE 1.1, ISO/IEC 11578:1996
            version: 3 (name based, MD5)
            content: D7:49:31:AB:BE:1D:0B:9F:07:98:01:A0:FE:9C:E9:E1
                     (not decipherable: MD5 message digest only)
    
    $ ./rpm --eval '%{uuid:4}' | uuid -d -
    encode: STR:     6a811350-afc6-4ca5-851c-2c3bf7dbc353
            SIV:     141568365606387151798945188698482525011
    decode: variant: DCE 1.1, ISO/IEC 11578:1996
            version: 4 (random data based)
            content: 6A:81:13:50:AF:C6:0C:A5:05:1C:2C:3B:F7:DB:C3:53
                     (no semantics: random data only)

  Summary:
    Revision    Changes     Path
    1.2122      +1  -0      rpm/CHANGES
    2.182       +36 -0      rpm/rpmio/macro.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.2121 -r1.2122 CHANGES
  --- rpm/CHANGES	1 Feb 2008 13:48:46 -0000	1.2121
  +++ rpm/CHANGES	1 Feb 2008 13:51:23 -0000	1.2122
  @@ -1,4 +1,5 @@
   5.0.0 -> 5.1a1:
  +    - rse: add new RPM macro "%{uuid:[<version>[, <ns>, <data>]]}" for generating UUIDs of version 1, 3, 4 or 5
       - rse: add new C API function rpmuuidMake() for generating UUIDs of version 1, 3, 4 or 5
       - rse: provide both ORIGINTIME (based on INSTALLTIME) and ORIGINTID (based on INSTALLTID)
       - jbj: pedantic identification of Foo (not foo) syscalls in --fsmdebug spew.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/macro.c
  ============================================================================
  $ cvs diff -u -r2.181 -r2.182 macro.c
  --- rpm/rpmio/macro.c	31 Jan 2008 21:10:13 -0000	2.181
  +++ rpm/rpmio/macro.c	1 Feb 2008 13:51:24 -0000	2.182
  @@ -1329,6 +1329,41 @@
   #else
           (void) mktemp(b);
   #endif
  +    } else if (STREQ("uuid", f, fn)) {
  +        int uuid_version;
  +        const char *uuid_ns;
  +        const char *uuid_data;
  +        char *cp;
  +        size_t n;
  +
  +        uuid_version = 1;
  +        uuid_ns = NULL;
  +        uuid_data = NULL;
  +        cp = buf;
  +        if ((n = strspn(cp, " \t\n")) > 0)
  +            cp += n;
  +        if ((n = strcspn(cp, " \t\n")) > 0) {
  +            uuid_version = (int)strtol(cp, (char **)NULL, 10);
  +            cp += n;
  +            if ((n = strspn(cp, " \t\n")) > 0)
  +                cp += n;
  +            if ((n = strcspn(cp, " \t\n")) > 0) {
  +                uuid_ns = cp;
  +                cp += n;
  +                *cp++ = '\0';
  +                if ((n = strspn(cp, " \t\n")) > 0)
  +                    cp += n;
  +                if ((n = strcspn(cp, " \t\n")) > 0) {
  +                    uuid_data = cp;
  +                    cp += n;
  +                    *cp++ = '\0';
  +                }
  +            }
  +        }
  +        if (rpmuuidMake(uuid_version, uuid_ns, uuid_data, buf, NULL))
  +            rpmlog(RPMLOG_ERR, "failed to create UUID\n");
  +        else
  +            b = buf;
       } else if (STREQ("S", f, fn)) {
   	for (b = buf; (c = (int)*b) && xisdigit(c);)
   	    b++;
  @@ -1665,6 +1700,7 @@
   	    STREQ("verbose", f, fn) ||
   	    STREQ("uncompress", f, fn) ||
   	    STREQ("mkstemp", f, fn) ||
  +	    STREQ("uuid", f, fn) ||
   	    STREQ("url2path", f, fn) ||
   	    STREQ("u2p", f, fn) ||
   	    STREQ("S", f, fn) ||
  @@ .
Received on Fri Feb 1 14:51:24 2008
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.