fpm-cookery 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # v0.2.0 (2011-10-22)
2
+ * Add flag for package target. (deb, rpm) (jordansissel)
3
+ * Improve recipe detection. (jordansissel)
4
+
1
5
  # v0.1.0 (2011-10-18)
2
6
  * Add `with_trueprefix` path helper.
3
7
  * Add and enable source integrity check.
data/README.md CHANGED
@@ -53,10 +53,8 @@ __fpm-cookery__ is my attempt to build such a tool.
53
53
  * Apply custom patches.
54
54
  * Dependency checking.
55
55
  * Recipe validation.
56
- * Integrity checks for downloaded archives.
57
56
  * More source types. (git, svn, ...)
58
57
  * Progress output and logging.
59
- * Make package output type configurable. (deb, rpm)
60
58
  * Extend recipe features and build/install helpers.
61
59
  * Configuration file. (for stuff like vendor and maintainer)
62
60
  * Options for the `fpm-cook` command.
@@ -133,7 +131,6 @@ The following is an example recipe. I have some more in my recipe collection
133
131
  * No recipe documentation and API documentation yet.
134
132
  * No recipe validation yet.
135
133
  * No dependency validation yet.
136
- * No integrity check of the downloaded archives yet.
137
134
  * No support for patches yet.
138
135
  * Only simple source/url types (via curl) for now.
139
136
  * No real logging output yet.
data/bin/fpm-cook CHANGED
@@ -4,4 +4,4 @@ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
4
4
 
5
5
  require 'fpm/cookery/cli'
6
6
 
7
- FPM::Cookery::CLI.new(ARGV).run
7
+ FPM::Cookery::CLI.new.args(ARGV).run
@@ -1,32 +1,90 @@
1
1
  require 'fpm/cookery/book_hook'
2
2
  require 'fpm/cookery/recipe'
3
3
  require 'fpm/cookery/packager'
4
+ require 'optparse'
4
5
 
5
6
  module FPM
6
7
  module Cookery
7
8
  class CLI
8
- def initialize(argv)
9
- @argv = argv
10
- end
9
+ def args(argv)
10
+ program = File.basename($0)
11
+ options = OptionParser.new
12
+ options.banner = \
13
+ "Usage: #{program} [options] [path/to/recipe.rb] action [...]"
14
+ options.separator "Actions:"
15
+ options.separator " package - builds the package"
16
+ options.separator " clean - cleans up"
17
+ options.separator "Options:"
11
18
 
12
- def run
13
- filename = @argv.find {|arg| arg =~ /\.rb$/ and File.exists?(arg) }
14
- filename ||= File.expand_path('recipe.rb')
19
+ options.on("-t TARGET", "--target TARGET",
20
+ "Set the desired fpm output target (deb, rpm, etc)") do |o|
21
+ @target = o
22
+ end
23
+
24
+ # Parse flags and such, remainder is all non-option args.
25
+ remainder = options.parse(argv)
26
+
27
+ # Default recipe to find is in current directory named 'recipe.rb'
28
+ @filename = File.expand_path('recipe.rb')
29
+
30
+ # See if something that looks like a recipe path is in arguments
31
+ remainder.each do |arg|
32
+ # If 'foo.rb' was given, and it exists, use it.
33
+ if arg =~ /\.rb$/ and File.exists?(arg)
34
+ remainder.delete(arg)
35
+ @filename = arg
36
+ break
37
+ end
38
+
39
+ # Allow giving the directory containing a recipe.rb
40
+ if File.directory?(arg) and File.exists?(File.join(arg, "recipe.rb"))
41
+ remainder.delete(arg)
42
+ @filename = File.join(arg, "recipe.rb")
43
+ break
44
+ end
45
+ end
15
46
 
16
- unless File.exists?(filename)
47
+ # Everything that's not the recipe filename is an action.
48
+ @actions = remainder
49
+ return self
50
+ end
51
+
52
+ def validate
53
+ unless File.exists?(@filename)
17
54
  STDERR.puts 'No recipe.rb found in the current directory, abort.'
18
55
  exit 1
19
56
  end
