Skip to content

Commit 7b9653a

Browse files
committed
feat: support adding topics before building
1 parent b8dad72 commit 7b9653a

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

completions/_ciel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ _arguments "${_arguments_options[@]}" \
140140
(build)
141141
_arguments "${_arguments_options[@]}" \
142142
'-i+[Instance to build in]: : ' \
143+
'*--with-topics=[Try to add topics before building, delimited by space]: : ' \
143144
'(--stage-select)-c+[Continue from a Ciel checkpoint]: : ' \
144145
'(--stage-select)--resume=[Continue from a Ciel checkpoint]: : ' \
145146
'--stage-select=[Select the starting point for a build]' \

src/actions/packaging.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ pub struct BuildCheckPoint {
3434
}
3535

3636
#[derive(Debug, Copy, Clone)]
37-
pub struct BuildSettings {
37+
pub struct BuildSettings<'a> {
3838
pub offline: bool,
3939
pub stage2: bool,
4040
pub force_use_apt: bool,
41+
pub with_topics: &'a [&'a str],
4142
}
4243

4344
pub fn load_build_checkpoint<P: AsRef<Path>>(path: P) -> Result<BuildCheckPoint> {
@@ -334,6 +335,15 @@ pub fn package_build<S: AsRef<str>, K: Clone + ExactSizeIterator<Item = S>>(
334335
info!("Running in stage 2 mode. ACBS and autobuild3 may behave differently.");
335336
}
336337

338+
if !settings.with_topics.is_empty() {
339+
let mut cmd = vec!["/bin/oma", "topics", "--yes"];
340+
for topic in settings.with_topics {
341+
cmd.push("--opt-in");
342+
cmd.push(topic);
343+
}
344+
let _ = run_in_container(instance, &cmd);
345+
}
346+
337347
mount_fs(instance)?;
338348
rollback_container(instance)?;
339349

src/cli.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ pub fn build_cli() -> Command {
123123
.arg(instance_arg.clone().help("Instance to build in"))
124124
.arg(Arg::new("STAGE2").long("stage2").short('2').action(clap::ArgAction::SetTrue).env("CIEL_STAGE2").help("Use stage 2 mode instead of the regular build mode"))
125125
.arg(Arg::new("force_use_apt").long("force-use-apt").action(clap::ArgAction::SetTrue).env("FORCE_USE_APT").help("Force use apt to run acbs"))
126+
.arg(Arg::new("TOPICS").long("with-topics").action(clap::ArgAction::Append).num_args(1..).help("Try to add topics before building, delimited by space"))
126127
.arg(Arg::new("CONTINUE").conflicts_with("SELECT").short('c').long("resume").alias("continue").num_args(1).help("Continue from a Ciel checkpoint"))
127128
.arg(Arg::new("SELECT").num_args(0..=1).long("stage-select").help("Select the starting point for a build"))
128129
.arg(Arg::new("PACKAGES").conflicts_with("CONTINUE").num_args(1..))

src/main.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,18 @@ fn main() -> Result<()> {
319319
}
320320
("build", args) => {
321321
let instance = get_instance_option(args)?;
322+
let topics = args
323+
.get_many::<String>("TOPICS")
324+
.unwrap_or_default()
325+
.into_iter()
326+
.map(|s| s.as_str())
327+
.collect::<Vec<_>>();
322328
let settings = BuildSettings {
323329
offline: args.get_flag("OFFLINE"),
324330
stage2: args.get_flag("STAGE2"),
325331
force_use_apt: args.get_flag("force_use_apt")
326332
|| read_config().is_ok_and(|config| config.force_use_apt),
333+
with_topics: &topics,
327334
};
328335
let mut state = None;
329336
if let Some(cont) = args.get_one::<String>("CONTINUE") {

0 commit comments

Comments
 (0)