Good catch, Scott. I'll get that patch applied tonight.
- Jamis
On May 10, 2007, at 3:43 PM, Scott Chacon wrote:
> In a previous change to copy.rb (6589), the tarball was moved from
> being created in the working directory to being created in /tmp.
> Doing that made the tar command include the 'tmp' as part of the
> tarred path, which means when it untars, it untars to:
>
> /u/apps/whatever/releases/tmp/YYYYMMDDHHMMSS
>
> The 'tmp' in that directory path is not good. I patched copy.rb to
> 'cd' to the temp_dir first, then run the compression command, which
> seems to work and is the only strategy I could think of that would
> work for all of the compression types (I tried '-C' to tar first, but
> zip doesn't have an equivalent). I've also patched the copy_test.rb
> file to reflect that.
>
> Also, I added a require 'rubygems' to the utils.rb file because it
> wasn't finding 'mocha' as a gem otherwise. If that's not proper, feel
> free to just strip it out.
>
> Thanks,
> Scott
>
> >
> Index: test/deploy/strategy/copy_test.rb
> ===================================================================
> --- test/deploy/strategy/copy_test.rb (revision 6709)
> +++ test/deploy/strategy/copy_test.rb (working copy)
> @@ -18,7 +18,7 @@
> @source.expects(:checkout).with("154", "/temp/dir/
> 1234567890").returns(:local_checkout)
>
> @strategy.expects(:system).with(:local_checkout)
> - @strategy.expects(:system).with("tar czf /temp/dir/
> 1234567890.tar.gz /temp/dir/1234567890")
> + @strategy.expects(:system).with("cd /temp/dir && tar czf /temp/
> dir/1234567890.tar.gz 1234567890")
> @strategy.expects(:put).with(:mock_file_contents, "/tmp/
> 1234567890.tar.gz")
> @strategy.expects(:run).with("cd /u/apps/test/releases && tar
> xzf /tmp/1234567890.tar.gz && rm /tmp/1234567890.tar.gz")
>
> @@ -39,7 +39,7 @@
> @source.expects(:export).with("154", "/temp/dir/
> 1234567890").returns(:local_export)
>
> @strategy.expects(:system).with(:local_export)
> - @strategy.expects(:system).with("tar czf /temp/dir/
> 1234567890.tar.gz /temp/dir/1234567890")
> + @strategy.expects(:system).with("cd /temp/dir && tar czf /temp/
> dir/1234567890.tar.gz 1234567890")
> @strategy.expects(:put).with(:mock_file_contents, "/tmp/
> 1234567890.tar.gz")
> @strategy.expects(:run).with("cd /u/apps/test/releases && tar
> xzf /tmp/1234567890.tar.gz && rm /tmp/1234567890.tar.gz")
>
> @@ -60,7 +60,7 @@
> @source.expects(:checkout).with("154", "/temp/dir/
> 1234567890").returns(:local_checkout)
>
> @strategy.expects(:system).with(:local_checkout)
> - @strategy.expects(:system).with("zip -qr /temp/dir/
> 1234567890.zip /temp/dir/1234567890")
> + @strategy.expects(:system).with("cd /temp/dir && zip -qr /temp/
> dir/1234567890.zip 1234567890")
> @strategy.expects(:put).with(:mock_file_contents, "/tmp/
> 1234567890.zip")
> @strategy.expects(:run).with("cd /u/apps/test/releases &&
> unzip -q /tmp/1234567890.zip && rm /tmp/1234567890.zip")
>
> @@ -81,7 +81,7 @@
> @source.expects(:checkout).with("154", "/temp/dir/
> 1234567890").returns(:local_checkout)
>
> @strategy.expects(:system).with(:local_checkout)
> - @strategy.expects(:system).with("tar cjf /temp/dir/
> 1234567890.tar.bz2 /temp/dir/1234567890")
> + @strategy.expects(:system).with("cd /temp/dir && tar cjf /temp/
> dir/1234567890.tar.bz2 1234567890")
> @strategy.expects(:put).with(:mock_file_contents, "/tmp/
> 1234567890.tar.bz2")
> @strategy.expects(:run).with("cd /u/apps/test/releases && tar
> xjf /tmp/1234567890.tar.bz2 && rm /tmp/1234567890.tar.bz2")
>
> @@ -102,7 +102,7 @@
> @source.expects(:checkout).with("154", "/other/path/
> 1234567890").returns(:local_checkout)
>
> @strategy.expects(:system).with(:local_checkout)
> - @strategy.expects(:system).with("tar czf /other/path/
> 1234567890.tar.gz /other/path/1234567890")
> + @strategy.expects(:system).with("cd /other/path && tar czf /
> other/path/1234567890.tar.gz 1234567890")
> @strategy.expects(:put).with(:mock_file_contents, "/tmp/
> 1234567890.tar.gz")
> @strategy.expects(:run).with("cd /u/apps/test/releases && tar
> xzf /tmp/1234567890.tar.gz && rm /tmp/1234567890.tar.gz")
>
> Index: test/utils.rb
> ===================================================================
> --- test/utils.rb (revision 6709)
> +++ test/utils.rb (working copy)
> @@ -2,6 +2,7 @@
> $:.unshift "#{File.dirname(__FILE__)}/../lib"
>
> require 'test/unit'
> + require 'rubygems'
> require 'mocha'
> require 'capistrano/server_definition'
>
> Index: lib/capistrano/recipes/deploy/strategy/copy.rb
> ===================================================================
> --- lib/capistrano/recipes/deploy/strategy/copy.rb (revision 6709)
> +++ lib/capistrano/recipes/deploy/strategy/copy.rb (working copy)
> @@ -109,10 +109,10 @@
> # into the given file. The command is returned as an
> array, where
> # the first element is the utility to be used to perform
> the compression.
> def compress(directory, file)
> - case compression
> - when :gzip, :gz then ["tar", "czf", file, directory]
> - when :bzip2, :bz2 then ["tar", "cjf", file, directory]
> - when :zip then ["zip", "-qr", file, directory]
> + ["cd #{File.dirname(file)}", '&&' ] << case compression
> + when :gzip, :gz then ["tar", "czf", file,
> File.basename(directory)]
> + when :bzip2, :bz2 then ["tar", "cjf", file,
> File.basename(directory)]
> + when :zip then ["zip", "-qr", file,
> File.basename(directory)]
> else raise ArgumentError, "invalid compression type #
> {compression.inspect}"
> end
> end
--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---