diff --git a/rust/agama-software/src/model/registration.rs b/rust/agama-software/src/model/registration.rs index e86456cad8..9ce1b67480 100644 --- a/rust/agama-software/src/model/registration.rs +++ b/rust/agama-software/src/model/registration.rs @@ -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, @@ -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); @@ -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(), @@ -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), @@ -332,6 +337,7 @@ impl RegistrationBuilder { connect_params: params, product: self.product.clone(), version: self.version.clone(), + arch, creds, services: vec![], addons: vec![], diff --git a/rust/agama-utils/src/arch.rs b/rust/agama-utils/src/arch.rs index 6277657382..aff1872ad3 100644 --- a/rust/agama-utils/src/arch.rs +++ b/rust/agama-utils/src/arch.rs @@ -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 { @@ -42,12 +40,13 @@ pub enum Error { impl Arch { /// Returns the current architecture. pub fn current() -> Result { - 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. diff --git a/rust/package/agama.changes b/rust/package/agama.changes index 3223a53af8..24f444664d 100644 --- a/rust/package/agama.changes +++ b/rust/package/agama.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Fri Jan 23 09:53:37 UTC 2026 - Imobach Gonzalez Sosa + +- 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