20
57
 
58
+ if @target.nil?
59
+ # TODO(sissel): Detect platform, try to guess @target?
60
+ @target = "deb"
61
+ puts "No --target given, assuming #{@target}"
62
+ end
63
+
64
+ # Default action is "package"
65
+ if @actions.empty?
66
+ @actions = ["package"]
67
+ puts "No actions given, assuming 'package'"
68
+ end
69
+ end
70
+
71
+ def run
72
+ validate
73
+
21
74
  FPM::Cookery::Recipe.send(:include, FPM::Cookery::BookHook)
22
75
 
23
- FPM::Cookery::Book.load_recipe(filename) do |recipe|
76
+ FPM::Cookery::Book.load_recipe(@filename) do |recipe|
24
77
  packager = FPM::Cookery::Packager.new(recipe)
78
+ packager.target = @target
25
79
 
26
- if @argv.include?('clean')
27
- packager.cleanup
28
- else
29
- packager.dispense
80
+ @actions.each do |action|
81
+ case action
82
+ when "clean" ; packager.cleanup
83
+ when "package" ; packager.dispense
84
+ else
85
+ # TODO(sissel): fail if this happens
86
+ puts "Unknown action: #{action}"
87
+ end
30
88
  end
31
89
  end
32
90
  end
@@ -16,7 +16,14 @@ module FPM
16
16
  @config = config
17
17
  end
18
18
 
19
+ def target=(target)
20
+ # TODO(sissel): do sanity checking
21
+ @target = target
22
+ end
23
+
19
24
  def cleanup
25
+ # TODO(sissel): do some sanity checking to make sure we don't
26
+ # accidentally rm -rf the wrong thing.
20
27
  FileUtils.rm_rf(recipe.builddir)
21
28
  FileUtils.rm_rf(recipe.destdir)
22
29
  end
@@ -68,7 +75,7 @@ Filename: #{check.filename}
68
75
  build_cookie = build_cookie_name("#{recipe.name}-#{recipe.version}")
69
76
 
70
77
  if File.exists?(build_cookie)
71
- STDERR.puts 'Skipping build (`cook clean` to rebuild)'
78
+ STDERR.puts 'Skipping build (`fpm-cook clean` to rebuild)'
72
79
  else
73
80
  recipe.build and FileUtils.touch(build_cookie)
74
81
  end
@@ -115,13 +122,15 @@ Filename: #{check.filename}
115
122
  "#{username} <#{useremail}>"
116
123
  end
117
124
 
125
+ # TODO(sissel): This should use an API in fpm. fpm doesn't have this
126
+ # yet. fpm needs this.
118
127
  opts = [
119
128
  '-n', recipe.name,
120
129
  '-v', version,
121
- '-t', 'deb',
130
+ '-t', @target,
122
131
  '-s', 'dir',
123
132
  '--url', recipe.homepage || recipe.url,
124
- '-C', recipe.destdir,
133
+ '-C', recipe.destdir.to_s,
125
134
  '--maintainer', maintainer,
126
135
  '--category', recipe.section || 'optional',
127
136
  ]
@@ -1,5 +1,5 @@
1
1
  module FPM
2
2
  module Cookery
3
- VERSION = '0.1.0'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fpm-cookery
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-18 00:00:00.000000000 Z
12
+ date: 2011-10-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fpm
16
- requirement: &82604870 !ruby/object:Gem::Requirement
16
+ requirement: &84285390 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *82604870
24
+ version_requirements: *84285390
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: minitest
27
- requirement: &82604340 !ruby/object:Gem::Requirement
27
+ requirement: &84285150 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *82604340
35
+ version_requirements: *84285150
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &82603770 !ruby/object:Gem::Requirement
38
+ requirement: &84284930 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *82603770
46
+ version_requirements: *84284930
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: fpm
49
- requirement: &82603240 !ruby/object:Gem::Requirement
49
+ requirement: &84284710 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *82603240
57
+ version_requirements: *84284710
58
58
  description: A tool for building software packages with fpm.
59
59
  email:
60
60
  - bernd@tuneafish.de