bernd / fpm-cookery

A tool for building software packages with fpm.
Other
460 stars 88 forks source link

Picking up all files in a directory #81

Closed haf closed 9 years ago

haf commented 10 years ago

Hi,

I'm trying to get it to pick up ALL files in the tmp-build folder. How do I do that?

(opt/'eventstore').install Dir['*'] only picks up a single subfolder:

===> Using cached file /opt/teamcity-agent/work/d29baefbba8cb0b/eventstore/cache/eventstore-mono-2.0.1.tgz
===> Building in /opt/teamcity-agent/work/d29baefbba8cb0b/eventstore/tmp-build/singlenode-web
===> Installing into /opt/teamcity-agent/work/d29baefbba8cb0b/eventstore/tmp-dest

https://github.com/haf/fpm-recipes/blob/master/eventstore/recipe.rb

haf commented 10 years ago

From this line of code https://github.com/bernd/fpm-cookery/blob/master/lib/fpm/cookery/source_handler/curl.rb#L71

        def extracted_source
          entries = Dir['*'].select {|dir| File.directory?(dir) }

          case entries.size
          when 0
            files = Dir['*'].select {|dir| File.file?(dir) }

            if files.size > 0
              builddir
            else
              raise "Empty archive! (#{local_path})"
            end
          when 1
            entries.first
          else
            # Use the directory that was created last.
            dir = entries.sort do |a, b|
              File.stat(a).ctime <=> File.stat(b).ctime
            end.last

            if File.exist?(dir)
              dir
            else
              raise "Could not find source directory for #{local_path.basename}"
            end
          end
        end

Why would it just pick a single of all the directories?

bernd commented 9 years ago

For most software projects you get one folder in a tarball/zip and that's why fpm-cookery changes into that directory by default.

If you want to get all directories in tmp-build into the package you can do the following.

Dir.chdir(builddir) do
  (opt/'eventstore').install Dir['*']
end

Closing this, please re-open if you still have problems. Thank you!