fpm-cookery 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +8 -0
- data/CHANGELOG.md +2 -0
- data/Gemfile +3 -0
- data/README.md +159 -0
- data/Rakefile +10 -0
- data/bin/fpm-cook +7 -0
- data/fpm-cookery.gemspec +24 -0
- data/lib/fpm/cookery/book.rb +16 -0
- data/lib/fpm/cookery/book_hook.rb +17 -0
- data/lib/fpm/cookery/cli.rb +35 -0
- data/lib/fpm/cookery/packager.rb +155 -0
- data/lib/fpm/cookery/path.rb +75 -0
- data/lib/fpm/cookery/path_helper.rb +49 -0
- data/lib/fpm/cookery/recipe.rb +88 -0
- data/lib/fpm/cookery/source_handler.rb +28 -0
- data/lib/fpm/cookery/source_handler/curl.rb +53 -0
- data/lib/fpm/cookery/source_handler/template.rb +32 -0
- data/lib/fpm/cookery/utils.rb +62 -0
- data/lib/fpm/cookery/version.rb +5 -0
- data/recipes/nodejs/recipe.rb +35 -0
- data/recipes/redis/recipe.rb +38 -0
- data/recipes/redis/redis-server.init.d +80 -0
- data/spec/path_spec.rb +123 -0
- data/spec/recipe_spec.rb +248 -0
- data/spec/spec_helper.rb +2 -0
- metadata +104 -0
@@ -0,0 +1,80 @@
|
|
1
|
+
#! /bin/sh
|
2
|
+
### BEGIN INIT INFO
|
3
|
+
# Provides: redis-server
|
4
|
+
# Required-Start: $syslog
|
5
|
+
# Required-Stop: $syslog
|
6
|
+
# Should-Start: $local_fs
|
7
|
+
# Should-Stop: $local_fs
|
8
|
+
# Default-Start: 2 3 4 5
|
9
|
+
# Default-Stop: 0 1 6
|
10
|
+
# Short-Description: redis-server - Persistent key-value db
|
11
|
+
# Description: redis-server - Persistent key-value db
|
12
|
+
### END INIT INFO
|
13
|
+
|
14
|
+
|
15
|
+
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
16
|
+
DAEMON=/usr/bin/redis-server
|
17
|
+
DAEMON_ARGS=/etc/redis/redis.conf
|
18
|
+
NAME=redis-server
|
19
|
+
DESC=redis-server
|
20
|
+
PIDFILE=/var/run/redis.pid
|
21
|
+
|
22
|
+
test -x $DAEMON || exit 0
|
23
|
+
test -x $DAEMONBOOTSTRAP || exit 0
|
24
|
+
|
25
|
+
set -e
|
26
|
+
|
27
|
+
case "$1" in
|
28
|
+
start)
|
29
|
+
echo -n "Starting $DESC: "
|
30
|
+
touch $PIDFILE
|
31
|
+
chown redis:redis $PIDFILE
|
32
|
+
chown redis:redis /var/log/redis
|
33
|
+
chown redis:redis /var/lib/redis
|
34
|
+
if start-stop-daemon --start --quiet --umask 007 --pidfile $PIDFILE --chuid redis:redis --exec $DAEMON -- $DAEMON_ARGS
|
35
|
+
then
|
36
|
+
echo "$NAME."
|
37
|
+
else
|
38
|
+
echo "failed"
|
39
|
+
fi
|
40
|
+
;;
|
41
|
+
stop)
|
42
|
+
echo -n "Stopping $DESC: "
|
43
|
+
if start-stop-daemon --stop --retry 10 --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON
|
44
|
+
then
|
45
|
+
echo "$NAME."
|
46
|
+
else
|
47
|
+
echo "failed"
|
48
|
+
fi
|
49
|
+
rm -f $PIDFILE
|
50
|
+
;;
|
51
|
+
|
52
|
+
restart|force-reload)
|
53
|
+
${0} stop
|
54
|
+
${0} start
|
55
|
+
;;
|
56
|
+
status)
|
57
|
+
if [ -f $PIDFILE ]
|
58
|
+
then
|
59
|
+
PID=`cat $PIDFILE`
|
60
|
+
echo -n "Redis (pid: $PID): "
|
61
|
+
if ps aux | grep $PID > /dev/null
|
62
|
+
then
|
63
|
+
echo "running"
|
64
|
+
exit 0
|
65
|
+
else
|
66
|
+
echo "failed"
|
67
|
+
exit 3
|
68
|
+
fi
|
69
|
+
else
|
70
|
+
echo "Redis not running"
|
71
|
+
exit 3
|
72
|
+
fi
|
73
|
+
;;
|
74
|
+
*)
|
75
|
+
echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}" >&2
|
76
|
+
exit 1
|
77
|
+
;;
|
78
|
+
esac
|
79
|
+
|
80
|
+
exit 0
|
data/spec/path_spec.rb
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fpm/cookery/path'
|
3
|
+
require 'tmpdir'
|
4
|
+
|
5
|
+
describe "Path" do
|
6
|
+
describe ".pwd" do
|
7
|
+
it "returns the current dir" do
|
8
|
+
Dir.chdir('/tmp') do
|
9
|
+
FPM::Cookery::Path.pwd.to_s.must_equal '/tmp'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
it "adds the given path to the current dir" do
|
14
|
+
Dir.chdir('/tmp') do
|
15
|
+
FPM::Cookery::Path.pwd('foo').to_s.must_equal '/tmp/foo'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#+" do
|
21
|
+
let(:path) { FPM::Cookery::Path.new('/foo') }
|
22
|
+
|
23
|
+
describe "with a path fragmet" do
|
24
|
+
it "returns a new concatenated path object" do
|
25
|
+
(path + 'bar').to_s.must_equal '/foo/bar'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "with an absolute path" do
|
30
|
+
it "overwrites the old path" do
|
31
|
+
(path + '/bar').to_s.must_equal '/bar'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "with an empty fragment" do
|
36
|
+
it "does't modify the path" do
|
37
|
+
(path + '').to_s.must_equal '/foo'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "#/" do
|
43
|
+
let(:path) { FPM::Cookery::Path.new('/foo') }
|
44
|
+
|
45
|
+
describe "with a path fragment" do
|
46
|
+
it "returns a new concatenated path object" do
|
47
|
+
(path/'bar').to_s.must_equal '/foo/bar'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "with an absolute path" do
|
52
|
+
it "returns a new concatenated path object" do
|
53
|
+
(path/'/baz').to_s.must_equal '/foo/baz'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "with a nil argument" do
|
58
|
+
it "does not modify the path" do
|
59
|
+
(path/nil).to_s.must_equal '/foo'
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "#mkdir" do
|
65
|
+
it "creates the directory" do
|
66
|
+
dir = Dir.mktmpdir
|
67
|
+
FileUtils.rm_rf(dir)
|
68
|
+
File.exists?(dir).must_equal false
|
69
|
+
|
70
|
+
FPM::Cookery::Path.new(dir).mkdir
|
71
|
+
File.exists?(dir).must_equal true
|
72
|
+
|
73
|
+
FileUtils.rm_rf(dir)
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "directory exists" do
|
77
|
+
it "does not throw an error" do
|
78
|
+
dir = Dir.mktmpdir
|
79
|
+
File.exists?(dir).must_equal true
|
80
|
+
|
81
|
+
FPM::Cookery::Path.new(dir).mkdir.must_equal [dir]
|
82
|
+
|
83
|
+
FileUtils.rm_rf(dir)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "#install" do
|
89
|
+
describe "with an array as src" do
|
90
|
+
it "installs every file in the list" do
|
91
|
+
Dir.mktmpdir do |dir|
|
92
|
+
path = FPM::Cookery::Path.new(dir)
|
93
|
+
path.install([__FILE__, File.expand_path('../spec_helper.rb', __FILE__)])
|
94
|
+
|
95
|
+
File.exist?(path/File.basename(__FILE__)).must_equal true
|
96
|
+
File.exist?(path/'spec_helper.rb').must_equal true
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe "with a hash as src" do
|
102
|
+
it "installs the file with a new basename" do
|
103
|
+
Dir.mktmpdir do |dir|
|
104
|
+
path = FPM::Cookery::Path.new(dir)
|
105
|
+
path.install(File.expand_path('../spec_helper.rb', __FILE__) => 'foo.rb')
|
106
|
+
|
107
|
+
File.exist?(path/'foo.rb').must_equal true
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe "with a string as src" do
|
113
|
+
it "installs the file" do
|
114
|
+
Dir.mktmpdir do |dir|
|
115
|
+
path = FPM::Cookery::Path.new(dir)
|
116
|
+
path.install(File.expand_path('../spec_helper.rb', __FILE__))
|
117
|
+
|
118
|
+
File.exist?(path/'spec_helper.rb').must_equal true
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
data/spec/recipe_spec.rb
ADDED
@@ -0,0 +1,248 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fpm/cookery/recipe'
|
3
|
+
|
4
|
+
class TestRecipe < FPM::Cookery::Recipe
|
5
|
+
end
|
6
|
+
|
7
|
+
describe "Recipe" do
|
8
|
+
let(:klass) { TestRecipe }
|
9
|
+
|
10
|
+
before do
|
11
|
+
# Reset the class level instance variables.
|
12
|
+
klass.instance_variables.each do |v|
|
13
|
+
klass.instance_variable_set(v, nil)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
let(:recipe) do
|
18
|
+
klass.new(__FILE__)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "sets the filename" do
|
22
|
+
recipe.filename.to_s.must_equal __FILE__
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#workdir" do
|
26
|
+
it "sets the workdir" do
|
27
|
+
recipe.workdir.to_s.must_equal File.dirname(__FILE__)
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "with a relative filename path" do
|
31
|
+
it "expands the workdir path" do
|
32
|
+
filename = "spec/#{File.basename(__FILE__)}"
|
33
|
+
r = klass.new(filename)
|
34
|
+
r.workdir.to_s.must_equal File.dirname(__FILE__)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "#source_handler" do
|
40
|
+
it "returns the recipe's source handler" do
|
41
|
+
klass.class_eval do
|
42
|
+
source 'http://example.com/foo-1.0.tar.gz', :foo => 'bar'
|
43
|
+
end
|
44
|
+
|
45
|
+
recipe.source_handler.must_be_instance_of FPM::Cookery::SourceHandler
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
#############################################################################
|
50
|
+
# Recipe attributes
|
51
|
+
#############################################################################
|
52
|
+
def self.spec_recipe_attribute(name, value)
|
53
|
+
value = Numeric === value ? value : "\"#{value}\""
|
54
|
+
class_eval %Q{
|
55
|
+
describe "##{name}" do
|
56
|
+
it "can be set" do
|
57
|
+
klass.class_eval { #{name} #{value} }
|
58
|
+
klass.#{name}.must_equal #{value}
|
59
|
+
recipe.#{name}.must_equal #{value}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
spec_recipe_attribute(:arch, 'i386')
|
66
|
+
spec_recipe_attribute(:description, 'A nice program.')
|
67
|
+
spec_recipe_attribute(:homepage, 'http://example.com')
|
68
|
+
spec_recipe_attribute(:maintainer, 'John Doe <john@example.com>')
|
69
|
+
spec_recipe_attribute(:md5, '123456789abcdef')
|
70
|
+
spec_recipe_attribute(:name, 'redis')
|
71
|
+
spec_recipe_attribute(:revision, 12)
|
72
|
+
spec_recipe_attribute(:section, 'lang')
|
73
|
+
spec_recipe_attribute(:spec, {:foo => true})
|
74
|
+
spec_recipe_attribute(:vendor, 'myvendor')
|
75
|
+
spec_recipe_attribute(:version, '1.2')
|
76
|
+
|
77
|
+
describe "#revision" do
|
78
|
+
it "sets a default revision" do
|
79
|
+
recipe.revision.must_equal 0
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "#vendor" do
|
84
|
+
it "sets a default vendor" do
|
85
|
+
recipe.vendor.must_equal 'fpm'
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.spec_recipe_attribute_list(name, list)
|
90
|
+
class_eval %Q{
|
91
|
+
describe "##{name}" do
|
92
|
+
it "can be set" do
|
93
|
+
klass.class_eval do
|
94
|
+
#{name} "#{list[0]}"
|
95
|
+
#{name} "#{list[1]}"
|
96
|
+
end
|
97
|
+
klass.#{name}.size.must_equal #{list.size}
|
98
|
+
recipe.#{name}.size.must_equal #{list.size}
|
99
|
+
klass.#{name}[0].must_equal "#{list[0]}"
|
100
|
+
klass.#{name}[1].must_equal "#{list[1]}"
|
101
|
+
recipe.#{name}[0].must_equal "#{list[0]}"
|
102
|
+
recipe.#{name}[1].must_equal "#{list[1]}"
|
103
|
+
end
|
104
|
+
end
|
105
|
+
}
|
106
|
+
end
|
107
|
+
|
108
|
+
spec_recipe_attribute_list(:build_depends, %w{one two})
|
109
|
+
spec_recipe_attribute_list(:config_files, %w{one two})
|
110
|
+
spec_recipe_attribute_list(:conflicts, %w{one two})
|
111
|
+
spec_recipe_attribute_list(:depends, %w{one two})
|
112
|
+
spec_recipe_attribute_list(:exclude, %w{one two})
|
113
|
+
spec_recipe_attribute_list(:patches, %w{one two})
|
114
|
+
spec_recipe_attribute_list(:provides, %w{one two})
|
115
|
+
spec_recipe_attribute_list(:replaces, %w{one two})
|
116
|
+
|
117
|
+
describe ".source" do
|
118
|
+
it "sets a source url" do
|
119
|
+
klass.class_eval do
|
120
|
+
source 'http://example.com/foo-1.0.tar.gz'
|
121
|
+
end
|
122
|
+
|
123
|
+
klass.source.must_equal 'http://example.com/foo-1.0.tar.gz'
|
124
|
+
klass.new(__FILE__).source.must_equal 'http://example.com/foo-1.0.tar.gz'
|
125
|
+
end
|
126
|
+
|
127
|
+
describe "with specs" do
|
128
|
+
it "sets specs" do
|
129
|
+
klass.class_eval do
|
130
|
+
source 'http://example.com/foo-1.0.tar.gz', :foo => 'bar'
|
131
|
+
end
|
132
|
+
|
133
|
+
klass.spec.must_equal({:foo => 'bar'})
|
134
|
+
klass.new(__FILE__).spec.must_equal({:foo => 'bar'})
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe ".url" do
|
140
|
+
it "sets a source type (homebrew compat)" do
|
141
|
+
klass.class_eval do
|
142
|
+
url 'http://example.com/foo-1.0.tar.gz'
|
143
|
+
end
|
144
|
+
|
145
|
+
klass.source.must_equal 'http://example.com/foo-1.0.tar.gz'
|
146
|
+
klass.new(__FILE__).source.must_equal 'http://example.com/foo-1.0.tar.gz'
|
147
|
+
end
|
148
|
+
|
149
|
+
describe "with specs" do
|
150
|
+
it "sets specs" do
|
151
|
+
klass.class_eval do
|
152
|
+
url 'http://example.com/foo-1.0.tar.gz', :foo => 'bar'
|
153
|
+
end
|
154
|
+
|
155
|
+
klass.spec.must_equal({:foo => 'bar'})
|
156
|
+
klass.new(__FILE__).spec.must_equal({:foo => 'bar'})
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
|
162
|
+
#############################################################################
|
163
|
+
# Directories
|
164
|
+
#############################################################################
|
165
|
+
describe "#destdir" do
|
166
|
+
describe "default" do
|
167
|
+
it "sets the destdir" do
|
168
|
+
recipe.destdir.must_equal recipe.workdir('tmp-dest')
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
describe "set manually" do
|
173
|
+
it "sets the destdir" do
|
174
|
+
recipe.destdir = '/tmp'
|
175
|
+
recipe.destdir.to_s.must_equal '/tmp'
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
describe "with an argument" do
|
180
|
+
it "returns a concatenated path" do
|
181
|
+
recipe.destdir('test').must_equal recipe.workdir('tmp-dest/test')
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
describe "#builddir" do
|
187
|
+
describe "default" do
|
188
|
+
it "sets the builddir" do
|
189
|
+
recipe.builddir.must_equal recipe.workdir('tmp-build')
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
describe "set manually" do
|
194
|
+
it "sets the builddir" do
|
195
|
+
recipe.builddir = '/tmp/jojo'
|
196
|
+
recipe.builddir.to_s.must_equal '/tmp/jojo'
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
describe "with an argument" do
|
201
|
+
it "returns a concatenated path" do
|
202
|
+
recipe.builddir('test').must_equal recipe.workdir('tmp-build/test')
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
describe "#pkgdir" do
|
208
|
+
describe "default" do
|
209
|
+
it "sets the pkgdir" do
|
210
|
+
recipe.pkgdir.must_equal recipe.workdir('pkg')
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
describe "set manually" do
|
215
|
+
it "sets the pkgdir" do
|
216
|
+
recipe.pkgdir = '/tmp/jojo'
|
217
|
+
recipe.pkgdir.to_s.must_equal '/tmp/jojo'
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
describe "with an argument" do
|
222
|
+
it "returns a concatenated path" do
|
223
|
+
recipe.pkgdir('test').must_equal recipe.workdir('pkg/test')
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
describe "#cachedir" do
|
229
|
+
describe "default" do
|
230
|
+
it "sets the cachedir" do
|
231
|
+
recipe.cachedir.must_equal recipe.workdir('cache')
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
describe "set manually" do
|
236
|
+
it "sets the cachedir" do
|
237
|
+
recipe.cachedir = '/tmp/jojo'
|
238
|
+
recipe.cachedir.to_s.must_equal '/tmp/jojo'
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
describe "with an argument" do
|
243
|
+
it "returns a concatenated path" do
|
244
|
+
recipe.cachedir('test').must_equal recipe.workdir('cache/test')
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
248
|
+
end
|