From 38c4eb007cea69d30b0054f4637d5ca795716104 Mon Sep 17 00:00:00 2001 From: Christopher Obbard Date: Fri, 4 Aug 2023 09:09:49 +0100 Subject: [PATCH] actions: debootstrap: Use parent-suite name as debootstrap script 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 --- actions/debootstrap_action.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/actions/debootstrap_action.go b/actions/debootstrap_action.go index 8def5836..9935b90a 100644 --- a/actions/debootstrap_action.go +++ b/actions/debootstrap_action.go @@ -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 @@ -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"} @@ -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. */