RPM Community Forums

Mailing List Message of <rpm-cvs>

[CVS] RPM: rpm/ CHANGES TODO configure.ac rpm/lib/ .cvsignore Makefile...

From: Ralf S. Engelschall <rse@rpm5.org>
Date: Sun 02 Dec 2007 - 16:33:54 CET
Message-Id: <20071202153354.E84DA34845E@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:   02-Dec-2007 16:33:54
  Branch: HEAD                             Handle: 2007120215335301

  Added files:
    rpm/lib                 rpmversion.c rpmversion.h.in
  Modified files:
    rpm                     CHANGES TODO configure.ac
    rpm/lib                 .cvsignore Makefile.am librpm.vers rpmlib.h

  Log:
    Finally provide RPM version in API via macros
       RPM_{VERSION,TIMESTAMP,VENDOR}
    (for compile-time checks) and functions
       rpm_{version,timestamp,vendor}()
    (for run-time checks).
    
    The important point here is that the version and timestamp are encoded
    into a steadily increasing number which can be easily compared.
    Additionally, the encoding is done with the C pre-processor so one can
    already perform the comparison during compile-time.

  Summary:
    Revision    Changes     Path
    1.1905      +1  -0      rpm/CHANGES
    1.30        +0  -1      rpm/TODO
    2.258       +51 -1      rpm/configure.ac
    1.9         +1  -0      rpm/lib/.cvsignore
    2.168       +2  -2      rpm/lib/Makefile.am
    1.27        +3  -0      rpm/lib/librpm.vers
    2.450       +1  -0      rpm/lib/rpmlib.h
    2.1         +23 -0      rpm/lib/rpmversion.c
    2.1         +139 -0     rpm/lib/rpmversion.h.in
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.1904 -r1.1905 CHANGES
  --- rpm/CHANGES	1 Dec 2007 19:54:20 -0000	1.1904
  +++ rpm/CHANGES	2 Dec 2007 15:33:53 -0000	1.1905
  @@ -1,4 +1,5 @@
   5.0a2 -> 5.0a3:
  +    - rse: provide RPM version in API via macros RPM_{VERSION,TIMESTAMP,VENDOR} and functions rpm_{version,timestamp,vendor}
       - jbj: pkgio: hdlist readers need RPMRC_NOTFOUND EOF indicator.
       - jbj: pkgio: drill in sufficient debugging to sort per/python I/O issues.
       - jbj: re-add symbols for perl "make test". hmm, headerRead failure todo++.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/TODO
  ============================================================================
  $ cvs diff -u -r1.29 -r1.30 TODO
  --- rpm/TODO	30 Nov 2007 15:43:36 -0000	1.29
  +++ rpm/TODO	2 Dec 2007 15:33:53 -0000	1.30
  @@ -49,7 +49,6 @@
     *CANDO* items.
   
     o to be resolved before RPM 5.0b1:
  -    - rse: provide RPM version number in C API for "#if RPM_VERSION > 0xXXXXXX" comparisons
       - rse: xar/ has weak (think RPM_CHECK_LIB) support its third-party libraries LibXML, OpenSSL, etc.
       - afb: remove xar and libxar from default install with internal xar (use through rpm and librpm*)
       - afb: make sure %standalone devtool target includes support for xar
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/configure.ac
  ============================================================================
  $ cvs diff -u -r2.257 -r2.258 configure.ac
  --- rpm/configure.ac	1 Dec 2007 17:54:00 -0000	2.257
  +++ rpm/configure.ac	2 Dec 2007 15:33:53 -0000	2.258
  @@ -9,6 +9,7 @@
   AC_PREREQ(2.60)
   AC_DEFUN([PACKAGE_BUGREPORT_DEFAULT], [rpm-devel@rpm5.org])
   AC_INIT(rpm, [5.0.DEVEL], [PACKAGE_BUGREPORT_DEFAULT])
  +PACKAGE_TIMESTAMP="2007" dnl # YYYY[-MM[-DD[ HH[:MM]]]]
   AC_MSG_TITLE([RPM Package Manager (RPM)], [$PACKAGE_VERSION])
   
   AC_MSG_HEADER([INITIALIZATION])
  @@ -37,6 +38,55 @@
   AC_SUBST(LT_REVISION, 0)
   AC_SUBST(LT_AGE,      0)
   
  +dnl # provide RPM exported version
  +RPM_VERSION="0,0,_,0,0,_"
  +case "$PACKAGE_VERSION" in
  +    *.*.DEVEL )
  +        RPM_VERSION=`echo "$PACKAGE_VERSION" |\
  +            sed -e 's;^\([[^.]]*\)\.\([[^.]]*\).*;\1,\2,_,0,0,_;'`
  +        ;;
  +    *.*.SNAPSHOT.* )
  +        RPM_VERSION=`echo "$PACKAGE_VERSION" |\
  +            sed -e 's;^\([[^.]]*\)\.\([[^.]]*\).*;\1,\2,_,0,0,s;'`
  +        ;;
  +    *.*a* )
  +        RPM_VERSION=`echo "$PACKAGE_VERSION" |\
  +            sed -e 's;^;X;' \
  +                -e 's;^X\([[^.]]*\)\.\([[^.]]*\)a\([[^.]]*\)\.\([[^.]]*\)$;\1,\2,a,\3,\4,_;' \
  +                -e 's;^X\([[^.]]*\)\.\([[^.]]*\)a\([[^.]]*\)$;\1,\2,a,\3,0,_;'`
  +        ;;
  +    *.*b* )
  +        RPM_VERSION=`echo "$PACKAGE_VERSION" |\
  +            sed -e 's;^;X;' \
  +                -e 's;^X\([[^.]]*\)\.\([[^.]]*\)b\([[^.]]*\)\.\([[^.]]*\)$;\1,\2,b,\3,\4,_;' \
  +                -e 's;^X\([[^.]]*\)\.\([[^.]]*\)b\([[^.]]*\)$;\1,\2,b,\3,0,_;'`
  +        ;;
  +    *.*rc* )
  +        RPM_VERSION=`echo "$PACKAGE_VERSION" |\
  +            sed -e 's;^;X;' \
  +                -e 's;^X\([[^.]]*\)\.\([[^.]]*\)rc\([[^.]]*\)\.\([[^.]]*\)$;\1,\2,c,\3,\4,_;' \
  +                -e 's;^X\([[^.]]*\)\.\([[^.]]*\)rc\([[^.]]*\)$;\1,\2,c,\3,0,_;'`
  +        ;;
  +    *.*.* )
  +        RPM_VERSION=`echo "$PACKAGE_VERSION" |\
  +            sed -e 's;^;X;' \
  +                -e 's;^X\([[^.]]*\)\.\([[^.]]*\)\.\([[^.]]*\)\.\([[^.]]*\)$;\1,\2,c,\3,\4,_;' \
  +                -e 's;^X\([[^.]]*\)\.\([[^.]]*\)\.\([[^.]]*\)$;\1,\2,r,\3,0,_;'`
  +        ;;
  +esac
  +RPM_TIMESTAMP=`echo "$PACKAGE_TIMESTAMP" |\
  +    sed -e 's;^;X;' \
  +        -e 's;^X\([[0-9]]*\)-\([[0-9]]*\)-\([[0-9]]*\) \([[0-9]]*\):\([[0-9]]*\)$;\1,\2,\3,\4,\5;' \
  +        -e 's;^X\([[0-9]]*\)-\([[0-9]]*\)-\([[0-9]]*\) \([[0-9]]*\)$;\1,\2,\3,\4,0;' \
  +        -e 's;^X\([[0-9]]*\)-\([[0-9]]*\)-\([[0-9]]*\)$;\1,\2,\3,0,0;' \
  +        -e 's;^X\([[0-9]]*\)-\([[0-9]]*\)$;\1,\2,0,0,0;' \
  +        -e 's;^X\([[0-9]]*\)$;\1,0,0,0,0;' \
  +        -e 's;^X.*$;0,0,0,0,0;'`
  +RPM_VENDOR="'R','P','M','5'"
  +AC_SUBST([RPM_VERSION])
  +AC_SUBST([RPM_TIMESTAMP])
  +AC_SUBST([RPM_VENDOR])
  +
   dnl # set of available languages.
   ALL_LINGUAS="cs da de fi fr gl id is ja ko nb pl pt pt_BR ro ru sk sl sr@Latn sv tr uk"
   
  @@ -1375,7 +1425,7 @@
       scripts/macros.python tools/Makefile misc/Makefile doc/Makefile
       doc/manual/Makefile doc/fr/Makefile doc/ja/Makefile doc/ko/Makefile
       doc/pl/Makefile doc/ru/Makefile doc/sk/Makefile python/Makefile
  -    python/rpm/Makefile scripts/rpm.pc
  +    python/rpm/Makefile scripts/rpm.pc lib/rpmversion.h
       rpmconstant/Makefile
   ])
   
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/.cvsignore
  ============================================================================
  $ cvs diff -u -r1.8 -r1.9 .cvsignore
  --- rpm/lib/.cvsignore	30 May 2007 02:49:34 -0000	1.8
  +++ rpm/lib/.cvsignore	2 Dec 2007 15:33:53 -0000	1.9
  @@ -3,6 +3,7 @@
   Makefile
   Makefile.in
   getdate.c
  +rpmversion.h
   .libs
   *.la
   *.lcd
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/Makefile.am
  ============================================================================
  $ cvs diff -u -r2.167 -r2.168 Makefile.am
  --- rpm/lib/Makefile.am	11 Nov 2007 15:05:18 -0000	2.167
  +++ rpm/lib/Makefile.am	2 Dec 2007 15:33:54 -0000	2.168
  @@ -24,7 +24,7 @@
   
   pkgincdir = $(pkgincludedir)$(WITH_PATH_VERSIONED_SUFFIX)
   pkginc_HEADERS = \
  -	fs.h misc.h rpmcli.h rpmlib.h \
  +	fs.h misc.h rpmcli.h rpmlib.h rpmversion.h \
   	rpmal.h rpmdpkg.h rpmds.h rpmevr.h rpmfc.h rpmfi.h rpmgi.h \
   	rpmns.h rpmps.h rpmsx.h rpmte.h rpmts.h stringbuf.h
   noinst_HEADERS = \
  @@ -37,7 +37,7 @@
   	manifest.c misc.c package.c \
   	poptALL.c poptI.c poptQV.c psm.c query.c \
   	rpmal.c rpmchecksig.c rpmdpkg.c rpmds.c rpmevr.c rpmfc.c \
  -	rpmfi.c rpmgi.c rpminstall.c rpmrollback.c \
  +	rpmfi.c rpmgi.c rpminstall.c rpmrollback.c rpmversion.c \
   	rpmlock.c rpmns.c rpmps.c rpmrc.c rpmsx.c rpmte.c rpmts.c \
   	stringbuf.c transaction.c \
   	verify.c tar.c
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/librpm.vers
  ============================================================================
  $ cvs diff -u -r1.26 -r1.27 librpm.vers
  --- rpm/lib/librpm.vers	24 Nov 2007 19:46:05 -0000	1.26
  +++ rpm/lib/librpm.vers	2 Dec 2007 15:33:54 -0000	1.27
  @@ -423,6 +423,9 @@
       XrpmtsiInit;
       XrpmtsLink;
       XrpmtsUnlink;
  +    rpm_version;
  +    rpm_timestamp;
  +    rpm_vendor;
     local:
       *;
   };
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/rpmlib.h
  ============================================================================
  $ cvs diff -u -r2.449 -r2.450 rpmlib.h
  --- rpm/lib/rpmlib.h	24 Nov 2007 17:18:57 -0000	2.449
  +++ rpm/lib/rpmlib.h	2 Dec 2007 15:33:54 -0000	2.450
  @@ -9,6 +9,7 @@
    */
   
   #include <rpmtag.h>
  +#include <rpmversion.h>
   
   #define RPM_FORMAT_VERSION 5
   #define RPM_MAJOR_VERSION 0
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/rpmversion.c
  ============================================================================
  $ cvs diff -u -r0 -r2.1 rpmversion.c
  --- /dev/null	2007-12-02 16:33:01 +0100
  +++ rpmversion.c	2007-12-02 16:33:54 +0100
  @@ -0,0 +1,23 @@
  +/** \ingroup rpmversion
  + * \file lib/rpmversion.c
  + */
  +
  +#include "system.h"
  +#include "rpmversion.h"
  +#include "debug.h"
  +
  +unsigned long rpm_version(void)
  +{
  +    return (unsigned long)RPM_VERSION;
  +}
  +
  +unsigned long rpm_timestamp(void)
  +{
  +    return (unsigned long)RPM_TIMESTAMP;
  +}
  +
  +unsigned long rpm_vendor(void)
  +{
  +    return (unsigned long)RPM_VENDOR;
  +}
  +
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/rpmversion.h.in
  ============================================================================
  $ cvs diff -u -r0 -r2.1 rpmversion.h.in
  --- /dev/null	2007-12-02 16:33:01 +0100
  +++ rpmversion.h.in	2007-12-02 16:33:54 +0100
  @@ -0,0 +1,139 @@
  +#ifndef __RPMVERSION_H__
  +#define __RPMVERSION_H__
  +
  +#ifdef __cplusplus
  +extern "C" {
  +#endif
  +
  +/*
  +   VERSION <M,N,t,O,R,s>
  +   ---------------------
  +
  +    3         2         1         0
  +   10987654321098765432109876543210
  +   |   ||     || ||      ||      ||
  +   | M ||   N ||t||  O   ||   R  |s
  +
  +   M: bits 31-27 (5 bit): [0... 32[    [0..31]      major version  (architecture  generation counter)
  +   N: bits 26-21 (6 bit): [0... 64[    [0..63]      minor version  (functionality generation counter)
  +   t: bits 20-18 (3 bit): {_,a,b,c,r}  {_,a,b,c,r}  release type
  +   O: bits 17-10 (8 bit): [0...256[    [0..255]     major revision (maintenance   generation counter)
  +   R: bits 09-01 (9 bit): [0...512[    [0..511]     minor revision (hotfix        generation counter)
  +   s: bits 00-00 (1 bit): {_,s}        {_,s}        is snapshot?
  +
  +   TIMESTAMP <Y,M,D,h,m>
  +   ---------------------
  +
  +    3         2         1         0
  +   10987654321098765432109876543210
  +   |          ||  ||   ||   ||    |
  +   |    Y     ||M || D || h || m  |
  +
  +   Y: bits 30-20 (12 bit): [0...4096[  [0...4095]   year
  +   M: bits 19-16 ( 4 bit): [0...16[    [1..12]      month
  +   D: bits 15-11 ( 5 bit): [0...32[    [1..31]      day
  +   h: bits 10-06 ( 5 bit): [0...32[    [00..23]     hour   (UTC +0000)
  +   m: bits 05-00 ( 6 bit): [0...64[    [00..61]     minute (UTC +0000)
  +
  +   EXAMPLES
  +   --------
  +
  +   version                        encoding
  +   5.6.DEV                        RPM_VERSION_ENCODE(5,6,_,0,0,_) RPM_TIMESTAMP_ENCODE(YYYY,MM,DD,HH,MM)
  +   5.6.SNAP.YYYYMMDD              RPM_VERSION_ENCODE(5,6,_,0,0,s) RPM_TIMESTAMP_ENCODE(YYYY,MM,DD,00,00)
  +   5.6a7                          RPM_VERSION_ENCODE(5,6,a,7,0,_) RPM_TIMESTAMP_ENCODE(YYYY,MM,DD,00,00)
  +   5.6b7                          RPM_VERSION_ENCODE(5,6,b,7,0,_) RPM_TIMESTAMP_ENCODE(YYYY,MM,DD,00,00)
  +   5.6rc7                         RPM_VERSION_ENCODE(5,6,b,7,0,_) RPM_TIMESTAMP_ENCODE(YYYY,MM,DD,00,00)
  +   5.6.7                          RPM_VERSION_ENCODE(5,6,r,7,0,_) RPM_TIMESTAMP_ENCODE(YYYY,MM,DD,00,00)
  +   5.6.7.8                        RPM_VERSION_ENCODE(5,6,r,7,8,_) RPM_TIMESTAMP_ENCODE(YYYY,MM,DD,00,00)
  +
  +   USAGE
  +   -----
  +
  +   #include <rpmversion.h>
  +   #if defined(RPM_VERSION) && RPM_VENDOR_EQ('R','P','M','5') && \
  +       RPM_VERSION_GE(5,0,a,1,0,_) && RPM_TIMESTAMP_GT(2007,11,13,00,00)
  +   [...]
  +   #endif
  +*/
  +
  +/* link-time information */
  +extern unsigned long rpm_version(void);
  +extern unsigned long rpm_timestamp(void);
  +extern unsigned long rpm_vendor(void);
  +
  +/* compile-time information */
  +#define RPM_VERSION   RPM_VERSION_ENCODE(@RPM_VERSION@)
  +#define RPM_TIMESTAMP RPM_TIMESTAMP_ENCODE(@RPM_TIMESTAMP@)
  +#define RPM_VENDOR    RPM_VENDOR_ENCODE(@RPM_VENDOR@)
  +
  +/* RPM release version encoding */
  +#define RPM_VERSION_ENCODE(major,minor,type,micro,revision,snap) \
  +    ( RPM_BITFIELD_SET(31,27,(major)) \
  +    | RPM_BITFIELD_SET(26,21,(minor)) \
  +    | RPM_BITFIELD_SET(20,18,RPM_VERSION_ENCODE_T(type)) \
  +    | RPM_BITFIELD_SET(17,10,(micro)) \
  +    | RPM_BITFIELD_SET(9,1,(revision)) \
  +    | RPM_BITFIELD_SET(0,0,RPM_VERSION_ENCODE_S(snap)))
  +#define RPM_VERSION_ENCODE_T(type) RPM_VERSION_ENCODE_T_##type
  +#define RPM_VERSION_ENCODE_T__     0
  +#define RPM_VERSION_ENCODE_T_a     1
  +#define RPM_VERSION_ENCODE_T_b     2
  +#define RPM_VERSION_ENCODE_T_c     3
  +#define RPM_VERSION_ENCODE_T_r     4
  +#define RPM_VERSION_ENCODE_S(snap) RPM_VERSION_ENCODE_S_##snap
  +#define RPM_VERSION_ENCODE_S__     0
  +#define RPM_VERSION_ENCODE_S_s     1
  +
  +/* RPM release timestamp encoding */
  +#define RPM_TIMESTAMP_ENCODE(year,month,date,hour,minute) \
  +    ( RPM_BITFIELD_SET(31,20,(year)) \
  +    | RPM_BITFIELD_SET(19,16,(month)) \
  +    | RPM_BITFIELD_SET(15,11,(date)) \
  +    | RPM_BITFIELD_SET(10,6,(hour)) \
  +    | RPM_BITFIELD_SET(5,0,(minute)))
  +
  +/* RPM vendor tag encoding */
  +#define RPM_VENDOR_ENCODE(c1,c2,c3,c4) \
  +    ( RPM_BITFIELD_SET(31,24,(c1)) \
  +    | RPM_BITFIELD_SET(23,16,(c2)) \
  +    | RPM_BITFIELD_SET(15,8,(c3)) \
  +    | RPM_BITFIELD_SET(7,0,(c4)))
  +
  +/* RPM release version assertion */
  +#define RPM_VERSION_LT(major,minor,type,micro,revision,snap) \
  +    (RPM_VERSION <  RPM_VERSION_ENCODE((major),(minor),(type),(micro),(revision),(snap)))
  +#define RPM_VERSION_LE(major,minor,type,micro,revision,snap) \
  +    (RPM_VERSION <= RPM_VERSION_ENCODE((major),(minor),(type),(micro),(revision),(snap)))
  +#define RPM_VERSION_EQ(major,minor,type,micro,revision,snap) \
  +    (RPM_VERSION == RPM_VERSION_ENCODE((major),(minor),(type),(micro),(revision),(snap)))
  +#define RPM_VERSION_GE(major,minor,type,micro,revision,snap) \
  +    (RPM_VERSION >= RPM_VERSION_ENCODE((major),(minor),(type),(micro),(revision),(snap)))
  +#define RPM_VERSION_GT(major,minor,type,micro,revision,snap) \
  +    (RPM_VERSION >  RPM_VERSION_ENCODE((major),(minor),(type),(micro),(revision),(snap)))
  +
  +/* RPM release timestamp assertion */
  +#define RPM_TIMESTAMP_LT(year,month,date,hour,minute) \
  +    (RPM_TIMESTAMP <  RPM_TIMESTAMP_ENCODE((year),(month),(date),(hour),(minute)))
  +#define RPM_TIMESTAMP_LE(major,minor,type,micro,revision) \
  +    (RPM_TIMESTAMP <= RPM_TIMESTAMP_ENCODE((year),(month),(date),(hour),(minute)))
  +#define RPM_TIMESTAMP_EQ(major,minor,type,micro,revision) \
  +    (RPM_TIMESTAMP == RPM_TIMESTAMP_ENCODE((year),(month),(date),(hour),(minute)))
  +#define RPM_TIMESTAMP_GE(major,minor,type,micro,revision) \
  +    (RPM_TIMESTAMP >= RPM_TIMESTAMP_ENCODE((year),(month),(date),(hour),(minute)))
  +#define RPM_TIMESTAMP_GT(major,minor,type,micro,revision) \
  +    (RPM_TIMESTAMP >  RPM_TIMESTAMP_ENCODE((year),(month),(date),(hour),(minute)))
  +
  +/* RPM vendor tag assertion */
  +#define RPM_VENDOR_EQ(c1,c2,c3,c4) \
  +    (RPM_VENDOR == RPM_VENDOR_ENCODE((c1),(c2),(c3),(c4)))
  +
  +/* encode numer "n" into the bits "l" (msb) to "r" (lsb) */
  +#define RPM_BITFIELD_SET(l,r,n) \
  +    (((n) & ((1<<(((l)-(r))+1))-1) ) << (r))
  +
  +#ifdef __cplusplus
  +}
  +#endif
  +
  +#endif /* __RPMVERSION_H__ */
  @@ .
Received on Sun Dec 2 16:33:55 2007
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.