The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/distrobuilder/pull/285

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) ===

From 80452e395b66cb42c10041e99442f17b9cc1c0ca Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.h...@canonical.com>
Date: Thu, 20 Feb 2020 16:04:45 +0100
Subject: [PATCH 1/2] managers: Add preRefresh hook

This adds the preRefresh hook which will run before a refresh.

Signed-off-by: Thomas Hipp <thomas.h...@canonical.com>
---
 managers/manager.go | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/managers/manager.go b/managers/manager.go
index 09945aaa..274ea724 100644
--- a/managers/manager.go
+++ b/managers/manager.go
@@ -14,7 +14,8 @@ type ManagerFlags struct {
 
 // ManagerHooks represents custom hooks.
 type ManagerHooks struct {
-       clean func() error
+       clean      func() error
+       preRefresh func() error
 }
 
 // ManagerCommands represents all commands.
@@ -139,6 +140,13 @@ func (m Manager) Refresh() error {
                return nil
        }
 
+       if m.hooks.preRefresh != nil {
+               err := m.hooks.preRefresh()
+               if err != nil {
+                       return err
+               }
+       }
+
        args := append(m.flags.global, m.flags.refresh...)
 
        return shared.RunCommand(m.commands.refresh, args...)

From e0005e85bacaaa6397106a7e867c8beabe488baf Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.h...@canonical.com>
Date: Thu, 20 Feb 2020 16:05:34 +0100
Subject: [PATCH 2/2] managers/opkg: Use preRefresh hook

Signed-off-by: Thomas Hipp <thomas.h...@canonical.com>
---
 managers/opkg.go | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/managers/opkg.go b/managers/opkg.go
index f185a1a5..25eb8e34 100644
--- a/managers/opkg.go
+++ b/managers/opkg.go
@@ -1,5 +1,7 @@
 package managers
 
+import "os"
+
 // NewOpkg creates a new Manager instance.
 func NewOpkg() *Manager {
        return &Manager{
@@ -28,5 +30,10 @@ func NewOpkg() *Manager {
                                "Not supported",
                        },
                },
+               hooks: ManagerHooks{
+                       preRefresh: func() error {
+                               return os.MkdirAll("/var/lock", 0755)
+                       },
+               },
        }
 }
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to