fpm 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
data/bin/fpm CHANGED
@@ -59,6 +59,11 @@ def main(args)
59
59
  opts.on("-s SOURCE_TYPE", "what to build the package from") do |st|
60
60
  settings.source_type = st
61
61
  end
62
+
63
+ opts.on("--prefix PREFIX",
64
+ "A path to prefix files with when building the target package. This may not be necessary for all source types. For example, the 'gem' type will prefix with your gem directory (gem env | grep -A1 PATHS:)") do |prefix|
65
+ settings.prefix = prefix
66
+ end
62
67
  end # OptionParser
63
68
 
64
69
  opts.parse!(args)
@@ -33,11 +33,14 @@ class FPM::Builder
33
33
  @source = source_class_for(settings.source_type || 'dir').new(
34
34
  paths, root,
35
35
  :version => settings.version,
36
- :name => settings.package_name
36
+ :name => settings.package_name,
37
+ :prefix => settings.prefix
37
38
  )
38
39
 
39
- @package = package_class_for(settings.package_type).new(@source)
40
40
  @paths = paths
41
+ @package = package_class_for(settings.package_type).new(@source)
42
+ # Append dependencies given from settings (-d flag for fpm)
43
+ @package.dependencies += settings.dependencies
41
44
 
42
45
  @output = settings.package_path
43
46
  @recurse_dependencies = settings.recurse_dependencies
@@ -57,7 +60,7 @@ class FPM::Builder
57
60
  make_builddir!
58
61
 
59
62
  ::Dir.chdir root do
60
- @source.make_tarball!(tar_path)
63
+ @source.make_tarball!(tar_path, builddir)
61
64
 
62
65
  generate_md5sums
63
66
  generate_specfile
@@ -50,7 +50,7 @@ class FPM::Source
50
50
  # noop by default
51
51
  end # def get_source
52
52
 
53
- def make_tarball!(tar_path)
53
+ def make_tarball!(tar_path, builddir)
54
54
  raise NoMethodError,
55
55
  "Please subclass FPM::Source and define make_tarball!(tar_path)"
56
56
  end
@@ -1,12 +1,41 @@
1
1
  require "fpm/source"
2
+ require "fileutils"
2
3
 
3
4
  class FPM::Source::Dir < FPM::Source
4
5
  def get_metadata
5
6
  self[:name] = File.basename(File.expand_path(root))
6
7
  end
7
8
 
8
- def make_tarball!(tar_path)
9
- tar(tar_path, paths)
9
+ def make_tarball!(tar_path, builddir)
10
+ if self[:prefix]
11
+ self[:prefix] = self[:prefix][1..-1] if self[:prefix] =~ /^\//
12
+ # Prefix all files with a path.
13
+ FileUtils.mkdir_p(self[:prefix])
14
+ paths.each do |path|
15
+ # Trim @root (--chdir)
16
+ path = path[@root.size .. -1] if path.start_with?(@root)
17
+
18
+ # Copy to self[:prefix] (aka --prefix)
19
+ dest = "#{builddir}/tarbuild/#{self[:prefix]}/#{path}"
20
+ FileUtils.mkdir_p(dest)
21
+ rsync = ["rsync", "-a", path, dest]
22
+ system(*rsync)
23
+
24
+ # FileUtils.cp_r is pretty silly about how it copies files in some
25
+ # cases (funky permissions, etc)
26
+ # Use rsync instead..
27
+ #FileUtils.cp_r(path, dest)
28
+ end
29
+ ::Dir.chdir("#{builddir}/tarbuild") do
30
+ puts "TAR"
31
+ puts tar_path
32
+ puts "#{builddir}/tarbuild"
33
+ system("ls #{builddir}/tarbuild")
34
+ tar(tar_path, ".")
35
+ end
36
+ else
37
+ tar(tar_path, paths)
38
+ end
10
39
 
11
40
  # TODO(sissel): Make a helper method.
12
41
  system(*["gzip", "-f", tar_path])
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fpm
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 6
10
- version: 0.1.6
9
+ - 7
10
+ version: 0.1.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jordan Sissel
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-07 00:00:00 -08:00
18
+ date: 2011-01-13 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency