@@ -17,9 +17,18 @@ const StepNameUpdate = "apt update"
1717// WithExtraUpdate adds a secondary `apt update` step with the given name. It
1818// will always run after the main `apt update` step. You may pass additional
1919// ordering constraints in the options.
20+ //
21+ // This is equivalent to calling [bootstrap.WithSteps] with the result of [ExtraUpdateStep].
2022func WithExtraUpdate (name string , opts ... bootstrap.StepOpt ) bootstrap.Option {
23+ return bootstrap .WithSteps (ExtraUpdateStep (name , opts ... ))
24+ }
25+
26+ // ExtraUpdateStep creates a secondary `apt update` step with the given name. It
27+ // will always run after the main `apt update` step. You should pass additional
28+ // ordering constraints in the options.
29+ func ExtraUpdateStep (name string , opts ... bootstrap.StepOpt ) * bootstrap.Step {
2130 opts = append ([]bootstrap.StepOpt {bootstrap .AfterSteps (StepNameUpdate )}, opts ... )
22- return bootstrap .WithSteps ( bootstrap . NewStep (name , DoUpdate , opts ... ) )
31+ return bootstrap .NewStep (name , DoUpdate , opts ... )
2332}
2433
2534func updateStep () * bootstrap.Step {
@@ -62,9 +71,7 @@ const StepNameInstall = "apt install"
6271func installStep () * bootstrap.Step {
6372 return bootstrap .NewStep (
6473 StepNameInstall ,
65- func (ctx * bootstrap.Context ) error {
66- return DoInstall (ctx , []string {"--no-install-recommends" }, nil , "" )
67- },
74+ doInstall ,
6875 bootstrap .AfterSteps (StepNameUpdate ),
6976 bootstrap .SimFunc (simInstall ),
7077 )
@@ -76,13 +83,34 @@ func installStep() *bootstrap.Step {
7683//
7784// You likely want to pair this with [WithExtraUpdate], one or more steps to
7885// add new apt sources that call [ChangedSources] and [AddPackages].
86+ //
87+ // This is equivalent to calling [bootstrap.WithSteps] with the result of
88+ // [ExtraInstallStep].
7989func WithExtraInstall (name string , opts ... bootstrap.StepOpt ) bootstrap.Option {
80- opts = append ([]bootstrap.StepOpt {bootstrap .AfterSteps (StepNameInstall )}, opts ... )
81- return bootstrap .WithSteps (bootstrap .NewStep (name , DoUpdate , opts ... ))
90+ return bootstrap .WithSteps (ExtraInstallStep (name , opts ... ))
91+ }
92+
93+ // ExtraInstallStep creates a secondary `apt install` step with the given name.
94+ // It will always run after the main `apt install` step. You should pass
95+ // additional ordering constraints in the options, e.g. ensuring this runs after
96+ // a custom update and package selection steps.
97+ func ExtraInstallStep (name string , opts ... bootstrap.StepOpt ) * bootstrap.Step {
98+ opts = append (
99+ []bootstrap.StepOpt {
100+ bootstrap .AfterSteps (StepNameInstall ),
101+ bootstrap .SimFunc (simInstall ),
102+ },
103+ opts ... ,
104+ )
105+ return bootstrap .NewStep (name , doInstall , opts ... )
82106}
83107
84108var pendingPackages = bootstrap.NewKey [map [string ]struct {}]("pending-apt-packages" )
85109
110+ func doInstall (ctx * bootstrap.Context ) error {
111+ return DoInstall (ctx , []string {"--no-install-recommends" }, nil , "" )
112+ }
113+
86114// DoInstall runs `apt install -y ...` with:
87115//
88116// - Any extra options you pass. Including `--no-install-recommends` is often
@@ -254,6 +282,21 @@ func AddPackagesStep(
254282 )
255283}
256284
285+ func AddExtraPackagesStep (
286+ stepName string ,
287+ packages ... string ,
288+ ) * bootstrap.Step {
289+ mark := func (ctx * bootstrap.Context ) error {
290+ AddPackages (ctx , packages ... )
291+ return nil
292+ }
293+ return bootstrap .NewStep (
294+ stepName ,
295+ mark ,
296+ bootstrap .SimFunc (mark ),
297+ )
298+ }
299+
257300// WithPackages is an option for [Configure] that will register a step to
258301// mark the given package(s) to be installed by the main `apt install` step.
259302func WithPackages (
0 commit comments