From 1fa7924fdc8b0f6be39a9f92b143a17903b67a49 Mon Sep 17 00:00:00 2001 From: Mingcong Bai Date: Sat, 20 Jul 2024 22:40:29 +0800 Subject: [PATCH] Revert "feat: use oma to update-os" This reverts commit 62fecdbb5cc808b06333f21c9f9e1a4dbccab398. --- src/actions/container.rs | 11 ++++------- src/actions/mod.rs | 3 +-- src/actions/packaging.rs | 12 +++--------- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/actions/container.rs b/src/actions/container.rs index 18356c5..a35db0e 100644 --- a/src/actions/container.rs +++ b/src/actions/container.rs @@ -11,7 +11,7 @@ use std::{ }; use crate::{ - actions::{ensure_host_sanity, OMA_UPDATE_SCRIPT}, + actions::ensure_host_sanity, common::*, config, error, info, machine::{self, get_container_ns_name, inspect_instance, spawn_container}, @@ -19,7 +19,7 @@ use crate::{ overlayfs, warn, }; -use super::{for_each_instance, APT_UPDATE_SCRIPT}; +use super::{for_each_instance, UPDATE_SCRIPT}; /// Get the branch name of the workspace TREE repository #[inline] @@ -380,12 +380,9 @@ pub fn update_os() -> Result<()> { info!("Updating base OS..."); let instance = format!("update-{:x}", random::()); add_instance(&instance)?; - let mut status = run_in_container(&instance, &["/bin/bash", "-ec", OMA_UPDATE_SCRIPT])?; + let status = run_in_container(&instance, &["/bin/bash", "-ec", UPDATE_SCRIPT])?; if status != 0 { - status = run_in_container(&instance, &["/bin/bash", "-ec", APT_UPDATE_SCRIPT])?; - if status != 0 { - return Err(anyhow!("Failed to update OS: {}", status)); - } + return Err(anyhow!("Failed to update OS: {}", status)); } commit_container(&instance)?; remove_instance(&instance)?; diff --git a/src/actions/mod.rs b/src/actions/mod.rs index d608b37..032f6e5 100644 --- a/src/actions/mod.rs +++ b/src/actions/mod.rs @@ -18,8 +18,7 @@ const DEFAULT_MOUNTS: &[(&str, &str)] = &[ ("SRCS", "/var/cache/acbs/tarballs"), ("CACHE", "/var/cache/apt/archives"), ]; -const APT_UPDATE_SCRIPT: &str = r#"export DEBIAN_FRONTEND=noninteractive;apt-get update -y --allow-releaseinfo-change && apt-get -y -o Dpkg::Options::="--force-confnew" full-upgrade --autoremove --purge && apt autoclean"#; -const OMA_UPDATE_SCRIPT: &str = r#"oma upgrade -y --force-confnew --no-progress && oma autoremove --remove-config && oma clean"#; +const UPDATE_SCRIPT: &str = r#"export DEBIAN_FRONTEND=noninteractive;apt-get update -y --allow-releaseinfo-change && apt-get -y -o Dpkg::Options::="--force-confnew" full-upgrade --autoremove --purge && apt autoclean"#; type MountOptions = (Vec, Vec<(String, &'static str)>); /// Ensure that the directories exist and mounted diff --git a/src/actions/packaging.rs b/src/actions/packaging.rs index a719e8d..f0c3956 100644 --- a/src/actions/packaging.rs +++ b/src/actions/packaging.rs @@ -12,11 +12,11 @@ use std::{ }; use walkdir::WalkDir; -use crate::{actions::OMA_UPDATE_SCRIPT, common::create_spinner, config, error, info, repo, warn}; +use crate::{common::create_spinner, config, error, info, repo, warn}; use super::{ container::{get_output_directory, mount_fs, rollback_container, run_in_container}, - APT_UPDATE_SCRIPT, + UPDATE_SCRIPT, }; #[derive(Debug, Clone, Deserialize, Serialize)] @@ -177,13 +177,8 @@ fn package_build_inner>( info!("Refreshing local repository..."); repo::init_repo(root.as_ref(), Path::new(instance))?; let mut status = -1; - let mut oma = true; for i in 1..=5 { - status = if oma { - run_in_container(instance, &["/bin/bash", "-ec", OMA_UPDATE_SCRIPT]).unwrap_or(-1) - } else { - run_in_container(instance, &["/bin/bash", "-ec", APT_UPDATE_SCRIPT]).unwrap_or(-1) - }; + status = run_in_container(instance, &["/bin/bash", "-ec", UPDATE_SCRIPT]).unwrap_or(-1); if status == 0 { break; } else { @@ -192,7 +187,6 @@ fn package_build_inner>( "Failed to update the OS, will retry in {} seconds ...", interval ); - oma = false; sleep(Duration::from_secs(interval)); } }