Using rake package task- suppressing initial segment of path

I have the following trivial bit of code, just to help me figure out
how to create a more usable tarball:

  require 'rake/packagetask'
  Rake::PackageTask.new('WCV', :noversion) do |p|
    p.need_tar_gz = true
    p.package_files.include("README")
  end
when I run "rake package", it creates a pkg directory
and a tarball in that directory called "wcv.tar.gz".
when I do "tar ztf pkg/wcv.tar.gz" I see this:

wcv/
wcv/README

I need for the initial "wcv" **not** to be included.
In other words, when I run "tar ztf pkg/wcv.tar.gz" I want to see:
README

Can this be done?

Thx

···

--
Posted via http://www.ruby-forum.com/.

Dan Tenenbaum wrote:
[...]

I need for the initial "wcv" **not** to be included.
In other words, when I run "tar ztf pkg/wcv.tar.gz" I want to see:
README

Yikes! I hate when packages dump their contained files intermingled
with files in the current directory. That's why PackageTask does it
that way it does.

However, read on if you feel you have a legitimate need.

Can this be done?

The package task does not do that, nor is there a straightforward way to
configure it to do so.

However ...

The guts of the package task are not that complex. It is just running
tar over the list of files it has collected. If you don't want to redo
everything, you can let the package task build the directory and then
just add your own task to build the tar file.

Assume your project is myproj, version 1.2.3

Add this task:

  file "myproj-1.2.3.tgz" => "pkg/myproj-1.2.3" do
    chdir("pkg/pkg/myproj-1.2.3") do
      sh %{tar zcvf ../../myproj-1.2.3.tgz *}
    end
  end

This will create a tgz file in the root of your project (rather than in
the pkg directory like the package task does). Typing:

    rake myproj-1.2.3.tgz

will do the trick.

Does this help?

-- Jim Weirich

···

--
Posted via http://www.ruby-forum.com/.

Jim Weirich wrote:

Dan Tenenbaum wrote:
[...]

I need for the initial "wcv" **not** to be included.
In other words, when I run "tar ztf pkg/wcv.tar.gz" I want to see:
README

Yikes! I hate when packages dump their contained files intermingled
with files in the current directory. That's why PackageTask does it
that way it does.

Yeah...but I'm not creating a package. I have a specialized need.

Assume your project is myproj, version 1.2.3

Add this task:

  file "myproj-1.2.3.tgz" => "pkg/myproj-1.2.3" do
    chdir("pkg/pkg/myproj-1.2.3") do
      sh %{tar zcvf ../../myproj-1.2.3.tgz *}
    end
  end

This will create a tgz file in the root of your project (rather than in
the pkg directory like the package task does). Typing:

    rake myproj-1.2.3.tgz

will do the trick.

Does this help?

Yes, that works, thanks. I ended up just doing it without the Package
task, and just using Find.find to generate the list of files, looping
through it to weed out my complicated exclusions.

···

--
Posted via http://www.ruby-forum.com/.