pi_customizer 0.3.0.pre.alpha → 0.3.1.pre.alpha
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 +4 -4
- data/.gitignore +24 -0
- data/.travis.yml +28 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/LICENSE +1 -1
- data/README.md +208 -2
- data/Rakefile +134 -6
- data/Vagrantfile +13 -2
- data/docs/concept.md +27 -0
- data/docs/incubation.md +38 -0
- data/pi_build_modifier/.gitignore +12 -0
- data/{.rspec → pi_build_modifier/.rspec} +0 -0
- data/pi_build_modifier/Gemfile +6 -0
- data/pi_build_modifier/LICENSE.txt +21 -0
- data/pi_build_modifier/README.md +3 -0
- data/pi_build_modifier/Rakefile +13 -0
- data/pi_build_modifier/bin/pi_build_modifier +25 -0
- data/pi_build_modifier/lib/pi_build_modifier.rb +53 -0
- data/pi_build_modifier/lib/pi_build_modifier/boot-files/boot.rb +64 -0
- data/pi_build_modifier/lib/pi_build_modifier/boot-files/templates/07-resize-init.diff.erb +5 -0
- data/pi_build_modifier/lib/pi_build_modifier/config/logex.rb +25 -0
- data/pi_build_modifier/lib/pi_build_modifier/locale/locale_debconf.rb +66 -0
- data/pi_build_modifier/lib/pi_build_modifier/locale/templates/00-debconf.erb +6 -0
- data/pi_build_modifier/lib/pi_build_modifier/modifier/erb_mapper.rb +72 -0
- data/pi_build_modifier/lib/pi_build_modifier/modifier/mapper.rb +49 -0
- data/pi_build_modifier/lib/pi_build_modifier/modifier/pi_modifier.rb +81 -0
- data/pi_build_modifier/lib/pi_build_modifier/modifier_task.rb +79 -0
- data/pi_build_modifier/lib/pi_build_modifier/net-tweaks/templates/wpa_supplicant.conf.erb +5 -0
- data/pi_build_modifier/lib/pi_build_modifier/net-tweaks/wifi_network.rb +124 -0
- data/pi_build_modifier/lib/pi_build_modifier/sys_tweaks/run_modifier.rb +63 -0
- data/pi_build_modifier/lib/pi_build_modifier/sys_tweaks/ssh.rb +61 -0
- data/pi_build_modifier/lib/pi_build_modifier/sys_tweaks/templates/ssh.sh.erb +8 -0
- data/pi_build_modifier/lib/pi_build_modifier/system/system_type.rb +84 -0
- data/pi_build_modifier/lib/pi_build_modifier/version.rb +23 -0
- data/pi_build_modifier/pi_build_modifier.gemspec +32 -0
- data/pi_build_modifier/spec/fixtures/config.json +26 -0
- data/pi_build_modifier/spec/pi_build_modifier/boot/boot_spec.rb +103 -0
- data/pi_build_modifier/spec/pi_build_modifier/locale/locale_spec.rb +87 -0
- data/pi_build_modifier/spec/pi_build_modifier/modifier/mapper_spec.rb +105 -0
- data/pi_build_modifier/spec/pi_build_modifier/modifier/modifier_spec.rb +83 -0
- data/pi_build_modifier/spec/pi_build_modifier/modifier_task_spec.rb +63 -0
- data/pi_build_modifier/spec/pi_build_modifier/net-tweaks/wifi_network_spec.rb +91 -0
- data/pi_build_modifier/spec/pi_build_modifier/sys_tweaks/run_modifier_spec.rb +74 -0
- data/pi_build_modifier/spec/pi_build_modifier/sys_tweaks/ssh_spec.rb +73 -0
- data/pi_build_modifier/spec/pi_build_modifier/system/system_spec.rb +66 -0
- data/pi_build_modifier/spec/pi_build_modifier_spec.rb +73 -0
- data/pi_build_modifier/spec/spec_helper.rb +10 -0
- data/pi_customizer/.rspec +2 -0
- data/{Gemfile → pi_customizer/Gemfile} +0 -0
- data/pi_customizer/LICENSE +21 -0
- data/pi_customizer/README.md +3 -0
- data/pi_customizer/Rakefile +13 -0
- data/pi_customizer/Vagrantfile +16 -0
- data/{bin → pi_customizer/bin}/pi_customizer +1 -1
- data/{envs → pi_customizer/envs}/aws/outputs.tf +0 -0
- data/{envs → pi_customizer/envs}/aws/pi-build-env.tf +0 -0
- data/{envs → pi_customizer/envs}/aws/variables.tf +0 -0
- data/{envs → pi_customizer/envs}/docker/Dockerfile +0 -0
- data/{envs → pi_customizer/envs}/sh/build-pi-img.sh +0 -0
- data/{lib → pi_customizer/lib}/pi_customizer.rb +7 -6
- data/{lib → pi_customizer/lib}/pi_customizer/build/builder/build_executor.rb +31 -2
- data/{lib → pi_customizer/lib}/pi_customizer/build/builder/builder.rb +4 -2
- data/{lib → pi_customizer/lib}/pi_customizer/build/builder/prepare_start_execute_builder.rb +1 -1
- data/{lib → pi_customizer/lib}/pi_customizer/build/builder/start_prepare_execute_builder.rb +1 -1
- data/{lib → pi_customizer/lib}/pi_customizer/build/environment/aws/aws.rb +1 -1
- data/{lib → pi_customizer/lib}/pi_customizer/build/environment/docker/docker.rb +1 -1
- data/{lib → pi_customizer/lib}/pi_customizer/build/environment/environment.rb +1 -1
- data/{lib → pi_customizer/lib}/pi_customizer/build/environment/environment_builder_factory.rb +9 -3
- data/{lib → pi_customizer/lib}/pi_customizer/build/environment/vagrant/templates/Vagrantfile.erb +3 -7
- data/{lib → pi_customizer/lib}/pi_customizer/build/environment/vagrant/vagrant.rb +1 -1
- data/{lib → pi_customizer/lib}/pi_customizer/build/environment/vagrant/vagrant_file.rb +2 -2
- data/{lib → pi_customizer/lib}/pi_customizer/build/workspace/local_workspace.rb +1 -1
- data/{lib → pi_customizer/lib}/pi_customizer/build/workspace/remote_workspace.rb +14 -4
- data/{lib → pi_customizer/lib}/pi_customizer/utils/logex.rb +1 -1
- data/{lib → pi_customizer/lib}/pi_customizer/version.rb +2 -2
- data/{lib → pi_customizer/lib}/pi_customizer/write/image_writer.rb +1 -1
- data/{pi_customizer.gemspec → pi_customizer/pi_customizer.gemspec} +5 -5
- data/pi_customizer/spec/fixtures/TestVagrantfile +61 -0
- data/pi_customizer/spec/fixtures/image.img +1 -0
- data/pi_customizer/spec/fixtures/image.zip +0 -0
- data/pi_customizer/spec/pi_customizer/builder/build_executor_spec.rb +64 -0
- data/pi_customizer/spec/pi_customizer/environment/aws_spec.rb +57 -0
- data/pi_customizer/spec/pi_customizer/environment/environment_builder_factory_spec.rb +48 -0
- data/pi_customizer/spec/pi_customizer/environment/environment_spec.rb +75 -0
- data/pi_customizer/spec/pi_customizer/environment/vagrant/vagrant_file_spec.rb +63 -0
- data/pi_customizer/spec/pi_customizer/environment/vagrant/vagrant_spec.rb +41 -0
- data/pi_customizer/spec/pi_customizer/version_spec.rb +29 -0
- data/pi_customizer/spec/pi_customizer/workspace/local_workspace_spec.rb +74 -0
- data/pi_customizer/spec/pi_customizer/workspace/remote_workspace_spec.rb +51 -0
- data/pi_customizer/spec/pi_customizer/write/image_writer_spec.rb +59 -0
- data/pi_customizer/spec/pi_customizer_spec.rb +93 -0
- data/pi_customizer/spec/spec_helper.rb +10 -0
- data/version.rb +21 -0
- metadata +102 -41
@@ -0,0 +1,83 @@
|
|
1
|
+
# Copyright (c) 2017-2019 Beate Ottenwälder
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
11
|
+
# copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
# SOFTWARE.
|
20
|
+
|
21
|
+
require_relative '../../spec_helper'
|
22
|
+
require 'rspec'
|
23
|
+
require 'fileutils'
|
24
|
+
require 'pi_build_modifier/modifier/pi_modifier'
|
25
|
+
require 'pi_build_modifier/modifier/mapper'
|
26
|
+
|
27
|
+
|
28
|
+
module PiBuildModifier
|
29
|
+
RSpec.describe PiModifier do
|
30
|
+
|
31
|
+
let(:tmp_json_config) {'tmp_config.json'}
|
32
|
+
|
33
|
+
before do
|
34
|
+
File.open(tmp_json_config, 'w') {|file| file.write('{"a":1,"b":2}')}
|
35
|
+
end
|
36
|
+
|
37
|
+
after do
|
38
|
+
FileUtils.rm(tmp_json_config)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'only accepts mappers that are a class Mapper' do
|
42
|
+
#Given
|
43
|
+
pi_modifier = PiModifier.new
|
44
|
+
|
45
|
+
#When #Then
|
46
|
+
expect{ pi_modifier.with_mapper(nil) }.to raise_error
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'performs a modification task on a mapper object with the specification given in a json configuration' do
|
51
|
+
|
52
|
+
#Given
|
53
|
+
pi_modifier = PiModifier.new
|
54
|
+
test_sum_component = TestSumComponent.new(nil)
|
55
|
+
|
56
|
+
#When
|
57
|
+
pi_modifier.with_json_configuration(tmp_json_config)
|
58
|
+
pi_modifier.with_mapper(test_sum_component)
|
59
|
+
pi_modifier.modify
|
60
|
+
|
61
|
+
#Then
|
62
|
+
expect(test_sum_component.a).to equal 1
|
63
|
+
expect(test_sum_component.b).to equal 2
|
64
|
+
expect(test_sum_component.sum).to equal 3
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
class TestSumComponent < Mapper
|
70
|
+
attr_accessor :a, :b, :sum
|
71
|
+
|
72
|
+
def map(json_data)
|
73
|
+
@a = json_data['a']
|
74
|
+
@b = json_data['b']
|
75
|
+
end
|
76
|
+
|
77
|
+
def modify
|
78
|
+
@sum = @a + @b
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# Copyright (c) 2017-2019 Beate Ottenwälder
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
11
|
+
# copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
# SOFTWARE.
|
20
|
+
|
21
|
+
require_relative '../spec_helper'
|
22
|
+
require 'rspec'
|
23
|
+
require 'fileutils'
|
24
|
+
require 'pi_build_modifier/modifier/pi_modifier'
|
25
|
+
require 'pi_build_modifier/modifier_task'
|
26
|
+
|
27
|
+
|
28
|
+
module PiBuildModifier
|
29
|
+
RSpec.describe Task::Modifier do
|
30
|
+
|
31
|
+
let(:json_config) {File.dirname(__FILE__) + '/../fixtures/config.json'}
|
32
|
+
let(:workspace) {File.dirname(__FILE__) + '/' + 'tmp_workspace'}
|
33
|
+
|
34
|
+
before do
|
35
|
+
FileUtils::mkdir_p workspace
|
36
|
+
end
|
37
|
+
|
38
|
+
after do
|
39
|
+
FileUtils.rm_rf workspace
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'registers all default mappers' do
|
43
|
+
#Given
|
44
|
+
pi_modifier = PiModifier.new
|
45
|
+
#When
|
46
|
+
Task::Modifier.new(json_config, workspace, pi_modifier)
|
47
|
+
#Then
|
48
|
+
expect(pi_modifier.mappers.size).to be >= 1
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'when the modification task is executed, modifications are made to the workspace directory' do
|
52
|
+
#Given
|
53
|
+
pi_modifier_task = Task::Modifier.new(json_config, workspace)
|
54
|
+
|
55
|
+
#When
|
56
|
+
pi_modifier_task.execute
|
57
|
+
|
58
|
+
#Then
|
59
|
+
expect(Dir["#{workspace}/**/*"].length).to be > 0
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# Copyright (c) 2017-2019 Beate Ottenwälder
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
11
|
+
# copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
# SOFTWARE.
|
20
|
+
|
21
|
+
require_relative '../../spec_helper'
|
22
|
+
require 'rspec'
|
23
|
+
require 'fileutils'
|
24
|
+
require 'pi_build_modifier/net-tweaks/wifi_network'
|
25
|
+
require 'pi_build_modifier/modifier/erb_mapper'
|
26
|
+
require 'pi_build_modifier/modifier/pi_modifier'
|
27
|
+
|
28
|
+
|
29
|
+
RSpec.describe PiBuildModifier::WPASupplicant do
|
30
|
+
|
31
|
+
let(:empty_json_config) {'config_empty.json'}
|
32
|
+
let(:json_config) {'config_full.json'}
|
33
|
+
let(:workspace) {File.dirname(__FILE__) + '/workspace'}
|
34
|
+
|
35
|
+
before do
|
36
|
+
FileUtils.mkdir_p workspace
|
37
|
+
File.open(empty_json_config, 'w') {|file| file.write('{}')}
|
38
|
+
File.open(json_config, 'w') {|file| file.write(' {"wifi" : {
|
39
|
+
"wpa_country" : "DE_test",
|
40
|
+
"networks": [
|
41
|
+
{
|
42
|
+
"ssid": "test_wpsk",
|
43
|
+
"wpsk": "test_wpsk"
|
44
|
+
}
|
45
|
+
]
|
46
|
+
}
|
47
|
+
}
|
48
|
+
')}
|
49
|
+
end
|
50
|
+
|
51
|
+
after do
|
52
|
+
FileUtils.rm(empty_json_config)
|
53
|
+
FileUtils.rm(json_config)
|
54
|
+
FileUtils.rm_rf workspace
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should create a default wpa_supplicant.config when no change is specified in the json configuration file' do
|
58
|
+
|
59
|
+
#Given
|
60
|
+
modifier = PiBuildModifier::PiModifier.new
|
61
|
+
wpa_supplicant = PiBuildModifier::WPASupplicant.new
|
62
|
+
mapper = PiBuildModifier::ERBMapper.new(wpa_supplicant, workspace)
|
63
|
+
|
64
|
+
#When
|
65
|
+
modifier.with_json_configuration(empty_json_config)
|
66
|
+
modifier.with_mapper(mapper)
|
67
|
+
modifier.modify
|
68
|
+
|
69
|
+
#Then
|
70
|
+
expect(Pathname.new(workspace + '/' + wpa_supplicant.relative_output_path)).to be_file
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should create a wpa_supplicant.config with all changes that are specified in the json configuration file' do
|
74
|
+
|
75
|
+
#Given
|
76
|
+
modifier = PiBuildModifier::PiModifier.new
|
77
|
+
wpa_supplicant = PiBuildModifier::WPASupplicant.new
|
78
|
+
mapper = wpa_supplicant.mapper(workspace)
|
79
|
+
|
80
|
+
#When
|
81
|
+
modifier.with_json_configuration(json_config)
|
82
|
+
modifier.with_mapper(mapper)
|
83
|
+
modifier.modify
|
84
|
+
|
85
|
+
#Then
|
86
|
+
wpa_supplicant_file = File.read(workspace + '/' + wpa_supplicant.relative_output_path)
|
87
|
+
expect(wpa_supplicant_file).to match(/network/)
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# Copyright (c) 2017-2019 Beate Ottenwälder
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
11
|
+
# copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
# SOFTWARE.
|
20
|
+
|
21
|
+
require_relative '../../spec_helper'
|
22
|
+
require 'rspec'
|
23
|
+
require 'fileutils'
|
24
|
+
require 'pi_build_modifier/sys_tweaks/run_modifier'
|
25
|
+
require 'pi_build_modifier/modifier/pi_modifier'
|
26
|
+
require 'pi_build_modifier/modifier/mapper'
|
27
|
+
|
28
|
+
RSpec.describe PiBuildModifier::RunModifier do
|
29
|
+
|
30
|
+
let(:workspace) {File.dirname(__FILE__) + '/workspace'}
|
31
|
+
|
32
|
+
before do
|
33
|
+
FileUtils.mkdir_p workspace
|
34
|
+
end
|
35
|
+
|
36
|
+
after do
|
37
|
+
FileUtils.rm_rf workspace
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should be of type Mapper' do
|
41
|
+
expect(PiBuildModifier::RunModifier.new).to be_a PiBuildModifier::Mapper
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should append lines to the 01-run.sh file' do
|
45
|
+
|
46
|
+
#Given
|
47
|
+
modifier = PiBuildModifier::RunModifier.new.mapper(workspace)
|
48
|
+
FileUtils.mkdir_p File.dirname(workspace + '/' + modifier.relative_output_path)
|
49
|
+
FileUtils.touch(workspace + '/' + modifier.relative_output_path)
|
50
|
+
modifier.append(Class.new do
|
51
|
+
def append_line
|
52
|
+
'1'
|
53
|
+
end
|
54
|
+
end.new
|
55
|
+
)
|
56
|
+
modifier.append(Class.new do
|
57
|
+
def append_line
|
58
|
+
'2'
|
59
|
+
end
|
60
|
+
end.new
|
61
|
+
)
|
62
|
+
|
63
|
+
|
64
|
+
#When
|
65
|
+
modifier.modify
|
66
|
+
|
67
|
+
#Then
|
68
|
+
expect(Pathname.new(workspace + '/' + modifier.relative_output_path)).to be_file
|
69
|
+
expect(IO.read(Pathname.new(workspace + '/' + modifier.relative_output_path))).to match(/\nsource #{workspace}\/1\nsource #{workspace}\/2\n/)
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# Copyright (c) 2017-2019 Beate Ottenwälder
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
11
|
+
# copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
# SOFTWARE.
|
20
|
+
|
21
|
+
require_relative '../../spec_helper'
|
22
|
+
require 'rspec'
|
23
|
+
require 'fileutils'
|
24
|
+
require 'pi_build_modifier/sys_tweaks/ssh'
|
25
|
+
require 'pi_build_modifier/sys_tweaks/run_modifier'
|
26
|
+
require 'pi_build_modifier/modifier/erb_mapper'
|
27
|
+
require 'pi_build_modifier/modifier/pi_modifier'
|
28
|
+
|
29
|
+
|
30
|
+
RSpec.describe PiBuildModifier::Ssh do
|
31
|
+
|
32
|
+
let(:empty_json_config) {'config_empty.json'}
|
33
|
+
let(:workspace) {File.dirname(__FILE__) + '/workspace'}
|
34
|
+
|
35
|
+
before do
|
36
|
+
File.open(empty_json_config, 'w') {|file| file.write('{}')}
|
37
|
+
FileUtils.mkdir_p workspace
|
38
|
+
end
|
39
|
+
|
40
|
+
after do
|
41
|
+
FileUtils.rm(empty_json_config)
|
42
|
+
FileUtils.rm_rf workspace
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'does not accept an invalid config' do
|
46
|
+
#Given
|
47
|
+
modifier = PiBuildModifier::PiModifier.new
|
48
|
+
ssh = PiBuildModifier::Ssh.new
|
49
|
+
mapper = ssh.mapper(workspace)
|
50
|
+
|
51
|
+
#When
|
52
|
+
modifier.with_json_configuration('cfg')
|
53
|
+
modifier.with_mapper(mapper)
|
54
|
+
|
55
|
+
expect{ modifier.modify }.to raise_error()
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should create a default ssh.sh file' do
|
59
|
+
#Given
|
60
|
+
modifier = PiBuildModifier::PiModifier.new
|
61
|
+
ssh = PiBuildModifier::Ssh.new
|
62
|
+
mapper = ssh.mapper(workspace)
|
63
|
+
|
64
|
+
#When
|
65
|
+
modifier.with_json_configuration(empty_json_config)
|
66
|
+
modifier.with_mapper(mapper)
|
67
|
+
modifier.modify
|
68
|
+
|
69
|
+
#Then
|
70
|
+
expect(Pathname.new(workspace + '/' + ssh.relative_output_path)).to be_file
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# Copyright (c) 2017-2019 Beate Ottenwälder
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
11
|
+
# copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
# SOFTWARE.
|
20
|
+
|
21
|
+
require_relative '../../spec_helper'
|
22
|
+
require 'rspec'
|
23
|
+
require 'fileutils'
|
24
|
+
require 'pi_build_modifier/system/system_type'
|
25
|
+
require 'pi_build_modifier/modifier/mapper'
|
26
|
+
|
27
|
+
RSpec.describe PiBuildModifier::System do
|
28
|
+
|
29
|
+
EXPECTED_SYSTEM_NAME = 'chiipi_test'
|
30
|
+
EXPECTED_SYSTEM_TYPE = 'lite'
|
31
|
+
let(:config) {{'system' => {'name' => EXPECTED_SYSTEM_NAME, 'type' => EXPECTED_SYSTEM_TYPE}}}
|
32
|
+
let(:workspace) {"#{File.dirname(__FILE__)}/workspace"}
|
33
|
+
|
34
|
+
|
35
|
+
after(:each) do
|
36
|
+
FileUtils.rm_rf(workspace) if Dir.exist?(workspace)
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
it 'should map the name and type given in a hash to corresponding members' do
|
41
|
+
#Given
|
42
|
+
system = PiBuildModifier::System.new.mapper(workspace)
|
43
|
+
|
44
|
+
#When
|
45
|
+
system.map(config)
|
46
|
+
|
47
|
+
#Then
|
48
|
+
expect(system.name).to eq(EXPECTED_SYSTEM_NAME)
|
49
|
+
expect(system.type).to eq(EXPECTED_SYSTEM_TYPE)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should map the name and type to variables' do
|
53
|
+
#Given
|
54
|
+
system = PiBuildModifier::System.new.mapper(workspace)
|
55
|
+
|
56
|
+
#When
|
57
|
+
system.map(config)
|
58
|
+
system.modify
|
59
|
+
|
60
|
+
#Then
|
61
|
+
%w(/config /stage3/SKIP /stage4/SKIP /stage5/SKIP).each do |file|
|
62
|
+
expect(Pathname.new(workspace + file)).to be_file
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|