The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/distrobuilder/pull/99
This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.
=== Description (from pull-request) ===
Before this patch, if a user executes distrobuilder using the debian
example without having debootstrap installed, the following message is
returned:
Error: Error while downloading source: exec: "debootstrap": executable file not found in $PATH
Usage:
distrobuilder build-dir <filename|-> <target dir> [flags]
Flags:
-h, --help help for build-dir
Global Flags:
--cache-dir Cache directory
--cleanup Clean up cache directory (default true)
-o, --options Override options (list of key=value)
This happens because distrobuilder subcommands uses cobra's RunE or PreRunE,
so if an error is returned, the help message is shown.
In order to avoid this message, execute os.Exit(1) when downloader.Run fails:
Error: Error while downloading source: exec: "debootstrap": executable file not found in $PATH
Signed-off-by: Marcos Paulo de Souza <[email protected]>
From 23fbd5a63c6ea18d1969de343c47ef0c67c90270 Mon Sep 17 00:00:00 2001
From: Marcos Paulo de Souza <[email protected]>
Date: Wed, 6 Jun 2018 22:38:16 -0300
Subject: [PATCH] main.go: Do not show help message if downloader.Run fails
Before this patch, if a user executes distrobuilder using the debian
example without having debootstrap installed, the following message is
returned:
Error: Error while downloading source: exec: "debootstrap": executable file not
found in $PATH
Usage:
distrobuilder build-dir <filename|-> <target dir> [flags]
Flags:
-h, --help help for build-dir
Global Flags:
--cache-dir Cache directory
--cleanup Clean up cache directory (default true)
-o, --options Override options (list of key=value)
This happens because distrobuilder subcommands uses cobra's RunE or PreRunE,
so if an error is returned, the help message is shown.
In order to avoid this message, execute os.Exit(1) when downloader.Run fails:
Error: Error while downloading source: exec: "debootstrap": executable file not
found in $PATH
Signed-off-by: Marcos Paulo de Souza <[email protected]>
---
distrobuilder/main.go | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/distrobuilder/main.go b/distrobuilder/main.go
index 89e2a4a..4a8d696 100644
--- a/distrobuilder/main.go
+++ b/distrobuilder/main.go
@@ -190,7 +190,8 @@ func (c *cmdGlobal) preRunBuild(cmd *cobra.Command, args
[]string) error {
// Download the root filesystem
err = downloader.Run(*c.definition, c.sourceDir)
if err != nil {
- return fmt.Errorf("Error while downloading source: %s", err)
+ fmt.Fprintf(os.Stderr, "Error while downloading source: %s\n",
err)
+ os.Exit(1)
}
// Setup the mounts and chroot into the rootfs
_______________________________________________
lxc-devel mailing list
[email protected]
http://lists.linuxcontainers.org/listinfo/lxc-devel