libsolv/libsolv-0.7.4-rpm5-5.2-endianess-fix.patch

51 lines
1.4 KiB
Diff

From 68d72a88d5dc983aff2ff5dce65581de0ee42b6d Mon Sep 17 00:00:00 2001
From: Michael Schroeder <mls@suse.de>
Date: Wed, 5 Jun 2019 15:58:55 +0200
Subject: [PATCH] Make libsolv work with rpm 5.2
Version 5.2 still used native endian encoding for the database ids.
---
ext/repo_rpmdb_bdb.h | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/ext/repo_rpmdb_bdb.h b/ext/repo_rpmdb_bdb.h
index ed82a69c..d0053f71 100644
--- a/ext/repo_rpmdb_bdb.h
+++ b/ext/repo_rpmdb_bdb.h
@@ -27,6 +27,13 @@
# define RPM_INDEX_SIZE 8 /* rpmdbid + array index */
#endif
+#ifdef RPM5
+# include <rpm/rpmversion.h>
+# if RPMLIB_VERSION_GE(5,3,_,0,0,_)
+# define RPM5_BIG_ENDIAN_ID
+# endif
+#endif
+
/******************************************************************/
/* Rpm Database stuff
@@ -66,11 +73,10 @@ stat_database(struct rpmdbstate *state, char *dbname, struct stat *statbuf, int
return 0;
}
-
static inline Id
db2rpmdbid(unsigned char *db, int byteswapped)
{
-#ifdef RPM5
+#ifdef RPM5_BIG_ENDIAN_ID
return db[0] << 24 | db[1] << 16 | db[2] << 8 | db[3];
#else
# if defined(WORDS_BIGENDIAN)
@@ -87,7 +93,7 @@ db2rpmdbid(unsigned char *db, int byteswapped)
static inline void
rpmdbid2db(unsigned char *db, Id id, int byteswapped)
{
-#ifdef RPM5
+#ifdef RPM5_BIG_ENDIAN_ID
db[0] = id >> 24, db[1] = id >> 16, db[2] = id >> 8, db[3] = id;
#else
# if defined(WORDS_BIGENDIAN)