[lxc-devel] [lxd/master] lxd-p2c: Add rsync version check

stgraber on Github lxc-bot at linuxcontainers.org
Mon May 28 19:55:42 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180528/dba11f3d/attachment.bin>
-------------- next part --------------
From 2e6d194cc128bb5e06110adb6c4eb2b070f8ff10 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Mon, 28 May 2018 15:49:52 -0400
Subject: [PATCH] lxd-p2c: Add rsync version check
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd-p2c/transfer.go | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/lxd-p2c/transfer.go b/lxd-p2c/transfer.go
index b60fe6e67..3347761c9 100644
--- a/lxd-p2c/transfer.go
+++ b/lxd-p2c/transfer.go
@@ -72,7 +72,31 @@ func rsyncSendSetup(path string, rsyncArgs string) (*exec.Cmd, net.Conn, io.Read
 		"--numeric-ids",
 		"--partial",
 		"--sparse",
-		"--ignore-missing-args",
+	}
+
+	// Ignore deletions (requires 3.1 or higher)
+	rsyncCheckVersion := func(min string) bool {
+		out, err := shared.RunCommand("rsync", "--version")
+		if err != nil {
+			return false
+		}
+
+		fields := strings.Split(out, " ")
+		curVer, err := version.Parse(fields[3])
+		if err != nil {
+			return false
+		}
+
+		minVer, err := version.Parse(min)
+		if err != nil {
+			return false
+		}
+
+		return curVer.Compare(minVer) >= 0
+	}
+
+	if rsyncCheckVersion("3.1.0") {
+		args = append(args, "--ignore-missing-args")
 	}
 
 	if rsyncArgs != "" {


More information about the lxc-devel mailing list