From ded8d400b4fd961f51be8c8d72de4c888b377009 Mon Sep 17 00:00:00 2001 From: Maximilian Schmidt Date: Sat, 29 Jun 2024 18:26:21 +0200 Subject: [PATCH] Flash hardware ids to `/media/internal/` (#1085) --- crates/constants/src/lib.rs | 2 +- crates/nao/src/lib.rs | 5 ++--- tools/pepsi/src/gammaray.rs | 17 ++++++++++++++--- tools/pepsi/src/main.rs | 2 +- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/crates/constants/src/lib.rs b/crates/constants/src/lib.rs index 482babd60f..e02e4d9e2d 100644 --- a/crates/constants/src/lib.rs +++ b/crates/constants/src/lib.rs @@ -14,7 +14,7 @@ pub const HULA_DBUS_SERVICE: &str = "org.hulks.hula"; pub const HULA_SOCKET_PATH: &str = "/tmp/hula"; pub const OS_IS_NOT_LINUX: bool = !cfg!(target_os = "linux"); pub const OS_RELEASE_PATH: &str = "/etc/os-release"; -pub const OS_VERSION: &str = "7.5.0"; +pub const OS_VERSION: &str = "7.5.1"; pub const SDK_VERSION: &str = "7.5.0"; lazy_static! { diff --git a/crates/nao/src/lib.rs b/crates/nao/src/lib.rs index 0df1df5e05..35e13a8cc1 100644 --- a/crates/nao/src/lib.rs +++ b/crates/nao/src/lib.rs @@ -83,7 +83,7 @@ impl Nao { command } - fn rsync_with_nao(&self, mkpath: bool) -> Command { + pub fn rsync_with_nao(&self, mkpath: bool) -> Command { let mut command = Command::new("rsync"); let ssh_flags = self.get_ssh_flags().join(" "); command @@ -376,8 +376,7 @@ impl Nao { .wrap_err("failed to execute rsync command")?; monitor_rsync_progress_with(rsync, progress_callback).await?; - - self.reboot().await + Ok(()) } } diff --git a/tools/pepsi/src/gammaray.rs b/tools/pepsi/src/gammaray.rs index b058661850..4ac03bd8bf 100644 --- a/tools/pepsi/src/gammaray.rs +++ b/tools/pepsi/src/gammaray.rs @@ -7,7 +7,7 @@ use argument_parsers::NaoAddress; use constants::OS_VERSION; use nao::Nao; use opn::verify_image; -use repository::get_image_path; +use repository::{get_image_path, Repository}; use crate::progress_indicator::ProgressIndicator; @@ -24,7 +24,7 @@ pub struct Arguments { naos: Vec, } -pub async fn gammaray(arguments: Arguments) -> Result<()> { +pub async fn gammaray(arguments: Arguments, repository: &Repository) -> Result<()> { let version = arguments.os_version.as_deref().unwrap_or(OS_VERSION); let image_path = match arguments.image_path { Some(image_path) => image_path, @@ -34,6 +34,8 @@ pub async fn gammaray(arguments: Arguments) -> Result<()> { verify_image(image_path).wrap_err("image verification failed")?; + let hardware_ids = &repository.parameters_root().join("hardware_ids.json"); + ProgressIndicator::map_tasks( arguments.naos, "Uploading image ...", @@ -43,7 +45,16 @@ pub async fn gammaray(arguments: Arguments) -> Result<()> { progress_bar.set_message(format!("Uploading image: {}", msg)) }) .await - .wrap_err_with(|| format!("failed to flash image to {nao_address}")) + .wrap_err_with(|| format!("failed to flash image to {nao_address}"))?; + progress_bar.set_message("Uploading hardware ids..."); + nao.rsync_with_nao(false) + .arg(hardware_ids.to_str().unwrap()) + .arg(format!("{}:/media/internal/", nao.host)) + .spawn() + .wrap_err("failed to upload hardware ids")?; + nao.reboot() + .await + .wrap_err_with(|| format!("failed to reboot {nao_address}")) }, ) .await; diff --git a/tools/pepsi/src/main.rs b/tools/pepsi/src/main.rs index 8af2ab18b7..e693bb8b19 100644 --- a/tools/pepsi/src/main.rs +++ b/tools/pepsi/src/main.rs @@ -85,7 +85,7 @@ async fn main() -> Result<()> { Command::Completions(arguments) => completions(arguments, Arguments::command()) .await .wrap_err("failed to execute completion command")?, - Command::Gammaray(arguments) => gammaray(arguments) + Command::Gammaray(arguments) => gammaray(arguments, &repository?) .await .wrap_err("failed to execute gammaray command")?, Command::Hulk(arguments) => hulk(arguments)