fpm 0.3.11 → 0.4.0pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/CHANGELIST +15 -0
  2. data/bin/fpm +2 -15
  3. data/lib/fpm.rb +5 -12
  4. data/lib/fpm/command.rb +323 -0
  5. data/lib/fpm/errors.rb +1 -0
  6. data/lib/fpm/namespace.rb +2 -11
  7. data/lib/fpm/package.rb +255 -100
  8. data/lib/fpm/package/deb.rb +367 -0
  9. data/lib/fpm/package/dir.rb +86 -0
  10. data/lib/fpm/package/gem.rb +162 -0
  11. data/lib/fpm/{source → package}/npm.rb +3 -3
  12. data/lib/fpm/package/pear.rb +41 -0
  13. data/lib/fpm/{target → package}/puppet.rb +1 -3
  14. data/lib/fpm/{source → package}/pyfpm/__init__.py +0 -0
  15. data/lib/fpm/package/pyfpm/__init__.pyc +0 -0
  16. data/lib/fpm/{source → package}/pyfpm/get_metadata.py +15 -3
  17. data/lib/fpm/package/pyfpm/get_metadata.pyc +0 -0
  18. data/lib/fpm/package/python.rb +125 -0
  19. data/lib/fpm/package/rpm.rb +132 -0
  20. data/lib/fpm/{target → package}/solaris.rb +3 -2
  21. data/lib/fpm/package/tar.rb +62 -0
  22. data/lib/fpm/util.rb +56 -7
  23. data/templates/deb.erb +12 -12
  24. data/templates/rpm.erb +32 -38
  25. data/templates/solaris.erb +1 -1
  26. metadata +119 -78
  27. data/lib/fpm/builder.rb +0 -220
  28. data/lib/fpm/flags.rb +0 -20
  29. data/lib/fpm/program.rb +0 -273
  30. data/lib/fpm/rubyfixes.rb +0 -11
  31. data/lib/fpm/source.rb +0 -155
  32. data/lib/fpm/source/dir.rb +0 -59
  33. data/lib/fpm/source/gem.rb +0 -162
  34. data/lib/fpm/source/python.rb +0 -137
  35. data/lib/fpm/source/rpm.rb +0 -28
  36. data/lib/fpm/source/tar.rb +0 -50
  37. data/lib/fpm/target/deb.rb +0 -184
  38. data/lib/fpm/target/rpm.rb +0 -68
  39. data/lib/rpm/header.rb +0 -89
  40. data/lib/rpm/lead.rb +0 -48
  41. data/lib/rpm/namespace.rb +0 -1
  42. data/lib/rpm/rpmfile.rb +0 -81
  43. data/lib/rpm/tag.rb +0 -304
@@ -6,7 +6,7 @@ require "fpm/util"
6
6
 
7
7
  # TODO(sissel): Add dependency checking support.
8
8
  # IIRC this has to be done as a 'checkinstall' step.
9
- class FPM::Target::Solaris < FPM::Package
9
+ class FPM::Package::Solaris < FPM::Package
10
10
  def architecture
11
11
  case @architecture
12
12
  when nil, "native"
@@ -59,7 +59,8 @@ class FPM::Target::Solaris < FPM::Package
59
59
  prototype.puts("i postinstall") if self.scripts["post-install"]
60
60
 
61
61
  # TODO(sissel): preinstall/postinstall
62
- IO.popen("pkgproto data=/").each_line do |line|
62
+ # strip @prefix, since BASEDIR will set prefix via the pkginfo file
63
+ IO.popen("pkgproto data/#{@prefix}=").each_line do |line|
63
64
  type, klass, path, mode, user, group = line.split
64
65
  # Override stuff in pkgproto
65
66
  # TODO(sissel): Make this tunable?
