set(RPM_LIBRARY)
set(RPM_INCLUDE_DIR)
-set(RPM_4_4_LEGACY)
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
-)
+set(RPM_SUSPECT_VERSION "RPM_SUSPECT_VERSION-NOTFOUND" )
+if ( RPM_INCLUDE_DIR )
+ FIND_PATH(RPM_SUSPECT_VERSION rpm/rpm4compat.h
+ ${RPM_INCLUDE_DIR}
+ NO_DEFAULT_PATH
+ )
+ if ( RPM_SUSPECT_VERSION )
+ set(RPM_SUSPECT_VERSION "5.x" )
+ else ( RPM_SUSPECT_VERSION )
+ FIND_PATH(RPM_SUSPECT_VERSION rpm/rpmlegacy.h
+ ${RPM_INCLUDE_DIR}
+ NO_DEFAULT_PATH
+ )
+ if ( RPM_SUSPECT_VERSION )
+ set(RPM_SUSPECT_VERSION "4.x" )
+ else ( RPM_SUSPECT_VERSION )
+ set(RPM_SUSPECT_VERSION "4.4" )
+ endif ( RPM_SUSPECT_VERSION )
+ endif ( RPM_SUSPECT_VERSION )
+endif ( RPM_INCLUDE_DIR )
+
FIND_LIBRARY(RPM_LIBRARY NAMES rpm
PATHS
)
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 )
+ MESSAGE( STATUS "rpm found: includes in ${RPM_INCLUDE_DIR}, library in ${RPM_LIBRARY} (suspect ${RPM_SUSPECT_VERSION})")
set(RPM_FOUND TRUE)
else(RPM_INCLUDE_DIR AND RPM_LIBRARY)
MESSAGE( STATUS "rpm not found")
/** \file zypp/target/rpm/librpmDb.cv3.cc
*
*/
-
#include "librpm.h"
extern "C"
{
#ifndef _RPM_4_4_COMPAT
+#ifdef _RPM_5
+typedef rpmuint32_t rpm_count_t;
+#else
typedef int32_t rpm_count_t;
#endif
+#endif
+
+#ifdef _RPM_5
+#define HGEPtr_t void *
+#define headerGetEntryMinMemory headerGetEntry
+#define headerNVR(h,n,v,r) headerNEVRA(h,n,NULL,v,r,NULL)
+#else
+#define HGEPtr_t const void *
+#endif
}
#include <iostream>
static void compressFilelist(Header h)
/*@*/
{
- HGE_t hge = (HGE_t)headerGetEntryMinMemory;
- HAE_t hae = (HAE_t)headerAddEntry;
- HRE_t hre = (HRE_t)headerRemoveEntry;
- HFD_t hfd = headerFreeData;
char ** fileNames;
const char ** dirNames;
const char ** baseNames;
int_32 * dirIndexes;
rpmTagType fnt;
rpm_count_t count;
- int i, xx;
+ int xx;
int dirIndex = -1;
/*
if (headerIsEntry(h, RPMTAG_DIRNAMES))
{
- xx = hre(h, RPMTAG_OLDFILENAMES);
+ xx = headerRemoveEntry(h, RPMTAG_OLDFILENAMES);
return; /* Already converted. */
}
- void *hgePtr = NULL;
- if (!hge(h, RPMTAG_OLDFILENAMES, &fnt, &hgePtr, &count))
+ HGEPtr_t hgePtr = NULL;
+ if (!headerGetEntryMinMemory(h, RPMTAG_OLDFILENAMES, hTYP_t(&fnt), &hgePtr, &count))
return; /* no file list */
fileNames = (char **)hgePtr;
if (fileNames == NULL || count <= 0)
/* HACK. Source RPM, so just do things differently */
dirIndex = 0;
dirNames[dirIndex] = "";
- for (i = 0; i < count; i++)
+ for (rpm_count_t i = 0; i < count; i++)
{
dirIndexes[i] = dirIndex;
baseNames[i] = fileNames[i];
}
/*@-branchstate@*/
- for (i = 0; i < count; i++)
+ for (rpm_count_t i = 0; i < count; i++)
{
const char ** needle;
char savechar;
exit:
if (count > 0)
{
- xx = hae(h, RPMTAG_DIRINDEXES, RPM_INT32_TYPE, dirIndexes, count);
- xx = hae(h, RPMTAG_BASENAMES, RPM_STRING_ARRAY_TYPE,
+ xx = headerAddEntry(h, RPMTAG_DIRINDEXES, RPM_INT32_TYPE, dirIndexes, count);
+ xx = headerAddEntry(h, RPMTAG_BASENAMES, RPM_STRING_ARRAY_TYPE,
baseNames, count);
- xx = hae(h, RPMTAG_DIRNAMES, RPM_STRING_ARRAY_TYPE,
+ xx = headerAddEntry(h, RPMTAG_DIRNAMES, RPM_STRING_ARRAY_TYPE,
dirNames, dirIndex + 1);
}
- fileNames = (char**)hfd(fileNames, fnt);
+ fileNames = (char**)headerFreeData(fileNames, fnt);
- xx = hre(h, RPMTAG_OLDFILENAMES);
+ xx = headerRemoveEntry(h, RPMTAG_OLDFILENAMES);
}
/*@=bounds@*/
*/
void providePackageNVR(Header h)
{
- HGE_t hge = (HGE_t)headerGetEntryMinMemory;
- HFD_t hfd = headerFreeData;
const char *name, *version, *release;
- void *hgePtr = NULL;
+ HGEPtr_t hgePtr = NULL;
int_32 * epoch;
const char *pEVR;
char *p;
rpmTagType pnt, pvt;
int_32 * provideFlags = NULL;
rpm_count_t providesCount;
- int i, xx;
+ int xx;
int bingo = 1;
/* Generate provides for this package name-version-release. */
return;
pEVR = p = (char *)alloca(21 + strlen(version) + 1 + strlen(release) + 1);
*p = '\0';
- if (hge(h, RPMTAG_EPOCH, NULL, &hgePtr, NULL))
+ if (headerGetEntryMinMemory(h, RPMTAG_EPOCH, NULL, &hgePtr, NULL))
{
epoch = (int_32 *)hgePtr;
sprintf(p, "%d:", *epoch);
* Rpm prior to 3.0.3 does not have versioned provides.
* If no provides at all are available, we can just add.
*/
- if (!hge(h, RPMTAG_PROVIDENAME, &pnt, &hgePtr, &providesCount))
+ if (!headerGetEntryMinMemory(h, RPMTAG_PROVIDENAME, hTYP_t(&pnt), &hgePtr, &providesCount))
goto exit;
provides = (const char **)hgePtr;
/*
* Otherwise, fill in entries on legacy packages.
*/
- if (!hge(h, RPMTAG_PROVIDEVERSION, &pvt, &hgePtr, NULL))
+ if (!headerGetEntryMinMemory(h, RPMTAG_PROVIDEVERSION, hTYP_t(&pvt), &hgePtr, NULL))
{
providesEVR = (const char **)hgePtr;
- for (i = 0; i < providesCount; i++)
+ for (rpm_count_t i = 0; i < providesCount; i++)
{
const char * vdummy = "";
int_32 fdummy = RPMSENSE_ANY;
goto exit;
}
- xx = hge(h, RPMTAG_PROVIDEFLAGS, NULL, &hgePtr, NULL);
+ xx = headerGetEntryMinMemory(h, RPMTAG_PROVIDEFLAGS, NULL, &hgePtr, NULL);
provideFlags = (int_32 *)hgePtr;
/*@-nullderef@*/ /* LCL: providesEVR is not NULL */
if (provides && providesEVR && provideFlags)
- for (i = 0; i < providesCount; i++)
+ for (rpm_count_t i = 0; i < providesCount; i++)
{
if (!(provides[i] && providesEVR[i]))
continue;
/*@=nullderef@*/
exit:
- provides = (const char **)hfd(provides, pnt);
- providesEVR = (const char **)hfd(providesEVR, pvt);
+ provides = (const char **)headerFreeData(provides, pnt);
+ providesEVR = (const char **)headerFreeData(providesEVR, pvt);
if (bingo)
{
continue;
}
rpmdbFreeIterator(mi);
+#ifdef _RPM_5
+ if (rpmdbAdd(db, -1, h, 0))
+#else
if (rpmdbAdd(db, -1, h, 0, 0))
+#endif
{
// report.dbWriteError( nrv );
proceed = false;//CBSuggest::CANCEL; // immediately stop loop