pi_build_modifier 0.4.0.pre.alpha → 0.5.0.pre.alpha
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -21,7 +21,7 @@
|
|
21
21
|
require_relative 'spec_helper'
|
22
22
|
require 'pi_build_modifier'
|
23
23
|
require 'pi_build_modifier/version'
|
24
|
-
require 'pi_build_modifier/
|
24
|
+
require 'pi_build_modifier/modify/modifiers'
|
25
25
|
|
26
26
|
RSpec.describe PiBuildModifier do
|
27
27
|
it 'has a version number' do
|
@@ -62,8 +62,8 @@ RSpec.describe PiBuildModifier::PiBuildModifier do
|
|
62
62
|
end
|
63
63
|
|
64
64
|
it 'triggers the modifier task' do
|
65
|
-
expect(PiBuildModifier::
|
66
|
-
expect_any_instance_of(PiBuildModifier::
|
65
|
+
expect(PiBuildModifier::Modifiers::ModifiersBuilder).to receive(:build_defaults).with(tmp_workspace, tmp_json_config).and_return(PiBuildModifier::Modifiers::Modifiers.new)
|
66
|
+
expect_any_instance_of(PiBuildModifier::Modifiers::Modifiers).to receive(:modify_configs)
|
67
67
|
PiBuildModifier::PiBuildModifier.start(['modify', tmp_json_config, tmp_workspace])
|
68
68
|
end
|
69
69
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
pi_customizer (0.5.0.pre.alpha)
|
5
|
+
thor (~> 0.20)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.3)
|
11
|
+
docile (1.3.2)
|
12
|
+
json (2.2.0)
|
13
|
+
rake (12.3.2)
|
14
|
+
rdoc (6.1.1)
|
15
|
+
rspec (3.8.0)
|
16
|
+
rspec-core (~> 3.8.0)
|
17
|
+
rspec-expectations (~> 3.8.0)
|
18
|
+
rspec-mocks (~> 3.8.0)
|
19
|
+
rspec-core (3.8.1)
|
20
|
+
rspec-support (~> 3.8.0)
|
21
|
+
rspec-expectations (3.8.4)
|
22
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
23
|
+
rspec-support (~> 3.8.0)
|
24
|
+
rspec-mocks (3.8.1)
|
25
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
+
rspec-support (~> 3.8.0)
|
27
|
+
rspec-support (3.8.2)
|
28
|
+
simplecov (0.16.1)
|
29
|
+
docile (~> 1.1)
|
30
|
+
json (>= 1.8, < 3)
|
31
|
+
simplecov-html (~> 0.10.0)
|
32
|
+
simplecov-html (0.10.2)
|
33
|
+
thor (0.20.3)
|
34
|
+
|
35
|
+
PLATFORMS
|
36
|
+
ruby
|
37
|
+
|
38
|
+
DEPENDENCIES
|
39
|
+
bundler (~> 2.0)
|
40
|
+
pi_customizer!
|
41
|
+
rake (~> 12.3)
|
42
|
+
rdoc (~> 6.1)
|
43
|
+
rspec (~> 3.8)
|
44
|
+
simplecov (~> 0.16)
|
45
|
+
|
46
|
+
BUNDLED WITH
|
47
|
+
2.0.2
|
@@ -21,9 +21,11 @@
|
|
21
21
|
require 'thor'
|
22
22
|
require 'fileutils'
|
23
23
|
require 'pi_customizer/version'
|
24
|
-
require 'pi_customizer/build/
|
25
|
-
require 'pi_customizer/build/
|
26
|
-
require 'pi_customizer/build/
|
24
|
+
require 'pi_customizer/build/builder/builder'
|
25
|
+
require 'pi_customizer/build/config/remote_workspace'
|
26
|
+
require 'pi_customizer/build/config/local_workspace'
|
27
|
+
require 'pi_customizer/build/config/build_config'
|
28
|
+
require 'pi_customizer/build/environment/environment_factory'
|
27
29
|
require 'pi_customizer/write/image_writer'
|
28
30
|
require 'pi_customizer/utils/logex'
|
29
31
|
|
@@ -39,7 +41,7 @@ module PiCustomizer
|
|
39
41
|
|
40
42
|
desc 'build ENV', 'Build pi image on environment ENV (valid environments are: VAGRANT).'
|
41
43
|
method_option :build_sources_git_url, :default => Workspace::DEFAULT_GIT_PATH, :aliases => '-g'
|
42
|
-
method_option :build_sources_git_tag, :default => Workspace::DEFAULT_GIT_TAG, :aliases => '-t'
|
44
|
+
method_option :build_sources_git_tag, :default => Workspace::DEFAULT_GIT_TAG, :aliases => '-t'
|
43
45
|
method_option :remote_workspace_dir, :default => Workspace::DEFAULT_REMOTE_WORKSPACE_DIRECTORY, :aliases => '-w'
|
44
46
|
method_option :config_file, :aliases => '-c', :required => true
|
45
47
|
method_option :local_workspace_dir, :default => Workspace::DEFAULT_LOCAL_WORKSPACE_DIRECTORY, :aliases => '-l'
|
@@ -50,9 +52,13 @@ module PiCustomizer
|
|
50
52
|
def build(env)
|
51
53
|
begin
|
52
54
|
remote_workspace = Workspace::RemoteWorkspace.new("#{options[:remote_workspace_dir]}", "#{options[:build_sources_git_url]}", "#{options[:build_sources_git_tag]}")
|
53
|
-
local_workspace = Workspace::
|
54
|
-
|
55
|
-
|
55
|
+
local_workspace = Workspace::LocalWorkspaceConfig.new("#{options[:config_file]}", "#{options[:local_workspace_dir]}", "#{options[:modifier_gem]}")
|
56
|
+
build_config = Config::BuildConfig.new(options[:skip_steps])
|
57
|
+
|
58
|
+
environment = Environment::environment_factory(env, local_workspace, remote_workspace)
|
59
|
+
builder = Builder::PiBuilder.new
|
60
|
+
|
61
|
+
builder.build(environment, build_config)
|
56
62
|
rescue Exception => e
|
57
63
|
$logger.error e.message
|
58
64
|
end
|
@@ -68,13 +74,13 @@ module PiCustomizer
|
|
68
74
|
end
|
69
75
|
|
70
76
|
##
|
71
|
-
# Allow
|
77
|
+
# Allow users to write an image to a device, i.e., a SD card
|
72
78
|
|
73
79
|
desc 'write IMAGE DEVICE', 'Write an image to a device.'
|
74
80
|
|
75
81
|
def write_image(image, device)
|
76
82
|
begin
|
77
|
-
ImageWriter.new
|
83
|
+
ImageWriter.new.write(image, device)
|
78
84
|
rescue Exception => e
|
79
85
|
$logger.error e.message
|
80
86
|
end
|
@@ -19,21 +19,23 @@
|
|
19
19
|
# SOFTWARE.
|
20
20
|
|
21
21
|
require 'pi_customizer/utils/logex'
|
22
|
+
require 'pi_customizer/build/environment/environment'
|
23
|
+
require 'pi_customizer/build/config/build_config'
|
22
24
|
|
23
25
|
module PiCustomizer
|
24
26
|
module Builder
|
25
27
|
|
26
28
|
##
|
27
|
-
# BuildExecutor triggers the steps of a build process
|
29
|
+
# BuildExecutor triggers the steps of a build process for a given environment (e.g., a vagrant box).
|
28
30
|
# It skips individual steps in the build process when they are defined as skip_build_steps.
|
29
31
|
|
30
32
|
class BuildExecutor
|
31
33
|
|
32
|
-
attr_reader :env
|
34
|
+
attr_reader :env
|
33
35
|
|
34
|
-
def initialize(environment,
|
36
|
+
def initialize(environment, build_config)
|
35
37
|
@env = environment
|
36
|
-
@
|
38
|
+
@build_config = build_config
|
37
39
|
end
|
38
40
|
|
39
41
|
##
|
@@ -48,7 +50,7 @@ module PiCustomizer
|
|
48
50
|
# execute the prepare step for the build environment
|
49
51
|
|
50
52
|
def prepare
|
51
|
-
unless @
|
53
|
+
unless @build_config.skip?(:prepare)
|
52
54
|
@env.prepare
|
53
55
|
end
|
54
56
|
end
|
@@ -57,7 +59,7 @@ module PiCustomizer
|
|
57
59
|
# execute the start step for the build environment
|
58
60
|
|
59
61
|
def start
|
60
|
-
unless @
|
62
|
+
unless @build_config.skip?(:start)
|
61
63
|
@env.start
|
62
64
|
end
|
63
65
|
end
|
@@ -66,7 +68,7 @@ module PiCustomizer
|
|
66
68
|
# execute the build_image step for the build environment
|
67
69
|
|
68
70
|
def build_image
|
69
|
-
unless @
|
71
|
+
unless @build_config.skip?(:build_image)
|
70
72
|
@env.build_image
|
71
73
|
end
|
72
74
|
end
|
@@ -75,7 +77,7 @@ module PiCustomizer
|
|
75
77
|
# publish the image from the build environment
|
76
78
|
|
77
79
|
def publish
|
78
|
-
unless @
|
80
|
+
unless @build_config.skip?(:publish)
|
79
81
|
@env.publish
|
80
82
|
end
|
81
83
|
end
|
@@ -84,7 +86,7 @@ module PiCustomizer
|
|
84
86
|
# clean_up the build environment
|
85
87
|
|
86
88
|
def clean_up
|
87
|
-
unless @
|
89
|
+
unless @build_config.skip?(:clean_up)
|
88
90
|
@env.clean_up
|
89
91
|
end
|
90
92
|
end
|
@@ -93,7 +95,7 @@ module PiCustomizer
|
|
93
95
|
# execute the stop step of the environment
|
94
96
|
|
95
97
|
def stop
|
96
|
-
unless @
|
98
|
+
unless @build_config.skip?(:stop)
|
97
99
|
@env.stop
|
98
100
|
end
|
99
101
|
end
|
@@ -105,20 +107,6 @@ module PiCustomizer
|
|
105
107
|
@env.ensure
|
106
108
|
end
|
107
109
|
|
108
|
-
##
|
109
|
-
# convert a list of stringified build steps to a list of symbols
|
110
|
-
|
111
|
-
private def convert_to_skip(skip_build_steps)
|
112
|
-
if skip_build_steps.nil?
|
113
|
-
skip_build_steps = Array.new
|
114
|
-
else
|
115
|
-
# convert every key to a symbol
|
116
|
-
skip_build_steps = skip_build_steps.collect {|k| k.to_sym}
|
117
|
-
end
|
118
|
-
$logger.debug "Skipping the following build steps: #{skip_build_steps}"
|
119
|
-
skip_build_steps
|
120
|
-
end
|
121
|
-
|
122
110
|
##
|
123
111
|
# check if an environment is specified
|
124
112
|
|
@@ -24,36 +24,40 @@ module PiCustomizer
|
|
24
24
|
module Builder
|
25
25
|
|
26
26
|
##
|
27
|
-
# PiBuilder defines
|
27
|
+
# PiBuilder abstractly defines the steps of a build process.
|
28
28
|
# However, the concrete orchestration of the build process's steps is done by its sub-classes.
|
29
29
|
|
30
30
|
class PiBuilder
|
31
31
|
|
32
|
-
attr_reader :build_executor
|
33
|
-
|
34
|
-
def initialize(environment, skip_build_steps)
|
35
|
-
@build_executor = BuildExecutor.new(environment,skip_build_steps)
|
36
|
-
end
|
37
|
-
|
38
32
|
##
|
39
|
-
# build orchestrates an environment and therefore the build process of an image
|
33
|
+
# build orchestrates the build steps related to an environment and therefore the build process of an image
|
40
34
|
|
41
|
-
def build
|
35
|
+
def build(environment, build_config)
|
36
|
+
build_executor = BuildExecutor.new(environment, build_config)
|
42
37
|
begin
|
43
|
-
execute_builder
|
38
|
+
execute_builder(build_executor)
|
44
39
|
rescue Exception => e
|
45
40
|
$logger.error e.message
|
46
41
|
ensure
|
47
|
-
ensure_builder
|
42
|
+
ensure_builder(build_executor)
|
48
43
|
end
|
49
44
|
end
|
50
45
|
|
51
|
-
|
46
|
+
private def execute_builder(build_executor)
|
47
|
+
build_executor.check
|
48
|
+
build_executor.prepare
|
49
|
+
build_executor.start
|
50
|
+
build_executor.build_image
|
51
|
+
build_executor.publish
|
52
|
+
build_executor.stop
|
53
|
+
build_executor.clean_up
|
52
54
|
end
|
53
55
|
|
54
|
-
|
56
|
+
private def ensure_builder(build_executor)
|
57
|
+
build_executor.ensure
|
55
58
|
end
|
56
59
|
|
57
60
|
end
|
61
|
+
|
58
62
|
end
|
59
63
|
end
|
@@ -18,31 +18,40 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
19
|
# SOFTWARE.
|
20
20
|
|
21
|
-
require_relative '../../spec_helper'
|
22
|
-
require 'rspec'
|
23
|
-
require 'pi_customizer/build/environment/environment_builder_factory'
|
24
|
-
require 'pi_customizer/build/environment/docker/docker'
|
25
|
-
require 'pi_customizer/build/environment/aws/aws'
|
26
|
-
|
27
21
|
module PiCustomizer
|
28
|
-
module
|
29
|
-
RSpec.describe 'environment_factory' do
|
22
|
+
module Config
|
30
23
|
|
31
|
-
|
32
|
-
|
33
|
-
expect(env).to be_a Vagrant
|
34
|
-
end
|
24
|
+
##
|
25
|
+
# BuildConfig holds all configurations for the build execution
|
35
26
|
|
36
|
-
|
37
|
-
|
38
|
-
|
27
|
+
class BuildConfig
|
28
|
+
attr_reader :skip_build_steps
|
29
|
+
|
30
|
+
def initialize(skip_build_steps = Array.new)
|
31
|
+
@skip_build_steps = convert_to_skip(skip_build_steps)
|
39
32
|
end
|
40
33
|
|
41
|
-
|
42
|
-
|
43
|
-
|
34
|
+
##
|
35
|
+
# check if a build step needs to be skipped
|
36
|
+
|
37
|
+
def skip?(build_step)
|
38
|
+
@skip_build_steps.include? build_step
|
44
39
|
end
|
45
40
|
|
41
|
+
##
|
42
|
+
# convert a list of stringified build steps to a list of symbols
|
43
|
+
|
44
|
+
private def convert_to_skip(skip_build_steps)
|
45
|
+
if skip_build_steps.nil?
|
46
|
+
skip_build_steps = Array.new
|
47
|
+
else
|
48
|
+
# convert every key to a symbol
|
49
|
+
skip_build_steps = skip_build_steps.collect(&:to_sym)
|
50
|
+
end
|
51
|
+
$logger.debug "Skipping the following build steps: #{skip_build_steps}"
|
52
|
+
skip_build_steps
|
53
|
+
end
|
46
54
|
end
|
55
|
+
|
47
56
|
end
|
48
57
|
end
|
@@ -28,17 +28,17 @@ module PiCustomizer
|
|
28
28
|
##
|
29
29
|
# The default path which points to the configuration file
|
30
30
|
|
31
|
-
DEFAULT_CONFIG_PATH = File.join(
|
31
|
+
DEFAULT_CONFIG_PATH = File.join(Dir.pwd, 'config.json')
|
32
32
|
|
33
33
|
##
|
34
34
|
# The default directory which is used to store temporary build files, e.g., the Vagrantfile for a build with vagrant
|
35
35
|
|
36
|
-
DEFAULT_LOCAL_WORKSPACE_DIRECTORY = Dir.pwd
|
36
|
+
DEFAULT_LOCAL_WORKSPACE_DIRECTORY = File.join(Dir.pwd, '/tmp')
|
37
37
|
|
38
38
|
##
|
39
|
-
# The LocalWorkspace class encapsulates the configuration of the
|
39
|
+
# The LocalWorkspace class encapsulates the configuration of the config on the machine where the build of the pi image is triggered
|
40
40
|
|
41
|
-
class
|
41
|
+
class LocalWorkspaceConfig
|
42
42
|
|
43
43
|
attr_reader :config_path, :workspace_directory, :modifier_gem_path
|
44
44
|
|
@@ -66,10 +66,10 @@ module PiCustomizer
|
|
66
66
|
|
67
67
|
private def workspace_directory=(workspace_directory)
|
68
68
|
@workspace_directory = if workspace_directory.nil? or workspace_directory == ''
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
69
|
+
Pathname.new(DEFAULT_LOCAL_WORKSPACE_DIRECTORY)
|
70
|
+
else
|
71
|
+
absolute_path_name(workspace_directory)
|
72
|
+
end
|
73
73
|
end
|
74
74
|
|
75
75
|
private def modifier_gem_path=(modifier_gem_path)
|
@@ -40,7 +40,7 @@ module PiCustomizer
|
|
40
40
|
DEFAULT_GIT_TAG = 'master'
|
41
41
|
|
42
42
|
##
|
43
|
-
# The RemoteWorkspace class encapsulates the configuration of the
|
43
|
+
# The RemoteWorkspace class encapsulates the configuration of the config in the build environment
|
44
44
|
|
45
45
|
class RemoteWorkspace
|
46
46
|
|
@@ -52,7 +52,7 @@ module PiCustomizer
|
|
52
52
|
$logger.info '[Build| Docker] customization of build sources'
|
53
53
|
system "sudo docker exec --tty \"$(cat cid)\" bash -c \"sudo pi_build_modifier modify #{CONFIG_PATH_IN_DOCKER}/resources.json #{@workspace.workspace_directory}\""
|
54
54
|
$logger.info '[Build| Docker] pi-image build step'
|
55
|
-
system "sudo docker exec --tty \"$(cat cid)\" bash -c \"cd #{@workspace.workspace_directory} && sudo ./build.sh\"" #sudo chown docker #{@
|
55
|
+
system "sudo docker exec --tty \"$(cat cid)\" bash -c \"cd #{@workspace.workspace_directory} && sudo ./build.sh\"" #sudo chown docker #{@config.workspace_directory} &&
|
56
56
|
end
|
57
57
|
|
58
58
|
def clean_up
|
@@ -18,26 +18,37 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
19
|
# SOFTWARE.
|
20
20
|
|
21
|
-
require 'pi_customizer/build/
|
21
|
+
require 'pi_customizer/build/environment/environment'
|
22
|
+
require 'pi_customizer/build/environment/vagrant/vagrant'
|
23
|
+
require 'pi_customizer/build/environment/docker/docker'
|
24
|
+
require 'pi_customizer/build/config/remote_workspace'
|
25
|
+
require 'pi_customizer/build/config/local_workspace'
|
26
|
+
require 'pi_customizer/utils/logex'
|
27
|
+
|
22
28
|
|
23
29
|
module PiCustomizer
|
24
|
-
module
|
25
|
-
class StartExecuteBuilder < PiBuilder
|
30
|
+
module Environment
|
26
31
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
@build_executor.prepare
|
31
|
-
@build_executor.build_image
|
32
|
-
@build_executor.publish
|
33
|
-
@build_executor.clean_up
|
34
|
-
@build_executor.stop
|
35
|
-
end
|
32
|
+
ENV_VAGRANT = 'VAGRANT'
|
33
|
+
ENV_DOCKER = 'DOCKER'
|
34
|
+
ENV_ECHO = 'ECHO'
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
end
|
36
|
+
##
|
37
|
+
# The environment_factory creates an environment controller tailored to the selected build environment env
|
40
38
|
|
39
|
+
def Environment.environment_factory(env, local_workspace, remote_workspace)
|
40
|
+
case env
|
41
|
+
when ENV_VAGRANT
|
42
|
+
environment = Vagrant.new(remote_workspace, local_workspace)
|
43
|
+
when ENV_DOCKER
|
44
|
+
environment = Docker.new(remote_workspace, local_workspace)
|
45
|
+
when ENV_ECHO
|
46
|
+
environment = EnvironmentControl.new(remote_workspace, local_workspace)
|
47
|
+
else
|
48
|
+
$logger.warn 'No valid environment (e.g., DOCKER or VAGRANT) defined!'
|
49
|
+
environment = EnvironmentControl.new(remote_workspace, local_workspace)
|
50
|
+
end
|
51
|
+
environment
|
41
52
|
end
|
42
53
|
end
|
43
|
-
end
|
54
|
+
end
|