@@ -0,0 +1,62 @@
1
+ require "backports" # gem backports
2
+ require "fpm/package"
3
+ require "fpm/util"
4
+ require "fileutils"
5
+ require "fpm/package/dir"
6
+
7
+ class FPM::Package::Tar < FPM::Package
8
+ def input(input_path)
9
+ # use part of the filename as the package name
10
+ self.name = File.basename(input_path).split(".").first
11
+
12
+ # Unpack the tarball to the build path before ultimately moving it to
13
+ # staging.
14
+ args = ["-xf", input_path, "-C", build_path]
15
+
16
+ # Add the tar compression flag if necessary
17
+ with(tar_compression_flag(input_path)) do |flag|
18
+ args << flag unless flag.nil?
19
+ end
20
+
21
+ safesystem("tar", *args)
22
+
23
+ # use dir to set stuff up properly, mainly so I don't have to reimplement
24
+ # the chdir/prefix stuff special for tar.
25
+ dir = convert(FPM::Package::Dir)
26
+ if attributes[:chdir]
27
+ dir.attributes[:chdir] = File.join(build_path, attributes[:chdir])
28
+ else
29
+ dir.attributes[:chdir] = build_path
30
+ end
31
+
32
+ cleanup_staging
33
+ # Tell 'dir' to input "." and chdir/prefix will help it figure out the
34
+ # rest.
35
+ dir.input(".")
36
+ @staging_path = dir.staging_path
37
+ dir.cleanup_build
38
+ end # def input
39
+
40
+ def output(output_path)
41
+ # Unpack the tarball to the staging path
42
+ args = ["-cf", output_path, "-C", staging_path, "."]
43
+ with(tar_compression_flag(output_path)) do |flag|
44
+ args << flag unless flag.nil?
45
+ end
46
+
47
+ safesystem("tar", *args)
48
+ end # def output
49
+
50
+ def tar_compression_flag(path)
51
+ case path
52
+ when /\.tar\.bz2$/
53
+ return "-j"
54
+ when /\.tar\.gz$|\.tgz$/
55
+ return "-z"
56
+ when /\.tar\.xz$/
57
+ return "-J"
58
+ else
59
+ return nil
60
+ end
61
+ end # def tar_compression_flag
62
+ end # class FPM::Package::Tar
data/lib/fpm/util.rb CHANGED
@@ -1,7 +1,56 @@
1
- def safesystem(*args)
2
- success = system(*args)
3
- if !success
4
- raise "'system(#{args.inspect})' failed with error code: #{$?.exitstatus}"
5
- end
6
- return success
7
- end # def safesystem
1
+ require "fpm/namespace"
2
+
3
+ # Some utility functions
4
+ module FPM::Util
5
+ # Raised if safesystem cannot find the program to run.
6
+ class ExecutableNotFound < StandardError; end
7
+
8
+ # Raised if a safesystem program exits nonzero
9
+ class ProcessFailed < StandardError; end
10
+
11
+ # Is the given program in the system's PATH?
12
+ def program_in_path?(program)
13
+ # Scan path to find the executable
14
+ # Do this to help the user get a better error message.
15
+ envpath = ENV["PATH"].split(":")
16
+ return envpath.select { |p| File.executable?(File.join(p, program)) }.any?
17
+ end # def program_in_path
18
+
19
+ # Run a command safely in a way that gets reports useful errors.
20
+ def safesystem(*args)
21
+ program = args[0]
22
+
23
+ # Scan path to find the executable
24
+ # Do this to help the user get a better error message.
25
+ if !program.include?("/") and !program_in_path?(program)
26
+ raise ExecutableNotFound.new(program)
27
+ end
28
+
29
+ @logger.debug("Running command", :args => args)
30
+ success = system(*args)
31
+ if !success
32
+ raise ProcessFailed.new("#{program} failed (exit code #{$?.exitstatus})" \
33
+ ". Full command was:#{args.inspect}")
34
+ end
35
+ return success
36
+ end # def safesystem
37
+
38
+ # Get the recommended 'tar' command for this platform.
39
+ def tar_cmd
40
+ # Rely on gnu tar for solaris and OSX.
41
+ case %x{uname -s}.chomp
42
+ when "SunOS"
43
+ return "gtar"
44
+ when "Darwin"
45
+ return "gnutar"
46
+ else
47
+ return "tar"
48
+ end
49
+ end # def tar_cmd
50
+
51
+ # Run a block with a value.
52
+ # Useful in lieu of assigning variables
53
+ def with(value, &block)
54
+ block.call(value)
55
+ end # def with
56
+ end # module FPM::Util
data/templates/deb.erb CHANGED
@@ -1,27 +1,27 @@
1
1
  Package: <%= name %>
2
- Version: <%= "#{epoch}:" if epoch %><%= version %><%= iteration && '-'+iteration.to_s %>
2
+ Version: <%= "#{epoch}:" if epoch %><%= version %><%= "-" + iteration.to_s if iteration %>
3
+ License: <%= license %>
4
+ Vendor: <%= vendor %>
3
5
  Architecture: <%= architecture %>
