Permalink
Browse files

option to edit the specfile before build

  • Loading branch information...
1 parent 3945f23 commit 42e25c193e42a4011027b9ad43c0d494a4364c6a @jneen jneen committed Feb 2, 2011
Showing with 17 additions and 0 deletions.
  1. +4 −0 bin/fpm
  2. +13 −0 lib/fpm/builder.rb
View
@@ -64,6 +64,10 @@ def main(args)
"A path to prefix files with when building the target package. This may not be necessary for all source types. For example, the 'gem' type will prefix with your gem directory (gem env | grep -A1 PATHS:)") do |prefix|
settings.prefix = prefix
end
+
+ opts.on("-e", "--edit", "Edit the specfile before building") do
+ settings.edit = true
+ end
end # OptionParser
opts.parse!(args)
View
@@ -37,6 +37,8 @@ def initialize(settings, paths=[])
:prefix => settings.prefix
)
+ @edit = !!settings.edit
+
@paths = paths
@package = package_class_for(settings.package_type).new(@source)
# Append dependencies given from settings (-d flag for fpm)
@@ -65,6 +67,7 @@ def assemble!
generate_md5sums
generate_specfile
+ edit_specfile if @edit
end
::Dir.chdir(builddir) do
@@ -128,6 +131,16 @@ def generate_specfile
end
private
+ def edit_specfile
+ editor = ENV['FPM_EDITOR'] || ENV['EDITOR'] || 'vi'
+ system("#{editor} '#{package.specfile(builddir)}'")
+ unless File.size? package.specfile(builddir)
+ puts "Empty specfile. Aborting."
+ exit 1
+ end
+ end
+
+ private
def generate_md5sums
md5sums = checksum(paths)
File.open("#{builddir}/md5sums", "w") { |f| f.puts md5sums }

0 comments on commit 42e25c1

Please sign in to comment.