Skip to content

Commit bf746be

Browse files
committed
feat: support adding topics before building
1 parent a9d4a6b commit bf746be

File tree

6 files changed

+26
-2
lines changed

6 files changed

+26
-2
lines changed

completions/_ciel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ _arguments "${_arguments_options[@]}" \
142142
'-i+[Instance to build in]: : ' \
143143
'(--stage-select)-c+[Continue from a Ciel checkpoint]: : ' \
144144
'(--stage-select)--resume=[Continue from a Ciel checkpoint]: : ' \
145+
'*--with-topics=[Try to add topics before building, delimited by space]: : ' \
145146
'--stage-select=[Select the starting point for a build]' \
146147
'-g[Fetch source packages only]' \
147148
'-x[Disable network in the container during the build]' \

completions/ciel.bash

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ _ciel() {
265265
return 0
266266
;;
267267
ciel__build)
268-
opts="-g -x -i -2 -c -h --offline --stage2 --resume --stage-select --help"
268+
opts="-g -x -i -2 -c -h --offline --stage2 --with-topics --resume --stage-select --help"
269269
_ciel_source_env 2>/dev/null || true
270270
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 && -z "${CIEL_INST}" ]] ; then
271271
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
@@ -276,6 +276,10 @@ _ciel() {
276276
COMPREPLY=($(compgen -W "$(_ciel_list_instances)" -- "$cur"))
277277
return 0
278278
;;
279+
--with-topics)
280+
COMPREPLY=($(compgen -f "${cur}"))
281+
return 0
282+
;;
279283
--resume)
280284
COMPREPLY=($(compgen -f "${cur}"))
281285
return 0

completions/ciel.fish

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ complete -c ciel -n "__fish_seen_subcommand_from config" -s h -l help -d 'Print
8484
complete -c ciel -n "__fish_seen_subcommand_from commit" -s h -l help -d 'Print help information'
8585
complete -c ciel -n "__fish_seen_subcommand_from doctor" -s h -l help -d 'Print help information'
8686
complete -c ciel -n "__fish_seen_subcommand_from build" -s c -l resume -d 'Continue from a Ciel checkpoint' -r
87+
complete -c ciel -n "__fish_seen_subcommand_from build" -l with-topics -d 'Try to add topics before building, delimited by space' -r
8788
complete -c ciel -n "__fish_seen_subcommand_from build" -l stage-select -d 'Select the starting point for a build' -r
8889
complete -c ciel -n "__fish_seen_subcommand_from build" -s g -d 'Fetch source packages only'
8990
complete -c ciel -n "__fish_seen_subcommand_from build" -s x -l offline -d 'Disable network in the container during the 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)