fpm 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -55,7 +55,9 @@ class FPM::Builder
55
55
  @edit = !!settings.edit
56
56
 
57
57
  @paths = paths
58
- @package = package_class_for(settings.package_type).new(@source)
58
+ @package = package_class_for(settings.package_type).new(@source,
59
+ :settings => settings.target
60
+ )
59
61
  # Append dependencies given from settings (-d flag for fpm)
60
62
  @package.dependencies += settings.dependencies if settings.dependencies
61
63
  # Append provides given from settings (--provides flag for fpm)
@@ -59,7 +59,10 @@ class FPM::Package
59
59
  # hash of paths for maintainer/package scripts (postinstall, etc)
60
60
  attr_accessor :scripts
61
61
 
62
- def initialize(source)
62
+ # target-specific settings
63
+ attr_accessor :settings
64
+
65
+ def initialize(source, params={})
63
66
  @source = source
64
67
  @logger = Logger.new(STDERR)
65
68
  @logger.level = $DEBUG ? Logger::DEBUG : Logger::WARN
@@ -106,6 +109,9 @@ class FPM::Package
106
109
  @provides = source[:provides] || []
107
110
  @replaces = source[:replaces] || []
108
111
  @scripts = source[:scripts]
112
+
113
+ # Target-specific settings, mirrors :settings metadata in FPM::Source
114
+ @settings = params[:settings] || {}
109
115
  end # def initialize
110
116
 
111
117
  # nobody needs md5sums by default.
@@ -15,9 +15,12 @@ class FPM::Program
15
15
  @settings.provides = []
16
16
  @settings.replaces = []
17
17
  @settings.source = {} # source settings
18
+ @settings.target = {} # target settings
18
19
 
19
20
  # Maintainer scripts - https://github.com/jordansissel/fpm/issues/18
20
21
  @settings.scripts ||= {}
22
+
23
+ @help = nil
21
24
  end # def initialize
22
25
 
23
26
  def run(args)
@@ -38,7 +41,7 @@ class FPM::Program
38
41
  if !ok
39
42
  $stderr.puts "There were errors; see above."
40
43
  $stderr.puts
41
- $stderr.puts opts.help
44
+ $stderr.puts @help
42
45
  return 1
43
46
  end
44
47
 
@@ -56,12 +59,17 @@ class FPM::Program
56
59
  FPM::Source::Gem.flags(FPM::Flags.new(opts, "gem", "gem source only"), @settings)
57
60
  FPM::Source::Python.flags(FPM::Flags.new(opts, "python", "python source only"),
58
61
  @settings)
59
-
62
+ FPM::Target::Deb.flags(FPM::Flags.new(opts, "deb", "deb target only"), @settings)
63
+
60
64
  # Process fpmrc first
61
65
  fpmrc(opts)
62
66
 
63
67
  # Proces normal flags now.
64
68
  remaining = opts.parse(args)
69
+
70
+ # need to print help in a different scope
71
+ @help = opts.help
72
+
65
73
  return remaining
66
74
  end # def options
67
75
 
@@ -197,5 +205,6 @@ class FPM::Program
197
205
  "Add a url for this package.") do |url|
198
206
  @settings.url = url
199
207
  end # --url
208
+
200
209
  end # def default_options
201
210
  end # class FPM::Program
@@ -55,6 +55,11 @@ class get_metadata(Command):
55
55
  if dependencies is None:
56
56
  dependencies = []
57
57
 
58
+ # Some cases (like paramiko) dependencies is actually just a string, not a
59
+ # list
60
+ if isinstance(dependencies, str):
61
+ dependencies = [dependencies]
62
+
58
63
  final_deps = []
59
64
  dep_re = re.compile("([^<>= ]+)(?:\s*([<>=]{1,2})\s*(.*))?$")
60
65
  for dep in dependencies:
@@ -4,6 +4,16 @@ require "fpm/package"
4
4
  require "fpm/errors"
5
5
 
6
6
  class FPM::Target::Deb < FPM::Package
