Compare commits

...

No commits in common. "a8" and "a10s" have entirely different histories.
a8 ... a10s

6 changed files with 114 additions and 258 deletions

View File

@ -1,5 +1,4 @@
actions:
- modify_release:
- suffix: ".alma.1"
enabled: true
@ -8,13 +7,17 @@ actions:
- name: "Eduard Abdullin"
email: "eabdullin@almalinux.org"
line:
- "Added patch for almalinux bugtracker"
- "Added patch to support multiple keys"
- "Add x86_64_v2 to arch_map"
- "Add link to AlmaLinux bugtracker"
- "Fix tests on x86_64_v2"
- add_files:
- type: "patch"
name: "almalinux_bugtracker.patch"
number: 10001
name: "0001-Add-link-to-AlmaLinux-bugtracker.patch"
number: 1001
- type: "patch"
name: "dnf-keyring-support-multiple-keys.patch"
number: 10002
name: "0001-Add-x86_64_v2-to-arch_map.patch"
number: "Latest"
- type: "patch"
name: "0001-Add-x86_64_v2-to-tests.patch"
number: "Latest"

View File

@ -0,0 +1,38 @@
From 5f7e4b85ed7331eb27654bb3dbab9592a3f8f722 Mon Sep 17 00:00:00 2001
From: eabdullin <ed.abdullin.1@gmail.com>
Date: Wed, 31 Jul 2024 16:18:32 +0300
Subject: [PATCH 1/2] Add link to AlmaLinux bugtracker
---
docs/hawkey/conf.py | 2 +-
libdnf/conf/Const.hpp | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/docs/hawkey/conf.py b/docs/hawkey/conf.py
index 93330c2..5ea39da 100644
--- a/docs/hawkey/conf.py
+++ b/docs/hawkey/conf.py
@@ -260,6 +260,6 @@ texinfo_documents = [
rst_prolog = """
.. default-domain:: py
.. _libsolv: https://github.com/openSUSE/libsolv
-.. _bugzilla: https://bugzilla.redhat.com/enter_bug.cgi?product=Fedora&component=hawkey
+.. _bugzilla: https://bugs.almalinux.org/
"""
diff --git a/libdnf/conf/Const.hpp b/libdnf/conf/Const.hpp
index ba21bbe..28cfa57 100644
--- a/libdnf/conf/Const.hpp
+++ b/libdnf/conf/Const.hpp
@@ -41,7 +41,7 @@ const std::vector<std::string> INSTALLONLYPKGS{"kernel", "kernel-PAE",
"installonlypkg(vm)",
"multiversion(kernel)"};
-constexpr const char * BUGTRACKER="https://bugzilla.redhat.com/enter_bug.cgi?product=Fedora&component=dnf";
+constexpr const char * BUGTRACKER="https://bugs.almalinux.org/";
}
--
2.39.3 (Apple Git-146)

View File

@ -0,0 +1,24 @@
From 51bf44398eedd4ede0f5021d477b8ef5ac0dc144 Mon Sep 17 00:00:00 2001
From: eabdullin <ed.abdullin.1@gmail.com>
Date: Thu, 12 Sep 2024 11:36:09 +0300
Subject: [PATCH] Add x86_64_v2 to arch_map
---
libdnf/dnf-context.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/libdnf/dnf-context.cpp b/libdnf/dnf-context.cpp
index d019743..37847ea 100644
--- a/libdnf/dnf-context.cpp
+++ b/libdnf/dnf-context.cpp
@@ -119,6 +119,7 @@ static const struct {
{ "sparc", { "sparc", "sparc64", "sparc64v", "sparcv8",
"sparcv9", "sparcv9v", NULL } },
{ "x86_64", { "x86_64", "amd64", "ia32e", NULL } },
+ { "x86_64_v2", { "x86_64_v2", NULL } },
{ "loongarch64", { "loongarch64", NULL } },
{ NULL, { NULL } }
};
--
2.39.3 (Apple Git-146)

