Skip to content
Browse files

- get a bare minimum deb output working

  • Loading branch information...
1 parent beca790 commit 084d2dd86c71087ccb4ec699f1f0a4b2b5f18407 @jordansissel committed Mar 2, 2012
Showing with 37 additions and 12 deletions.
  1. +1 −0 lib/fpm.rb
  2. +14 −2 lib/fpm/package.rb
  3. +17 −5 lib/fpm/util.rb
  4. +5 −5 templates/deb.erb
View
1 lib/fpm.rb
@@ -3,5 +3,6 @@
require "fpm/package"
require "fpm/package/dir"
require "fpm/package/gem"
+require "fpm/package/deb"
require "fpm/package/rpm"
require "fpm/package/python"
View
16 lib/fpm/package.rb
@@ -199,12 +199,24 @@ def output(path)
raise NotImplementedError.new("This must be implemented by FPM::Package subclasses")
end # def output
- def staging_path
+ def staging_path(path=nil)
@staging_path ||= ::Dir.mktmpdir(File.join(::Dir.pwd, "package-#{type}-staging"))
+
+ if path.nil?
+ return @staging_path
+ else
+ return File.join(@staging_path, path)
+ end
end # def staging_path
- def build_path
+ def build_path(path=nil)
@build_path ||= ::Dir.mktmpdir(File.join(::Dir.pwd, "package-#{type}-build"))
+
+ if path.nil?
+ return @build_path
+ else
+ return File.join(@build_path, path)
+ end
end # def build_path
# Clean up any temporary storage used by this class.
View
22 lib/fpm/util.rb
@@ -8,19 +8,25 @@ class ExecutableNotFound < StandardError; end
# Raised if a safesystem program exits nonzero
class ProcessFailed < StandardError; end
+ # Is the given program in the system's PATH?
+ def program_in_path?(program)
+ # Scan path to find the executable
+ # Do this to help the user get a better error message.
+ envpath = ENV["PATH"].split(":")
+ return envpath.select { |p| File.executable?(File.join(p, program)) }.any?
+ end # def program_in_path
+
# Run a command safely in a way that gets reports useful errors.
def safesystem(*args)
program = args[0]
# Scan path to find the executable
# Do this to help the user get a better error message.
- if !program.include("/")
- envpath = ENV["PATH"].split(":")
- if envpath.select { |p| File.executable?(File.join(p, program)) }.empty?
- raise ExecutableNotFound.new(program)
- end
+ if !program.include?("/") and !program_in_path?(program)
+ raise ExecutableNotFound.new(program)
end
+ @logger.debug("Running command", :args => args)
success = system(*args)
if !success
raise ProcessFailed.new("#{program} failed (exit code #{$?.exitstatus})" \
@@ -41,4 +47,10 @@ def tar_cmd
return "tar"
end
end # def tar_cmd
+
+ # Run a block with a value.
+ # Useful in lieu of assigning variables
+ def with(value, &block)
+ block.call(value)
+ end # def with
end # module FPM::Util
View
10 templates/deb.erb
@@ -1,5 +1,5 @@
Package: <%= name %>
-Version: <%= "#{epoch}:" if epoch %><%= version %><%= iteration && '-'+iteration.to_s %>
+Version: <%= "#{epoch}:" if epoch %><%= version %><%= "-" + iteration.to_s if iteration %>
License: <%= license %>
Vendor: <%= vendor %>
Architecture: <%= architecture %>
@@ -8,10 +8,10 @@ Maintainer: <%= maintainer or "<unknown>" %>
<% properdeps = dependencies.collect { |d| fix_dependency(d) }.flatten -%>
Depends: <%= properdeps.flatten.join(", ") %>
<% end -%>
-<% if !pre_dependencies.empty? -%>
-<% properpredeps = pre_dependencies.collect { |d| fix_dependency(d) }.flatten -%>
-Pre-Depends: <%= properpredeps.flatten.join(", ") %>
-<% end -%>
+<%# if !pre_dependencies.empty? -%>
+<%# properpredeps = pre_dependencies.collect { |d| fix_dependency(d) }.flatten -%>
+#Pre-Depends: <%#= properpredeps.flatten.join(", ") %>
+<%# end -%>
<% if !conflicts.empty? -%>
Conflicts: <%= conflicts.join(", ") %>
<% end -%>

0 comments on commit 084d2dd

Please sign in to comment.
Something went wrong with that request. Please try again.