From f334d32c71ea90d6dcc406ed8447651c2e8e2aa7 Mon Sep 17 00:00:00 2001 From: Christopher Obbard Date: Fri, 11 Aug 2023 14:31:36 +0100 Subject: [PATCH] Check if artifactdir exists early Currently debos fails if an action attempts to use artifactdir and it doesn't exist on the host: $ debos --artifactdir=out rpi64/debimage-rpi64.yaml Action `image-partition` failed at stage PreMachine, error: open /home/obbardc/projects/debos/debos-recipes/out/debian-rpi64.img: no such file or directory Check that artifactdir exists early and return an error in case that it does not exist. Closes: #426 Signed-off-by: Christopher Obbard --- cmd/debos/debos.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/debos/debos.go b/cmd/debos/debos.go index 0f9d6a16..ab4c0b4b 100644 --- a/cmd/debos/debos.go +++ b/cmd/debos/debos.go @@ -192,6 +192,11 @@ func main() { context.Artifactdir, _ = os.Getwd() } context.Artifactdir = debos.CleanPath(context.Artifactdir) + if _, err := os.Stat(context.Artifactdir); os.IsNotExist(err) { + log.Printf("artifactdir does not exist: %v", err) + exitcode = 1 + return + } // Initialise origins map context.Origins = make(map[string]string)