Skip to content

Commit

Permalink
[libzypp] Use rpm platform file for architecture autodetection. JB#51353
Browse files Browse the repository at this point in the history
If /etc/rpm/platform file exists use the architecture defined. This way
we get correct behavior with for example aarch64 kernel and armv7hl
platform.
  • Loading branch information
jusa committed Nov 26, 2020
1 parent 7be7f21 commit 5902f7c
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
65 changes: 65 additions & 0 deletions rpm/0006-Use-rpm-platform-for-architecture-autodetection.patch
@@ -0,0 +1,65 @@
From d55afcc05982769183c5d78e158157065a12d7db Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Juho=20H=C3=A4m=C3=A4l=C3=A4inen?=
<juho.hamalainen@jolla.com>
Date: Wed, 25 Nov 2020 14:03:30 +0200
Subject: [PATCH] Use rpm platform for architecture autodetection.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

If /etc/rpm/platform file exists use the architecture defined. This way
we get correct behavior with for example aarch64 kernel and armv7hl
platform.

Signed-off-by: Juho Hämäläinen <juho.hamalainen@jolla.com>
---
zypp/ZConfig.cc | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)

diff --git a/zypp/ZConfig.cc b/zypp/ZConfig.cc
index 3bf1185af..9ebccea51 100644
--- a/zypp/ZConfig.cc
+++ b/zypp/ZConfig.cc
@@ -164,6 +164,39 @@ namespace zypp
architecture = Arch_ppc64p7;
}
#endif
+
+ /* JB#51353 - We need to override architecture when we get certain architectures from uname
+ * which don't match platform. For example aarch64 kernel with armv7hl platform.
+ * This detection mimics what is implemented in kickstart file, writing platform architecture
+ * to /etc/rpm/platform - rpm uses this file to get it right and we use it now as well.
+ * */
+ std::ifstream rpm_platform( "/etc/rpm/platform" );
+
+ if ( rpm_platform )
+ {
+ std::string rpmArch;
+
+ for( iostr::EachLine in( rpm_platform ); in; in.next() )
+ {
+ std::string s = *in;
+ size_t pos = s.find ("-");
+
+ if ( pos != std::string::npos )
+ {
+ rpmArch = s.substr (0, pos);
+ break;
+ }
+ }
+
+ if ( !rpmArch.empty() && rpmArch != architecture.asString() )
+ {
+ MIL << "Uname is '" << architecture
+ << "' but /etc/rpm/platform architecture is '" << rpmArch
+ << "' - use what platform says." << endl;
+ architecture = Arch(rpmArch);
+ }
+ }
+
return architecture;
}

--
2.25.1

1 change: 1 addition & 0 deletions rpm/libzypp.spec
Expand Up @@ -13,6 +13,7 @@ Patch2: 0002-Set-rpminstallexcludedocs--yes-Save-space-on.patch
Patch3: 0003-Ensure-that-the-destination-path-for-applyi.patch
Patch4: 0004-libzypp-Enable-netrcoptional-on-libcurl-to-allow-for.patch
Patch5: 0005-Disable-docs-building-with-force.patch
Patch6: 0006-Use-rpm-platform-for-architecture-autodetection.patch
BuildRequires: cmake
BuildRequires: pkgconfig(openssl) >= 1.1
# Need boost > 1.53 for string_ref utility
Expand Down

0 comments on commit 5902f7c

Please sign in to comment.