View File

@ -0,0 +1,42 @@
From 9b2b677bee48f18d41f958f01e00142b0e39e543 Mon Sep 17 00:00:00 2001
From: eabdullin <ed.abdullin.1@gmail.com>
Date: Wed, 31 Jul 2024 16:34:28 +0300
Subject: [PATCH] Add x86_64_v2 to tests
---
tests/hawkey/test_sack.cpp | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/tests/hawkey/test_sack.cpp b/tests/hawkey/test_sack.cpp
index 98a8660..5b085f3 100644
--- a/tests/hawkey/test_sack.cpp
+++ b/tests/hawkey/test_sack.cpp
@@ -83,7 +83,7 @@ START_TEST(test_list_arches)
const char ** arches = dnf_sack_list_arches(sack);
/* noarch, x86_64, athlon, i686, i586, i486, i386 */
- fail_unless(g_strv_length((gchar**)arches) >= 6 && g_strv_length((gchar**)arches) <= 7);
+ fail_unless(g_strv_length((gchar**)arches) >= 6 && g_strv_length((gchar**)arches) <= 8);
if (g_strv_length((gchar**)arches) == 7) {
// Fedora, Mageia
@@ -94,6 +94,16 @@ START_TEST(test_list_arches)
ck_assert_str_eq(arches[4], "i586");
ck_assert_str_eq(arches[5], "i486");
ck_assert_str_eq(arches[6], "i386");
+ } else if (g_strv_length((gchar**)arches) == 8) {
+ // AlmaLinux x86_64_v2 arch is available
+ ck_assert_str_eq(arches[0], "noarch");
+ ck_assert_str_eq(arches[1], "x86_64");
+ ck_assert_str_eq(arches[2], "x86_64_v2");
+ ck_assert_str_eq(arches[3], "athlon");
+ ck_assert_str_eq(arches[4], "i686");
+ ck_assert_str_eq(arches[5], "i586");
+ ck_assert_str_eq(arches[6], "i486");
+ ck_assert_str_eq(arches[7], "i386");
} else {
// openSUSE, Debian - "athlon" is not available
ck_assert_str_eq(arches[0], "noarch");
--
2.39.3 (Apple Git-146)

View File

@ -1,23 +0,0 @@
diff -aruN libdnf-0.63.0/docs/hawkey/conf.py libdnf-0.63.0_alma/docs/hawkey/conf.py
--- libdnf-0.63.0/docs/hawkey/conf.py 2021-05-18 17:07:23.000000000 +0300
+++ libdnf-0.63.0_alma/docs/hawkey/conf.py 2021-12-30 11:03:39.179244600 +0300
@@ -260,6 +260,6 @@
rst_prolog = """
.. default-domain:: py
.. _libsolv: https://github.com/openSUSE/libsolv
-.. _bugzilla: https://bugzilla.redhat.com/enter_bug.cgi?product=Fedora&component=hawkey
+.. _bugzilla: https://bugs.almalinux.org/
"""
diff -aruN libdnf-0.63.0/libdnf/conf/Const.hpp libdnf-0.63.0_alma/libdnf/conf/Const.hpp
--- libdnf-0.63.0/libdnf/conf/Const.hpp 2021-05-18 17:07:23.000000000 +0300
+++ libdnf-0.63.0_alma/libdnf/conf/Const.hpp 2021-12-30 11:03:47.004789800 +0300
@@ -41,7 +41,7 @@
"installonlypkg(vm)",
"multiversion(kernel)"};
-constexpr const char * BUGTRACKER="https://bugzilla.redhat.com/enter_bug.cgi?product=Fedora&component=dnf";
+constexpr const char * BUGTRACKER="https://bugs.almalinux.org/";
}

View File

