context libdnf (microdnf): set and substitute $arch variable

Resolves: RHEL-80370
This commit is contained in:
Aleš Matěj 2026-06-10 15:42:57 +02:00
parent d71150502c
commit 40a49dab1b
2 changed files with 45 additions and 1 deletions

View File

@ -0,0 +1,39 @@
From 5f2278ee2a30b94b5d80ab480505bf6b4750dd1a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
Date: Thu, 28 May 2026 14:02:05 +0200
Subject: [PATCH] [context] automatically setup $arch variable
---
libdnf/dnf-repo.cpp | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/libdnf/dnf-repo.cpp b/libdnf/dnf-repo.cpp
index 7b4f83bb..0d92c676 100644
--- a/libdnf/dnf-repo.cpp
+++ b/libdnf/dnf-repo.cpp
@@ -1212,6 +1212,14 @@ dnf_repo_setup(DnfRepo *repo, GError **error) try
"basearch not set");
return FALSE;
}
+ auto * arch = dnf_context_get_arch_info(priv->context);
+ if (arch == NULL) {
+ g_set_error_literal(error,
+ DNF_ERROR,
+ DNF_ERROR_INTERNAL_ERROR,
+ "arch not set");
+ return FALSE;
+ }
release = g_key_file_get_string(priv->keyfile, "general", "version", NULL);
if (release == NULL) {
release = g_strdup(dnf_context_get_release_ver(priv->context));
@@ -1238,6 +1246,7 @@ dnf_repo_setup(DnfRepo *repo, GError **error) try
priv->urlvars = lr_urlvars_set(priv->urlvars, "releasever_major", release_major);
priv->urlvars = lr_urlvars_set(priv->urlvars, "releasever_minor", release_minor);
priv->urlvars = lr_urlvars_set(priv->urlvars, "basearch", basearch);
+ priv->urlvars = lr_urlvars_set(priv->urlvars, "arch", arch);
/* Call libdnf::dnf_context_load_vars(priv->context); only when values not in cache.
* But what about if variables on disk change during long running programs (PackageKit daemon)?
* if (!libdnf::dnf_context_get_vars_cached(priv->context))
--
2.54.0

View File

@ -56,7 +56,7 @@
Name: libdnf
Version: %{libdnf_major_version}.%{libdnf_minor_version}.%{libdnf_micro_version}
Release: 16%{?dist}
Release: 17%{?dist}
Summary: Library providing simplified C and Python API to libsolv
License: LGPL-2.1-or-later
URL: https://github.com/rpm-software-management/libdnf
@ -92,6 +92,7 @@ Patch28: 0028-Fix-dnf_keyring_add_public_key-to-add-all-keys-from-.patch
Patch29: 0029-Fix-dnf_keyring_add_public_key-to-add-keys-from-all-.patch
Patch30: 0030-Fix-formatting-error-messages-when-importing-subkeys.patch
Patch31: 0031-swig-Add-missing-template-for-std-vector-Transaction.patch
Patch32: 0032-context-automatically-setup-arch-variable.patch
BuildRequires: cmake
BuildRequires: gcc
@ -335,6 +336,10 @@ popd
%endif
%changelog
* Wed Jun 10 2026 Ales Matej <amatej@redhat.com> - 0.73.1-17
- context libdnf (microdnf): automatically set and substitute $arch variable
(RHEL-80370)
* Wed Apr 22 2026 Evan Goode <egoode@redhat.com> - 0.73.1-16
- swig: Add missing %template for std::vector<TransactionPersistence>
(RHEL-154736)