[lxc-devel] [distrobuilder/master] main: Check VM dependencies
monstermunchkin on Github
lxc-bot at linuxcontainers.org
Thu Feb 20 09:09:22 UTC 2020
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 364 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200220/dc22e750/attachment-0001.bin>
-------------- next part --------------
From 50bddef754d396d1138d09f356c9fd0212b8eec0 Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at canonical.com>
Date: Thu, 20 Feb 2020 09:58:37 +0100
Subject: [PATCH] main: Check VM dependencies
Signed-off-by: Thomas Hipp <thomas.hipp at canonical.com>
---
distrobuilder/main_lxd.go | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/distrobuilder/main_lxd.go b/distrobuilder/main_lxd.go
index 1915ec27..9517cd8a 100644
--- a/distrobuilder/main_lxd.go
+++ b/distrobuilder/main_lxd.go
@@ -38,9 +38,9 @@ func (c *cmdLXD) commandBuild() *cobra.Command {
// Check dependencies
if c.flagVM {
- _, err := exec.LookPath("qemu-img")
+ err := c.checkVMDependencies()
if err != nil {
- return fmt.Errorf("Required tool 'qemu-img' is missing")
+ return err
}
}
@@ -80,9 +80,9 @@ func (c *cmdLXD) commandPack() *cobra.Command {
// Check dependencies
if c.flagVM {
- _, err := exec.LookPath("qemu-img")
+ err := c.checkVMDependencies()
if err != nil {
- return fmt.Errorf("Required tool 'qemu-img' is missing")
+ return err
}
}
@@ -321,3 +321,16 @@ func (c *cmdLXD) run(cmd *cobra.Command, args []string, overlayDir string) error
return nil
}
+
+func (c *cmdLXD) checkVMDependencies() error {
+ dependencies := []string{"btrfs", "qemu-img", "rsync", "sgdisk"}
+
+ for _, dep := range dependencies {
+ _, err := exec.LookPath(dep)
+ if err != nil {
+ return fmt.Errorf("Required tool %q is missing", dep)
+ }
+ }
+
+ return nil
+}
More information about the lxc-devel
mailing list