[lxc-devel] [lxd/master] Fix file push p

tych0 on Github lxc-bot at linuxcontainers.org
Fri Oct 14 21:04:20 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20161014/91a8f1f5/attachment.bin>
-------------- next part --------------
From f45741c6c7d4920af8b249750975df0743175ab1 Mon Sep 17 00:00:00 2001
From: Tycho Andersen <tycho.andersen at canonical.com>
Date: Fri, 14 Oct 2016 14:11:36 -0600
Subject: [PATCH 1/2] lxc file: fix help typo

Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
 lxc/file.go | 2 +-
 po/lxd.pot  | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lxc/file.go b/lxc/file.go
index 19626cb..36f34fb 100644
--- a/lxc/file.go
+++ b/lxc/file.go
@@ -37,7 +37,7 @@ func (c *fileCmd) usage() string {
 		`Manage files on a container.
 
 lxc file pull [-r|--recursive] <source> [<source>...] <target>
-lxc file push [-r|--recursive] [-p|create-dirs] [--uid=UID] [--gid=GID] [--mode=MODE] <source> [<source>...] <target>
+lxc file push [-r|--recursive] [-p|--create-dirs] [--uid=UID] [--gid=GID] [--mode=MODE] <source> [<source>...] <target>
 lxc file edit <file>
 
 <source> in the case of pull, <target> in the case of push and <file> in the case of edit are <container name>/<path>
diff --git a/po/lxd.pot b/po/lxd.pot
index 4b4d21e..1b5448a 100644
--- a/po/lxd.pot
+++ b/po/lxd.pot
@@ -7,7 +7,7 @@
 msgid   ""
 msgstr  "Project-Id-Version: lxd\n"
         "Report-Msgid-Bugs-To: lxc-devel at lists.linuxcontainers.org\n"
-        "POT-Creation-Date: 2016-10-10 23:45-0400\n"
+        "POT-Creation-Date: 2016-10-14 14:11-0600\n"
         "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
         "Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
         "Language-Team: LANGUAGE <LL at li.org>\n"
@@ -665,7 +665,7 @@ msgstr  ""
 msgid   "Manage files on a container.\n"
         "\n"
         "lxc file pull [-r|--recursive] <source> [<source>...] <target>\n"
-        "lxc file push [-r|--recursive] [-p|create-dirs] [--uid=UID] [--gid=GID] [--mode=MODE] <source> [<source>...] <target>\n"
+        "lxc file push [-r|--recursive] [-p|--create-dirs] [--uid=UID] [--gid=GID] [--mode=MODE] <source> [<source>...] <target>\n"
         "lxc file edit <file>\n"
         "\n"
         "<source> in the case of pull, <target> in the case of push and <file> in the case of edit are <container name>/<path>\n"

From 343d9f69a6df3f6f712de08cd6337bb536f73300 Mon Sep 17 00:00:00 2001
From: Tycho Andersen <tycho.andersen at canonical.com>
Date: Fri, 14 Oct 2016 20:54:00 +0000
Subject: [PATCH 2/2] push: fix typo

We want to use the path of the file in the container for mkdir -p in the
container, not the path on the host :)

Closes #2501

Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
 lxc/file.go              | 10 +++++-----
 test/suites/filemanip.sh | 10 +++++-----
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/lxc/file.go b/lxc/file.go
index 36f34fb..cd00d55 100644
--- a/lxc/file.go
+++ b/lxc/file.go
@@ -107,13 +107,13 @@ func (c *fileCmd) push(config *lxd.Config, send_file_perms bool, args []string)
 			return fmt.Errorf(i18n.G("can't supply uid/gid/mode in recursive mode"))
 		}
 
-		for _, fname := range sourcefilenames {
-			if c.mkdirs {
-				if err := d.MkdirP(container, fname, mode); err != nil {
-					return err
-				}
+		if c.mkdirs {
+			if err := d.MkdirP(container, pathSpec[1], mode); err != nil {
+				return err
 			}
+		}
 
+		for _, fname := range sourcefilenames {
 			if err := d.RecursivePushFile(container, fname, pathSpec[1]); err != nil {
 				return err
 			}
diff --git a/test/suites/filemanip.sh b/test/suites/filemanip.sh
index bda8916..d59d08c 100644
--- a/test/suites/filemanip.sh
+++ b/test/suites/filemanip.sh
@@ -20,14 +20,14 @@ test_filemanip() {
   echo "foo" > "${TEST_DIR}"/source/foo
   echo "bar" > "${TEST_DIR}"/source/bar
 
-  lxc file push -r "${TEST_DIR}"/source filemanip/tmp
+  lxc file push -p -r "${TEST_DIR}"/source filemanip/tmp/ptest
 
-  [ "$(lxc exec filemanip -- stat -c "%u" /tmp/source)" = "$(id -u)" ]
-  [ "$(lxc exec filemanip -- stat -c "%g" /tmp/source)" = "$(id -g)" ]
-  [ "$(lxc exec filemanip -- stat -c "%a" /tmp/source)" = "755" ]
+  [ "$(lxc exec filemanip -- stat -c "%u" /tmp/ptest/source)" = "$(id -u)" ]
+  [ "$(lxc exec filemanip -- stat -c "%g" /tmp/ptest/source)" = "$(id -g)" ]
+  [ "$(lxc exec filemanip -- stat -c "%a" /tmp/ptest/source)" = "755" ]
 
   mkdir "${TEST_DIR}"/dest
-  lxc file pull -r filemanip/tmp/source "${TEST_DIR}"/dest
+  lxc file pull -r filemanip/tmp/ptest/source "${TEST_DIR}"/dest
 
   [ "$(cat "${TEST_DIR}"/dest/source/foo)" = "foo" ]
   [ "$(cat "${TEST_DIR}"/dest/source/bar)" = "bar" ]


More information about the lxc-devel mailing list