Skip to content

Commit

Permalink
Revert "feat: use oma to update-os"
Browse files Browse the repository at this point in the history
This reverts commit 62fecdb.
  • Loading branch information
MingcongBai committed Jul 20, 2024
1 parent 5badef4 commit 1fa7924
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 18 deletions.
11 changes: 4 additions & 7 deletions src/actions/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ 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},
network::download_file_progress,
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]
Expand Down Expand Up @@ -380,12 +380,9 @@ pub fn update_os() -> Result<()> {
info!("Updating base OS...");
let instance = format!("update-{:x}", random::<u32>());
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)?;
Expand Down
3 changes: 1 addition & 2 deletions src/actions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>, Vec<(String, &'static str)>);
/// Ensure that the directories exist and mounted
Expand Down
12 changes: 3 additions & 9 deletions src/actions/packaging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -177,13 +177,8 @@ fn package_build_inner<P: AsRef<Path>>(
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 {
Expand All @@ -192,7 +187,6 @@ fn package_build_inner<P: AsRef<Path>>(
"Failed to update the OS, will retry in {} seconds ...",
interval
);
oma = false;
sleep(Duration::from_secs(interval));
}
}
Expand Down

0 comments on commit 1fa7924

Please sign in to comment.