From 3a19d3ef3c513e542780857b6bad2225dc774022 Mon Sep 17 00:00:00 2001 From: spongeben Date: Mon, 9 Feb 2015 14:43:33 +0100 Subject: [PATCH 1/2] Fix release directory not created on first deploy --- Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php b/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php index 3555ce0..cd8f648 100644 --- a/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php +++ b/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php @@ -73,11 +73,13 @@ class RsyncTask extends BaseStrategyTaskAbstract implements IsReleaseAware // rsync: { copy: yes } $rsync_copy = $this->getConfig()->deployment('rsync'); // If copy_tool_rsync, use rsync rather than cp for finer control of what is copied - if ($rsync_copy && is_array($rsync_copy) && $rsync_copy['copy'] && isset($rsync_copy['copy_tool_rsync'])) { - $this->runCommandRemote("rsync -a {$this->excludes(array_merge($excludes, $rsync_copy['rsync_excludes']))} " + if ($rsync_copy && is_array($rsync_copy) && $rsync_copy['copy'] && is_dir("$releasesDirectory/$currentRelease")) { + if (isset($rsync_copy['copy_tool_rsync'])) { + $this->runCommandRemote("rsync -a {$this->excludes(array_merge($excludes, $rsync_copy['rsync_excludes']))} " . "$releasesDirectory/$currentRelease/ $releasesDirectory/{$this->getConfig()->getReleaseId()}"); - } elseif ($rsync_copy && is_array($rsync_copy) && $rsync_copy['copy']) { - $this->runCommandRemote('cp -R ' . $releasesDirectory . '/' . $currentRelease . ' ' . $releasesDirectory . '/' . $this->getConfig()->getReleaseId()); + } else { + $this->runCommandRemote('cp -R ' . $releasesDirectory . '/' . $currentRelease . ' ' . $releasesDirectory . '/' . $this->getConfig()->getReleaseId()); + } } else { $this->runCommandRemote('mkdir -p ' . $releasesDirectory . '/' . $this->getConfig()->getReleaseId()); } From aab71eceac19697f33fea8abf73f19b8eb0e84cf Mon Sep 17 00:00:00 2001 From: spongeben Date: Mon, 9 Feb 2015 14:44:34 +0100 Subject: [PATCH 2/2] Change "current" symlink owner only if it exists --- Mage/Task/BuiltIn/Deployment/ReleaseTask.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Mage/Task/BuiltIn/Deployment/ReleaseTask.php b/Mage/Task/BuiltIn/Deployment/ReleaseTask.php index 4ecf586..095116e 100644 --- a/Mage/Task/BuiltIn/Deployment/ReleaseTask.php +++ b/Mage/Task/BuiltIn/Deployment/ReleaseTask.php @@ -74,12 +74,13 @@ class ReleaseTask extends AbstractTask implements IsReleaseAware, SkipOnOverride } } - if ($resultFetch && $userGroup != '') { - $command = 'chown -h ' . $userGroup . ' ' . $symlink - . ' && ' - . 'chown -R ' . $userGroup . ' ' . $currentCopy + if ($resultFetch && $userGroup != '') { + $command = 'chown -R ' . $userGroup . ' ' . $currentCopy . ' && ' . 'chown ' . $userGroup . ' ' . $releasesDirectory; + if (file_exists($symlink)) { + $command.= ' && ' . 'chown -h ' . $userGroup . ' ' . $symlink; + } $result = $this->runCommandRemote($command); if (!$result) { return $result;