pi_customizer 0.4.0.pre.alpha → 0.5.0.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 +0 -1
- data/CODE_OF_CONDUCT.md +1 -1
- data/README.md +55 -20
- data/Rakefile +6 -5
- data/docs/concept.md +0 -18
- data/docs/incubation.md +3 -14
- data/pi_build_modifier/Gemfile.lock +50 -0
- data/pi_build_modifier/lib/pi_build_modifier.rb +4 -7
- data/pi_build_modifier/lib/pi_build_modifier/modify/configs.rb +335 -0
- data/pi_build_modifier/lib/pi_build_modifier/modify/modifiers.rb +281 -0
- data/pi_build_modifier/lib/pi_build_modifier/{locale → modify}/templates/00-debconf.erb +1 -1
- data/pi_build_modifier/lib/pi_build_modifier/{boot-files → modify}/templates/07-resize-init.diff.erb +1 -1
- data/pi_build_modifier/lib/pi_build_modifier/{net-tweaks → modify}/templates/wpa_supplicant.conf.erb +1 -1
- data/pi_build_modifier/lib/pi_build_modifier/{config → utils}/logex.rb +5 -1
- data/pi_build_modifier/lib/pi_build_modifier/version.rb +1 -1
- data/pi_build_modifier/spec/pi_build_modifier/modify/modify_spec.rb +306 -0
- data/pi_build_modifier/spec/pi_build_modifier_spec.rb +3 -3
- data/pi_build_modifier/spec/spec_helper.rb +1 -0
- data/pi_customizer/Gemfile.lock +47 -0
- data/pi_customizer/lib/pi_customizer.rb +15 -9
- data/pi_customizer/lib/pi_customizer/build/builder/build_executor.rb +12 -24
- data/pi_customizer/lib/pi_customizer/build/builder/builder.rb +17 -13
- data/pi_customizer/{spec/pi_customizer/environment/environment_builder_factory_spec.rb → lib/pi_customizer/build/config/build_config.rb} +27 -18
- data/pi_customizer/lib/pi_customizer/build/{workspace → config}/local_workspace.rb +8 -8
- data/pi_customizer/lib/pi_customizer/build/{workspace → config}/remote_workspace.rb +1 -1
- data/pi_customizer/lib/pi_customizer/build/environment/docker/docker.rb +1 -1
- data/pi_customizer/lib/pi_customizer/build/environment/environment.rb +1 -1
- data/pi_customizer/lib/pi_customizer/build/{builder/start_prepare_execute_builder.rb → environment/environment_factory.rb} +27 -16
- data/pi_customizer/lib/pi_customizer/build/environment/vagrant/templates/Vagrantfile.erb +2 -2
- data/pi_customizer/lib/pi_customizer/build/environment/vagrant/vagrant.rb +3 -8
- data/pi_customizer/lib/pi_customizer/build/environment/vagrant/vagrant_file.rb +3 -3
- data/pi_customizer/lib/pi_customizer/version.rb +1 -1
- data/pi_customizer/lib/pi_customizer/write/image_writer.rb +3 -2
- data/pi_customizer/spec/pi_customizer/build/builder/builder_spec.rb +122 -0
- data/pi_customizer/spec/pi_customizer/{environment/aws_spec.rb → build/config/build_config_spec.rb} +20 -25
- data/pi_customizer/spec/pi_customizer/{workspace/local_workspace_spec.rb → build/config/local_workspace_config_spec.rb} +10 -10
- data/pi_customizer/spec/pi_customizer/{workspace → build/config}/remote_workspace_spec.rb +2 -2
- data/pi_customizer/spec/pi_customizer/{environment/vagrant/vagrant_spec.rb → build/environment/environment_builder_factory_spec.rb} +17 -13
- data/pi_customizer/spec/pi_customizer/{environment → build/environment}/environment_spec.rb +1 -1
- data/pi_customizer/spec/pi_customizer/{environment → build/environment}/vagrant/vagrant_file_spec.rb +7 -7
- data/pi_customizer/spec/pi_customizer/build/environment/vagrant/vagrant_spec.rb +80 -0
- data/pi_customizer/spec/pi_customizer_spec.rb +19 -14
- data/pi_customizer/spec/spec_helper.rb +21 -0
- data/version.rb +1 -1
- metadata +23 -42
- data/Vagrantfile +0 -27
- data/pi_build_modifier/.gitignore +0 -12
- data/pi_build_modifier/lib/pi_build_modifier/boot-files/boot.rb +0 -64
- data/pi_build_modifier/lib/pi_build_modifier/locale/locale_debconf.rb +0 -66
- data/pi_build_modifier/lib/pi_build_modifier/modifier/erb_mapper.rb +0 -72
- data/pi_build_modifier/lib/pi_build_modifier/modifier/mapper.rb +0 -49
- data/pi_build_modifier/lib/pi_build_modifier/modifier/pi_modifier.rb +0 -81
- data/pi_build_modifier/lib/pi_build_modifier/modifier_task.rb +0 -79
- data/pi_build_modifier/lib/pi_build_modifier/net-tweaks/wifi_network.rb +0 -124
- data/pi_build_modifier/lib/pi_build_modifier/sys_tweaks/run_modifier.rb +0 -63
- data/pi_build_modifier/lib/pi_build_modifier/sys_tweaks/ssh.rb +0 -61
- data/pi_build_modifier/lib/pi_build_modifier/sys_tweaks/templates/ssh.sh.erb +0 -8
- data/pi_build_modifier/lib/pi_build_modifier/system/system_type.rb +0 -84
- data/pi_build_modifier/spec/pi_build_modifier/boot/boot_spec.rb +0 -103
- data/pi_build_modifier/spec/pi_build_modifier/locale/locale_spec.rb +0 -87
- data/pi_build_modifier/spec/pi_build_modifier/modifier/mapper_spec.rb +0 -105
- data/pi_build_modifier/spec/pi_build_modifier/modifier/modifier_spec.rb +0 -83
- data/pi_build_modifier/spec/pi_build_modifier/modifier_task_spec.rb +0 -63
- data/pi_build_modifier/spec/pi_build_modifier/net-tweaks/wifi_network_spec.rb +0 -91
- data/pi_build_modifier/spec/pi_build_modifier/sys_tweaks/run_modifier_spec.rb +0 -74
- data/pi_build_modifier/spec/pi_build_modifier/sys_tweaks/ssh_spec.rb +0 -73
- data/pi_build_modifier/spec/pi_build_modifier/system/system_spec.rb +0 -66
- data/pi_customizer/lib/pi_customizer/build/builder/prepare_start_execute_builder.rb +0 -43
- data/pi_customizer/lib/pi_customizer/build/environment/aws/aws.rb +0 -76
- data/pi_customizer/lib/pi_customizer/build/environment/environment_builder_factory.rb +0 -81
- data/pi_customizer/spec/pi_customizer/builder/build_executor_spec.rb +0 -64
@@ -1,43 +0,0 @@
|
|
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 'pi_customizer/build/builder/builder'
|
22
|
-
|
23
|
-
module PiCustomizer
|
24
|
-
module Builder
|
25
|
-
class PrepareExecuteBuilder < PiBuilder
|
26
|
-
|
27
|
-
protected def execute_builder
|
28
|
-
@build_executor.check
|
29
|
-
@build_executor.prepare
|
30
|
-
@build_executor.publish
|
31
|
-
@build_executor.clean_up
|
32
|
-
@build_executor.start
|
33
|
-
@build_executor.build_image
|
34
|
-
@build_executor.stop
|
35
|
-
end
|
36
|
-
|
37
|
-
protected def ensure_builder
|
38
|
-
@build_executor.ensure
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,76 +0,0 @@
|
|
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 'fileutils'
|
22
|
-
require 'pi_customizer/utils/logex'
|
23
|
-
require 'pi_customizer/build/environment/environment'
|
24
|
-
|
25
|
-
module PiCustomizer
|
26
|
-
module Environment
|
27
|
-
class AWS < EnvironmentControl
|
28
|
-
|
29
|
-
def build
|
30
|
-
|
31
|
-
puts 'NOTE: AWS is not yet officially supported!'
|
32
|
-
|
33
|
-
create_ssh_folder
|
34
|
-
create_keys
|
35
|
-
begin
|
36
|
-
terraform
|
37
|
-
ensure
|
38
|
-
del_keys
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def terraform
|
43
|
-
puts 'Build env with terraform'
|
44
|
-
Dir.chdir 'envs/aws' do
|
45
|
-
system 'terraform plan'
|
46
|
-
system 'terraform apply'
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def create_keys(key_name = 'pi-builder')
|
51
|
-
$logger.info 'Create AWS key unless it exists'
|
52
|
-
FileUtils.mkdir_p 'ssh'
|
53
|
-
unless File.file?("ssh/#{key_name}.pub")
|
54
|
-
system "ssh-keygen -t rsa -C pi-builder -P '' -f ssh/#{key_name} -b 4096"
|
55
|
-
FileUtils.mv "ssh/#{key_name}", "ssh/#{key_name}.pem"
|
56
|
-
FileUtils.chmod 400, "ssh/#{key_name}.pem"
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def del_keys(key_name = 'pi-builder')
|
61
|
-
if File.file?("ssh/#{key_name}.pub")
|
62
|
-
FileUtils.rm "ssh/#{key_name}.pub"
|
63
|
-
end
|
64
|
-
if File.file?("ssh/#{key_name}.pem")
|
65
|
-
FileUtils.rm "ssh/#{key_name}.pem"
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def create_ssh_folder
|
70
|
-
unless File.directory?('ssh')
|
71
|
-
FileUtils.mkdir_p 'ssh'
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
@@ -1,81 +0,0 @@
|
|
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 'pi_customizer/build/environment/environment'
|
22
|
-
require 'pi_customizer/build/environment/aws/aws'
|
23
|
-
require 'pi_customizer/build/environment/vagrant/vagrant'
|
24
|
-
require 'pi_customizer/build/environment/docker/docker'
|
25
|
-
require 'pi_customizer/build/builder/builder'
|
26
|
-
require 'pi_customizer/build/builder/prepare_start_execute_builder'
|
27
|
-
require 'pi_customizer/build/builder/start_prepare_execute_builder'
|
28
|
-
require 'pi_customizer/build/workspace/remote_workspace'
|
29
|
-
require 'pi_customizer/build/workspace/local_workspace'
|
30
|
-
require 'pi_customizer/utils/logex'
|
31
|
-
|
32
|
-
|
33
|
-
module PiCustomizer
|
34
|
-
module Environment
|
35
|
-
|
36
|
-
ENV_AWS = 'AWS'
|
37
|
-
ENV_VAGRANT = 'VAGRANT'
|
38
|
-
ENV_DOCKER = 'DOCKER'
|
39
|
-
ENV_ECHO = 'ECHO'
|
40
|
-
|
41
|
-
##
|
42
|
-
# The builder_factory creates a builder for the selected environment env. The builder orchestrates the environment and the build process in the environment.
|
43
|
-
|
44
|
-
def Environment.builder_factory(env, local_workspace, remote_workspace, skip_build_steps)
|
45
|
-
|
46
|
-
environment = environment_factory(env, local_workspace, remote_workspace)
|
47
|
-
|
48
|
-
case env
|
49
|
-
when ENV_AWS, ENV_VAGRANT
|
50
|
-
env_builder = Builder::PrepareExecuteBuilder.new(environment, skip_build_steps)
|
51
|
-
when ENV_DOCKER, ENV_ECHO
|
52
|
-
puts "Echo: - Git Path: #{remote_workspace.git_path}, Workspace Path: #{remote_workspace.workspace_directory}, Config Path: #{local_workspace.config_path}, #{skip_build_steps}"
|
53
|
-
env_builder = Builder::StartExecuteBuilder.new(environment, skip_build_steps)
|
54
|
-
else
|
55
|
-
$logger.warn 'No valid build environment defined!'
|
56
|
-
env_builder = Builder::PiBuilder.new(environment, skip_build_steps)
|
57
|
-
end
|
58
|
-
env_builder
|
59
|
-
end
|
60
|
-
|
61
|
-
##
|
62
|
-
# The environment_factory creates an environment configuration tailored to the selected build environment env
|
63
|
-
|
64
|
-
def Environment.environment_factory(env, local_workspace, remote_workspace)
|
65
|
-
case env
|
66
|
-
when ENV_AWS
|
67
|
-
environment = AWS.new(remote_workspace, local_workspace)
|
68
|
-
when ENV_VAGRANT
|
69
|
-
environment = Vagrant.new(remote_workspace, local_workspace)
|
70
|
-
when ENV_DOCKER
|
71
|
-
environment = Docker.new(remote_workspace, local_workspace)
|
72
|
-
when ENV_ECHO
|
73
|
-
environment = EnvironmentControl.new(remote_workspace, local_workspace)
|
74
|
-
else
|
75
|
-
$logger.warn 'No valid environment (e.g., AWS or VAGRANT) defined!'
|
76
|
-
environment = EnvironmentControl.new(remote_workspace, local_workspace)
|
77
|
-
end
|
78
|
-
environment
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
@@ -1,64 +0,0 @@
|
|
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 'pi_customizer/build/builder/build_executor'
|
24
|
-
require 'pi_customizer/build/environment/environment'
|
25
|
-
|
26
|
-
describe PiCustomizer::Builder::BuildExecutor do
|
27
|
-
|
28
|
-
it 'internally converts keys of skip steps to symbols' do
|
29
|
-
build_exec = PiCustomizer::Builder::BuildExecutor.new(PiCustomizer::Environment::EnvironmentControl.new('',''), ['prepare'])
|
30
|
-
expect(build_exec.skip_build_steps).to include(:prepare)
|
31
|
-
expect(build_exec.skip_build_steps).not_to include('prepare')
|
32
|
-
end
|
33
|
-
|
34
|
-
|
35
|
-
it 'honors skipping the build step prepare' do
|
36
|
-
build_exec = PiCustomizer::Builder::BuildExecutor.new(PiCustomizer::Environment::EnvironmentControl.new('',''), [:prepare])
|
37
|
-
expect(build_exec.env).not_to receive(:prepare)
|
38
|
-
build_exec.prepare
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'honors skipping the build step start' do
|
42
|
-
build_exec = PiCustomizer::Builder::BuildExecutor.new(PiCustomizer::Environment::EnvironmentControl.new('',''), [:start])
|
43
|
-
expect(build_exec.env).not_to receive(:start)
|
44
|
-
build_exec.start
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'honors skipping the build step' do
|
48
|
-
build_exec = PiCustomizer::Builder::BuildExecutor.new(PiCustomizer::Environment::EnvironmentControl.new('',''), [:build_image])
|
49
|
-
expect(build_exec.env).not_to receive(:build_image)
|
50
|
-
build_exec.build_image
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'honors skipping the build step clean' do
|
54
|
-
build_exec = PiCustomizer::Builder::BuildExecutor.new(PiCustomizer::Environment::EnvironmentControl.new('',''), [:clean_up])
|
55
|
-
expect(build_exec.env).not_to receive(:clean_up)
|
56
|
-
build_exec.clean_up
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'honors skipping the build step stop' do
|
60
|
-
build_exec = PiCustomizer::Builder::BuildExecutor.new(PiCustomizer::Environment::EnvironmentControl.new('',''), [:stop])
|
61
|
-
expect(build_exec.env).not_to receive(:stop)
|
62
|
-
build_exec.stop
|
63
|
-
end
|
64
|
-
end
|