4
- Maintainer: <%= maintainer or "<unknown>" %>
6
+ Maintainer: <%= maintainer %>
7
+ Installed-Size: <%= attributes[:deb_installed_size] %>
5
8
  <% if !dependencies.empty? -%>
6
- <% properdeps = dependencies.collect { |d| fix_dependency(d) }.flatten -%>
7
- Depends: <%= properdeps.flatten.join(", ") %>
8
- <% end -%>
9
- <% if !pre_dependencies.empty? -%>
10
- <% properpredeps = pre_dependencies.collect { |d| fix_dependency(d) }.flatten -%>
11
- Pre-Depends: <%= properpredeps.flatten.join(", ") %>
9
+ Depends: <%= dependencies.join(", ") %>
12
10
  <% end -%>
13
11
  <% if !conflicts.empty? -%>
14
12
  Conflicts: <%= conflicts.join(", ") %>
15
13
  <% end -%>
14
+ <%# if !pre_dependencies.empty? -%>
15
+ <%# properpredeps = pre_dependencies.collect { |d| fix_dependency(d) }.flatten -%>
16
+ #Pre-Depends: <%#= properpredeps.flatten.join(", ") %>
17
+ <%# end -%>
16
18
  <% if !provides.empty? -%>
17
19
  Provides: <%= provides.join(", ") %>
18
20
  <% end -%>
19
21
  <% if !replaces.empty? -%>
20
- <% properrepl = replaces.collect { |d| fix_dependency(d) }.flatten -%>
21
- Replaces: <%= properrepl.flatten.join(", ") %>
22
+ Replaces: <%= replaces.join(", ") %>
22
23
  <% end -%>
23
- Standards-Version: 3.9.1
24
- Section: <%= category or "unknown" %>
24
+ Section: <%= category %>
25
25
  Priority: extra
26
26
  Homepage: <%= url or "http://nourlgiven.example.com/" %>
27
27
  <% lines = (description or "no description given").split("\n") -%>
data/templates/rpm.erb CHANGED
@@ -1,3 +1,13 @@
1
+ # Disable the stupid stuff rpm distros include in the build process by default:
2
+ <% %w(prep build install clean).each do |step| -%>
3
+ <%# These definitions have to be non-empty... I guess... -%>
4
+ # Disable any <%= step %> shell actions. replace them with simply 'true'
5
+ %define __spec_<%= step %>_post true
6
+ %define __spec_<%= step %>_pre true
7
+ <% end -%>
8
+ # Disable checking for unpackaged files ?
9
+ #%undefine __check_files
10
+
1
11
  Name: <%= name %>
2
12
  Version: <%= version %>
3
13
  <% if epoch -%>
@@ -5,43 +15,18 @@ Epoch: <%= epoch %>
5
15
  <% end -%>
6
16
  Release: <%= iteration or 1 %>
7
17
  <%# use the first line of the description as the summary -%>
8
- Summary: <%= description.split("\n").first %>
18
+ Summary: <%= description.split("\n").first.empty? ? "_" : description.split("\n").first %>
9
19
  BuildArch: <%= architecture %>
10
20
  AutoReqProv: no
11
21
 
12
22
  Group: <%= category %>
13
- <%#
14
- TODO: [Jay] rpms require a license
15
- let's detect it intelligently
16
- -%>
17
23
  License: <%= license %>
24
+ Vendor: <%= vendor %>
18
25
  URL: <%= url or "http://nourlgiven.example.com/" %>
19
- Source0: %{_sourcedir}/data.tar.gz
20
- BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
26
+ Packager: <%= maintainer %>
21
27
 
22
- <% if !dependencies.empty? -%>
23
- <%
24
- properdeps = dependencies.collect do |d|
25
- # Convert gem ~> X.Y.Z to '>= X.Y.Z' and < X.Y+1.0
26
- if d =~ /\~>/
27
- name, version = d.gsub(/[()~>]/, "").split(/ +/)[0..1]
28
- nextversion = version.split(".").collect { |v| v.to_i }
29
- l = nextversion.length
30
- nextversion[l-2] += 1
31
- nextversion[l-1] = 0
32
- nextversion = nextversion.join(".")
33
- ["#{name} >= #{version}", "#{name} < #{nextversion}"]
34
- elsif d =~ /\d [<>]=? [0-9.+] [<>]=? \d/
35
- # Convert gem >= A.B.C <= X.Y.Z to '>= A.B.C' and '<= X.Y.Z'
36
- puts d
37
- # split out version numbers with their equality sign
38
- name, lower_version, upper_version = d.scan(/([\w-]+) ([<>]=? [\d\.]+) ([<>]=? [\d\.]+)/)[0]
39
- ["#{name} #{lower_version}", "#{name} #{upper_version}"]
40
- else
41
- d
42
- end
43
- end
44
- -%>Requires: <%= properdeps.join(", ") %>
28
+ <% dependencies.each do |req| -%>
29
+ Requires: <%= req %>
45
30
  <% end -%>