@ -1,228 +0,0 @@
From 5b87a29c78fe7b3fce8ac167a1a650449d25f54c Mon Sep 17 00:00:00 2001
From: Dmitriy Popov <dpopov@cloudlinux.com>
Date: Wed, 1 May 2024 23:16:47 +0300
Subject: [PATCH] dnf-keyring-support-multiple-keys
Since it is known from the bug (and practically proven) that "rpm --import"
is capable of supporting multiple containers in one file, unlike the internal
implementation, due to the need to globally rewrite the structure of parameters.
https://github.com/rpm-software-management/rpm/pull/2242
"This does not affect rpmkeys --import because it explicitly checks
for multiple PGPTAG_PUBLIC_KEY packets and imports them separately"
The patch implies the logic of the cli rpmcliImportPubkeys
in dnf_keyring_add_public_key, except that instead of direct import,
it continues to expand the keyring as before, and then imports it,
making this change atomic.
Signed-off-by: Dmitriy Popov <dpopov@cloudlinux.com>
---
libdnf/dnf-keyring.cpp | 167 +++++++++++++++++++++++------------------
1 file changed, 96 insertions(+), 71 deletions(-)
diff --git a/libdnf/dnf-keyring.cpp b/libdnf/dnf-keyring.cpp
index 62a6248..f4afd35 100644
--- a/libdnf/dnf-keyring.cpp
+++ b/libdnf/dnf-keyring.cpp
@@ -62,13 +62,16 @@ dnf_keyring_add_public_key(rpmKeyring keyring,
gboolean ret = TRUE;
int rc;
gsize len;
- pgpArmor armor;
pgpDig dig = NULL;
rpmPubkey pubkey = NULL;
rpmPubkey *subkeys = NULL;
int nsubkeys = 0;
uint8_t *pkt = NULL;
g_autofree gchar *data = NULL;
+ char const * const pgpmark = "-----BEGIN PGP ";
+ size_t marklen = strlen(pgpmark);
+ int keyno = 1;
+ char *start = NULL;
/* ignore symlinks and directories */
if (!g_file_test(filename, G_FILE_TEST_IS_REGULAR))
@@ -81,79 +84,99 @@ dnf_keyring_add_public_key(rpmKeyring keyring,
if (!ret)
goto out;
- /* rip off the ASCII armor and parse it */
- armor = pgpParsePkts(data, &pkt, &len);
- if (armor < 0) {
- ret = FALSE;
- g_set_error(error,
- DNF_ERROR,
- DNF_ERROR_GPG_SIGNATURE_INVALID,
- "failed to parse PKI file %s",
- filename);
- goto out;
- }
-
- /* make sure it's something we can add to rpm */
- if (armor != PGPARMOR_PUBKEY) {
- ret = FALSE;
- g_set_error(error,
- DNF_ERROR,
- DNF_ERROR_GPG_SIGNATURE_INVALID,
- "PKI file %s is not a public key",
- filename);
- goto out;
- }
+ start = strstr(data, pgpmark);
- /* test each one */
- pubkey = rpmPubkeyNew(pkt, len);
- if (pubkey == NULL) {
- ret = FALSE;
- g_set_error(error,
- DNF_ERROR,
- DNF_ERROR_GPG_SIGNATURE_INVALID,
- "failed to parse public key for %s",
- filename);
- goto out;
- }
-
- /* does the key exist in the keyring */
- dig = rpmPubkeyDig(pubkey);
- rc = rpmKeyringLookup(keyring, dig);
- if (rc == RPMRC_OK) {
- ret = TRUE;
- g_debug("%s is already present", filename);
- goto out;
- }
+ do {
+ uint8_t *pkt = NULL;
+ uint8_t *pkti = NULL;
+ size_t pktlen = 0;
+ size_t certlen;
+
+ /* Read pgp packet. */
+ if (pgpParsePkts(start, &pkt, &pktlen) == PGPARMOR_PUBKEY) {
+ pkti = pkt;
+
+ /* Iterate over certificates in pkt */
+ while (pktlen > 0) {
+ if (pgpPubKeyCertLen(pkti, pktlen, &certlen)) {
+ g_debug("%s: key %d import failed.\n", filename, keyno);
+ break;
+ }
+
+ /* test each one */
+ pubkey = rpmPubkeyNew(pkti, certlen);
+ if (pubkey == NULL) {
+ ret = FALSE;
+ g_set_error(error,
+ DNF_ERROR,
+ DNF_ERROR_GPG_SIGNATURE_INVALID,
+ "failed to parse public key for %s",
+ filename);
+ goto out;
+ }
+
+ /* add to in-memory keyring */
+ rc = rpmKeyringAddKey(keyring, pubkey);
+ if (rc == 1) {
+ ret = TRUE;
+ g_debug("%s is already added", filename);
+ goto out;
+ } else if (rc < 0) {
+ ret = FALSE;
+ g_set_error(error,
+ DNF_ERROR,
+ DNF_ERROR_GPG_SIGNATURE_INVALID,
+ "failed to add public key %s to rpmdb",
+ filename);
+ goto out;
+ }
+
+ subkeys = rpmGetSubkeys(pubkey, &nsubkeys);
+ for (int i = 0; i < nsubkeys; i++) {
+ rpmPubkey subkey = subkeys[i];
+ if (rpmKeyringAddKey(keyring, subkey) < 0) {
+ ret = FALSE;
+ g_set_error(error,
+ DNF_ERROR,
+ DNF_ERROR_GPG_SIGNATURE_INVALID,
+ "failed to add subkeys for %s to rpmdb",
+ filename);
+ goto out;
+ }
+ }
+
+ pkti += certlen;
+ pktlen -= certlen;
+ }
+ } else {
+ g_debug("%s: key %d not an armored public key.\n", filename, keyno);
+ }
- /* add to rpmdb automatically, without a prompt */
- rc = rpmKeyringAddKey(keyring, pubkey);
- if (rc == 1) {
- ret = TRUE;
- g_debug("%s is already added", filename);
- goto out;
- } else if (rc < 0) {
- ret = FALSE;
- g_set_error(error,
- DNF_ERROR,
- DNF_ERROR_GPG_SIGNATURE_INVALID,
- "failed to add public key %s to rpmdb",
- filename);
- goto out;
- }
+ /* See if there are more keys in the buffer */
+ if (start && start + marklen < data + len) {
+ start = strstr(start + marklen, pgpmark);
+ } else {
+ start = NULL;
+ }
- subkeys = rpmGetSubkeys(pubkey, &nsubkeys);
- for (int i = 0; i < nsubkeys; i++) {
- rpmPubkey subkey = subkeys[i];
- if (rpmKeyringAddKey(keyring, subkey) < 0) {
- ret = FALSE;
- g_set_error(error,
- DNF_ERROR,
- DNF_ERROR_GPG_SIGNATURE_INVALID,
- "failed to add subkeys for %s to rpmdb",
- filename);
- goto out;
+ keyno++;
+ if (pkt != NULL)
+ free(pkt); /* yes, free() */
+ pkt = NULL;
+ if (pubkey != NULL)
+ rpmPubkeyFree(pubkey);
+ pubkey = NULL;
+ if (subkeys != NULL) {
+ for (int i = 0; i < nsubkeys; i++) {
+ if (subkeys[i] != NULL) {
+ rpmPubkeyFree (subkeys[i]);
+ subkeys[i] = NULL;
+ }
+ }
+ free (subkeys);
+ subkeys = NULL;
}
- }
+ } while (start != NULL);
/* success */
g_debug("added missing public key %s to rpmdb", filename);
@@ -165,7 +188,9 @@ out:
rpmPubkeyFree(pubkey);
if (subkeys != NULL) {
for (int i = 0; i < nsubkeys; i++) {
- rpmPubkeyFree(subkeys[i]);
+ if (subkeys[i] != NULL) {
+ rpmPubkeyFree (subkeys[i]);
+ }
}
free(subkeys);
}
--
2.34.1