Skip to content

Commit

Permalink
workspace: replace extra-apt-repos with apt-repos
Browse files Browse the repository at this point in the history
  • Loading branch information
xtexx committed Jan 17, 2025
1 parent 6b06570 commit b64cc00
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
4 changes: 2 additions & 2 deletions ciel/src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,8 @@ impl ContainerConfig {
/// and [InstanceConfig::use_local_repo]),
/// `deb [trusted=yes] file:///debs/ /` will also be included.
pub fn all_apt_repos(&self) -> Vec<String> {
let mut repos = vec!["deb https://repo.aosc.io/debs/ stable main".to_string()];
repos.extend(self.workspace_config.extra_apt_repos.iter().cloned());
let mut repos = Vec::new();
repos.extend(self.workspace_config.apt_repos.iter().cloned());
repos.extend(self.instance_config.extra_apt_repos.iter().cloned());
if self.workspace_config.use_local_repo && self.instance_config.use_local_repo {
repos.push("deb [trusted=yes] file:///debs/ /".to_string());
Expand Down
30 changes: 16 additions & 14 deletions ciel/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ impl Workspace {
}

/// Returns the output directory of the workspace.
///
///
/// See [Container::output_directory].
pub fn output_directory(&self) -> PathBuf {
let name = if self.config().branch_exclusive_output {
Expand Down Expand Up @@ -322,7 +322,7 @@ pub struct WorkspaceConfig {
apt_sources: Option<String>,
/// Extra APT repositories to use.
#[serde(default)]
pub extra_apt_repos: Vec<String>,
pub apt_repos: Vec<String>,
/// Whether local repository (the output directory) should be enabled in containers.
#[serde(alias = "local_repo", default)]
pub use_local_repo: bool,
Expand Down Expand Up @@ -368,7 +368,7 @@ impl Default for WorkspaceConfig {
maintainer: "Bot <[email protected]>".to_string(),
dnssec: false,
apt_sources: None,
extra_apt_repos: vec![],
apt_repos: vec!["deb https://repo.aosc.io/debs/ stable main".to_string()],
use_local_repo: true,
branch_exclusive_output: true,
no_cache_packages: false,
Expand Down Expand Up @@ -464,14 +464,11 @@ impl WorkspaceConfig {

// Convert old `apt_sources` into `extra_apt_repos`
if let Some(sources) = config.apt_sources.take() {
config.extra_apt_repos.extend(
config.apt_repos.extend(
sources
.lines()
.map(|line| line.trim())
.filter(|line| !line.is_empty())
.filter(|line| {
!line.eq_ignore_ascii_case("deb https://repo.aosc.io/debs/ stable main")
})
.map(|line| line.to_string()),
);
}
Expand Down Expand Up @@ -522,7 +519,7 @@ mod test {
r##"version = 3
maintainer = "Bot <[email protected]>"
dnssec = false
extra-apt-repos = []
apt-repos = ["deb https://repo.aosc.io/debs/ stable main"]
use-local-repo = true
branch-exclusive-output = true
no-cache-packages = false
Expand Down Expand Up @@ -560,7 +557,8 @@ nspawn-extra-options = ["-E", "NO_COLOR=1"]
maintainer: "AOSC OS Maintainers <[email protected]>".to_string(),
dnssec: false,
apt_sources: None,
extra_apt_repos: vec![],
apt_repos: vec![
"deb https://repo.aosc.io/debs/ stable main".to_string(),],
use_local_repo: true,
branch_exclusive_output: true,
cache_sources: true,
Expand Down Expand Up @@ -591,7 +589,10 @@ volatile-mount = false
maintainer: "AOSC OS Maintainers <[email protected]>".to_string(),
dnssec: false,
apt_sources: None,
extra_apt_repos: vec!["deb file:///test/ test test".to_string()],
apt_repos: vec![
"deb https://repo.aosc.io/debs/ stable main".to_string(),
"deb file:///test/ test test".to_string()
],
use_local_repo: true,
branch_exclusive_output: true,
cache_sources: true,
Expand Down Expand Up @@ -629,7 +630,7 @@ volatile-mount = false
let ws = testdir.init_workspace(WorkspaceConfig::default()).unwrap();
dbg!(&ws);
assert!(!ws.is_system_loaded());
assert!(ws.config().extra_apt_repos.is_empty());
assert!(ws.config().apt_repos.len() == 1);
fs::write(ws.directory().join(".ciel/container/dist/init"), "").unwrap();
let ws = testdir.workspace().unwrap();
dbg!(&ws);
Expand All @@ -645,8 +646,9 @@ volatile-mount = false
dbg!(&ws);
assert!(ws.is_system_loaded());
assert_eq!(
ws.config().extra_apt_repos,
vec!["deb file:///test/ test test".to_string(),]
ws.config().apt_repos,
vec![
"deb https://repo.aosc.io/debs/ stable main".to_string(),"deb file:///test/ test test".to_string(),]
);
assert!(ws.config().branch_exclusive_output);
}
Expand All @@ -658,7 +660,7 @@ volatile-mount = false
let ws = testdir.workspace().unwrap();
dbg!(&ws);
assert!(ws.is_system_loaded());
assert!(ws.config().extra_apt_repos.is_empty());
assert!(ws.config().apt_repos.len() == 1);
assert!(ws.config().branch_exclusive_output);
}

Expand Down
2 changes: 1 addition & 1 deletion cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub fn patch_workspace_config(args: &ArgMatches, config: &mut WorkspaceConfig) -
}

config_scalar(args, "dnssec", &mut config.dnssec);
config_list(args, "repo", &mut config.extra_apt_repos);
config_list(args, "repo", &mut config.apt_repos);
config_scalar(args, "local-repo", &mut config.use_local_repo);
config_scalar(args, "source-cache", &mut config.cache_sources);
config_list(args, "nspawn-opt", &mut config.extra_nspawn_options);
Expand Down

0 comments on commit b64cc00

Please sign in to comment.