INCLUDE_DIRECTORIES(${RPM_INCLUDE_DIR})
# fix includes not relative to rpm
INCLUDE_DIRECTORIES(${RPM_INCLUDE_DIR}/rpm)
+ if (RPM_4_4_LEGACY)
+ MESSAGE( STATUS "Enable rpm 4.4 legacy interface")
+ ADD_DEFINITIONS(-D_RPM_4_4_COMPAT)
+ endif (RPM_4_4_LEGACY)
ENDIF( NOT RPM_FOUND)
FIND_PACKAGE(Boost REQUIRED)
if(RPM_INCLUDE_DIR AND RPM_LIBRARY)
# Already in cache, be silent
- set(RPM_FIND_QUIETLY TRUE)
+ set(RPM_FIND_QUIETLY TRUE)
endif(RPM_INCLUDE_DIR AND RPM_LIBRARY)
set(RPM_LIBRARY)
set(RPM_INCLUDE_DIR)
+set(RPM_4_4_LEGACY)
-FIND_PATH(RPM_INCLUDE_DIR rpm/misc.h
+FIND_PATH(RPM_INCLUDE_DIR rpm/rpmdb.h
/usr/include
/usr/local/include
)
+FIND_PATH(RPM_4_4_LEGACY rpm/rpmlegacy.h
+ ${RPM_INCLUDE_DIR}
+ NO_DEFAULT_PATH
+)
+
FIND_LIBRARY(RPM_LIBRARY NAMES rpm
PATHS
/usr/lib
if(RPM_INCLUDE_DIR AND RPM_LIBRARY)
MESSAGE( STATUS "rpm found: includes in ${RPM_INCLUDE_DIR}, library in ${RPM_LIBRARY}")
+ if ( RPM_4_4_LEGACY )
+ MESSAGE( STATUS "rpm provides 4.4 legacy interface")
+ endif ( RPM_4_4_LEGACY )
set(RPM_FOUND TRUE)
else(RPM_INCLUDE_DIR AND RPM_LIBRARY)
MESSAGE( STATUS "rpm not found")
: cnt( 0 ), val( 0 ), type( RPM_NULL_TYPE )
{}
-unsigned BinHeader::intList::set( void * val_r, tag cnt_r, tag type_r )
+unsigned BinHeader::intList::set( void * val_r, unsigned cnt_r, rpmTagType type_r )
{
val = val_r;
cnt = val ? cnt_r : 0;
case RPM_CHAR_TYPE:
return ((char*)val)[idx_r];
case RPM_INT8_TYPE:
- return ((int_8*)val)[idx_r];
+ return ((int8_t*)val)[idx_r];
case RPM_INT16_TYPE:
- return ((int_16*)val)[idx_r];
+ return ((int16_t*)val)[idx_r];
case RPM_INT32_TYPE:
- return ((int_32*)val)[idx_r];
+ return ((int32_t*)val)[idx_r];
}
}
return 0;
: cnt( 0 ), val( 0 )
{}
-unsigned BinHeader::stringList::set( char ** val_r, tag cnt_r )
+unsigned BinHeader::stringList::set( char ** val_r, unsigned cnt_r )
{
clear();
val = val_r;
{
if ( !empty() )
{
- int_32 type = 0;
- int_32 cnt = 0;
+ rpmTagType type = RPM_NULL_TYPE;
+ rpm_count_t cnt = 0;
void * val = 0;
- ::headerGetEntry( _h, tag_r, &type, &val, &cnt );
+ ::headerGetEntry( _h, tag_r, hTYP_t(&type), &val, &cnt );
if ( val )
{
{
if ( !empty() )
{
- int_32 type = 0;
- int_32 cnt = 0;
+ rpmTagType type = RPM_NULL_TYPE;
+ rpm_count_t cnt = 0;
void * val = 0;
- ::headerGetEntry( _h, tag_r, &type, &val, &cnt );
+ ::headerGetEntry( _h, tag_r, hTYP_t(&type), &val, &cnt );
if ( val )
{
{
if ( !empty() )
{
- int_32 type = 0;
- int_32 cnt = 0;
+ rpmTagType type = RPM_NULL_TYPE;
+ rpm_count_t cnt = 0;
void * val = 0;
- ::headerGetEntry( _h, tag_r, &type, &val, &cnt );
+ ::headerGetEntry( _h, tag_r, hTYP_t(&type), &val, &cnt );
if ( val )
{
case RPM_CHAR_TYPE:
return *((char*)val);
case RPM_INT8_TYPE:
- return *((int_8*)val);
+ return *((int8_t*)val);
case RPM_INT16_TYPE:
- return *((int_16*)val);
+ return *((int16_t*)val);
case RPM_INT32_TYPE:
- return *((int_32*)val);
+ return *((int32_t*)val);
case RPM_STRING_ARRAY_TYPE:
free( val );
{
if ( !empty() )
{
- int_32 type = 0;
- int_32 cnt = 0;
+ rpmTagType type = RPM_NULL_TYPE;
+ rpm_count_t cnt = 0;
void * val = 0;
- ::headerGetEntry( _h, tag_r, &type, &val, &cnt );
+ ::headerGetEntry( _h, tag_r, hTYP_t(&type), &val, &cnt );
if ( val )
{
typedef intrusive_ptr<const BinHeader> constPtr;
- typedef int32_t tag;
+ typedef rpmTag tag;
class intList;
private:
unsigned cnt;
void * val;
- tag type;
+ rpmTagType type;
private:
friend class BinHeader;
- unsigned set( void * val_r, tag cnt_r, tag type_r );
+ unsigned set( void * val_r, unsigned cnt_r, rpmTagType type_r );
public:
intList();
bool empty() const
void clear();
private:
friend class BinHeader;
- unsigned set( char ** val_r, tag cnt_r );
+ unsigned set( char ** val_r, unsigned cnt_r );
public:
stringList();
~stringList()
*
*/
#include "librpm.h"
+#ifndef _RPM_4_4_COMPAT
+#include <rpm/ugid.h>
+inline uid_t getUidS(const char * uname) { uid_t tmp; return ::unameToUid( uname, &tmp ); }
+inline gid_t getGidS(const char * gname) { gid_t tmp; return ::gnameToGid( gname, &tmp ); }
+#else
+#include <rpm/rpmbuild.h>
+#endif
#include <iostream>
#include <map>
{
CapabilitySet ret;
- int_32 kindFlags = 0;
- int_32 kindVersion = 0;
+ rpmTag kindFlags = rpmTag(0);
+ rpmTag kindVersion = rpmTag(0);
switch ( tag_r )
{
std::string n( names[i] );
Rel op = Rel::ANY;
- int_32 f = flags[i];
- std::string v = versions[i];
+ int32_t f = flags[i];
+ std::string v = versions[i];
if ( n[0] == '/' )
{
uid_t uid;
if (uids.empty())
{
- uid = unameToUid( usernames[i].c_str(), &uid );
+ uid = getUidS( usernames[i].c_str() );
}
else
{
gid_t gid;
if (gids.empty())
{
- gid = gnameToGid( groupnames[i].c_str(), &gid );
+ gid = getGidS( groupnames[i].c_str() );
}
else
{
#include <rpm/rpmmacro.h>
#include <rpm/rpmdb.h>
#include <rpm/rpmts.h>
-#include <rpm/ugid.h>
#include <fcntl.h>
+
+#ifndef _RPM_4_4_COMPAT
+typedef int32_t rpm_count_t;
+#endif
}
#endif // ZYPP_TARGET_RPM_LIBRPM_H
unsigned count = 0;
if ( valid() )
{
+#ifdef _RPM_4_4_COMPAT
+ // looks like rpm-4.7 has no public dbi interface anymore
+ int dbi = ::rpmdbOpen("/", &_d._db, O_RDONLY, 0);
+ if (dbi == 0) {
+ rpmdbMatchIterator mi = ::rpmdbInitIterator(_d._db, RPMTAG_NAME, NULL, 0);
+ if (mi != NULL) {
+ rpmtd item;
+ for (;;) {
+ Header rpmHeader = ::rpmdbNextIterator(mi);
+ if (rpmHeader != NULL)
+ ++count;
+ }
+ }
+ ::rpmdbClose(_d._db);
+ }
+#else
dbiIndex dbi = dbiOpen( _d._db, RPMTAG_NAME, 0 );
if ( dbi )
{
dbiCclose( dbi, dbcursor, 0 );
/* no need to close dbi */
}
+#endif
}
return count;
}
const char ** baseNames;
int_32 * dirIndexes;
rpmTagType fnt;
- int count;
+ rpm_count_t count;
int i, xx;
int dirIndex = -1;
const char ** providesEVR = NULL;
rpmTagType pnt, pvt;
int_32 * provideFlags = NULL;
- int providesCount;
+ rpm_count_t providesCount;
int i, xx;
int bingo = 1;
::rpmdbClose( db );
}
Fclose( fd );
- ZYPP_THROW(RpmDbOpenException(root, Pathname(string(db->db_root))));
+ ZYPP_THROW(RpmDbOpenException(root, v4db_r->dbPath()));
}
// Check ammount of packages to process.