From b2013219cb2832033ae7b3f8116bbf83351c467f Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Mon, 28 May 2018 16:23:52 +0200 Subject: [PATCH] [rpm] Backport upstream changes to support newer RPM. JB#28828 --- ...pre-posttrans-scripts-from-RpmHeader.patch | 121 +++ ...dapt-to-new-rpm-weak-dependency-tags.patch | 131 +++ rpm/0003-Adapt-to-API-changes-in-rpm412.patch | 34 + rpm/0004-Remove-dead-code-for-rpm44.patch | 826 ++++++++++++++++++ rpm/libzypp.spec | 8 + 5 files changed, 1120 insertions(+) create mode 100644 rpm/0001-Get-pre-posttrans-scripts-from-RpmHeader.patch create mode 100644 rpm/0002-adapt-to-new-rpm-weak-dependency-tags.patch create mode 100644 rpm/0003-Adapt-to-API-changes-in-rpm412.patch create mode 100644 rpm/0004-Remove-dead-code-for-rpm44.patch diff --git a/rpm/0001-Get-pre-posttrans-scripts-from-RpmHeader.patch b/rpm/0001-Get-pre-posttrans-scripts-from-RpmHeader.patch new file mode 100644 index 0000000..98c0d7f --- /dev/null +++ b/rpm/0001-Get-pre-posttrans-scripts-from-RpmHeader.patch @@ -0,0 +1,121 @@ +From ec0df2f6360e498e0aa3251a5a926d67d74c5434 Mon, 28 May 2018 15:34:57 +0200 +From: Michael Andres +Date: Sat, 25 Jan 2014 17:05:48 +0100 +Subject: [PATCH] Get pre/posttrans scripts from RpmHeader + + +diff --git a/zypp/target/rpm/RpmHeader.cc b/zypp/target/rpm/RpmHeader.cc +index 45e4b90..c638dd7 100644 +--- a/zypp/target/rpm/RpmHeader.cc ++++ b/zypp/target/rpm/RpmHeader.cc +@@ -751,59 +751,44 @@ + std::string RpmHeader::tag_os() const + { + return string_val( RPMTAG_OS ); ++ + } + +-/////////////////////////////////////////////////////////////////// +-// +-// +-// METHOD NAME : RpmHeader::tag_prein +-// METHOD TYPE : std::string +-// +-// DESCRIPTION : +-// + std::string RpmHeader::tag_prein() const +-{ +- return string_val( RPMTAG_PREIN ); +-} ++{ return string_val( RPMTAG_PREIN ); } + +-/////////////////////////////////////////////////////////////////// +-// +-// +-// METHOD NAME : RpmHeader::tag_postin +-// METHOD TYPE : std::string +-// +-// DESCRIPTION : +-// ++std::string RpmHeader::tag_preinprog() const ++{ return string_val( RPMTAG_PREINPROG ); } ++ + std::string RpmHeader::tag_postin() const +-{ +- return string_val( RPMTAG_POSTIN ); +-} ++{ return string_val( RPMTAG_POSTIN ); } + +-/////////////////////////////////////////////////////////////////// +-// +-// +-// METHOD NAME : RpmHeader::tag_preun +-// METHOD TYPE : std::string +-// +-// DESCRIPTION : +-// ++std::string RpmHeader::tag_postinprog() const ++{ return string_val( RPMTAG_POSTINPROG ); } ++ + std::string RpmHeader::tag_preun() const +-{ +- return string_val( RPMTAG_PREUN ); +-} ++{ return string_val( RPMTAG_PREUN ); } + +-/////////////////////////////////////////////////////////////////// +-// +-// +-// METHOD NAME : RpmHeader::tag_postun +-// METHOD TYPE : std::string +-// +-// DESCRIPTION : +-// ++std::string RpmHeader::tag_preunprog() const ++{ return string_val( RPMTAG_PREUNPROG ); } ++ + std::string RpmHeader::tag_postun() const +-{ +- return string_val( RPMTAG_POSTUN ); +-} ++{ return string_val( RPMTAG_POSTUN ); } ++ ++std::string RpmHeader::tag_postunprog() const ++{ return string_val( RPMTAG_POSTUNPROG ); } ++ ++std::string RpmHeader::tag_pretrans() const ++{ return string_val( RPMTAG_PRETRANS ); } ++ ++std::string RpmHeader::tag_pretransprog() const ++{ return string_val( RPMTAG_PRETRANSPROG ); } ++ ++std::string RpmHeader::tag_posttrans() const ++{ return string_val( RPMTAG_POSTTRANS ); } ++ ++std::string RpmHeader::tag_posttransprog() const ++{ return string_val( RPMTAG_POSTTRANSPROG ); } + + /////////////////////////////////////////////////////////////////// + // +diff --git a/zypp/target/rpm/RpmHeader.h b/zypp/target/rpm/RpmHeader.h +index 02dd8d1..eae75ca 100644 +--- a/zypp/target/rpm/RpmHeader.h ++++ b/zypp/target/rpm/RpmHeader.h +@@ -145,9 +145,17 @@ + std::string tag_url() const; + std::string tag_os() const; + std::string tag_prein() const; ++ std::string tag_preinprog() const; + std::string tag_postin() const; ++ std::string tag_postinprog() const; + std::string tag_preun() const; ++ std::string tag_preunprog() const; + std::string tag_postun() const; ++ std::string tag_postunprog() const; ++ std::string tag_pretrans() const; ++ std::string tag_pretransprog() const; ++ std::string tag_posttrans() const; ++ std::string tag_posttransprog()const; + std::string tag_sourcerpm() const; + + /** just the list of names */ diff --git a/rpm/0002-adapt-to-new-rpm-weak-dependency-tags.patch b/rpm/0002-adapt-to-new-rpm-weak-dependency-tags.patch new file mode 100644 index 0000000..0332d7e --- /dev/null +++ b/rpm/0002-adapt-to-new-rpm-weak-dependency-tags.patch @@ -0,0 +1,131 @@ +From 14d33595257bc6f8f31a8b0ed64441a2162e8880 Mon, 28 May 2018 15:07:41 +0200 +From: Michael Schroeder +Date: Fri, 21 Feb 2014 13:21:14 +0100 +Subject: [PATCH] adapt to new rpm weak dependency tags + + +diff --git a/zypp/target/rpm/RpmHeader.cc b/zypp/target/rpm/RpmHeader.cc +index c638dd7..e4327e5 100644 +--- a/zypp/target/rpm/RpmHeader.cc ++++ b/zypp/target/rpm/RpmHeader.cc +@@ -422,6 +422,32 @@ + kindFlags = RPMTAG_CONFLICTFLAGS; + kindVersion = RPMTAG_CONFLICTVERSION; + break; ++#ifdef RPMTAG_OLDSUGGESTS ++ case RPMTAG_OLDENHANCESNAME: ++ kindFlags = RPMTAG_OLDENHANCESFLAGS; ++ kindVersion = RPMTAG_OLDENHANCESVERSION; ++ break; ++ case RPMTAG_OLDSUGGESTSNAME: ++ kindFlags = RPMTAG_OLDSUGGESTSFLAGS; ++ kindVersion = RPMTAG_OLDSUGGESTSVERSION; ++ break; ++ case RPMTAG_RECOMMENDNAME: ++ kindFlags = RPMTAG_RECOMMENDFLAGS; ++ kindVersion = RPMTAG_RECOMMENDVERSION; ++ break; ++ case RPMTAG_SUPPLEMENTNAME: ++ kindFlags = RPMTAG_SUPPLEMENTFLAGS; ++ kindVersion = RPMTAG_SUPPLEMENTVERSION; ++ break; ++ case RPMTAG_SUGGESTNAME: ++ kindFlags = RPMTAG_SUGGESTFLAGS; ++ kindVersion = RPMTAG_SUGGESTVERSION; ++ break; ++ case RPMTAG_ENHANCENAME: ++ kindFlags = RPMTAG_ENHANCEFLAGS; ++ kindVersion = RPMTAG_ENHANCEVERSION; ++ break; ++#else + case RPMTAG_ENHANCESNAME: + kindFlags = RPMTAG_ENHANCESFLAGS; + kindVersion = RPMTAG_ENHANCESVERSION; +@@ -430,6 +456,7 @@ + kindFlags = RPMTAG_SUGGESTSFLAGS; + kindVersion = RPMTAG_SUGGESTSVERSION; + break; ++#endif + default: + INT << "Illegal RPMTAG_dependencyNAME " << tag_r << endl; + return ret; +@@ -581,7 +608,11 @@ + // + CapabilitySet RpmHeader::tag_enhances( std::set * freq_r ) const + { ++#ifdef RPMTAG_OLDSUGGESTS ++ return PkgRelList_val( RPMTAG_ENHANCENAME, false, freq_r ); ++#else + return PkgRelList_val( RPMTAG_ENHANCESNAME, false, freq_r ); ++#endif + } + + /////////////////////////////////////////////////////////////////// +@@ -594,7 +625,45 @@ + // + CapabilitySet RpmHeader::tag_suggests( std::set * freq_r ) const + { ++#ifdef RPMTAG_OLDSUGGESTS ++ return PkgRelList_val( RPMTAG_SUGGESTNAME, false, freq_r ); ++#else + return PkgRelList_val( RPMTAG_SUGGESTSNAME, false, freq_r ); ++#endif ++ } ++ ++/////////////////////////////////////////////////////////////////// ++// ++// ++// METHOD NAME : RpmHeader::tag_supplements ++// METHOD TYPE : CapabilitySet ++// ++// DESCRIPTION : ++// ++CapabilitySet RpmHeader::tag_supplements( std::set * freq_r ) const ++ { ++#ifdef RPMTAG_OLDSUGGESTS ++ return PkgRelList_val( RPMTAG_SUPPLEMENTNAME, false, freq_r ); ++#else ++ return CapabilitySet(); ++#endif ++ } ++ ++/////////////////////////////////////////////////////////////////// ++// ++// ++// METHOD NAME : RpmHeader::tag_recommends ++// METHOD TYPE : CapabilitySet ++// ++// DESCRIPTION : ++// ++CapabilitySet RpmHeader::tag_recommends( std::set * freq_r ) const ++ { ++#ifdef RPMTAG_OLDSUGGESTS ++ return PkgRelList_val( RPMTAG_RECOMMENDNAME, false, freq_r ); ++#else ++ return CapabilitySet(); ++#endif + } + + /////////////////////////////////////////////////////////////////// +diff --git a/zypp/target/rpm/RpmHeader.h b/zypp/target/rpm/RpmHeader.h +index eae75ca..697b2cb 100644 +--- a/zypp/target/rpm/RpmHeader.h ++++ b/zypp/target/rpm/RpmHeader.h +@@ -125,11 +125,14 @@ + * @see #tag_provides + **/ + CapabilitySet tag_suggests( std::set * freq_r = 0 ) const; +- /** Unsupported by rpm. ++ /** + * @see #tag_provides + **/ +- CapabilitySet tag_supplements( std::set * freq_r = 0 ) const +- { return CapabilitySet(); } ++ CapabilitySet tag_supplements( std::set * freq_r = 0 ) const; ++ /** ++ * @see #tag_provides ++ **/ ++ CapabilitySet tag_recommends( std::set * freq_r = 0 ) const; + + ByteCount tag_size() const; + ByteCount tag_archivesize() const; diff --git a/rpm/0003-Adapt-to-API-changes-in-rpm412.patch b/rpm/0003-Adapt-to-API-changes-in-rpm412.patch new file mode 100644 index 0000000..b27139b --- /dev/null +++ b/rpm/0003-Adapt-to-API-changes-in-rpm412.patch @@ -0,0 +1,34 @@ +From e6982194dd7e7d1521c52dec5508a22e188da257 Mon, 28 May 2018 15:08:37 +0200 +From: Michael Andres +Date: Mon, 22 Sep 2014 14:20:47 +0200 +Subject: [PATCH] Adapt to API changes in rpm.4.12 + + +diff --git a/zypp/target/rpm/librpm.h b/zypp/target/rpm/librpm.h +index 2d7425d..17e801d 100644 +--- a/zypp/target/rpm/librpm.h ++++ b/zypp/target/rpm/librpm.h +@@ -28,6 +28,7 @@ + #include + #include + #include ++#include + #include + } + +diff --git a/zypp/target/rpm/librpmDb.cc b/zypp/target/rpm/librpmDb.cc +index 3f472f4..cc419dd 100644 +--- a/zypp/target/rpm/librpmDb.cc ++++ b/zypp/target/rpm/librpmDb.cc +@@ -679,7 +679,11 @@ + if ( ! create( RPMDBI_PACKAGES ) ) + return false; + #warning TESTCASE: rpmdbAppendIterator and (non)sequential access? ++#ifdef RPMFILEITERMAX // since rpm.4.12 ++ ::rpmdbAppendIterator( _mi, (const unsigned *)&off_r, 1 ); ++#else + ::rpmdbAppendIterator( _mi, &off_r, 1 ); ++#endif + return advance(); + } + diff --git a/rpm/0004-Remove-dead-code-for-rpm44.patch b/rpm/0004-Remove-dead-code-for-rpm44.patch new file mode 100644 index 0000000..201e54c --- /dev/null +++ b/rpm/0004-Remove-dead-code-for-rpm44.patch @@ -0,0 +1,826 @@ +From 73e2f204b23aac77ac5ae80c4672b966cd673084 Mon, 28 May 2018 16:04:24 +0200 +From: Michael Andres +Date: Wed, 16 Aug 2017 11:39:20 +0200 +Subject: [PATCH] Remove dead code for rpm<=4.4 + + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 7711a9b..851a958 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -81,12 +81,6 @@ + if ( RPM_SUSPECT_VERSION STREQUAL "5.x" ) + MESSAGE( STATUS "rpm found: enable rpm-4 compat interface." ) + ADD_DEFINITIONS(-D_RPM_5) +- elseif ( RPM_SUSPECT_VERSION STREQUAL "4.x" ) +- MESSAGE( STATUS "rpm found: use rpm-4.x interface." ) +- ADD_DEFINITIONS(-D_RPM_4_X) +- elseif ( RPM_SUSPECT_VERSION STREQUAL "4.4" ) +- MESSAGE( STATUS "rpm found: enable rpm-4.4 legacy interface." ) +- ADD_DEFINITIONS(-D_RPM_4_4) + endif ( RPM_SUSPECT_VERSION STREQUAL "5.x" ) + ENDIF( NOT RPM_FOUND) + +diff --git a/zypp/target/rpm/BinHeader.cc b/zypp/target/rpm/BinHeader.cc +index 2133278..95350c8 100644 +--- a/zypp/target/rpm/BinHeader.cc ++++ b/zypp/target/rpm/BinHeader.cc +@@ -16,10 +16,6 @@ + #undef RPM_NULL_TYPE + #define RPM_NULL_TYPE rpmTagType(0) + typedef rpmuint32_t rpm_count_t; +-#else +-#ifdef _RPM_4_4 +-typedef int32_t rpm_count_t; +-#endif + #endif + } + +@@ -43,7 +39,7 @@ + { + + /** Helper for header data retieval. +- * With \c _RPM_4_X use \c ::headerGet; with older \c _RPM_4_4 ++ * With \c _RPM_4 use \c ::headerGet; with \c _RPM_5 + * use the meanwhile deprecated \c ::headerGetEntry. + * \ingroup g_RAII + */ +@@ -56,16 +52,16 @@ + rpm_count_t cnt(); + void * val(); + private: +-#ifdef _RPM_4_X ++#ifndef _RPM_5 + ::rpmtd _rpmtd; + #else + rpmTagType _type; + rpm_count_t _cnt; + void * _val; +-#endif //_RPM_4_X ++#endif //_RPM_5 + }; + +-#ifdef _RPM_4_X ++#ifndef _RPM_5 + inline HeaderEntryGetter::HeaderEntryGetter( const Header & h_r, rpmTag & tag_r ) + : _rpmtd( ::rpmtdNew() ) + { ::headerGet( h_r, tag_r, _rpmtd, HEADERGET_DEFAULT ); } +@@ -85,7 +81,7 @@ + inline rpmTagType HeaderEntryGetter::type() { return _type; } + inline rpm_count_t HeaderEntryGetter::cnt() { return _cnt; } + inline void * HeaderEntryGetter::val() { return _val; } +-#endif //_RPM_4_X ++#endif //_RPM_5 + + /////////////////////////////////////////////////////////////////// + // +@@ -113,7 +109,7 @@ + case RPM_INT32_TYPE: + std::vector( (int32_t*)val_r, ((int32_t*)val_r)+cnt_r ).swap( _data ); + break; +-#ifdef _RPM_4_X ++#ifndef _RPM_5 + case RPM_INT64_TYPE: + std::vector( (int64_t*)val_r, ((int64_t*)val_r)+cnt_r ).swap( _data ); + break; +@@ -257,7 +253,7 @@ + case RPM_INT8_TYPE: + case RPM_INT16_TYPE: + case RPM_INT32_TYPE: +-#ifdef _RPM_4_X ++#ifndef _RPM_5 + case RPM_INT64_TYPE: + #endif + return lst_r.set( headerget.val(), headerget.cnt(), headerget.type() ); +@@ -331,7 +327,7 @@ + return *((int16_t*)headerget.val()); + case RPM_INT32_TYPE: + return *((int32_t*)headerget.val()); +-#ifdef _RPM_4_X ++#ifndef _RPM_5 + case RPM_INT64_TYPE: + return *((int64_t*)headerget.val()); + #endif +diff --git a/zypp/target/rpm/RpmHeader.cc b/zypp/target/rpm/RpmHeader.cc +index f09edfa..95ab82b 100644 +--- a/zypp/target/rpm/RpmHeader.cc ++++ b/zypp/target/rpm/RpmHeader.cc +@@ -10,9 +10,7 @@ + * + */ + #include "librpm.h" +-#ifdef _RPM_4_4 +-#include +-#else ++ + //////////////////////////////////////////////////////////////////// + // unameToUid and gnameToGid are shamelessly stolen from rpm-4.4. + // (rpmio/ugid.c) Those functions were dropped in RPM_4_7 +@@ -142,7 +140,6 @@ + return 0; + } + //////////////////////////////////////////////////////////////////// +-#endif + + #include + #include +diff --git a/zypp/target/rpm/librpmDb.cv3.cc b/zypp/target/rpm/librpmDb.cv3.cc +index 185f7af..a3442cb 100644 +--- a/zypp/target/rpm/librpmDb.cv3.cc ++++ b/zypp/target/rpm/librpmDb.cv3.cc +@@ -9,695 +9,6 @@ + /** \file zypp/target/rpm/librpmDb.cv3.cc + * + */ +-#if 0 +-#include "librpm.h" +-extern "C" +-{ +-#ifdef _RPM_5 +-typedef rpmuint32_t rpm_count_t; +-#define HGEPtr_t void * +-#define headerGetEntryMinMemory headerGetEntry +-#define headerNVR(h,n,v,r) headerNEVRA(h,n,NULL,v,r,NULL) +-#else +-#ifdef _RPM_4_4 +-typedef int32_t rpm_count_t; +-#define HGEPtr_t const void * +-#endif +-#endif +-} +- +-#include +- +-#include "zypp/base/Logger.h" +- +-#include "zypp/target/rpm/librpmDb.h" +-#include "zypp/target/rpm/RpmCallbacks.h" +-#include "zypp/ZYppCallbacks.h" +- +-#define xmalloc malloc +-#define xstrdup strdup +- +-extern "C" +-{ +-#include +- +-#define FA_MAGIC 0x02050920 +- +- struct faFileHeader +- { +- unsigned int magic; +- unsigned int firstFree; +- }; +- +- struct faHeader +- { +- unsigned int size; +- unsigned int freeNext; /* offset of the next free block, 0 if none */ +- unsigned int freePrev; +- unsigned int isFree; +- +- /* note that the u16's appear last for alignment/space reasons */ +- }; +-} +- +-namespace zypp +-{ +-namespace target +-{ +-namespace rpm +-{ +-static int fadFileSize; +- +-static ssize_t Pread(FD_t fd, void * buf, size_t count, off_t offset) +-{ +- if (Fseek(fd, offset, SEEK_SET) < 0) +- return -1; +- return Fread(buf, sizeof(char), count, fd); +-} +- +-static FD_t fadOpen(const char * path) +-{ +- struct faFileHeader newHdr; +- FD_t fd; +- struct stat stb; +- +- fd = Fopen(path, "r.fdio"); +- if (!fd || Ferror(fd)) +- return NULL; +- +- if (fstat(Fileno(fd), &stb)) +- { +- Fclose(fd); +- return NULL; +- } +- fadFileSize = stb.st_size; +- +- /* is this file brand new? */ +- if (fadFileSize == 0) +- { +- Fclose(fd); +- return NULL; +- } +- if (Pread(fd, &newHdr, sizeof(newHdr), 0) != sizeof(newHdr)) +- { +- Fclose(fd); +- return NULL; +- } +- if (newHdr.magic != FA_MAGIC) +- { +- Fclose(fd); +- return NULL; +- } +- /*@-refcounttrans@*/ return fd /*@=refcounttrans@*/ ; +-} +- +-static int fadNextOffset(FD_t fd, unsigned int lastOffset) +-{ +- struct faHeader header; +- int offset; +- +- offset = (lastOffset) +- ? (lastOffset - sizeof(header)) +- : sizeof(struct faFileHeader); +- +- if (offset >= fadFileSize) +- return 0; +- +- if (Pread(fd, &header, sizeof(header), offset) != sizeof(header)) +- return 0; +- +- if (!lastOffset && !header.isFree) +- return (offset + sizeof(header)); +- +- do +- { +- offset += header.size; +- +- if (Pread(fd, &header, sizeof(header), offset) != sizeof(header)) +- return 0; +- +- if (!header.isFree) break; +- } +- while (offset < fadFileSize && header.isFree); +- +- if (offset < fadFileSize) +- { +- /* Sanity check this to make sure we're not going in loops */ +- offset += sizeof(header); +- +- if (offset < 0 || (unsigned)offset <= lastOffset) return -1; +- +- return offset; +- } +- else +- return 0; +-} +- +-static int fadFirstOffset(FD_t fd) +-{ +- return fadNextOffset(fd, 0); +-} +- +-/*@-boundsread@*/ +-static int dncmp(const void * a, const void * b) +-/*@*/ +-{ +- const char *const * first = (const char *const *)a; +- const char *const * second = (const char *const *)b; +- return strcmp(*first, *second); +-} +-/*@=boundsread@*/ +- +-/*@-bounds@*/ +-#ifndef _RPM_4_X +-static void compressFilelist(Header h) +-/*@*/ +-{ +- char ** fileNames; +- const char ** dirNames; +- const char ** baseNames; +- int_32 * dirIndexes; +- rpmTagType fnt; +- rpm_count_t count; +- int xx; +- int dirIndex = -1; +- +- /* +- * This assumes the file list is already sorted, and begins with a +- * single '/'. That assumption isn't critical, but it makes things go +- * a bit faster. +- */ +- +- if (headerIsEntry(h, RPMTAG_DIRNAMES)) +- { +- xx = headerRemoveEntry(h, RPMTAG_OLDFILENAMES); +- return; /* Already converted. */ +- } +- +- 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) +- return; +- +- dirNames = (const char **)alloca(sizeof(*dirNames) * count); /* worst case */ +- baseNames = (const char **)alloca(sizeof(*dirNames) * count); +- dirIndexes = (int_32 *)alloca(sizeof(*dirIndexes) * count); +- +- if (fileNames[0][0] != '/') +- { +- /* HACK. Source RPM, so just do things differently */ +- dirIndex = 0; +- dirNames[dirIndex] = ""; +- for (rpm_count_t i = 0; i < count; i++) +- { +- dirIndexes[i] = dirIndex; +- baseNames[i] = fileNames[i]; +- } +- goto exit; +- } +- +- /*@-branchstate@*/ +- for (rpm_count_t i = 0; i < count; i++) +- { +- const char ** needle; +- char savechar; +- char * baseName; +- int len; +- +- if (fileNames[i] == NULL) /* XXX can't happen */ +- continue; +- baseName = strrchr(fileNames[i], '/') + 1; +- len = baseName - fileNames[i]; +- needle = dirNames; +- savechar = *baseName; +- *baseName = '\0'; +- /*@-compdef@*/ +- if (dirIndex < 0 || +- (needle = (const char **)bsearch(&fileNames[i], dirNames, dirIndex + 1, sizeof(dirNames[0]), dncmp)) == NULL) +- { +- char *s = (char *)alloca(len + 1); +- memcpy(s, fileNames[i], len + 1); +- s[len] = '\0'; +- dirIndexes[i] = ++dirIndex; +- dirNames[dirIndex] = s; +- } +- else +- dirIndexes[i] = needle - dirNames; +- /*@=compdef@*/ +- +- *baseName = savechar; +- baseNames[i] = baseName; +- } +- /*@=branchstate@*/ +- +-exit: +- if (count > 0) +- { +- xx = headerAddEntry(h, RPMTAG_DIRINDEXES, RPM_INT32_TYPE, dirIndexes, count); +- xx = headerAddEntry(h, RPMTAG_BASENAMES, RPM_STRING_ARRAY_TYPE, +- baseNames, count); +- xx = headerAddEntry(h, RPMTAG_DIRNAMES, RPM_STRING_ARRAY_TYPE, +- dirNames, dirIndex + 1); +- } +- +- fileNames = (char**)headerFreeData(fileNames, fnt); +- +- xx = headerRemoveEntry(h, RPMTAG_OLDFILENAMES); +-} +-/*@=bounds@*/ +- +-/* +- * Up to rpm 3.0.4, packages implicitly provided their own name-version-release. +- * Retrofit an explicit "Provides: name = epoch:version-release". +- */ +-void providePackageNVR(Header h) +-{ +- const char *name, *version, *release; +- HGEPtr_t hgePtr = NULL; +- int_32 * epoch; +- const char *pEVR; +- char *p; +- int_32 pFlags = RPMSENSE_EQUAL; +- const char ** provides = NULL; +- const char ** providesEVR = NULL; +- rpmTagType pnt, pvt; +- int_32 * provideFlags = NULL; +- rpm_count_t providesCount; +- int xx; +- int bingo = 1; +- +- /* Generate provides for this package name-version-release. */ +- xx = headerNVR(h, &name, &version, &release); +- if (!(name && version && release)) +- return; +- pEVR = p = (char *)alloca(21 + strlen(version) + 1 + strlen(release) + 1); +- *p = '\0'; +- if (headerGetEntryMinMemory(h, RPMTAG_EPOCH, NULL, &hgePtr, NULL)) +- { +- epoch = (int_32 *)hgePtr; +- sprintf(p, "%d:", *epoch); +- while (*p != '\0') +- p++; +- } +- (void) stpcpy( stpcpy( stpcpy(p, version) , "-") , release); +- +- /* +- * Rpm prior to 3.0.3 does not have versioned provides. +- * If no provides at all are available, we can just add. +- */ +- if (!headerGetEntryMinMemory(h, RPMTAG_PROVIDENAME, hTYP_t(&pnt), &hgePtr, &providesCount)) +- goto exit; +- provides = (const char **)hgePtr; +- +- /* +- * Otherwise, fill in entries on legacy packages. +- */ +- if (!headerGetEntryMinMemory(h, RPMTAG_PROVIDEVERSION, hTYP_t(&pvt), &hgePtr, NULL)) +- { +- providesEVR = (const char **)hgePtr; +- for (rpm_count_t i = 0; i < providesCount; i++) +- { +- const char * vdummy = ""; +- int_32 fdummy = RPMSENSE_ANY; +- xx = headerAddOrAppendEntry(h, RPMTAG_PROVIDEVERSION, RPM_STRING_ARRAY_TYPE, +- &vdummy, 1); +- xx = headerAddOrAppendEntry(h, RPMTAG_PROVIDEFLAGS, RPM_INT32_TYPE, +- &fdummy, 1); +- } +- goto exit; +- } +- +- xx = headerGetEntryMinMemory(h, RPMTAG_PROVIDEFLAGS, NULL, &hgePtr, NULL); +- provideFlags = (int_32 *)hgePtr; +- +- /*@-nullderef@*/ /* LCL: providesEVR is not NULL */ +- if (provides && providesEVR && provideFlags) +- for (rpm_count_t i = 0; i < providesCount; i++) +- { +- if (!(provides[i] && providesEVR[i])) +- continue; +- if (!(provideFlags[i] == RPMSENSE_EQUAL && +- !strcmp(name, provides[i]) && !strcmp(pEVR, providesEVR[i]))) +- continue; +- bingo = 0; +- break; +- } +- /*@=nullderef@*/ +- +-exit: +- provides = (const char **)headerFreeData(provides, pnt); +- providesEVR = (const char **)headerFreeData(providesEVR, pvt); +- +- if (bingo) +- { +- xx = headerAddOrAppendEntry(h, RPMTAG_PROVIDENAME, RPM_STRING_ARRAY_TYPE, +- &name, 1); +- xx = headerAddOrAppendEntry(h, RPMTAG_PROVIDEFLAGS, RPM_INT32_TYPE, +- &pFlags, 1); +- xx = headerAddOrAppendEntry(h, RPMTAG_PROVIDEVERSION, RPM_STRING_ARRAY_TYPE, +- &pEVR, 1); +- } +-} +-#else +-static void compressFilelist(Header h) +-{ +- struct rpmtd_s fileNames; +- char ** dirNames; +- const char ** baseNames; +- uint32_t * dirIndexes; +- rpm_count_t count; +- int xx, i; +- int dirIndex = -1; +- +- /* +- * This assumes the file list is already sorted, and begins with a +- * single '/'. That assumption isn't critical, but it makes things go +- * a bit faster. +- */ +- +- if (headerIsEntry(h, RPMTAG_DIRNAMES)) { +- xx = headerDel(h, RPMTAG_OLDFILENAMES); +- return; /* Already converted. */ +- } +- +- if (!headerGet(h, RPMTAG_OLDFILENAMES, &fileNames, HEADERGET_MINMEM)) +- return; +- count = rpmtdCount(&fileNames); +- if (count < 1) +- return; +- +- dirNames = (char**)malloc(sizeof(*dirNames) * count); /* worst case */ +- baseNames = (const char**)malloc(sizeof(*dirNames) * count); +- dirIndexes = (uint32_t*)malloc(sizeof(*dirIndexes) * count); +- +- /* HACK. Source RPM, so just do things differently */ +- { const char *fn = rpmtdGetString(&fileNames); +- if (fn && *fn != '/') { +- dirIndex = 0; +- dirNames[dirIndex] = xstrdup(""); +- while ((i = rpmtdNext(&fileNames)) >= 0) { +- dirIndexes[i] = dirIndex; +- baseNames[i] = rpmtdGetString(&fileNames); +- } +- goto exit; +- } +- } +- +- while ((i = rpmtdNext(&fileNames)) >= 0) { +- char ** needle; +- char savechar; +- char * baseName; +- size_t len; +- const char *filename = rpmtdGetString(&fileNames); +- +- if (filename == NULL) /* XXX can't happen */ +- continue; +- baseName = strrchr((char*)filename, '/') + 1; +- len = baseName - filename; +- needle = dirNames; +- savechar = *baseName; +- *baseName = '\0'; +- if (dirIndex < 0 || +- (needle = (char**)bsearch(&filename, dirNames, dirIndex + 1, sizeof(dirNames[0]), dncmp)) == NULL) { +- char *s = (char*)malloc(len + 1); +- rstrlcpy(s, filename, len + 1); +- dirIndexes[i] = ++dirIndex; +- dirNames[dirIndex] = s; +- } else +- dirIndexes[i] = needle - dirNames; +- +- *baseName = savechar; +- baseNames[i] = baseName; +- } +- +-exit: +- if (count > 0) { +- headerPutUint32(h, RPMTAG_DIRINDEXES, dirIndexes, count); +- headerPutStringArray(h, RPMTAG_BASENAMES, baseNames, count); +- headerPutStringArray(h, RPMTAG_DIRNAMES, +- (const char **) dirNames, dirIndex + 1); +- } +- +- rpmtdFreeData(&fileNames); +- for (i = 0; i <= dirIndex; i++) { +- free(dirNames[i]); +- } +- free(dirNames); +- free(baseNames); +- free(dirIndexes); +- +- xx = headerDel(h, RPMTAG_OLDFILENAMES); +-} +- +-/* +- * Up to rpm 3.0.4, packages implicitly provided their own name-version-release. +- * Retrofit an explicit "Provides: name = epoch:version-release. +- */ +-static void providePackageNVR(Header h) +-{ +- const char *name; +- char *pEVR; +- rpmsenseFlags pFlags = RPMSENSE_EQUAL; +- int bingo = 1; +- struct rpmtd_s pnames; +- rpmds hds, nvrds; +- +- /* Generate provides for this package name-version-release. */ +- pEVR = headerGetEVR(h, &name); +- if (!(name && pEVR)) +- return; +- +- /* +- * Rpm prior to 3.0.3 does not have versioned provides. +- * If no provides at all are available, we can just add. +- */ +- if (!headerGet(h, RPMTAG_PROVIDENAME, &pnames, HEADERGET_MINMEM)) { +- goto exit; +- } +- +- /* +- * Otherwise, fill in entries on legacy packages. +- */ +- if (!headerIsEntry(h, RPMTAG_PROVIDEVERSION)) { +- while (rpmtdNext(&pnames) >= 0) { +- uint32_t fdummy = RPMSENSE_ANY; +- +- headerPutString(h, RPMTAG_PROVIDEVERSION, ""); +- headerPutUint32(h, RPMTAG_PROVIDEFLAGS, &fdummy, 1); +- } +- goto exit; +- } +- +- /* see if we already have this provide */ +- hds = rpmdsNew(h, RPMTAG_PROVIDENAME, 0); +- nvrds = rpmdsSingle(RPMTAG_PROVIDENAME, name, pEVR, pFlags); +- if (rpmdsFind(hds, nvrds) >= 0) { +- bingo = 0; +- } +- rpmdsFree(hds); +- rpmdsFree(nvrds); +- +-exit: +- if (bingo) { +- const char *evr = pEVR; +- uint32_t fdummy = pFlags; +- headerPutString(h, RPMTAG_PROVIDENAME, name); +- headerPutString(h, RPMTAG_PROVIDEVERSION, evr); +- headerPutUint32(h, RPMTAG_PROVIDEFLAGS, &fdummy, 1); +- } +- rpmtdFreeData(&pnames); +- free(pEVR); +-} +- +-#endif +- +-/////////////////////////////////////////////////////////////////// +-/////////////////////////////////////////////////////////////////// +-/////////////////////////////////////////////////////////////////// +- +-using namespace std; +- +-#undef Y2LOG +-#define Y2LOG "librpmDb" +- +-/****************************************************************** +-** +-** +-** FUNCTION NAME : internal_convertV3toV4 +-** FUNCTION TYPE : int +-*/ +-void internal_convertV3toV4( const Pathname & v3db_r, const librpmDb::constPtr & v4db_r, +- callback::SendReport & report ) +-{ +-// Timecount _t( "convert V3 to V4" ); +- MIL << "Convert rpm3 database to rpm4" << endl; +- +- // Check arguments +- FD_t fd = fadOpen( v3db_r.asString().c_str() ); +- if ( fd == 0 ) +- { +- Fclose( fd ); +- ZYPP_THROW(RpmDbOpenException(Pathname("/"), v3db_r)); +- } +- +- if ( ! v4db_r ) +- { +- Fclose( fd ); +- INT << "NULL rpmV4 database passed as argument!" << endl; +- ZYPP_THROW(RpmNullDatabaseException()); +- } +- +- shared_ptr err = v4db_r->error(); +- if ( err ) +- { +- Fclose( fd ); +- INT << "Can't access rpmV4 database " << v4db_r << endl; +- ZYPP_THROW(*err); +- } +- +- // open rpmV4 database for writing. v4db_r is ok so librpm should +- // be properly initialized. +- rpmdb db = 0; +- string rootstr( v4db_r->root().asString() ); +- const char * root = ( rootstr == "/" ? NULL : rootstr.c_str() ); +- +- int res = ::rpmdbOpen( root, &db, O_RDWR, 0644 ); +- if ( res || ! db ) +- { +- if ( db ) +- { +- ::rpmdbClose( db ); +- } +- Fclose( fd ); +- ZYPP_THROW(RpmDbOpenException(root, v4db_r->dbPath())); +- } +- +- // Check ammount of packages to process. +- int max = 0; +- for ( int offset = fadFirstOffset(fd); offset; offset = fadNextOffset(fd, offset) ) +- { +- ++max; +- } +- MIL << "Packages in rpmV3 database " << v3db_r << ": " << max << endl; +- +- unsigned failed = 0; +- unsigned ignored = 0; +- unsigned alreadyInV4 = 0; +- report->progress( (100 * (failed + ignored + alreadyInV4) / max), v3db_r ); +- +- if ( !max ) +- { +- Fclose( fd ); +- ::rpmdbClose( db ); +- return; +- } +- +- // Start conversion. +-#warning Add CBSuggest handling if needed, also on lines below +-// CBSuggest proceed; +- bool proceed = true; +- for ( int offset = fadFirstOffset(fd); offset && proceed /*!= CBSuggest::CANCEL*/; +- offset = fadNextOffset(fd, offset), +- report->progress( (100 * (failed + ignored + alreadyInV4) / max), v3db_r ) ) +- { +- +- // have to use lseek instead of Fseek because headerRead +- // uses low level IO +- if ( lseek( Fileno( fd ), (off_t)offset, SEEK_SET ) == -1 ) +- { +- ostream * reportAs = &(ERR); +- /* proceed = report->dbReadError( offset ); +- if ( proceed == CBSuggest::SKIP ) { +- // ignore this error +- ++ignored; +- reportAs = &(WAR << "IGNORED: "); +- } else {*/ +- // PROCEED will fail after conversion; CANCEL immediately stop loop +- ++failed; +-// } +- (*reportAs) << "rpmV3 database entry: Can't seek to offset " << offset << " (errno " << errno << ")" << endl; +- continue; +- } +- Header h = headerRead(fd, HEADER_MAGIC_NO); +- if ( ! h ) +- { +- ostream * reportAs = &(ERR); +- /* proceed = report->dbReadError( offset ); +- if ( proceed == CBSuggest::SKIP ) { +- // ignore this error +- ++ignored; +- reportAs = &(WAR << "IGNORED: "); +- } else {*/ +- // PROCEED will fail after conversion; CANCEL immediately stop loop +- ++failed; +-// } +- (*reportAs) << "rpmV3 database entry: No header at offset " << offset << endl; +- continue; +- } +- compressFilelist(h); +- providePackageNVR(h); +- const char *name = 0; +- const char *version = 0; +- const char *release = 0; +- headerNVR(h, &name, &version, &release); +- string nrv( string(name) + "-" + version + "-" + release ); +- rpmdbMatchIterator mi = rpmdbInitIterator(db, RPMTAG_NAME, name, 0); +- rpmdbSetIteratorRE(mi, RPMTAG_VERSION, RPMMIRE_DEFAULT, version); +- rpmdbSetIteratorRE(mi, RPMTAG_RELEASE, RPMMIRE_DEFAULT, release); +- if (rpmdbNextIterator(mi)) +- { +-// report.dbInV4( nrv ); +- WAR << "SKIP: rpmV3 database entry: " << nrv << " is already in rpmV4 database" << endl; +- rpmdbFreeIterator(mi); +- headerFree(h); +- ++alreadyInV4; +- 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 +- ++failed; +- ERR << "rpmV4 database error: could not add " << nrv << " to rpmV4 database" << endl; +- headerFree(h); +- continue; +- } +- headerFree(h); +- } +- +- Fclose(fd); +- ::rpmdbClose(db); +- +- if ( failed ) +- { +- ERR << "Convert rpm3 database to rpm4: Aborted after " +- << alreadyInV4 << " package(s) and " << (failed+ignored) << " error(s)." +- << endl; +- ZYPP_THROW(RpmDbConvertException()); +- } +- else +- { +- MIL << "Convert rpm3 database to rpm4: " << max << " package(s) processed"; +- if ( alreadyInV4 ) +- { +- MIL << "; " << alreadyInV4 << " already present in rpmV4 database"; +- } +- if ( ignored ) +- { +- MIL << "; IGNORED: " << ignored << " unconverted due to error"; +- } +- MIL << endl; +- } +-} +-#endif +- + #include + + #include "zypp/base/Logger.h" diff --git a/rpm/libzypp.spec b/rpm/libzypp.spec index eff271e..15da2a8 100644 --- a/rpm/libzypp.spec +++ b/rpm/libzypp.spec @@ -6,6 +6,10 @@ Version: 12.2.0 Release: 1 Source: %{name}-%{version}.tar.bz2 Source1: %{name}-rpmlintrc +Patch1: 0001-Get-pre-posttrans-scripts-from-RpmHeader.patch +Patch2: 0002-adapt-to-new-rpm-weak-dependency-tags.patch +Patch3: 0003-Adapt-to-API-changes-in-rpm412.patch +Patch4: 0004-Remove-dead-code-for-rpm44.patch BuildRequires: cmake BuildRequires: openssl-devel BuildRequires: libudev-devel @@ -73,6 +77,10 @@ Authors: %prep %setup -q -n %{name}-%{version}/%{name} +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 %build mkdir -p build