fpm 0.1.9 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -94,7 +94,7 @@ class FPM::Builder
94
94
  # TODO: [Jay] make this better.
95
95
  private
96
96
  def package_class_for(type)
97
- type = FPM::Target::constants.find { |c| c.downcase == type }
97
+ type = FPM::Target::constants.find { |c| c.downcase.to_s == type }
98
98
  if !type
99
99
  raise ArgumentError, "unknown package type #{type.inspect}"
100
100
  end
@@ -105,7 +105,7 @@ class FPM::Builder
105
105
  # TODO: [Jay] make this better.
106
106
  private
107
107
  def source_class_for(type)
108
- type = FPM::Source::constants.find { |c| c.downcase == type }
108
+ type = FPM::Source::constants.find { |c| c.downcase.to_s == type }
109
109
  if !type
110
110
  raise ArgumentError, "unknown package type #{type.inspect}"
111
111
  end
@@ -75,6 +75,7 @@ class FPM::Source
75
75
  private
76
76
  def tar(output, paths, chdir=".")
77
77
  dirs = []
78
+ paths = [ paths ] if paths.is_a? String
78
79
  paths.each do |path|
79
80
  while path != "/" and path != "."
80
81
  dirs << path if !dirs.include?(path)
@@ -91,7 +91,10 @@ class FPM::Source::Gem < FPM::Source
91
91
  args = ["gem", "install", "--quiet", "--no-ri", "--no-rdoc",
92
92
  "--install-dir", installdir, "--ignore-dependencies", @paths.first]
93
93
  system(*args)
94
- tar(tar_path, ".", tmpdir)
94
+
95
+ @paths = [ ::Gem::dir ]
96
+ tar(tar_path, ".#{@paths.first}", tmpdir)
97
+ FileUtils.rm_r(tmpdir)
95
98
 
96
99
  # TODO(sissel): Make a helper method.
97
100
  system(*["gzip", "-f", tar_path])
@@ -0,0 +1,35 @@
1
+ require "fpm/namespace"
2
+ require "fpm/source"
3
+ require "fileutils"
4
+
5
+ class FPM::Source::Npm < FPM::Source
6
+ def get_source(params)
7
+ @npm = @paths.first
8
+ end # def get_source
9
+
10
+ def download(npm_name, version=nil)
11
+ end # def download
12
+
13
+ def get_metadata
14
+ # set self[:...] values
15
+ # :name
16
+ # :maintainer
17
+ # :url
18
+ # :category
19
+ # :dependencies
20
+ end # def get_metadata
21
+
22
+ def make_tarball!(tar_path, builddir)
23
+ tmpdir = "#{tar_path}.dir"
24
+ installdir = "#{tmpdir}/#{::Gem::dir}"
25
+ ::FileUtils.mkdir_p(installdir)
26
+ args = ["gem", "install", "--quiet", "--no-ri", "--no-rdoc",
27
+ "--install-dir", installdir, "--ignore-dependencies", @paths.first]
28
+ system(*args)
29
+ tar(tar_path, ".", tmpdir)
30
+
31
+ # TODO(sissel): Make a helper method.
32
+ system(*["gzip", "-f", tar_path])
33
+ end
34
+
35
+ end # class FPM::Source::Gem
@@ -14,6 +14,10 @@ class FPM::Target::Rpm < FPM::Package
14
14
  "--define", "_sourcedir #{Dir.pwd}",
15
15
  "--define", "_rpmdir #{params[:output]}",
16
16
  "#{name}.spec"]
17
- system(*args)
17
+ ret = system(*args)
18
+ if !ret
19
+ raise "rpmbuild failed"
20
+ end
21
+
18
22
  end
19
23
  end
@@ -12,8 +12,22 @@ License: <%= @license %>
12
12
  Source0: %{_sourcedir}/data.tar.gz
13
13
  BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
14
14
 
15
- <% if @dependencies && !@dependencies.empty? %>
16
- Requires: <%= @dependencies.join(", ") %>
15
+ <% if !dependencies.empty? %>
16
+ <%
17
+ properdeps = dependencies.collect do |d|
18
+ # Convert gem ~> X.Y.Z to '>= X.Y.Z' and < X.Y+1.0
19
+ if d =~ /\~>/
20
+ name, version = d.gsub(/[()~>]/, "").split(/ +/)[0..1]
21
+ nextversion = version.split(".").collect { |v| v.to_i }
22
+ nextversion[1] += 1
23
+ nextversion[2] = 0
24
+ nextversion = nextversion.join(".")
25
+ ["#{name} >= #{version}", "#{name} < #{nextversion}"]
26
+ else
27
+ d
28
+ end
29
+ end
30
+ %>Requires: <%= properdeps.join(", ") %>
17
31
  <% end %>
18
32
 
19
33
  %description
@@ -33,9 +47,9 @@ tar -zvxf %SOURCE0
33
47
  %clean
34
48
  rm -rf $RPM_BUILD_ROOT
35
49
 
36
-
37
50
  %files
38
51
  %defattr(-,root,root,-)
39
- <%= @source.paths.join("\n") %>
52
+ <%# Trim leading '.' from paths if they are './blah...' %>
53
+ <%= @source.paths.collect { |p| p.gsub(/^\.\//, "/") }.join("\n") %>
40
54
 
41
55
  %changelog
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: 9
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 9
10
- version: 0.1.9
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
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-20 00:00:00 -08:00
18
+ date: 2011-01-22 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -45,6 +45,7 @@ files:
45
45
  - lib/fpm/builder.rb
46
46
  - lib/fpm/namespace.rb
47
47
  - lib/fpm/source.rb
48
+ - lib/fpm/source/npm.rb
48
49
  - lib/fpm/source/dir.rb
49
50
  - lib/fpm/source/rpm.rb
50
51
  - lib/fpm/source/gem.rb