fpm 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/bin/fpm CHANGED
@@ -63,7 +63,6 @@ def main(args)
63
63
 
64
64
  opts.parse!(args)
65
65
 
66
- p settings
67
66
  FPM::Builder.new(settings, args).assemble!
68
67
 
69
68
  return 0
@@ -40,6 +40,7 @@ class FPM::Builder
40
40
  @paths = paths
41
41
 
42
42
  @output = settings.package_path
43
+ @recurse_dependencies = settings.recurse_dependencies
43
44
  end # def initialize
44
45
 
45
46
  def tar_path
@@ -48,7 +49,7 @@ class FPM::Builder
48
49
 
49
50
  # Assemble the package
50
51
  def assemble!
51
- output.gsub!(/VERSION/, "#{@source[:version]}-#{@source[:iteration]}")
52
+ output.gsub!(/VERSION/, "#{@source[:version]}-#{@package.iteration}")
52
53
  output.gsub!(/ARCH/, @package.architecture)
53
54
 
54
55
  File.delete(output) if File.exists?(output) && !File.directory?(output)
@@ -70,15 +71,17 @@ class FPM::Builder
70
71
  end
71
72
 
72
73
  cleanup!
74
+
73
75
  end # def assemble!
74
76
 
75
- private
77
+ private
76
78
  def builddir
77
79
  @builddir ||= File.expand_path(
78
80
  "#{Dir.pwd}/build-#{@package.type}-#{File.basename(output)}"
79
81
  )
80
82
  end
81
83
 
84
+ private
82
85
  def make_builddir!
83
86
  FileUtils.rm_rf builddir
84
87
  garbage << builddir
@@ -86,6 +89,7 @@ private
86
89
  end
87
90
 
88
91
  # TODO: [Jay] make this better.
92
+ private
89
93
  def package_class_for(type)
90
94
  type = FPM::Target::constants.find { |c| c.downcase == type }
91
95
  if !type
@@ -96,6 +100,7 @@ private
96
100
  end
97
101
 
98
102
  # TODO: [Jay] make this better.
103
+ private
99
104
  def source_class_for(type)
100
105
  type = FPM::Source::constants.find { |c| c.downcase == type }
101
106
  if !type
@@ -105,29 +110,31 @@ private
105
110
  return FPM::Source.const_get(type)
106
111
  end
107
112
 
113
+ private
108
114
  def cleanup!
109
115
  return [] if garbage.empty?
110
116
  FileUtils.rm_rf(garbage) && garbage.clear
111
117
  end
112
118
 
119
+ private
113
120
  def generate_specfile
114
121
  File.open(@package.specfile(builddir), "w") do |f|
115
122
  f.puts @package.render_spec
116
123
  end
117
124
  end
118
125
 
126
+ private
119
127
  def generate_md5sums
120
128
  md5sums = checksum(paths)
121
129
  File.open("#{builddir}/md5sums", "w") { |f| f.puts md5sums }
122
130
  md5sums
123
131
  end
124
132
 
133
+ private
125
134
  def checksum(paths)
126
135
  md5sums = []
127
136
  paths.each do |path|
128
137
  md5sums += %x{find #{path} -type f -print0 | xargs -0 md5sum}.split("\n")
129
138
  end
130
139
  end # def checksum
131
-
132
-
133
140
  end
@@ -28,7 +28,7 @@ class FPM::Source
28
28
  @paths = paths
29
29
  @root = root
30
30
 
31
- get_source
31
+ get_source(params)
32
32
  get_metadata
33
33
 
34
34
  # override the inferred data with the passed-in data
@@ -46,9 +46,10 @@ class FPM::Source
46
46
 
47
47
  # This method should be overridden by package sources that need to do any
48
48
  # kind of fetching.
49
- def get_source
49
+ def get_source(params)
50
50
  # noop by default
51
51
  end # def get_source
52
+
52
53
  def make_tarball!(tar_path)
53
54
  raise NoMethodError,
54
55
  "Please subclass FPM::Source and define make_tarball!(tar_path)"
@@ -5,19 +5,22 @@ require "rubygems"
5
5
  require "fileutils"
6
6
 
7
7
  class FPM::Source::Gem < FPM::Source
8
- def get_source
8
+ def get_source(params)
9
9
  gem = @paths.first
10
10
  looks_like_name_re = /^[A-Za-z0-9_-]+$/
11
11
  if !File.exists?(gem)
12
12
  if gem =~ looks_like_name_re
13
- # TODO(sissel): Use the Gem API
14
- download(gem)
13
+ download(gem, params[:version])
15
14
  else
16
15
  raise "Path '#{gem}' is not a file and does not appear to be the name of a rubygem."
17
16
  end
18
17
  end
19
18
  end # def get_source
20
19
 
20
+ def can_recurse_dependencies
21
+ true
22
+ end
23
+
21
24
  def download(gem_name, version=nil)
22
25
  # This code mostly mutated from rubygem's fetch_command.rb
23
26
  # Code use permissible by rubygems's "GPL or these conditions below"
@@ -27,11 +30,12 @@ class FPM::Source::Gem < FPM::Source
27
30
  dep = ::Gem::Dependency.new gem_name, version
28
31
  # How to handle prerelease? Some extra magic options?
29
32
  #dep.prerelease = options[:prerelease]
30
-
33
+
31
34
  specs_and_sources, errors =
32
35
  ::Gem::SpecFetcher.fetcher.fetch_with_errors(dep, false, true, false)
33
36
  spec, source_uri = specs_and_sources.sort_by { |s,| s.version }.last
34
37
 
38
+
35
39
  if spec.nil? then
36
40
  raise "Invalid gem? Name: #{gem_name}, Version: #{version}, Errors: #{errors}"
37
41
  end
@@ -75,7 +79,7 @@ class FPM::Source::Gem < FPM::Source
75
79
  installdir = "#{tmpdir}/#{::Gem::dir}"
76
80
  ::FileUtils.mkdir_p(installdir)
77
81
  args = ["gem", "install", "--quiet", "--no-ri", "--no-rdoc",
78
- "--install-dir", installdir, @paths.first]
82
+ "--install-dir", installdir, "--ignore-dependencies", @paths.first]
79
83
  system(*args)
80
84
  tar(tar_path, ".", tmpdir)
81
85
 
@@ -3,7 +3,17 @@ Version: <%= version %>-<%= iteration %>
3
3
  Architecture: <%= architecture %>
4
4
  Maintainer: <%= maintainer or "<unknown>" %>
5
5
  <% if dependencies.size > 0 %>
6
- Depends: <%= dependencies.join(", ") %>
6
+ <%
7
+ properdeps = dependencies.collect do |d|
8
+ if d =~ /\(/
9
+ d
10
+ else
11
+ # Convert strings 'foo >= bar' to 'foo (>= bar)'
12
+ da = d.split(/ +/)
13
+ "#{da[0]} (#{da[1]} #{da[2]})"
14
+ end
15
+ end
16
+ %>Depends: <%= properdeps.join(", ") %>
7
17
  <% end %>
8
18
  Standards-Version: 3.9.1
9
19
  Section: <%= category or "unknown" %>
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: 17
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 5
10
- version: 0.1.5
9
+ - 6
10
+ version: 0.1.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jordan Sissel