Skip to content

Commit b8dad72

Browse files
committed
config: if the config file contains "foreign architecture" ...
... `ARCH={arch}` will be added to the ab4 config file
1 parent d706bc2 commit b8dad72

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/actions/onboarding.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ pub fn onboarding(custom_tarball: Option<&String>, arch: Option<&str>) -> Result
3939
} else {
4040
ask_for_target_arch()?
4141
};
42-
let config = config::ask_for_config(None)?;
42+
let mut config = config::ask_for_config(None)?;
43+
// check if this is a "foreign architecture"
44+
if real_arch.contains("_") {
45+
config.foreign_arch = Some(real_arch.to_string());
46+
}
4347
let mut init_instance: Option<String> = None;
4448
if user_attended()
4549
&& Confirm::with_theme(&theme)

src/config.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ pub struct CielConfig {
3636
pub volatile_mount: bool,
3737
#[serde(default = "CielConfig::default_force_use_apt")]
3838
pub force_use_apt: bool,
39+
#[serde(default)]
40+
pub foreign_arch: Option<String>,
3941
}
4042

4143
impl CielConfig {
@@ -65,6 +67,7 @@ impl Default for CielConfig {
6567
sep_mount: true,
6668
volatile_mount: false,
6769
force_use_apt: false,
70+
foreign_arch: None,
6871
}
6972
}
7073
}
@@ -231,6 +234,9 @@ pub fn apply_config<P: AsRef<Path>>(root: P, config: &CielConfig) -> Result<()>
231234
)
232235
.as_bytes(),
233236
)?;
237+
if let Some(foreign_arch) = &config.foreign_arch {
238+
f.write_all(format!("\nARCH={}", foreign_arch).as_bytes())?;
239+
}
234240
config_path.set_file_name(DEFAULT_AB4_CONFIG_FILE);
235241
// write sources.list
236242
if !config.apt_sources.is_empty() {

0 commit comments

Comments
 (0)