7
+
8
+ def self.flags(opts, settings)
9
+ settings.target[:deb] = "deb"
10
+
11
+ opts.on("--ignore-iteration-in-dependencies",
12
+ "For = dependencies, allow iterations on the specified version. Default is to be specific.") do |x|
13
+ settings.target[:ignore_iteration] = true
14
+ end
15
+ end
16
+
7
17
  def needs_md5sums
8
18
  true
9
19
  end # def needs_md5sums
@@ -107,17 +117,31 @@ class FPM::Target::Deb < FPM::Package
107
117
  name_re = /^[^ \(]+/
108
118
  name = dep[name_re]
109
119
  if name =~ /[A-Z]/
110
- @logger.warn("Downcasing dependnecy '#{name}' because deb packages " \
120
+ @logger.warn("Downcasing dependency '#{name}' because deb packages " \
111
121
  " don't work so good with uppercase names")
112
122
  dep.gsub!(name_re) { |n| n.downcase }
113
123
  end
114
124
 
125
+ if dep =~ /_/
126
+ @logger.warn("Replacing underscores with dashes in '#{dep}' because " \
127
+ "debs don't like underscores")
128
+ dep.gsub!("_", "-")
129
+ end
130
+
115
131
  # Convert gem ~> X.Y.Z to '>= X.Y.Z' and << X.Y+1.0
116
132
  if dep =~ /\(~>/
117
133
  name, version = dep.gsub(/[()~>]/, "").split(/ +/)[0..1]
118
134
  nextversion = version.split(".").collect { |v| v.to_i }
119
- nextversion[1] += 1
120
- nextversion[2] = 0
135
+ l = nextversion.length
136
+ nextversion[l-2] += 1
137
+ nextversion[l-1] = 0
138
+ nextversion = nextversion.join(".")
139
+ return ["#{name} (>= #{version})", "#{name} (<< #{nextversion})"]
140
+ # ignore iterations for = dependencies if flag specified
141
+ elsif (m = dep.match(/(\S+)\s+\(= (.+)\)/)) && self.settings[:ignore_iteration]
142
+ name, version = m[1..2]
143
+ nextversion = version.split('.').collect { |v| v.to_i }
144
+ nextversion[-1] += 1
121
145
  nextversion = nextversion.join(".")
122
146
  return ["#{name} (>= #{version})", "#{name} (<< #{nextversion})"]
123
147
  else
@@ -20,8 +20,7 @@ Homepage: <%= url or "http://nourlgiven.example.com/" %>
20
20
  Description: <%= name %> (FPM-generated package)
21
21
  <% max_len = 74 -%>
22
22
  <% if description -%>
23
- <%= description.gsub(/^$/, ".").gsub(/(.{1,#{max_len}})( +|$)\n?|(.{#{max_len}})/," \\1\\3\n") %>
23
+ <%= description.gsub(/^$/, ".").gsub(/(.{1,#{max_len}})( +|$)\n?|(.{#{max_len}})/," \\1\\3\n") -%>
24
24
  <% else -%>
25
25
  <%= "no description given" %>
26
26
  <% end -%>
27
-
@@ -26,8 +26,9 @@ BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
26
26
  if d =~ /\~>/
27
27
  name, version = d.gsub(/[()~>]/, "").split(/ +/)[0..1]
28
28
  nextversion = version.split(".").collect { |v| v.to_i }
29
- nextversion[1] += 1
30
- nextversion[2] = 0
29
+ l = nextversion.length
30
+ nextversion[l-2] += 1
31
+ nextversion[l-1] = 0
31
32
  nextversion = nextversion.join(".")
32
33
  ["#{name} >= #{version}", "#{name} < #{nextversion}"]
33
34
  # Convert gem >= A.B.C <= X.Y.Z to '>= A.B.C' and '<= X.Y.Z'
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: 21
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 3
10
- version: 0.3.3
9
+ - 4
10
+ version: 0.3.4
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-06-24 00:00:00 -07:00
18
+ date: 2011-07-07 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency