[packages/dnf5] - pulling *system* arch from cpu is so stupid on so many levels that it needs to disappear
baggins
baggins at pld-linux.org
Sun Feb 16 15:12:03 CET 2025
commit 1c05540345d0ae761fa93dce38674f1b3a0f7071
Author: Jan Rękorajski <baggins at pld-linux.org>
Date: Sun Feb 16 15:27:28 2025 +0100
- pulling *system* arch from cpu is so stupid on so many levels that it needs to disappear
dnf5.spec | 2 +
system-arch-from-rpmrc.patch | 110 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 112 insertions(+)
---
diff --git a/dnf5.spec b/dnf5.spec
index 7d70f71..86b25a1 100644
--- a/dnf5.spec
+++ b/dnf5.spec
@@ -41,6 +41,7 @@ Patch0: repos.d.patch
Patch1: uname-cpuinfo-deps.patch
Patch2: systemdunitdir.patch
Patch3: perl-long-long.patch
+Patch4: system-arch-from-rpmrc.patch
# sdbus-cpp 2.x
Patch100: 0001-cmake-Move-sdbus-c-check-to-one-place.patch
Patch101: 0002-dnfdaemon-sdbus-cpp-v.-2-requires-strong-types.patch
@@ -328,6 +329,7 @@ similar.
%patch -P 1 -p1
%patch -P 2 -p1
%patch -P 3 -p1
+%patch -P 4 -p1
%patch -P 100 -p1
%patch -P 101 -p1
%patch -P 102 -p1
diff --git a/system-arch-from-rpmrc.patch b/system-arch-from-rpmrc.patch
new file mode 100644
index 0000000..0596e04
--- /dev/null
+++ b/system-arch-from-rpmrc.patch
@@ -0,0 +1,110 @@
+--- dnf5-5.2.10.0/libdnf5/conf/config_main.cpp~ 2025-02-06 09:25:15.000000000 +0100
++++ dnf5-5.2.10.0/libdnf5/conf/config_main.cpp 2025-02-16 15:15:38.276658825 +0100
+@@ -90,7 +90,7 @@
+ static std::string get_user_agent() {
+ utils::OSRelease os_release;
+ auto os = utils::get_os();
+- auto base_arch = rpm::get_base_arch(utils::detect_arch());
++ auto base_arch = rpm::get_base_arch(utils::get_arch());
+
+ if (!(os_release.contains("NAME") && os_release.contains("VERSION_ID") && !os.empty() && !base_arch.empty())) {
+ return "libdnf";
+--- dnf5-5.2.10.0/libdnf5/conf/vars.cpp~ 2025-02-06 09:25:15.000000000 +0100
++++ dnf5-5.2.10.0/libdnf5/conf/vars.cpp 2025-02-16 15:11:22.079992155 +0100
+@@ -385,9 +385,9 @@
+ }
+
+ void Vars::detect_vars(const std::string & installroot) {
+- set_lazy("arch", []() -> auto { return std::make_unique<std::string>(utils::detect_arch()); }, Priority::AUTO);
++ set_lazy("arch", []() -> auto { return std::make_unique<std::string>(utils::get_arch()); }, Priority::AUTO);
+
+- utils::init_lib_rpm(get_value("arch").c_str());
++ utils::init_lib_rpm();
+
+ set_lazy(
+ "basearch",
+--- dnf5-5.2.10.0/libdnf5/utils/system.cpp.orig 2025-02-16 15:05:10.366658823 +0100
++++ dnf5-5.2.10.0/libdnf5/utils/system.cpp 2025-02-16 15:09:32.026658830 +0100
+@@ -27,61 +27,26 @@
+
+ namespace libdnf5::utils {
+
+-void init_lib_rpm(const char * arch) {
++void init_lib_rpm() {
+ static bool lib_rpm_initiated{false};
+ if (!lib_rpm_initiated) {
+- if (rpmReadConfigFiles(nullptr, arch) != 0) {
++ if (rpmReadConfigFiles(nullptr, NULL) != 0) {
+ throw RuntimeError(M_("failed to read rpm config files"));
+ }
+ lib_rpm_initiated = true;
+ }
+ }
+
+-/* ARM specific HWCAP defines may be missing on non-ARM devices */
+-#ifndef HWCAP_ARM_VFP
+-#define HWCAP_ARM_VFP (1 << 6)
+-#endif
+-#ifndef HWCAP_ARM_NEON
+-#define HWCAP_ARM_NEON (1 << 12)
+-#endif
+-
+-std::string detect_arch() {
+- struct utsname un;
+-
+- if (uname(&un) < 0) {
+- throw RuntimeError(M_("Failed to execute uname()"));
+- }
+-
+- if (!strncmp(un.machine, "armv", 4)) {
+- /* un.machine is armvXE, where X is version number and E is
+- * endianness (b or l); we need to add modifiers such as
+- * h (hardfloat), n (neon). Neon is a requirement of armv8 so
+- * as far as rpm is concerned armv8l is the equivalent of armv7hnl
+- * (or 7hnb) so we don't explicitly add 'n' for 8+ as it's expected. */
+- char endian = un.machine[strlen(un.machine) - 1];
+- char * modifier = un.machine + 5;
+- while (isdigit(*modifier)) /* keep armv7, armv8, armv9, armv10, armv100, ... */
+- modifier++;
+- if (getauxval(AT_HWCAP) & HWCAP_ARM_VFP)
+- *modifier++ = 'h';
+- if ((atoi(un.machine + 4) == 7) && (getauxval(AT_HWCAP) & HWCAP_ARM_NEON))
+- *modifier++ = 'n';
+- *modifier++ = endian;
+- *modifier = 0;
+- }
+-#ifdef __MIPSEL__
+- // support for little endian MIPS
+- if (!strcmp(un.machine, "mips"))
+- strcpy(un.machine, "mipsel");
+- else if (!strcmp(un.machine, "mips64"))
+- strcpy(un.machine, "mips64el");
+-#endif
+- return un.machine;
++std::string get_arch() {
++ const char * value;
++ init_lib_rpm();
++ rpmGetArchInfo(&value, nullptr);
++ return value;
+ }
+
+ std::string get_os() {
+ const char * value;
+- init_lib_rpm(detect_arch().c_str());
++ init_lib_rpm();
+ rpmGetOsInfo(&value, nullptr);
+ return value;
+ }
+--- dnf5-5.2.10.0/libdnf5/utils/system.hpp.orig 2025-02-06 09:25:15.000000000 +0100
++++ dnf5-5.2.10.0/libdnf5/utils/system.hpp 2025-02-16 15:17:46.629992165 +0100
+@@ -23,8 +23,8 @@
+
+ namespace libdnf5::utils {
+
+-void init_lib_rpm(const char * arch);
+-std::string detect_arch();
++void init_lib_rpm();
++std::string get_arch();
+ std::string get_os();
+
+ } // namespace libdnf5::utils
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/dnf5.git/commitdiff/671c535d102176c550c76febc1db09b5ba37c4a9
More information about the pld-cvs-commit
mailing list