From 4ef237a642f40937c6670cab50101ba0db0f43ba Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 6 May 2014 13:41:37 -0700 Subject: [PATCH] synced_folders/rsync: mkdir before rsync --- CHANGELOG.md | 1 + plugins/guests/darwin/cap/rsync.rb | 6 ++++++ plugins/guests/freebsd/cap/rsync.rb | 6 ++++++ plugins/guests/linux/cap/rsync.rb | 6 ++++++ plugins/guests/netbsd/cap/rsync.rb | 6 ++++++ plugins/guests/openbsd/cap/rsync.rb | 6 ++++++ plugins/guests/smartos/cap/rsync.rb | 6 ++++++ plugins/guests/solaris/cap/rsync.rb | 6 ++++++ plugins/guests/solaris11/cap/rsync.rb | 6 ++++++ 9 files changed, 49 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ca295383..b8b293855 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ BUG FIXES: Vagrantfile. - commands/package: `--base` works without crashing for VirtualBox. - guests/redhat: Fix networking issues with CentOS. [GH-3649] + - synced\_folders/rsync: Create the directory before syncing. ## 1.6.0 (May 6, 2014) diff --git a/plugins/guests/darwin/cap/rsync.rb b/plugins/guests/darwin/cap/rsync.rb index e69439af4..d4b53213a 100644 --- a/plugins/guests/darwin/cap/rsync.rb +++ b/plugins/guests/darwin/cap/rsync.rb @@ -10,6 +10,12 @@ module VagrantPlugins "sudo rsync" end + def self.rsync_pre(machine, opts) + machine.communicate.tap do |comm| + comm.sudo("mkdir -p '#{opts[:guestpath]}'") + end + end + def self.rsync_post(machine, opts) machine.communicate.sudo( "find '#{opts[:guestpath]}' '(' ! -user #{opts[:owner]} -or ! -group #{opts[:group]} ')' -print0 | " + diff --git a/plugins/guests/freebsd/cap/rsync.rb b/plugins/guests/freebsd/cap/rsync.rb index 05cec8b72..a718fab87 100644 --- a/plugins/guests/freebsd/cap/rsync.rb +++ b/plugins/guests/freebsd/cap/rsync.rb @@ -16,6 +16,12 @@ module VagrantPlugins "sudo rsync" end + def self.rsync_pre(machine, opts) + machine.communicate.tap do |comm| + comm.sudo("mkdir -p '#{opts[:guestpath]}'") + end + end + def self.rsync_post(machine, opts) machine.communicate.sudo( "find '#{opts[:guestpath]}' '(' ! -user #{opts[:owner]} -or ! -group #{opts[:group]} ')' -print0 | " + diff --git a/plugins/guests/linux/cap/rsync.rb b/plugins/guests/linux/cap/rsync.rb index 6df67167a..906b33cb1 100644 --- a/plugins/guests/linux/cap/rsync.rb +++ b/plugins/guests/linux/cap/rsync.rb @@ -10,6 +10,12 @@ module VagrantPlugins "sudo rsync" end + def self.rsync_pre(machine, opts) + machine.communicate.tap do |comm| + comm.sudo("mkdir -p '#{opts[:guestpath]}'") + end + end + def self.rsync_post(machine, opts) machine.communicate.sudo( "find '#{opts[:guestpath]}' '(' ! -user #{opts[:owner]} -or ! -group #{opts[:group]} ')' -print0 | " + diff --git a/plugins/guests/netbsd/cap/rsync.rb b/plugins/guests/netbsd/cap/rsync.rb index 3d2f9cfcd..0aa2e20ee 100644 --- a/plugins/guests/netbsd/cap/rsync.rb +++ b/plugins/guests/netbsd/cap/rsync.rb @@ -17,6 +17,12 @@ module VagrantPlugins "sudo rsync" end + def self.rsync_pre(machine, opts) + machine.communicate.tap do |comm| + comm.sudo("mkdir -p '#{opts[:guestpath]}'") + end + end + def self.rsync_post(machine, opts) machine.communicate.sudo( "find '#{opts[:guestpath]}' '(' ! -user #{opts[:owner]} -or ! -group #{opts[:group]} ')' -print0 | " + diff --git a/plugins/guests/openbsd/cap/rsync.rb b/plugins/guests/openbsd/cap/rsync.rb index 61a942f30..74048623c 100644 --- a/plugins/guests/openbsd/cap/rsync.rb +++ b/plugins/guests/openbsd/cap/rsync.rb @@ -17,6 +17,12 @@ module VagrantPlugins "sudo rsync" end + def self.rsync_pre(machine, opts) + machine.communicate.tap do |comm| + comm.sudo("mkdir -p '#{opts[:guestpath]}'") + end + end + def self.rsync_post(machine, opts) machine.communicate.sudo( "find '#{opts[:guestpath]}' '(' ! -user #{opts[:owner]} -or ! -group #{opts[:group]} ')' -print0 | " + diff --git a/plugins/guests/smartos/cap/rsync.rb b/plugins/guests/smartos/cap/rsync.rb index 5c8cbab97..5f5100213 100644 --- a/plugins/guests/smartos/cap/rsync.rb +++ b/plugins/guests/smartos/cap/rsync.rb @@ -10,6 +10,12 @@ module VagrantPlugins "#{machine.config.smartos.suexec_cmd} rsync" end + def self.rsync_pre(machine, opts) + machine.communicate.tap do |comm| + comm.sudo("mkdir -p '#{opts[:guestpath]}'") + end + end + def self.rsync_post(machine, opts) machine.communicate.sudo("find '#{opts[:guestpath]}' '(' ! -user #{opts[:owner]} -or ! -group #{opts[:group]} ')' -print0 | " + "xargs -0 -r chown -v #{opts[:owner]}:#{opts[:group]}") diff --git a/plugins/guests/solaris/cap/rsync.rb b/plugins/guests/solaris/cap/rsync.rb index 96851b03c..dab779c98 100644 --- a/plugins/guests/solaris/cap/rsync.rb +++ b/plugins/guests/solaris/cap/rsync.rb @@ -10,6 +10,12 @@ module VagrantPlugins "#{machine.config.solaris.suexec_cmd} rsync" end + def self.rsync_pre(machine, opts) + machine.communicate.tap do |comm| + comm.sudo("mkdir -p '#{opts[:guestpath]}'") + end + end + def self.rsync_post(machine, opts) su_cmd = machine.config.solaris.su_cmd machine.communicate.execute( diff --git a/plugins/guests/solaris11/cap/rsync.rb b/plugins/guests/solaris11/cap/rsync.rb index 1b48ddc56..8ec9d3249 100644 --- a/plugins/guests/solaris11/cap/rsync.rb +++ b/plugins/guests/solaris11/cap/rsync.rb @@ -10,6 +10,12 @@ module VagrantPlugins "#{machine.config.solaris11.suexec_cmd} rsync" end + def self.rsync_pre(machine, opts) + machine.communicate.tap do |comm| + comm.sudo("mkdir -p '#{opts[:guestpath]}'") + end + end + def self.rsync_post(machine, opts) su_cmd = machine.config.solaris11.su_cmd machine.communicate.execute(