diff --git a/completions/_ciel b/completions/_ciel index f462e8a..35d2792 100644 --- a/completions/_ciel +++ b/completions/_ciel @@ -142,6 +142,7 @@ _arguments "${_arguments_options[@]}" \ '-i+[Instance to build in]: : ' \ '(--stage-select)-c+[Continue from a Ciel checkpoint]: : ' \ '(--stage-select)--resume=[Continue from a Ciel checkpoint]: : ' \ +'*--with-topics=[Try to add topics before building, delimited by space]: : ' \ '--stage-select=[Select the starting point for a build]' \ '-g[Fetch source packages only]' \ '-x[Disable network in the container during the build]' \ diff --git a/completions/ciel.bash b/completions/ciel.bash index 4cb3eee..5aa4d28 100644 --- a/completions/ciel.bash +++ b/completions/ciel.bash @@ -265,7 +265,7 @@ _ciel() { return 0 ;; ciel__build) - opts="-g -x -i -2 -c -h --offline --stage2 --resume --stage-select --help" + opts="-g -x -i -2 -c -h --offline --stage2 --with-topics --resume --stage-select --help" _ciel_source_env 2>/dev/null || true if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 && -z "${CIEL_INST}" ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) @@ -276,6 +276,10 @@ _ciel() { COMPREPLY=($(compgen -W "$(_ciel_list_instances)" -- "$cur")) return 0 ;; + --with-topics) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; --resume) COMPREPLY=($(compgen -f "${cur}")) return 0 diff --git a/completions/ciel.fish b/completions/ciel.fish index 6d7b584..3d808be 100644 --- a/completions/ciel.fish +++ b/completions/ciel.fish @@ -84,6 +84,7 @@ complete -c ciel -n "__fish_seen_subcommand_from config" -s h -l help -d 'Print complete -c ciel -n "__fish_seen_subcommand_from commit" -s h -l help -d 'Print help information' complete -c ciel -n "__fish_seen_subcommand_from doctor" -s h -l help -d 'Print help information' complete -c ciel -n "__fish_seen_subcommand_from build" -s c -l resume -d 'Continue from a Ciel checkpoint' -r +complete -c ciel -n "__fish_seen_subcommand_from build" -l with-topics -d 'Try to add topics before building, delimited by space' -r complete -c ciel -n "__fish_seen_subcommand_from build" -l stage-select -d 'Select the starting point for a build' -r complete -c ciel -n "__fish_seen_subcommand_from build" -s g -d 'Fetch source packages only' complete -c ciel -n "__fish_seen_subcommand_from build" -s x -l offline -d 'Disable network in the container during the build' diff --git a/src/actions/packaging.rs b/src/actions/packaging.rs index bc90f98..91f35d1 100644 --- a/src/actions/packaging.rs +++ b/src/actions/packaging.rs @@ -34,10 +34,11 @@ pub struct BuildCheckPoint { } #[derive(Debug, Copy, Clone)] -pub struct BuildSettings { +pub struct BuildSettings<'a> { pub offline: bool, pub stage2: bool, pub force_use_apt: bool, + pub with_topics: &'a [&'a str], } pub fn load_build_checkpoint>(path: P) -> Result { @@ -334,6 +335,15 @@ pub fn package_build, K: Clone + ExactSizeIterator>( info!("Running in stage 2 mode. ACBS and autobuild3 may behave differently."); } + if !settings.with_topics.is_empty() { + let mut cmd = vec!["/bin/oma", "topics", "--yes"]; + for topic in settings.with_topics { + cmd.push("--opt-in"); + cmd.push(topic); + } + let _ = run_in_container(instance, &cmd); + } + mount_fs(instance)?; rollback_container(instance)?; diff --git a/src/cli.rs b/src/cli.rs index c0633a8..e53a638 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -123,6 +123,7 @@ pub fn build_cli() -> Command { .arg(instance_arg.clone().help("Instance to build in")) .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")) .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")) + .arg(Arg::new("TOPICS").long("with-topics").action(clap::ArgAction::Append).num_args(1..).help("Try to add topics before building, delimited by space")) .arg(Arg::new("CONTINUE").conflicts_with("SELECT").short('c').long("resume").alias("continue").num_args(1).help("Continue from a Ciel checkpoint")) .arg(Arg::new("SELECT").num_args(0..=1).long("stage-select").help("Select the starting point for a build")) .arg(Arg::new("PACKAGES").conflicts_with("CONTINUE").num_args(1..)) diff --git a/src/main.rs b/src/main.rs index 0c16d8e..97d7d5c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -319,11 +319,18 @@ fn main() -> Result<()> { } ("build", args) => { let instance = get_instance_option(args)?; + let topics = args + .get_many::("TOPICS") + .unwrap_or_default() + .into_iter() + .map(|s| s.as_str()) + .collect::>(); let settings = BuildSettings { offline: args.get_flag("OFFLINE"), stage2: args.get_flag("STAGE2"), force_use_apt: args.get_flag("force_use_apt") || read_config().is_ok_and(|config| config.force_use_apt), + with_topics: &topics, }; let mut state = None; if let Some(cont) = args.get_one::("CONTINUE") {