packager-dsl 0.0.1 → 0.1.0
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.
- checksums.yaml +5 -13
- data/.rspec +5 -5
- data/Changes +9 -4
- data/Gemfile +12 -12
- data/LICENSE +21 -340
- data/README.md +50 -48
- data/Rakefile +39 -37
- data/bin/packager +8 -8
- data/lib/packager.rb +5 -5
- data/lib/packager/cli.rb +72 -72
- data/lib/packager/dsl.rb +55 -55
- data/lib/packager/executor.rb +63 -63
- data/lib/packager/struct.rb +80 -80
- data/lib/packager/version.rb +3 -3
- data/on_what.rb +15 -15
- data/packager.gemspec +44 -44
- data/spec/cli/context.rb +17 -17
- data/spec/cli/execute_spec.rb +79 -79
- data/spec/cli/validate_spec.rb +47 -47
- data/spec/cli/version_spec.rb +7 -7
- data/spec/dsl/args_spec.rb +16 -16
- data/spec/dsl/context.rb +5 -5
- data/spec/dsl/defaults_spec.rb +19 -19
- data/spec/dsl/dependency_spec.rb +62 -62
- data/spec/dsl/error_spec.rb +48 -48
- data/spec/dsl/files_spec.rb +46 -46
- data/spec/executor/basic_spec.rb +21 -21
- data/spec/executor/command_spec.rb +18 -18
- data/spec/executor/context.rb +4 -4
- data/spec/executor/dependency_spec.rb +46 -46
- data/spec/executor/execute_command_spec.rb +25 -25
- data/spec/executor/files_spec.rb +33 -33
- data/spec/fpm-test_spec.rb +98 -98
- data/spec/integration/context.rb +57 -57
- data/spec/integration/dependency_spec.rb +51 -51
- data/spec/integration/files_spec.rb +104 -104
- data/spec/lib/fpm/package/test.rb +27 -27
- data/spec/shared_context/workdir.rb +18 -18
- data/spec/spec_helper.rb +55 -55
- data/spec/struct/command_spec.rb +67 -67
- data/spec/struct/error_spec.rb +12 -12
- metadata +45 -46
data/spec/integration/context.rb
CHANGED
@@ -1,57 +1,57 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
require 'tmpdir'
|
3
|
-
|
4
|
-
require './spec/shared_context/workdir.rb'
|
5
|
-
RSpec.shared_context :integration do
|
6
|
-
include_context :workdir
|
7
|
-
|
8
|
-
before(:all) { Packager::DSL.default_type('test') }
|
9
|
-
after(:all) { Packager::DSL.default_type = nil }
|
10
|
-
|
11
|
-
# This is to get access to the 'test' FPM type in the FPM executable.
|
12
|
-
before(:all) {
|
13
|
-
Packager::Struct::Command.default_executable =
|
14
|
-
"ruby -I#{File.join(@dir,'spec/lib')} -rfpm/package/test `which fpm`"
|
15
|
-
}
|
16
|
-
after(:all) {
|
17
|
-
Packager::Struct::Command.default_executable = 'fpm'
|
18
|
-
}
|
19
|
-
|
20
|
-
before(:each) { $sourcedir = sourcedir }
|
21
|
-
before(:all) {
|
22
|
-
Packager::DSL.add_helper(:sourcedir) do |path|
|
23
|
-
File.join($sourcedir, path)
|
24
|
-
end
|
25
|
-
}
|
26
|
-
after(:all) {
|
27
|
-
Packager::DSL.remove_helper(:sourcedir)
|
28
|
-
}
|
29
|
-
end
|
30
|
-
|
31
|
-
RSpec.shared_context :test_package do
|
32
|
-
# This is used to verify the FPM/test package format is created properly.
|
33
|
-
def verify_test_package(name, metadata={}, files={})
|
34
|
-
expect(File).to exist(name)
|
35
|
-
expect(File).to exist(File.join(name, 'META.json'))
|
36
|
-
expect(JSON.parse(IO.read(File.join(name, 'META.json')))).to eq({
|
37
|
-
'requires' => [],
|
38
|
-
'provides' => [],
|
39
|
-
}.merge(metadata))
|
40
|
-
if files.empty?
|
41
|
-
expect(Dir[File.join(name, 'contents/*')].empty?).to be(true)
|
42
|
-
else
|
43
|
-
file_expectations = files.clone
|
44
|
-
Dir[File.join(name, 'contents/**/*')].each do |filename|
|
45
|
-
if File.file?(filename)
|
46
|
-
content = IO.read(filename)
|
47
|
-
filename.gsub! /#{File.join(name, 'contents', '')}/, ''
|
48
|
-
|
49
|
-
expect(file_expectations).to have_key(filename)
|
50
|
-
expect(file_expectations[filename]).to eq(content)
|
51
|
-
file_expectations.delete(filename)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
expect(file_expectations).to be_empty
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
1
|
+
require 'fileutils'
|
2
|
+
require 'tmpdir'
|
3
|
+
|
4
|
+
require './spec/shared_context/workdir.rb'
|
5
|
+
RSpec.shared_context :integration do
|
6
|
+
include_context :workdir
|
7
|
+
|
8
|
+
before(:all) { Packager::DSL.default_type('test') }
|
9
|
+
after(:all) { Packager::DSL.default_type = nil }
|
10
|
+
|
11
|
+
# This is to get access to the 'test' FPM type in the FPM executable.
|
12
|
+
before(:all) {
|
13
|
+
Packager::Struct::Command.default_executable =
|
14
|
+
"ruby -I#{File.join(@dir,'spec/lib')} -rfpm/package/test `which fpm`"
|
15
|
+
}
|
16
|
+
after(:all) {
|
17
|
+
Packager::Struct::Command.default_executable = 'fpm'
|
18
|
+
}
|
19
|
+
|
20
|
+
before(:each) { $sourcedir = sourcedir }
|
21
|
+
before(:all) {
|
22
|
+
Packager::DSL.add_helper(:sourcedir) do |path|
|
23
|
+
File.join($sourcedir, path)
|
24
|
+
end
|
25
|
+
}
|
26
|
+
after(:all) {
|
27
|
+
Packager::DSL.remove_helper(:sourcedir)
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
RSpec.shared_context :test_package do
|
32
|
+
# This is used to verify the FPM/test package format is created properly.
|
33
|
+
def verify_test_package(name, metadata={}, files={})
|
34
|
+
expect(File).to exist(name)
|
35
|
+
expect(File).to exist(File.join(name, 'META.json'))
|
36
|
+
expect(JSON.parse(IO.read(File.join(name, 'META.json')))).to eq({
|
37
|
+
'requires' => [],
|
38
|
+
'provides' => [],
|
39
|
+
}.merge(metadata))
|
40
|
+
if files.empty?
|
41
|
+
expect(Dir[File.join(name, 'contents/*')].empty?).to be(true)
|
42
|
+
else
|
43
|
+
file_expectations = files.clone
|
44
|
+
Dir[File.join(name, 'contents/**/*')].each do |filename|
|
45
|
+
if File.file?(filename)
|
46
|
+
content = IO.read(filename)
|
47
|
+
filename.gsub! /#{File.join(name, 'contents', '')}/, ''
|
48
|
+
|
49
|
+
expect(file_expectations).to have_key(filename)
|
50
|
+
expect(file_expectations[filename]).to eq(content)
|
51
|
+
file_expectations.delete(filename)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
expect(file_expectations).to be_empty
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -1,51 +1,51 @@
|
|
1
|
-
require './spec/integration/context.rb'
|
2
|
-
describe "Packager integration" do
|
3
|
-
context "dependencies" do
|
4
|
-
include_context :integration
|
5
|
-
include_context :test_package
|
6
|
-
|
7
|
-
it "can create a package with 1 dependency" do
|
8
|
-
append_to_file('definition', "
|
9
|
-
package {
|
10
|
-
name 'foo'
|
11
|
-
version '0.0.1'
|
12
|
-
requires 'bar'
|
13
|
-
}
|
14
|
-
")
|
15
|
-
|
16
|
-
FileUtils.chdir(workdir) do
|
17
|
-
capture(:stdout) {
|
18
|
-
Packager::CLI.start(['execute', './definition'])
|
19
|
-
}
|
20
|
-
|
21
|
-
verify_test_package('foo.test', {
|
22
|
-
'name' => 'foo',
|
23
|
-
'version' => '0.0.1',
|
24
|
-
'requires' => ['bar'],
|
25
|
-
})
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
it "can create a package with 1 provides" do
|
30
|
-
append_to_file('definition', "
|
31
|
-
package {
|
32
|
-
name 'foo'
|
33
|
-
version '0.0.1'
|
34
|
-
provides 'bar'
|
35
|
-
}
|
36
|
-
")
|
37
|
-
|
38
|
-
FileUtils.chdir(workdir) do
|
39
|
-
capture(:stdout) {
|
40
|
-
Packager::CLI.start(['execute', './definition'])
|
41
|
-
}
|
42
|
-
|
43
|
-
verify_test_package('foo.test', {
|
44
|
-
'name' => 'foo',
|
45
|
-
'version' => '0.0.1',
|
46
|
-
'provides' => ['bar'],
|
47
|
-
})
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
1
|
+
require './spec/integration/context.rb'
|
2
|
+
describe "Packager integration" do
|
3
|
+
context "dependencies" do
|
4
|
+
include_context :integration
|
5
|
+
include_context :test_package
|
6
|
+
|
7
|
+
it "can create a package with 1 dependency" do
|
8
|
+
append_to_file('definition', "
|
9
|
+
package {
|
10
|
+
name 'foo'
|
11
|
+
version '0.0.1'
|
12
|
+
requires 'bar'
|
13
|
+
}
|
14
|
+
")
|
15
|
+
|
16
|
+
FileUtils.chdir(workdir) do
|
17
|
+
capture(:stdout) {
|
18
|
+
Packager::CLI.start(['execute', './definition'])
|
19
|
+
}
|
20
|
+
|
21
|
+
verify_test_package('foo.test', {
|
22
|
+
'name' => 'foo',
|
23
|
+
'version' => '0.0.1',
|
24
|
+
'requires' => ['bar'],
|
25
|
+
})
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it "can create a package with 1 provides" do
|
30
|
+
append_to_file('definition', "
|
31
|
+
package {
|
32
|
+
name 'foo'
|
33
|
+
version '0.0.1'
|
34
|
+
provides 'bar'
|
35
|
+
}
|
36
|
+
")
|
37
|
+
|
38
|
+
FileUtils.chdir(workdir) do
|
39
|
+
capture(:stdout) {
|
40
|
+
Packager::CLI.start(['execute', './definition'])
|
41
|
+
}
|
42
|
+
|
43
|
+
verify_test_package('foo.test', {
|
44
|
+
'name' => 'foo',
|
45
|
+
'version' => '0.0.1',
|
46
|
+
'provides' => ['bar'],
|
47
|
+
})
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -1,104 +1,104 @@
|
|
1
|
-
# Because of the vagaries of producing OS-specific packages on varying platforms,
|
2
|
-
# we will test command execution using a new output target for FPM called 'test.
|
3
|
-
# This target is based on the 'dir' target and exists in spec/lib.
|
4
|
-
#
|
5
|
-
# Note: We assume that fpm produces good packages of other types, given a correct
|
6
|
-
# invocations.
|
7
|
-
|
8
|
-
require './spec/integration/context.rb'
|
9
|
-
describe "Packager integration" do
|
10
|
-
context 'files' do
|
11
|
-
include_context :integration
|
12
|
-
include_context :test_package
|
13
|
-
|
14
|
-
it "can create a package with no files" do
|
15
|
-
append_to_file('definition', "
|
16
|
-
package {
|
17
|
-
name 'foo'
|
18
|
-
version '0.0.1'
|
19
|
-
}
|
20
|
-
")
|
21
|
-
|
22
|
-
FileUtils.chdir(workdir) do
|
23
|
-
capture(:stdout) {
|
24
|
-
Packager::CLI.start(['execute', './definition'])
|
25
|
-
}
|
26
|
-
|
27
|
-
verify_test_package('foo.test', {
|
28
|
-
'name' => 'foo',
|
29
|
-
'version' => '0.0.1',
|
30
|
-
})
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
it "can create a package with one file" do
|
35
|
-
FileUtils.chdir(sourcedir) do
|
36
|
-
FileUtils.touch('file1')
|
37
|
-
end
|
38
|
-
|
39
|
-
append_to_file('definition', "
|
40
|
-
package {
|
41
|
-
name 'foo'
|
42
|
-
version '0.0.1'
|
43
|
-
|
44
|
-
file {
|
45
|
-
source sourcedir('file1')
|
46
|
-
dest '/foo/bar/file2'
|
47
|
-
}
|
48
|
-
}
|
49
|
-
")
|
50
|
-
|
51
|
-
# Stub out execute_command
|
52
|
-
FileUtils.chdir(workdir) do
|
53
|
-
capture(:stdout) {
|
54
|
-
Packager::CLI.start(['execute', './definition'])
|
55
|
-
}
|
56
|
-
|
57
|
-
verify_test_package('foo.test', {
|
58
|
-
'name' => 'foo',
|
59
|
-
'version' => '0.0.1',
|
60
|
-
}, {
|
61
|
-
'foo/bar/file2' => '',
|
62
|
-
})
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
it "can create a package with two files" do
|
67
|
-
FileUtils.chdir(sourcedir) do
|
68
|
-
FileUtils.touch('file1')
|
69
|
-
append_to_file('file3', 'stuff')
|
70
|
-
end
|
71
|
-
|
72
|
-
append_to_file('definition', "
|
73
|
-
package {
|
74
|
-
name 'foo'
|
75
|
-
version '0.0.1'
|
76
|
-
|
77
|
-
file {
|
78
|
-
source sourcedir('file1')
|
79
|
-
dest '/foo/bar/file2'
|
80
|
-
}
|
81
|
-
|
82
|
-
file {
|
83
|
-
source sourcedir('file3')
|
84
|
-
dest '/bar/foo/file4'
|
85
|
-
}
|
86
|
-
}
|
87
|
-
")
|
88
|
-
|
89
|
-
FileUtils.chdir(workdir) do
|
90
|
-
capture(:stdout) {
|
91
|
-
Packager::CLI.start(['execute', './definition'])
|
92
|
-
}
|
93
|
-
|
94
|
-
verify_test_package('foo.test', {
|
95
|
-
'name' => 'foo',
|
96
|
-
'version' => '0.0.1',
|
97
|
-
}, {
|
98
|
-
'foo/bar/file2' => '',
|
99
|
-
'bar/foo/file4' => 'stuff',
|
100
|
-
})
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
1
|
+
# Because of the vagaries of producing OS-specific packages on varying platforms,
|
2
|
+
# we will test command execution using a new output target for FPM called 'test.
|
3
|
+
# This target is based on the 'dir' target and exists in spec/lib.
|
4
|
+
#
|
5
|
+
# Note: We assume that fpm produces good packages of other types, given a correct
|
6
|
+
# invocations.
|
7
|
+
|
8
|
+
require './spec/integration/context.rb'
|
9
|
+
describe "Packager integration" do
|
10
|
+
context 'files' do
|
11
|
+
include_context :integration
|
12
|
+
include_context :test_package
|
13
|
+
|
14
|
+
it "can create a package with no files" do
|
15
|
+
append_to_file('definition', "
|
16
|
+
package {
|
17
|
+
name 'foo'
|
18
|
+
version '0.0.1'
|
19
|
+
}
|
20
|
+
")
|
21
|
+
|
22
|
+
FileUtils.chdir(workdir) do
|
23
|
+
capture(:stdout) {
|
24
|
+
Packager::CLI.start(['execute', './definition'])
|
25
|
+
}
|
26
|
+
|
27
|
+
verify_test_package('foo.test', {
|
28
|
+
'name' => 'foo',
|
29
|
+
'version' => '0.0.1',
|
30
|
+
})
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
it "can create a package with one file" do
|
35
|
+
FileUtils.chdir(sourcedir) do
|
36
|
+
FileUtils.touch('file1')
|
37
|
+
end
|
38
|
+
|
39
|
+
append_to_file('definition', "
|
40
|
+
package {
|
41
|
+
name 'foo'
|
42
|
+
version '0.0.1'
|
43
|
+
|
44
|
+
file {
|
45
|
+
source sourcedir('file1')
|
46
|
+
dest '/foo/bar/file2'
|
47
|
+
}
|
48
|
+
}
|
49
|
+
")
|
50
|
+
|
51
|
+
# Stub out execute_command
|
52
|
+
FileUtils.chdir(workdir) do
|
53
|
+
capture(:stdout) {
|
54
|
+
Packager::CLI.start(['execute', './definition'])
|
55
|
+
}
|
56
|
+
|
57
|
+
verify_test_package('foo.test', {
|
58
|
+
'name' => 'foo',
|
59
|
+
'version' => '0.0.1',
|
60
|
+
}, {
|
61
|
+
'foo/bar/file2' => '',
|
62
|
+
})
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
it "can create a package with two files" do
|
67
|
+
FileUtils.chdir(sourcedir) do
|
68
|
+
FileUtils.touch('file1')
|
69
|
+
append_to_file('file3', 'stuff')
|
70
|
+
end
|
71
|
+
|
72
|
+
append_to_file('definition', "
|
73
|
+
package {
|
74
|
+
name 'foo'
|
75
|
+
version '0.0.1'
|
76
|
+
|
77
|
+
file {
|
78
|
+
source sourcedir('file1')
|
79
|
+
dest '/foo/bar/file2'
|
80
|
+
}
|
81
|
+
|
82
|
+
file {
|
83
|
+
source sourcedir('file3')
|
84
|
+
dest '/bar/foo/file4'
|
85
|
+
}
|
86
|
+
}
|
87
|
+
")
|
88
|
+
|
89
|
+
FileUtils.chdir(workdir) do
|
90
|
+
capture(:stdout) {
|
91
|
+
Packager::CLI.start(['execute', './definition'])
|
92
|
+
}
|
93
|
+
|
94
|
+
verify_test_package('foo.test', {
|
95
|
+
'name' => 'foo',
|
96
|
+
'version' => '0.0.1',
|
97
|
+
}, {
|
98
|
+
'foo/bar/file2' => '',
|
99
|
+
'bar/foo/file4' => 'stuff',
|
100
|
+
})
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -1,27 +1,27 @@
|
|
1
|
-
require 'fpm/package/dir'
|
2
|
-
|
3
|
-
require 'fileutils'
|
4
|
-
|
5
|
-
class FPM::Package::Test < FPM::Package::Dir
|
6
|
-
# Trigger the inherited capture of subclasses.
|
7
|
-
FPM::Package.inherited(FPM::Package::Test)
|
8
|
-
|
9
|
-
def output(output_path)
|
10
|
-
output_check(output_path)
|
11
|
-
|
12
|
-
# We have to create the ouput_path so that the Dir type will write out to the
|
13
|
-
# contents subdirectory.
|
14
|
-
FileUtils.mkdir_p output_path
|
15
|
-
super(File.join(output_path, 'contents'))
|
16
|
-
|
17
|
-
# Write out the META.json file.
|
18
|
-
File.open(File.join(output_path, 'META.json'), 'w') do |f|
|
19
|
-
f.write({
|
20
|
-
:name => name,
|
21
|
-
:version => version,
|
22
|
-
:requires => dependencies.sort,
|
23
|
-
:provides => provides.sort,
|
24
|
-
}.to_json)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
1
|
+
require 'fpm/package/dir'
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
class FPM::Package::Test < FPM::Package::Dir
|
6
|
+
# Trigger the inherited capture of subclasses.
|
7
|
+
FPM::Package.inherited(FPM::Package::Test)
|
8
|
+
|
9
|
+
def output(output_path)
|
10
|
+
output_check(output_path)
|
11
|
+
|
12
|
+
# We have to create the ouput_path so that the Dir type will write out to the
|
13
|
+
# contents subdirectory.
|
14
|
+
FileUtils.mkdir_p output_path
|
15
|
+
super(File.join(output_path, 'contents'))
|
16
|
+
|
17
|
+
# Write out the META.json file.
|
18
|
+
File.open(File.join(output_path, 'META.json'), 'w') do |f|
|
19
|
+
f.write({
|
20
|
+
:name => name,
|
21
|
+
:version => version,
|
22
|
+
:requires => dependencies.sort,
|
23
|
+
:provides => provides.sort,
|
24
|
+
}.to_json)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|