46
31
  <% provides.each do |prov| -%>
47
32
  Provides: <%= prov %>
@@ -62,13 +47,21 @@ Obsoletes: <%= repl %>
62
47
  # noop
63
48
 
64
49
  %install
65
- # some rpm implementations delete the build dir and then recreate it by
66
- # default, for some reason. Whatever, let's work around it.
67
- cd $RPM_BUILD_ROOT
68
- tar -zxf %SOURCE0
50
+ <% files.each do |path| -%>
51
+ <% source = File.join(staging_path, path) -%>
52
+ <% # Copy to the build_path/BUILD/ to make rpmbuild happy -%>
53
+ <% target = File.join(build_path, "BUILD", path) -%>
54
+ <% dir = File.dirname(target) %>
55
+ mkdir -p "<%= dir %>"
56
+ if [ -f "<%= source %>" ] ; then
57
+ cp "<%= source %>" "<%= target %>"
58
+ elif [ -d "<%= source %>" ] ; then
59
+ mkdir "<%= target %>"
60
+ fi
61
+ <% end %>
69
62
 
70
63
  %clean
71
- rm -rf $RPM_BUILD_ROOT
64
+ # noop
72
65
 
73
66
  <% if scripts["pre-install"] -%>
74
67
  %pre
@@ -92,8 +85,9 @@ rm -rf $RPM_BUILD_ROOT
92
85
  <% end -%>
93
86
  %files
94
87
  %defattr(-,root,root,-)
