Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions rust/agama-software/src/model/registration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ pub struct Registration {
root_dir: Utf8PathBuf,
product: String,
version: String,
arch: Arch,
// The connection parameters are kept because they are needed by the
// `to_registration_info` function.
connect_params: ConnectParams,
Expand Down Expand Up @@ -109,7 +110,7 @@ impl Registration {
version: &str,
code: Option<&str>,
) -> RegistrationResult<()> {
let product = Self::product_specification(name, version);
let product = Self::product_specification(name, version, self.arch);
let mut params = self.connect_params.clone();
params.token = code.map(ToString::to_string);

Expand Down Expand Up @@ -203,12 +204,15 @@ impl Registration {
}

fn base_product_specification(&self) -> suseconnect_agama::ProductSpecification {
Self::product_specification(&self.product, &self.version)
Self::product_specification(&self.product, &self.version, self.arch)
}

fn product_specification(id: &str, version: &str) -> suseconnect_agama::ProductSpecification {
fn product_specification(
id: &str,
version: &str,
arch: Arch,
) -> suseconnect_agama::ProductSpecification {
// We do not expect this to happen.
let arch = Arch::current().expect("Failed to determine the architecture");
suseconnect_agama::ProductSpecification {
identifier: id.to_string(),
arch: arch.to_string(),
Expand Down Expand Up @@ -308,7 +312,8 @@ impl RegistrationBuilder {
};
// https://github.com/agama-project/agama/blob/master/service/lib/agama/registration.rb#L294
let version = self.version.split(".").next().unwrap_or("1");
let target_distro = format!("{}-{}-{}", &self.product, version, std::env::consts::ARCH);
let arch = Arch::current().expect("Failed to determine the architecture");
let target_distro = format!("{}-{}-{}", &self.product, version, arch.to_string());
tracing::debug!("Announcing system {target_distro}");
let creds = handle_registration_error(
|| suseconnect_agama::announce_system(params.clone(), &target_distro),
Expand All @@ -332,6 +337,7 @@ impl RegistrationBuilder {
connect_params: params,
product: self.product.clone(),
version: self.version.clone(),
arch,
creds,
services: vec![],
addons: vec![],
Expand Down
15 changes: 7 additions & 8 deletions rust/agama-utils/src/arch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

//! Implement support for detecting and converting architeture identifiers.

use std::process::Command;

#[derive(Clone, Copy, Debug, PartialEq, strum::Display, strum::EnumString)]
#[strum(serialize_all = "lowercase")]
pub enum Arch {
Expand All @@ -42,12 +40,13 @@ pub enum Error {
impl Arch {
/// Returns the current architecture.
pub fn current() -> Result<Self, Error> {
let output = Command::new("uname").arg("-m").output()?;
let arch_str = String::from_utf8_lossy(&output.stdout).trim().to_string();
arch_str
.as_str()
.try_into()
.map_err(|_| Error::Unknown(arch_str))
match std::env::consts::ARCH {
"aarch64" => Ok(Arch::AARCH64),
"powerpc64" => Ok(Arch::PPC64LE),
"s390x" => Ok(Arch::S390X),
"x86_64" => Ok(Arch::X86_64),
_ => Err(Error::Unknown(std::env::consts::ARCH.to_string())),
}
}

/// Returns the identifier used in the products definition.
Expand Down
6 changes: 6 additions & 0 deletions rust/package/agama.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Fri Jan 23 09:53:37 UTC 2026 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

- Use the right architecture when regisrering a system in ppc64le
(gh#agama-project/agama#3068).

-------------------------------------------------------------------
Thu Jan 22 16:16:55 UTC 2026 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

Expand Down
Loading