Skip to content

Commit

Permalink
actions: debootstrap: Use parent-suite name as debootstrap script
Browse files Browse the repository at this point in the history
Set the script debootstrap uses to the parent suite, falling back to
unstable if the requested suite does not exist.

Signed-off-by: Christopher Obbard <[email protected]>
  • Loading branch information
obbardc committed Aug 4, 2023
1 parent eaaad3f commit 38c4eb0
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions actions/debootstrap_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ Example:
- private-key -- provide the client's private key in a file separate from the certificate.
- parent-suite -- release code name which this suite is based on. Useful for downstreams which do
not use debian codenames for their suite names (e.g. "stable").
not use debian codenames for their suite names (e.g. "stable"). The script debootstrap uses will
be set to this property. If the script does not exist, debos will fall back to using the "unstable"
debootstrap script.
*/
package actions

Expand Down Expand Up @@ -184,6 +186,10 @@ func shouldExcludeUsrIsMerged(suite string) bool {
}
}

func getDebootstrapScriptPath(script string) string {
return path.Join("/usr/share/debootstrap/scripts/", script)
}

func (d *DebootstrapAction) Run(context *debos.DebosContext) error {
d.LogStart()
cmdline := []string{"debootstrap"}
Expand Down Expand Up @@ -238,7 +244,15 @@ func (d *DebootstrapAction) Run(context *debos.DebosContext) error {
cmdline = append(cmdline, d.Suite)
cmdline = append(cmdline, context.Rootdir)
cmdline = append(cmdline, d.Mirror)
cmdline = append(cmdline, "/usr/share/debootstrap/scripts/unstable")

/* Determine debootstrap script to use from d.ParentSuite, falling back to
unstable if a script for the parent suite does not exist. */
script := getDebootstrapScriptPath(d.ParentSuite)
if _, err := os.Stat(script); err != nil {
script = getDebootstrapScriptPath("unstable")
}
log.Printf("using debootstrap script %s\n", script)
cmdline = append(cmdline, script)

/* Make sure /etc/apt/apt.conf.d exists inside the fakemachine otherwise
debootstrap prints a warning about the path not existing. */
Expand Down

0 comments on commit 38c4eb0

Please sign in to comment.