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 +4 -0
- data/README.md +0 -3
- data/bin/fpm-cook +1 -1
- data/lib/fpm/cookery/cli.rb +70 -12
- data/lib/fpm/cookery/packager.rb +12 -3
- data/lib/fpm/cookery/version.rb +1 -1
- metadata +10 -10
data/CHANGELOG.md
CHANGED
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
data/lib/fpm/cookery/cli.rb
CHANGED
@@ -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
|
9
|
-
|
10
|
-
|
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
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
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
|
-
|
27
|
-
|
28
|
-
|
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
|
data/lib/fpm/cookery/packager.rb
CHANGED
@@ -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',
|
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
|
]
|
data/lib/fpm/cookery/version.rb
CHANGED
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.
|
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-
|
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: &
|
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: *
|
24
|
+
version_requirements: *84285390
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: minitest
|
27
|
-
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: *
|
35
|
+
version_requirements: *84285150
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
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: *
|
46
|
+
version_requirements: *84284930
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: fpm
|
49
|
-
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: *
|
57
|
+
version_requirements: *84284710
|
58
58
|
description: A tool for building software packages with fpm.
|
59
59
|
email:
|
60
60
|
- bernd@tuneafish.de
|