# Rake's PackageTask should have tar -h for symbolic links

**URL:** <https://www.ruby-forum.com/t/rakes-packagetask-should-have-tar-h-for-symbolic-links/93547>\
**Category:** Ruby\
**Created:** [April 4, 2006, 6:06pm UTC](https://www.ruby-forum.com/t/rakes-packagetask-should-have-tar-h-for-symbolic-links/93547 "2006-04-04T18:06:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ed\_Howland](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/7993a0/32.png) [@Ed\_Howland](https://www.ruby-forum.com/u/Ed_Howland)\
**Post date:** [April 4, 2006, 6:06pm UTC](https://www.ruby-forum.com/t/rakes-packagetask-should-have-tar-h-for-symbolic-links/93547/1 "2006-04-04T18:06:54Z")

</div>

Hi,

I have a need to have Rake::PackageTask implement the -h option on tar  
+gz and bz2. This would allow for tar to include any linked  
files/folders. The workaround is to cp -r the entire contents of the  
linked dir. This is klunky at best.

Any chance of this? Any other workarounds?

Thanks  
Ed

---

<div class="post-metadata">

**Author:** ![Ed\_Howland](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/7993a0/32.png) [@Ed\_Howland](https://www.ruby-forum.com/u/Ed_Howland)\
**Post date:** [April 4, 2006, 7:43pm UTC](https://www.ruby-forum.com/t/rakes-packagetask-should-have-tar-h-for-symbolic-links/93547/2 "2006-04-04T19:43:09Z")

</div>

Ed Howland wrote:

> Hi,
> 
> I have a need to have Rake::PackageTask implement the -h option on tar  
> +gz and bz2. This would allow for tar to include any linked  
> files/folders. The workaround is to cp -r the entire contents of the  
> linked dir. This is klunky at best.
> 
> Any chance of this? Any other workarounds?

Two issues:

(1) Rake actually makes a copy of the directory and tars that up. That  
way the tar file will not accidently pick up non-package files that  
might be laying around. It will use hard links on Unix do keep the disk  
space usage down (Windows, however, uses a full copy). Any symbolic  
links would have to be added to that copied directory structure for the  
package task to pick it up.

(2) I’m considering adding support for the pure-ruby tar library to  
build the tarfile. This would allow the package to be built on windows  
machines that don’t a tar program. But I’m not sure if the pure ruby  
tar library supports a -h option. That would have to be verfified.

I’m open to patches for supporting the -h option given the above  
constraints.

–  
– Jim W.

---

<div class="post-metadata">

**Author:** ![Ed\_Howland](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/7993a0/32.png) [@Ed\_Howland](https://www.ruby-forum.com/u/Ed_Howland)\
**Post date:** [April 4, 2006, 8:30pm UTC](https://www.ruby-forum.com/t/rakes-packagetask-should-have-tar-h-for-symbolic-links/93547/3 "2006-04-04T20:30:38Z")

</div>

On 4/4/06, Jim W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> (2) I’m considering adding support for the pure-ruby tar library to  
> build the tarfile. This would allow the package to be built on windows  
> machines that don’t a tar program. But I’m not sure if the pure ruby  
> tar library supports a -h option. That would have to be verfified.

I have been given a patch for minitar that is supposed to support  
symlinks. I have not had time to review or apply it yet.

Additionally, a significant upgrade to minitar may be in the works if  
something else I’m working on pans out.

-austin

---

<div class="post-metadata">

**Author:** ![Ed\_Howland](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/7993a0/32.png) [@Ed\_Howland](https://www.ruby-forum.com/u/Ed_Howland)\
**Post date:** [April 4, 2006, 11:14pm UTC](https://www.ruby-forum.com/t/rakes-packagetask-should-have-tar-h-for-symbolic-links/93547/4 "2006-04-04T23:14:11Z")

</div>

On 4/4/06, Jim W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Ed Howland wrote:  
> Two issues:
> 
> (1) Rake actually makes a copy of the directory and tars that up. That  
> way the tar file will not accidently pick up non-package files that  
> might be laying around. It will use hard links on Unix do keep the disk  
> space usage down (Windows, however, uses a full copy). Any symbolic  
> links would have to be added to that copied directory structure for the  
> package task to pick it up.

The workaround I came up with does the copy, but at the time time of  
Rake’s copy:

require ‘find’  
Rake::PackageTask.new(“mytarball”, “3-31-2006”) do |p|  
p.need\_tar\_gz = true  
Find.find(‘mydir’) do |path|  
p.package\_files \<\< path  
end  
end

It works on any symbolic links by just recursing down the other tree  
and adding pathnames to the package’s file list. So it minimizes the  
disk space usage to only what Rake uses.

> (2) I’m considering adding support for the pure-ruby tar library to  
> build the tarfile. This would allow the package to be built on windows  
> machines that don’t a tar program. But I’m not sure if the pure ruby  
> tar library supports a -h option. That would have to be verfified.
> 
> I’m open to patches for supporting the -h option given the above  
> constraints.

That would be nice. Would using the pure-ruby tar library in Rake  
avoid the need to do the copy to pkg/? My Rakefile tasks leave  
everything in a final folder to be tarballed. It seems an unneccesary  
step to create the pkg directory and copy everything in there. Could  
an option be added to PackageTask to just tar an existing dir?

BTW, Curt H. just taught us StL Rubyists how to use Rake. It is  
great!

> –  
> – Jim W.

Ed