95
- <%# Trim leading '.' from paths if they are './blah...' -%>
96
- <%# Also ensure paths start with '/' -%>
97
- <%= @source.paths.collect { |p| p.gsub(/^\.\//, "/").gsub(/^[^\/]/, "/\\0") }.join("\n") %>
88
+ <%# Output config files and then regular files. -%>
89
+ <%= config_files.collect { |c| '%config ' + c }.join("\n") -%>
90
+ <%# list only files, not directories? %>
91
+ <%= files.reject { |f| File.directory?(File.join(staging_path, f)) }.collect { |f| "/#{f}" }.join("\n") %>
98
92
 
99
93
  %changelog
@@ -1,5 +1,5 @@
1
1
  CLASSES=none
2
- BASEDIR=/usr/local
2
+ BASEDIR=<%= prefix %>
3
3
  TZ=PST
4
4
  PATH=/sbin:/usr/sbin:/usr/bin:/usr/sadm/install/bin
5
5
  PKG=<%= name %>
metadata CHANGED
@@ -1,116 +1,157 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: fpm
3
- version: !ruby/object:Gem::Version
4
- hash: 5
5
- prerelease:
6
- segments:
7
- - 0
8
- - 3
9
- - 11
10
- version: 0.3.11
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0pre1
5
+ prerelease: 5
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Jordan Sissel
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-11-03 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-03-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: json
16
+ requirement: &14920820 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *14920820
25
+ - !ruby/object:Gem::Dependency
26
+ name: cabin
27
+ requirement: &14920320 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 0.4.2
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *14920320
36
+ - !ruby/object:Gem::Dependency
37
+ name: backports
38
+ requirement: &14919820 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - =
42
+ - !ruby/object:Gem::Version
43
+ version: 2.3.0
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *14919820
47
+ - !ruby/object:Gem::Dependency
48
+ name: arr-pm
49
+ requirement: &14919440 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *14919440
58
+ - !ruby/object:Gem::Dependency
59
+ name: rush
60
+ requirement: &14918980 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *14918980
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: &14918560 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
22
78
  prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
79
+ version_requirements: *14918560
80
+ - !ruby/object:Gem::Dependency
81
+ name: insist
82
+ requirement: &14918140 !ruby/object:Gem::Requirement
24
83
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 3
29
- segments:
30
- - 0
31
- version: "0"
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
32
88
  type: :runtime
33
- version_requirements: *id001
34
- description: Convert directories, rpms, python eggs, rubygems, and more to rpms, debs, solaris packages and more. Win at package management without wasting pointless hours debugging bad rpm specs!
89
+ prerelease: false
90
+ version_requirements: *14918140
91
+ description: Convert directories, rpms, python eggs, rubygems, and more to rpms, debs,
92
+ solaris packages and more. Win at package management without wasting pointless hours
93
+ debugging bad rpm specs!
35
94
  email: jls@semicomplete.com
36
- executables:
95
+ executables:
37
96
  - fpm
38
97
  - fpm-npm
39
98
  extensions: []
40
-
41
99
  extra_rdoc_files: []
42
-
43
- files:
44
- - lib/fpm.rb
45
- - lib/rpm/lead.rb
46
- - lib/rpm/namespace.rb
47
- - lib/rpm/rpmfile.rb
48
- - lib/rpm/tag.rb
49
- - lib/rpm/header.rb
50
- - lib/fpm/rubyfixes.rb
51
- - lib/fpm/flags.rb
52
- - lib/fpm/namespace.rb
53
- - lib/fpm/program.rb
54
- - lib/fpm/source/gem.rb
55
- - lib/fpm/source/dir.rb
56
- - lib/fpm/source/tar.rb
57
- - lib/fpm/source/npm.rb
58
- - lib/fpm/source/rpm.rb
59
- - lib/fpm/source/pyfpm/get_metadata.py
60
- - lib/fpm/source/pyfpm/__init__.py
61
- - lib/fpm/source/python.rb
62
- - lib/fpm/builder.rb
63
- - lib/fpm/source.rb
64
- - lib/fpm/package.rb
65
- - lib/fpm/target/puppet.rb
66
- - lib/fpm/target/deb.rb
67
- - lib/fpm/target/solaris.rb
68
- - lib/fpm/target/rpm.rb
69
- - lib/fpm/util.rb
100
+ files:
70
101
  - lib/fpm/errors.rb
102
+ - lib/fpm/util.rb
103
+ - lib/fpm/command.rb
104
+ - lib/fpm/package/pyfpm/get_metadata.py
105
+ - lib/fpm/package/pyfpm/__init__.pyc
106
+ - lib/fpm/package/pyfpm/get_metadata.pyc
107
+ - lib/fpm/package/pyfpm/__init__.py
108
+ - lib/fpm/package/python.rb
109
+ - lib/fpm/package/rpm.rb
110
+ - lib/fpm/package/npm.rb
111
+ - lib/fpm/package/deb.rb
112
+ - lib/fpm/package/gem.rb
113
+ - lib/fpm/package/tar.rb
114
+ - lib/fpm/package/pear.rb
115
+ - lib/fpm/package/dir.rb
116
+ - lib/fpm/package/puppet.rb
117
+ - lib/fpm/package/solaris.rb
118
+ - lib/fpm/package.rb
119
+ - lib/fpm/namespace.rb
120
+ - lib/fpm.rb
71
121
  - bin/fpm-npm
72
122
  - bin/fpm
73
- - templates/rpm.erb
74
- - templates/solaris.erb
75
123
  - templates/puppet/package/remove.pp.erb
76
124
  - templates/puppet/package.pp.erb
77
125
  - templates/deb.erb
126
+ - templates/solaris.erb
127
+ - templates/rpm.erb
78
128
  - LICENSE
79
129
  - CONTRIBUTORS
80
130
  - CHANGELIST
81
131
  homepage: https://github.com/jordansissel/fpm
82
132
  licenses: []
83
-
84
133
  post_install_message:
85
134
  rdoc_options: []
86
-
87
- require_paths:
135
+ require_paths:
88
136
  - lib
89
137
  - lib
90
- required_ruby_version: !ruby/object:Gem::Requirement
138
+ required_ruby_version: !ruby/object:Gem::Requirement
91
139
  none: false
92
- requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- hash: 3
96
- segments:
97
- - 0
98
- version: "0"
99
- required_rubygems_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ! '>='
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
145
  none: false
101
- requirements:
102
- - - ">="
103
- - !ruby/object:Gem::Version
104
- hash: 3
105
- segments:
106
- - 0
107
- version: "0"
146
+ requirements:
147
+ - - ! '>'
148
+ - !ruby/object:Gem::Version
149
+ version: 1.3.1
108
150
  requirements: []
109
-
110
151
  rubyforge_project:
111
- rubygems_version: 1.8.10
152
+ rubygems_version: 1.8.16
112
153
  signing_key:
113
154
  specification_version: 3
114
155
  summary: fpm - package building and mangling
115
156
  test_files: []
116
-
157
+ has_rdoc: