The thing that wouldn't work on windows was this:

   "cd /tmp && tar ..."

Windows command-line syntax is about as far from POSIX as you can  
get. I've worked around it in the latest release, though, so preview  
2 should work correctly. What I wound up doing was this:

   Dir.chdir(tmpdir) { system(compress(...)) }

- Jamis

On May 11, 2007, at 8:54 AM, Scott Chacon wrote:

>
> Sorry, I don't have access to a windows box to test this on.  What
> about this breaks on Windows?  I'm assuming that the original version
> also does not work on windows, right?
>
> What if you moved the directory changing to ruby in the 'deploy!'  
> method?
>
> 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)
> @@ -30,7 +30,9 @@
>            File.open(File.join(destination, "REVISION"), "w") { |f|
> f.puts(revision) }
>
>            logger.trace "compressing #{destination} to #{filename}"
> -          system(compress(destination, filename).join(" "))
> +          Dir.chdir(File.dirname(destination)) do
> +            system(compress(File.basename(destination),  
> filename).join(" "))
> +          end
>
>            put File.read(filename), remote_filename
>            run "cd #{configuration[:releases_path]} &&
> #{decompress(remote_filename).join(" ")} && rm #{remote_filename}"
>
> In this verison, the 'compress' method stays the same.  I can verify
> that this still works on Linux - if you think that would work on Win,
> I can fix the tests to work with this format, too.
>
> Scott
>
> On 5/10/07, Jamis Buck <[EMAIL PROTECTED]> wrote:
>>
>> Hmm, actually, that patch won't work on Windows. Lemme think about
>> this some.
>>
>> - 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to