Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

identity: remove requirement for coreos-assembler.basearch #876

Merged
merged 1 commit into from
Nov 2, 2022
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
1 change: 0 additions & 1 deletion docs/development/os-metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ Booted deployment must provide several mandatory metadata entries:
* `checksum`: OSTree commit revision
* `version`: OS version
* under `base-commit-meta`:
* `coreos-assembler.basearch`: base architecture
* `fedora-coreos.stream`: update stream

All those metadata entries must exist with a non-empty string value.
Expand Down
14 changes: 12 additions & 2 deletions src/identity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ impl Identity {
pub fn try_default() -> Result<Self> {
// Invoke rpm-ostree to get the status of the currently booted deployment.
let status = rpm_ostree::invoke_cli_status(true)?;
let basearch = rpm_ostree::parse_basearch(&status)
.context("failed to introspect OS base architecture")?;
let basearch = crate::identity::current_architeture().to_string();
let current_os =
rpm_ostree::parse_booted(&status).context("failed to introspect booted OS image")?;
let node_uuid = {
Expand Down Expand Up @@ -190,6 +189,17 @@ fn compute_node_uuid(app_id: &id128::Id128) -> Result<id128::Id128> {
Ok(id)
}

// Translate the architecture we were compiled for to the
// output from the `arch` command that is used for RPM and
// coreos-assembler builds.
pub(crate) fn current_architeture() -> &'static str {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

match std::env::consts::ARCH {
"powerpc64" if cfg!(target_endian = "big") => "ppc64",
"powerpc64" if cfg!(target_endian = "little") => "ppc64le",
o => o,
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
16 changes: 0 additions & 16 deletions src/rpm_ostree/cli_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ pub struct DeploymentJson {
/// Metadata from base commit (only fields relevant to zincati).
#[derive(Clone, Debug, Deserialize)]
struct BaseCommitMetaJson {
#[serde(rename = "coreos-assembler.basearch")]
basearch: String,
#[serde(rename = "fedora-coreos.stream")]
stream: String,
}
Expand All @@ -85,12 +83,6 @@ impl DeploymentJson {
}
}

/// Parse base architecture for booted deployment from status object.
pub fn parse_basearch(status: &StatusJson) -> Result<String> {
let json = booted_json(status)?;
Ok(json.base_metadata.basearch)
}

/// Parse the booted deployment from status object.
pub fn parse_booted(status: &StatusJson) -> Result<Release> {
let json = booted_json(status)?;
Expand Down Expand Up @@ -157,7 +149,6 @@ fn booted_json(status: &StatusJson) -> Result<DeploymentJson> {

ensure!(!booted.base_revision().is_empty(), "empty base revision");
ensure!(!booted.version.is_empty(), "empty version");
ensure!(!booted.base_metadata.basearch.is_empty(), "empty basearch");
Ok(booted)
}

Expand Down Expand Up @@ -244,13 +235,6 @@ mod tests {
}
}

#[test]
fn mock_booted_basearch() {
let status = mock_status("tests/fixtures/rpm-ostree-status.json").unwrap();
let booted = booted_json(&status).unwrap();
assert_eq!(booted.base_metadata.basearch, "x86_64");
}

#[test]
fn mock_booted_updates_stream() {
let status = mock_status("tests/fixtures/rpm-ostree-status.json").unwrap();
Expand Down
4 changes: 1 addition & 3 deletions src/rpm_ostree/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
mod cli_deploy;
mod cli_finalize;
mod cli_status;
pub use cli_status::{
invoke_cli_status, parse_basearch, parse_booted, parse_booted_updates_stream,
};
pub use cli_status::{invoke_cli_status, parse_booted, parse_booted_updates_stream};

mod actor;
pub use actor::{
Expand Down