libdnf/libdnf-0.22.0-rpm5.patch

532 lines
16 KiB
Diff

--- libdnf-0.11.1/libdnf/rpmorg-compat.h.orig 1970-01-01 01:00:00.000000000 +0100
+++ libdnf-0.11.1/libdnf/rpmorg-compat.h 2018-05-27 11:32:14.263706303 +0200
@@ -0,0 +1,64 @@
+#ifndef RPMORG_COMPAT_H
+#define RPMORG_COMPAT_H
+
+#include <rpm/rpm46compat.h>
+
+#define _RPMVSF_NOSIGNATURES (RPMVSF_NODSAHEADER | RPMVSF_NORSAHEADER | RPMVSF_NODSA | RPMVSF_NORSA)
+#define _RPMVSF_NODIGESTS (RPMVSF_NOSHA1HEADER | RPMVSF_NOMD5HEADER | RPMVSF_NOSHA1 | RPMVSF_NOMD5)
+
+static inline const char * headerGetString(Header h, rpmTag tag)
+{
+ const char *res = NULL;
+ struct rpmtd_s td;
+
+ if (headerGet(h, tag, &td, HEADERGET_MINMEM)) {
+ if (rpmtdCount(&td) == 1) {
+ res = rpmtdGetString(&td);
+ }
+ rpmtdFreeData(&td);
+ }
+ return res;
+}
+
+static inline uint64_t rpmtdGetNumber(rpmtd td)
+{
+ uint64_t val = 0;
+ int ix;
+ assert(td != NULL);
+ ix = (td->ix >= 0 ? td->ix : 0);
+
+ switch (td->type) {
+ case RPM_INT64_TYPE:
+ val = *((uint64_t *) td->data + ix);
+ break;
+ case RPM_INT32_TYPE:
+ val = *((uint32_t *) td->data + ix);
+ break;
+ case RPM_INT16_TYPE:
+ val = *((uint16_t *) td->data + ix);
+ break;
+ case RPM_INT8_TYPE:
+ case RPM_CHAR_TYPE:
+ val = *((uint8_t *) td->data + ix);
+ break;
+ default:
+ break;
+ }
+ return val;
+}
+
+static inline uint64_t headerGetNumber(Header h, rpmTag tag)
+{
+ uint64_t res = 0;
+ struct rpmtd_s td;
+
+ if (headerGet(h, tag, &td, HEADERGET_EXT)) {
+ if (rpmtdCount(&td) == 1) {
+ res = rpmtdGetNumber(&td);
+ }
+ rpmtdFreeData(&td);
+ }
+ return res;
+}
+
+#endif /* RPMORG_COMPAT_H */
diff -ru libdnf-0.22.0.orig/CMakeLists.txt libdnf-0.22.0/CMakeLists.txt
--- libdnf-0.22.0.orig/CMakeLists.txt 2019-06-01 21:09:37.000000000 +0200
+++ libdnf-0.22.0/CMakeLists.txt 2019-06-02 10:44:31.421947961 +0200
@@ -54,6 +54,8 @@
pkg_check_modules(SMARTCOLS REQUIRED smartcols)
FIND_LIBRARY (RPMDB_LIBRARY NAMES rpmdb)
find_package (LibSolv 0.6.30 REQUIRED COMPONENTS ext)
+PKG_CHECK_MODULES(RPM rpm REQUIRED)
+include_directories (${RPM_INCLUDE_DIRS})
if (ENABLE_RHSM_SUPPORT)
pkg_check_modules (RHSM REQUIRED librhsm>=0.0.3)
include_directories (${RHSM_INCLUDE_DIRS})
@@ -96,13 +98,14 @@
# rpm:
FIND_LIBRARY (RPMDB_LIBRARY NAMES rpmdb)
-IF (NOT RPMDB_LIBRARY)
- FIND_LIBRARY (RPMDB_LIBRARY NAMES rpm)
-ENDIF (NOT RPMDB_LIBRARY)
+FIND_LIBRARY (RPMLIB_LIBRARY NAMES rpm)
FIND_LIBRARY (RPMIO_LIBRARY NAMES rpmio)
IF (RPMIO_LIBRARY)
SET(RPMDB_LIBRARY ${RPMIO_LIBRARY} ${RPMDB_LIBRARY})
ENDIF (RPMIO_LIBRARY)
+IF (RPMLIB_LIBRARY)
+ SET(RPMDB_LIBRARY ${RPMDB_LIBRARY} ${RPMLIB_LIBRARY})
+ENDIF (RPMLIB_LIBRARY)
pkg_check_modules(SQLite3 sqlite3 REQUIRED)
diff -ru libdnf-0.22.0.orig/libdnf/dnf-context.cpp libdnf-0.22.0/libdnf/dnf-context.cpp
--- libdnf-0.22.0.orig/libdnf/dnf-context.cpp 2019-06-01 21:09:37.000000000 +0200
+++ libdnf-0.22.0/libdnf/dnf-context.cpp 2019-06-02 10:38:31.050550741 +0200
@@ -36,7 +36,7 @@
#include <string>
#include <vector>
#include <gio/gio.h>
-#include <rpm/rpmlib.h>
+#include "rpmorg-compat.h"
#include <rpm/rpmmacro.h>
#include <rpm/rpmts.h>
#include <rpm/rpmdb.h>
@@ -328,9 +328,9 @@
return priv->base_arch;
/* get info from RPM */
- rpmGetOsInfo(&value, NULL);
+ value = rpmExpand("%{_target_os}", NULL);
priv->os_info = g_strdup(value);
- rpmGetArchInfo(&value, NULL);
+ value = rpmExpand("%{_target_cpu}", NULL);
priv->arch_info = g_strdup(value);
/* find the base architecture */
diff -ru libdnf-0.22.0.orig/libdnf/dnf-keyring.cpp libdnf-0.22.0/libdnf/dnf-keyring.cpp
--- libdnf-0.22.0.orig/libdnf/dnf-keyring.cpp 2019-06-01 21:09:37.000000000 +0200
+++ libdnf-0.22.0/libdnf/dnf-keyring.cpp 2019-06-02 10:48:29.955925592 +0200
@@ -32,7 +32,9 @@
#include <stdlib.h>
#include <glib.h>
-#include <rpm/rpmlib.h>
+#include "rpmorg-compat.h"
+#include <rpm/rpmcli.h>
+#include <rpm/rpmio.h>
#include <rpm/rpmts.h>
#include "dnf-types.h"
@@ -52,7 +54,7 @@
* Since: 0.1.0
**/
gboolean
-dnf_keyring_add_public_key(rpmKeyring keyring,
+dnf_keyring_add_public_key(const rpmts ts,
const gchar *filename,
GError **error)
{
@@ -60,10 +62,7 @@
gint rc;
gsize len;
pgpArmor armor;
- pgpDig dig = NULL;
- rpmPubkey pubkey = NULL;
uint8_t *pkt = NULL;
- g_autofree gchar *data = NULL;
/* ignore symlinks and directories */
if (!g_file_test(filename, G_FILE_TEST_IS_REGULAR))
@@ -71,13 +70,8 @@
if (g_file_test(filename, G_FILE_TEST_IS_SYMLINK))
goto out;
- /* get data */
- ret = g_file_get_contents(filename, &data, &len, error);
- if (!ret)
- goto out;
-
/* rip off the ASCII armor and parse it */
- armor = pgpParsePkts(data, &pkt, &len);
+ armor = pgpReadPkts(filename, &pkt, &len);
if (armor < 0) {
ret = FALSE;
g_set_error(error,
@@ -100,7 +94,7 @@
}
/* test each one */
- pubkey = rpmPubkeyNew(pkt, len);
+/* pubkey = rpmPubkeyNew(pkt, len);
if (pubkey == NULL) {
ret = FALSE;
g_set_error(error,
@@ -109,19 +103,19 @@
"failed to parse public key for %s",
filename);
goto out;
- }
+ } */
/* does the key exist in the keyring */
- dig = rpmPubkeyDig(pubkey);
+/* dig = rpmPubkeyDig(pubkey);
rc = rpmKeyringLookup(keyring, dig);
if (rc == RPMRC_OK) {
ret = TRUE;
g_debug("%s is already present", filename);
goto out;
- }
+ } */
/* add to rpmdb automatically, without a prompt */
- rc = rpmKeyringAddKey(keyring, pubkey);
+ rc = rpmcliImportPubkey(ts, pkt, len);
if (rc == 1) {
ret = TRUE;
g_debug("%s is already added", filename);
@@ -142,10 +136,10 @@
out:
if (pkt != NULL)
free(pkt); /* yes, free() */
- if (pubkey != NULL)
+/* if (pubkey != NULL)
rpmPubkeyFree(pubkey);
if (dig != NULL)
- pgpFreeDig(dig);
+ pgpFreeDig(dig); */
return ret;
}
@@ -161,7 +155,7 @@
* Since: 0.1.0
**/
gboolean
-dnf_keyring_add_public_keys(rpmKeyring keyring, GError **error)
+dnf_keyring_add_public_keys(rpmts ts, GError **error)
{
const gchar *gpg_dir = "/etc/pki/rpm-gpg";
gboolean ret = TRUE;
@@ -178,7 +172,7 @@
if (filename == NULL)
break;
path_tmp = g_build_filename(gpg_dir, filename, NULL);
- ret = dnf_keyring_add_public_key(keyring, path_tmp, error);
+ ret = dnf_keyring_add_public_key(ts, path_tmp, error);
} while (ret);
return TRUE;
}
@@ -187,7 +181,7 @@
* dnf_keyring_check_untrusted_file:
*/
gboolean
-dnf_keyring_check_untrusted_file(rpmKeyring keyring,
+dnf_keyring_check_untrusted_file(
const gchar *filename,
GError **error)
{
@@ -237,10 +231,10 @@
}
/* convert and upscale */
- headerConvert(hdr, HEADERCONV_RETROFIT_V3);
+ /*headerConvert(hdr, HEADERCONV_RETROFIT_V3);*/
/* get RSA key */
- td = rpmtdNew();
+ td = (rpmtd)malloc (sizeof (*td));
rc = static_cast<rpmRC>(headerGet(hdr, RPMTAG_RSAHEADER, td, HEADERGET_MINMEM));
if (rc != RPMRC_NOTFOUND) {
/* try to read DSA key as a fallback */
@@ -259,7 +253,7 @@
}
/* make it into a digest */
- dig = pgpNewDig();
+ dig = rpmtsDig(ts);
rc = static_cast<rpmRC>(pgpPrtPkts(static_cast<const uint8_t *>(td->data), td->count, dig, 0));
if (rc != RPMRC_OK) {
g_set_error(error,
@@ -271,7 +265,7 @@
}
/* does the key exist in the keyring */
- rc = rpmKeyringLookup(keyring, dig);
+ rc = rpmtsFindPubkey(ts, dig);
if (rc != RPMRC_OK) {
g_set_error(error,
DNF_ERROR,
@@ -286,15 +280,15 @@
ret = TRUE;
out:
if (dig != NULL)
- pgpFreeDig(dig);
+ dig = pgpDigFree(dig);
if (td != NULL) {
rpmtdFreeData(td);
- rpmtdFree(td);
+ free(td);
}
if (ts != NULL)
- rpmtsFree(ts);
+ ts = rpmtsFree(ts);
if (hdr != NULL)
- headerFree(hdr);
+ hdr = headerFree(hdr);
if (fd != NULL)
Fclose(fd);
return ret;
diff -ru libdnf-0.22.0.orig/libdnf/dnf-keyring.h libdnf-0.22.0/libdnf/dnf-keyring.h
--- libdnf-0.22.0.orig/libdnf/dnf-keyring.h 2019-06-01 21:09:37.000000000 +0200
+++ libdnf-0.22.0/libdnf/dnf-keyring.h 2019-06-02 10:46:47.839503435 +0200
@@ -24,16 +24,16 @@
#include <glib.h>
-#include <rpm/rpmkeyring.h>
+#include <rpm/rpmts.h>
G_BEGIN_DECLS
-gboolean dnf_keyring_add_public_key (rpmKeyring keyring,
+gboolean dnf_keyring_add_public_key (const rpmts ts,
const gchar *filename,
GError **error);
-gboolean dnf_keyring_add_public_keys (rpmKeyring keyring,
+gboolean dnf_keyring_add_public_keys (rpmts ts,
GError **error);
-gboolean dnf_keyring_check_untrusted_file (rpmKeyring keyring,
+gboolean dnf_keyring_check_untrusted_file (
const gchar *filename,
GError **error);
diff -ru libdnf-0.22.0.orig/libdnf/dnf-repo.cpp libdnf-0.22.0/libdnf/dnf-repo.cpp
--- libdnf-0.22.0.orig/libdnf/dnf-repo.cpp 2019-06-01 21:09:37.000000000 +0200
+++ libdnf-0.22.0/libdnf/dnf-repo.cpp 2019-06-02 10:38:31.051550744 +0200
@@ -1558,15 +1558,12 @@
GError **error)
{
gboolean ret;
- rpmKeyring keyring;
rpmts ts;
/* then import to rpmdb */
ts = rpmtsCreate();
- keyring = rpmtsGetKeyring(ts, 1);
- ret = dnf_keyring_add_public_key(keyring, tmp_path, error);
- rpmKeyringFree(keyring);
- rpmtsFree(ts);
+ ret = dnf_keyring_add_public_key(ts, tmp_path, error);
+ ts = rpmtsFree(ts);
return ret;
}
diff -ru libdnf-0.22.0.orig/libdnf/dnf-rpmts.cpp libdnf-0.22.0/libdnf/dnf-rpmts.cpp
--- libdnf-0.22.0.orig/libdnf/dnf-rpmts.cpp 2019-06-01 21:09:37.000000000 +0200
+++ libdnf-0.22.0/libdnf/dnf-rpmts.cpp 2019-06-02 10:38:31.051550744 +0200
@@ -32,7 +32,8 @@
#include <glib.h>
-#include <rpm/rpmlib.h>
+#define _RPMLOG_INTERNAL
+#include <rpm/rpm46compat.h>
#include <rpm/rpmlog.h>
#include <rpm/rpmdb.h>
@@ -157,7 +158,7 @@
}
out:
Fclose(fd);
- headerFree(hdr);
+ hdr = headerFree(hdr);
return ret;
}
@@ -218,7 +219,7 @@
DNF_ERROR_INTERNAL_ERROR,
_("Error running transaction and no problems were reported!"));
out:
- rpmpsFree(probs);
+ probs = rpmpsFree(probs);
return ret;
}
@@ -231,11 +232,11 @@
GString **string =(GString **) data;
/* only log errors */
- if (rpmlogRecPriority(rec) != RPMLOG_ERR)
+ if (rec->pri != RPMLOG_ERR)
return RPMLOG_DEFAULT;
/* do not log internal BDB errors */
- if (g_strstr_len(rpmlogRecMessage(rec), -1, "BDB") != NULL)
+ if (g_strstr_len(rec->message, -1, "BDB") != NULL)
return 0;
/* create string if required */
@@ -245,7 +246,7 @@
/* if text already exists, join them */
if ((*string)->len > 0)
g_string_append(*string, ": ");
- g_string_append(*string, rpmlogRecMessage(rec));
+ g_string_append(*string, rec->message);
/* remove the trailing /n which rpm does */
if ((*string)->len > 0)
@@ -294,7 +295,7 @@
}
/* success */
- headerLink(hdr);
+ hdr = headerLink(hdr);
out:
rpmlogSetCallback(NULL, NULL);
if (iter != NULL)
@@ -340,6 +341,6 @@
}
out:
if (hdr != NULL)
- headerFree(hdr);
+ hdr = headerFree(hdr);
return ret;
}
diff -ru libdnf-0.22.0.orig/libdnf/dnf-transaction.cpp libdnf-0.22.0/libdnf/dnf-transaction.cpp
--- libdnf-0.22.0.orig/libdnf/dnf-transaction.cpp 2019-06-01 21:09:37.000000000 +0200
+++ libdnf-0.22.0/libdnf/dnf-transaction.cpp 2019-06-02 10:55:58.480821893 +0200
@@ -28,7 +28,7 @@
* This object represents an RPM transaction.
*/
-#include <rpm/rpmlib.h>
+#include "rpmorg-compat.h"
#include <rpm/rpmlog.h>
#include <rpm/rpmts.h>
@@ -56,7 +56,6 @@
} DnfTransactionStep;
typedef struct {
- rpmKeyring keyring;
rpmts ts;
DnfContext *context; /* weak reference */
GPtrArray *repos;
@@ -93,7 +92,6 @@
g_ptr_array_unref(priv->pkgs_to_download);
g_timer_destroy(priv->timer);
- rpmKeyringFree(priv->keyring);
rpmtsFree(priv->ts);
if (priv->swdb != NULL)
@@ -335,7 +333,7 @@
}
/* check file */
- if (!dnf_keyring_check_untrusted_file(priv->keyring, fn, &error_local)) {
+ if (!dnf_keyring_check_untrusted_file(fn, &error_local)) {
/* probably an i/o error */
if (!g_error_matches(error_local, DNF_ERROR, DNF_ERROR_GPG_SIGNATURE_INVALID)) {
@@ -692,22 +690,6 @@
/* don't do anything */
break;
- case RPMCALLBACK_INST_STOP:
- pkg = dnf_find_pkg_from_header(priv->install, hdr);
- if (pkg == NULL && filename != NULL) {
- pkg = dnf_find_pkg_from_filename_suffix(priv->install, filename);
- }
-
- // transaction item install complete
- _swdb_transaction_item_progress(swdb, pkg);
-
- /* phase complete */
- ret = dnf_state_done(priv->state, &error_local);
- if (!ret) {
- g_warning("state increment failed: %s", error_local->message);
- }
- break;
-
case RPMCALLBACK_UNINST_STOP:
pkg = dnf_find_pkg_from_header(priv->remove, hdr);
@@ -1025,7 +1007,7 @@
DnfTransactionPrivate *priv = GET_PRIVATE(transaction);
/* import all system wide GPG keys */
- if (!dnf_keyring_add_public_keys(priv->keyring, error))
+ if (!dnf_keyring_add_public_keys(priv->ts, error))
return FALSE;
/* import downloaded repo GPG keys */
@@ -1038,7 +1020,7 @@
const char *pubkey = *iter;
if (g_file_test(pubkey, G_FILE_TEST_EXISTS)) {
/* import */
- if (!dnf_keyring_add_public_key(priv->keyring, pubkey, error))
+ if (!dnf_keyring_add_public_key(priv->ts, pubkey, error))
return FALSE;
}
}
@@ -1134,12 +1116,7 @@
/* setup the transaction */
tmp = dnf_context_get_install_root(priv->context);
- rc = rpmtsSetRootDir(priv->ts, tmp);
- if (rc < 0) {
- ret = FALSE;
- g_set_error_literal(error, DNF_ERROR, DNF_ERROR_INTERNAL_ERROR, _("failed to set root"));
- goto out;
- }
+ rpmtsSetRootDir(priv->ts, tmp);
rpmtsSetNotifyCallback(priv->ts, dnf_transaction_ts_progress_cb, transaction);
/* add things to install */
@@ -1471,6 +1448,5 @@
g_object_add_weak_pointer(G_OBJECT(priv->context), (void **)&priv->context);
priv->ts = rpmtsCreate();
rpmtsSetRootDir(priv->ts, dnf_context_get_install_root(context));
- priv->keyring = rpmtsGetKeyring(priv->ts, 1);
return transaction;
}
--- libdnf-0.22.0/libdnf/dnf-keyring.cpp.orig 2019-06-02 10:58:36.901502058 +0200
+++ libdnf-0.22.0/libdnf/dnf-keyring.cpp 2019-06-02 10:58:42.824527553 +0200
@@ -280,7 +280,7 @@
ret = TRUE;
out:
if (dig != NULL)
- dig = pgpDigFree(dig);
+ dig = pgpDigFree(dig, 0);
if (td != NULL) {
rpmtdFreeData(td);
free(td);
--- libdnf-0.22.0/libdnf/dnf-keyring.cpp.orig 2019-06-02 11:26:04.809681377 +0200
+++ libdnf-0.22.0/libdnf/dnf-keyring.cpp 2019-06-02 11:24:00.029136905 +0200
@@ -215,7 +215,7 @@
/* we don't want to abort on missing keys */
ts = rpmtsCreate();
- rpmtsSetVSFlags(ts, _RPMVSF_NOSIGNATURES);
+ rpmtsSetVSFlags(ts, (rpmVSFlags)_RPMVSF_NOSIGNATURES);
/* read in the file */
rc = rpmReadPackageFile(ts, fd, filename, &hdr);