Skip to content

Commit

Permalink
Use existing --deb-ignore-iteration-in-dependencies flag to determine…
Browse files Browse the repository at this point in the history
… if dependencies should be strictly versioned or allow iteration.
  • Loading branch information
specialunderwear committed Apr 12, 2012
1 parent 50bd59b commit 7b4dd7f
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lib/fpm/package/deb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,22 @@ def fix_dependency(dep)

# Convert gem ~> X.Y.Z to '>= X.Y.Z' and << X.Y+1.0
if dep =~ /\(~>/
return "#{name} (= #{version})"
name, version = dep.gsub(/[()~>]/, "").split(/ +/)[0..1]
nextversion = version.split(".").collect { |v| v.to_i }
l = nextversion.length
nextversion[l-2] += 1
nextversion[l-1] = 0
nextversion = nextversion.join(".")
return ["#{name} (>= #{version})", "#{name} (<< #{nextversion})"]
elsif (m = dep.match(/(\S+)\s+\(= (.+)\)/)) and
self.attributes[:deb_ignore_iteration_in_dependencies?]
# Convert 'foo (= x)' to 'foo (>= x)' and 'foo (<< x+1)'
# but only when flag --ignore-iteration-in-dependencies is passed.
name, version = m[1..2]
nextversion = version.split('.').collect { |v| v.to_i }
nextversion[-1] += 1
nextversion = nextversion.join(".")
return ["#{name} (>= #{version})", "#{name} (<< #{nextversion})"]
else
# otherwise the dep is probably fine
return dep
Expand Down

0 comments on commit 7b4dd7f

Please sign in to comment.