pi_customizer 0.1.4.pre.alpha → 0.2.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/Gemfile +1 -4
- data/lib/pi_customizer.rb +13 -11
- data/lib/pi_customizer/builder/build_executor.rb +115 -0
- data/lib/pi_customizer/builder/builder.rb +9 -17
- data/lib/pi_customizer/builder/prepare_start_execute_builder.rb +10 -11
- data/lib/pi_customizer/builder/start_prepare_execute_builder.rb +10 -11
- data/lib/pi_customizer/environment/docker/docker.rb +4 -4
- data/lib/pi_customizer/environment/environment.rb +17 -9
- data/lib/pi_customizer/environment/environment_builder_factory.rb +5 -5
- data/lib/pi_customizer/environment/vagrant/templates/Vagrantfile.erb +3 -1
- data/lib/pi_customizer/environment/vagrant/vagrant.rb +4 -4
- data/lib/pi_customizer/environment/vagrant/vagrant_file.rb +14 -14
- data/lib/pi_customizer/version.rb +1 -1
- data/lib/pi_customizer/workspace/local_workspace.rb +11 -11
- data/lib/pi_customizer/workspace/remote_workspace.rb +3 -4
- data/{envs → resources}/config.json +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5dc9b4e7152770e5dbad6a7f8539e2e63ea3fe48
|
4
|
+
data.tar.gz: a336cd72baf1151fb86ed2bd5397f2be82c1cc9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11340fbf8960862852cd043351a85e98cc76595ce15387fd91e4135f81f042f7548c5bc35966f5abd1263eea037f65a70e491dace4b34a20297b4c7639f729f7
|
7
|
+
data.tar.gz: f31266d2b711aa37349b918b0cba741ac58b46f706ce3af0853795b0126352ea83934b4ad67042cc40f88828e943909247fdadb2bf8377931feddd59297fccbd
|
data/Gemfile
CHANGED
data/lib/pi_customizer.rb
CHANGED
@@ -24,6 +24,7 @@ require 'pi_customizer/version'
|
|
24
24
|
require 'pi_customizer/environment/environment_builder_factory'
|
25
25
|
require 'pi_customizer/workspace/remote_workspace'
|
26
26
|
require 'pi_customizer/workspace/local_workspace'
|
27
|
+
require 'pi_customizer/utils/logex'
|
27
28
|
|
28
29
|
module PiCustomizer
|
29
30
|
|
@@ -33,20 +34,21 @@ module PiCustomizer
|
|
33
34
|
class PiCustomizer < Thor
|
34
35
|
|
35
36
|
##
|
36
|
-
# The build command can be called to trigger a build of a pi image
|
37
|
+
# The build command can be called by a user to trigger a build of a pi image
|
37
38
|
|
38
39
|
desc 'build ENV', 'Build pi image on environment ENV (valid environments are DOCKER, AWS or VAGRANT).'
|
39
|
-
method_option :
|
40
|
-
method_option :
|
41
|
-
method_option :deploy_dir, :default => Dir.getwd, :aliases => '-d'
|
40
|
+
method_option :build_sources_git_url, :default => Workspace::DEFAULT_GIT_PATH, :aliases => '-g'
|
41
|
+
method_option :remote_workspace_dir, :default => Workspace::DEFAULT_REMOTE_WORKSPACE_DIRECTORY, :aliases => '-w'
|
42
42
|
method_option :config_file, :default => Workspace::DEFAULT_CONFIG_PATH, :aliases => '-c'
|
43
|
-
method_option :
|
44
|
-
method_option :
|
43
|
+
method_option :local_workspace_dir, :default => Workspace::DEFAULT_LOCAL_WORKSPACE_DIRECTORY, :aliases => '-t'
|
44
|
+
method_option :modifier_gem, :default => '', :aliases => '-m', :desc => 'Path to the modifier_gem. If not specified, the most recent gem from rubygems.org is downloaded.'
|
45
|
+
method_option :deploy_dir, :default => Dir.getwd, :aliases => '-d'
|
46
|
+
method_option :skip_steps, :type => :array, :aliases => '-s'
|
45
47
|
def build(env)
|
46
48
|
begin
|
47
|
-
remote_workspace = Workspace::RemoteWorkspace.new("#{options[:
|
48
|
-
local_workspace = Workspace::LocalWorkspace.new("#{options[:config_file]}", "#{options[:
|
49
|
-
builder = Environment::environment_builder_factory(env, local_workspace, remote_workspace)
|
49
|
+
remote_workspace = Workspace::RemoteWorkspace.new("#{options[:remote_workspace_dir]}", "#{options[:build_sources_git_url]}")
|
50
|
+
local_workspace = Workspace::LocalWorkspace.new("#{options[:config_file]}", "#{options[:local_workspace_dir]}", "#{options[:modifier_gem]}")
|
51
|
+
builder = Environment::environment_builder_factory(env, local_workspace, remote_workspace, options[:skip_steps])
|
50
52
|
builder.build
|
51
53
|
rescue Exception => e
|
52
54
|
$logger.error e.message
|
@@ -54,9 +56,9 @@ module PiCustomizer
|
|
54
56
|
end
|
55
57
|
|
56
58
|
##
|
57
|
-
# The version command
|
59
|
+
# The version command allows users to query for the current version of the pi_customizer gem. It is printed on the command line.
|
58
60
|
|
59
|
-
desc 'version', 'Shows the version number.'
|
61
|
+
desc 'v, version', 'Shows the version number.'
|
60
62
|
def version
|
61
63
|
puts VERSION
|
62
64
|
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
# Copyright (c) 2017 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/environment/environment_builder_factory'
|
22
|
+
require 'pi_customizer/utils/logex'
|
23
|
+
|
24
|
+
module PiCustomizer
|
25
|
+
module Builder
|
26
|
+
class BuildExecutor
|
27
|
+
|
28
|
+
attr_reader :env, :skip_build_steps
|
29
|
+
|
30
|
+
def initialize(environment, skip_build_steps = Array.new)
|
31
|
+
@env = environment
|
32
|
+
@skip_build_steps = convert_to_skip(skip_build_steps)
|
33
|
+
end
|
34
|
+
|
35
|
+
def check
|
36
|
+
check_env
|
37
|
+
@env.check
|
38
|
+
end
|
39
|
+
|
40
|
+
def prepare
|
41
|
+
unless @skip_build_steps.include?(:prepare)
|
42
|
+
@env.prepare
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def start
|
47
|
+
unless @skip_build_steps.include?(:start)
|
48
|
+
@env.start
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def build_image
|
53
|
+
unless @skip_build_steps.include?(:build_image)
|
54
|
+
@env.build_image
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def publish
|
59
|
+
unless @skip_build_steps.include?(:publish)
|
60
|
+
@env.publish
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def clean_up
|
65
|
+
unless @skip_build_steps.include?(:clean_up)
|
66
|
+
@env.clean_up
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def stop
|
71
|
+
unless @skip_build_steps.include?(:stop)
|
72
|
+
@env.stop
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def ensure
|
77
|
+
@env.ensure
|
78
|
+
end
|
79
|
+
|
80
|
+
private def convert_to_skip(skip_build_steps)
|
81
|
+
if skip_build_steps.nil?
|
82
|
+
skip_build_steps = Array.new
|
83
|
+
else
|
84
|
+
# convert every key to a symbol
|
85
|
+
skip_build_steps = skip_build_steps.collect {|k| k.to_sym}
|
86
|
+
end
|
87
|
+
$logger.debug "Skipping the following build steps: #{skip_build_steps}"
|
88
|
+
skip_build_steps
|
89
|
+
end
|
90
|
+
|
91
|
+
private def check_env
|
92
|
+
if @env.nil?
|
93
|
+
raise 'No environment specified, please specify the "environment", e.g. Vagrant'
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
@@ -19,40 +19,32 @@
|
|
19
19
|
# SOFTWARE.
|
20
20
|
|
21
21
|
require 'pi_customizer/environment/environment_builder_factory'
|
22
|
+
require 'pi_customizer/builder/build_executor'
|
22
23
|
|
23
24
|
module PiCustomizer
|
24
25
|
module Builder
|
25
26
|
class PiBuilder
|
26
27
|
|
27
|
-
|
28
|
-
|
28
|
+
attr_reader :build_executor
|
29
|
+
|
30
|
+
def initialize(environment, skip_build_steps)
|
31
|
+
@build_executor = BuildExecutor.new(environment,skip_build_steps)
|
29
32
|
end
|
30
33
|
|
31
34
|
def build
|
32
|
-
check_builder
|
33
35
|
begin
|
34
|
-
|
35
|
-
execute
|
36
|
+
execute_builder
|
36
37
|
rescue Exception => e
|
37
38
|
$logger.error e.message
|
38
39
|
ensure
|
39
|
-
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
protected def check_builder
|
44
|
-
if @env.nil?
|
45
|
-
raise 'No environment specified, please specify the "environment", e.g. Vagrant'
|
40
|
+
ensure_builder
|
46
41
|
end
|
47
42
|
end
|
48
43
|
|
49
|
-
protected def
|
50
|
-
end
|
51
|
-
|
52
|
-
protected def execute
|
44
|
+
protected def ensure_builder
|
53
45
|
end
|
54
46
|
|
55
|
-
protected def
|
47
|
+
protected def execute_builder
|
56
48
|
end
|
57
49
|
|
58
50
|
end
|
@@ -24,19 +24,18 @@ module PiCustomizer
|
|
24
24
|
module Builder
|
25
25
|
class PrepareExecuteBuilder < PiBuilder
|
26
26
|
|
27
|
-
protected def
|
28
|
-
@
|
29
|
-
@
|
30
|
-
@
|
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
|
31
35
|
end
|
32
36
|
|
33
|
-
protected def
|
34
|
-
@
|
35
|
-
end
|
36
|
-
|
37
|
-
protected def stop
|
38
|
-
@env.clean_up
|
39
|
-
@env.stop
|
37
|
+
protected def ensure_builder
|
38
|
+
@build_executor.ensure
|
40
39
|
end
|
41
40
|
|
42
41
|
end
|
@@ -24,19 +24,18 @@ module PiCustomizer
|
|
24
24
|
module Builder
|
25
25
|
class StartExecuteBuilder < PiBuilder
|
26
26
|
|
27
|
-
protected def
|
28
|
-
@
|
29
|
-
@
|
30
|
-
@
|
27
|
+
protected def execute_builder
|
28
|
+
@build_executor.check
|
29
|
+
@build_executor.start
|
30
|
+
@build_executor.prepare
|
31
|
+
@build_executor.build_image
|
32
|
+
@build_executor.publish
|
33
|
+
@build_executor.clean_up
|
34
|
+
@build_executor.stop
|
31
35
|
end
|
32
36
|
|
33
|
-
protected def
|
34
|
-
@
|
35
|
-
end
|
36
|
-
|
37
|
-
protected def stop
|
38
|
-
@env.clean_up
|
39
|
-
@env.stop
|
37
|
+
protected def ensure_builder
|
38
|
+
@build_executor.ensure
|
40
39
|
end
|
41
40
|
|
42
41
|
end
|
@@ -26,7 +26,7 @@ module PiCustomizer
|
|
26
26
|
|
27
27
|
DOCKERFILE_PATH = File.join(File.dirname(__FILE__), '/../../../../envs/docker')
|
28
28
|
DOCKERFILE = "#{DOCKERFILE_PATH}/Dockerfile"
|
29
|
-
CONFIG_PATH_IN_DOCKER = '/
|
29
|
+
CONFIG_PATH_IN_DOCKER = '/resources'
|
30
30
|
|
31
31
|
def check
|
32
32
|
|
@@ -50,7 +50,7 @@ module PiCustomizer
|
|
50
50
|
|
51
51
|
def build_image
|
52
52
|
$logger.info '[Build| Docker] customization of build sources'
|
53
|
-
system "sudo docker exec --tty \"$(cat cid)\" bash -c \"sudo pi_build_modifier modify #{CONFIG_PATH_IN_DOCKER}/
|
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
55
|
system "sudo docker exec --tty \"$(cat cid)\" bash -c \"cd #{@workspace.workspace_directory} && sudo ./build.sh\"" #sudo chown docker #{@workspace.workspace_directory} &&
|
56
56
|
end
|
@@ -74,9 +74,9 @@ module PiCustomizer
|
|
74
74
|
end
|
75
75
|
|
76
76
|
private def prepare_configuration
|
77
|
-
$logger.info "[Prepare | Docker] Copy the configuration file from #{@config.config_path} to #{CONFIG_PATH_IN_DOCKER}/
|
77
|
+
$logger.info "[Prepare | Docker] Copy the configuration file from #{@config.config_path} to #{CONFIG_PATH_IN_DOCKER}/resources.json in container"
|
78
78
|
system "docker exec --tty \"$(cat cid)\" bash -c \"sudo mkdir -p #{CONFIG_PATH_IN_DOCKER}\""
|
79
|
-
system "docker cp #{@config.config_path} \"$(cat cid)\":#{CONFIG_PATH_IN_DOCKER}/
|
79
|
+
system "docker cp #{@config.config_path} \"$(cat cid)\":#{CONFIG_PATH_IN_DOCKER}/resources.json"
|
80
80
|
gem_path = File.join(File.dirname(__FILE__), '/../../../../envs/pi_build_modifier.gem')
|
81
81
|
system "docker cp #{gem_path} \"$(cat cid)\":#{CONFIG_PATH_IN_DOCKER}/pi_build_modifier.gem"
|
82
82
|
system "docker exec --tty \"$(cat cid)\" bash -c \"sudo gem install #{CONFIG_PATH_IN_DOCKER}/pi_build_modifier.gem\""
|
@@ -26,33 +26,41 @@ module PiCustomizer
|
|
26
26
|
|
27
27
|
attr_reader :workspace, :config
|
28
28
|
|
29
|
-
def initialize(
|
30
|
-
@workspace =
|
31
|
-
@config =
|
29
|
+
def initialize(remote_workspace, local_workspace)
|
30
|
+
@workspace = remote_workspace
|
31
|
+
@config = local_workspace
|
32
32
|
end
|
33
33
|
|
34
34
|
def check
|
35
|
-
$logger.warn '[Check]
|
35
|
+
$logger.warn '[Check] skipped...'
|
36
36
|
end
|
37
37
|
|
38
38
|
def prepare
|
39
|
-
$logger.warn '[Prepare]
|
39
|
+
$logger.warn '[Prepare] skipped...'
|
40
40
|
end
|
41
41
|
|
42
42
|
def start
|
43
|
-
$logger.warn '[Start]
|
43
|
+
$logger.warn '[Start] skipped...'
|
44
44
|
end
|
45
45
|
|
46
46
|
def build_image
|
47
|
-
$logger.warn '[Build Image]
|
47
|
+
$logger.warn '[Build Image] skipped...'
|
48
|
+
end
|
49
|
+
|
50
|
+
def publish
|
51
|
+
$logger.warn '[Publish] skipped...'
|
48
52
|
end
|
49
53
|
|
50
54
|
def clean_up
|
51
|
-
$logger.warn '[Clean up]
|
55
|
+
$logger.warn '[Clean up] skipped...'
|
52
56
|
end
|
53
57
|
|
54
58
|
def stop
|
55
|
-
$logger.warn '[Stop]
|
59
|
+
$logger.warn '[Stop] skipped...'
|
60
|
+
end
|
61
|
+
|
62
|
+
def ensure
|
63
|
+
$logger.info '[Ensure] skipped...'
|
56
64
|
end
|
57
65
|
|
58
66
|
end
|
@@ -38,16 +38,16 @@ module PiCustomizer
|
|
38
38
|
ENV_DOCKER = 'DOCKER'
|
39
39
|
ENV_ECHO = 'ECHO'
|
40
40
|
|
41
|
-
def Environment.environment_builder_factory(env, local_workspace, remote_workspace)
|
41
|
+
def Environment.environment_builder_factory(env, local_workspace, remote_workspace, skip_build_steps)
|
42
42
|
|
43
43
|
environment = environment_factory(env, local_workspace, remote_workspace)
|
44
44
|
|
45
45
|
case env
|
46
46
|
when ENV_AWS, ENV_VAGRANT
|
47
|
-
env_builder = Builder::PrepareExecuteBuilder.new(environment)
|
47
|
+
env_builder = Builder::PrepareExecuteBuilder.new(environment, skip_build_steps)
|
48
48
|
when ENV_DOCKER, ENV_ECHO
|
49
|
-
puts "Echo: - Git Path: #{remote_workspace.git_path}, Workspace Path: #{remote_workspace.workspace_directory}, Config Path: #{local_workspace.config_path}"
|
50
|
-
env_builder = Builder::StartExecuteBuilder.new(environment)
|
49
|
+
puts "Echo: - Git Path: #{remote_workspace.git_path}, Workspace Path: #{remote_workspace.workspace_directory}, Config Path: #{local_workspace.config_path}, #{skip_build_steps}"
|
50
|
+
env_builder = Builder::StartExecuteBuilder.new(environment, skip_build_steps)
|
51
51
|
else
|
52
52
|
$logger.warn 'No valid build environment defined!'
|
53
53
|
env_builder = Builder::PiBuilder.new(environment)
|
@@ -66,7 +66,7 @@ module PiCustomizer
|
|
66
66
|
when ENV_ECHO
|
67
67
|
environment = EnvironmentControl.new(remote_workspace, local_workspace)
|
68
68
|
else
|
69
|
-
$logger.info '
|
69
|
+
$logger.info 'No valid environment (e.g., AWS or VAGRANT) defined!'
|
70
70
|
environment = EnvironmentControl.new(remote_workspace, local_workspace)
|
71
71
|
end
|
72
72
|
environment
|
@@ -6,6 +6,7 @@ sudo apt update
|
|
6
6
|
sudo apt -y upgrade
|
7
7
|
sudo apt -y install quilt parted qemu-user-static debootstrap zerofree pxz zip dosfstools libcap2-bin bsdtar
|
8
8
|
sudo apt -y install git curl ruby-full build-essential
|
9
|
+
sudo apt -y install wpasupplicant openssl libssl-dev
|
9
10
|
SCRIPT
|
10
11
|
|
11
12
|
$install_modifier_gem = <<SCRIPT
|
@@ -29,7 +30,8 @@ $modify = <<SCRIPT
|
|
29
30
|
cd <%= workspace.workspace_directory %>
|
30
31
|
pi_build_modifier modify <%= config_file_destination %> <%= workspace.workspace_directory %>
|
31
32
|
sudo ./build.sh
|
32
|
-
cp -r deploy /vagrant
|
33
|
+
cp -r <%= workspace.workspace_directory %>/deploy /vagrant
|
34
|
+
echo "Pi Image copied to your local workspace <%= config.workspace_directory.to_s %>"
|
33
35
|
SCRIPT
|
34
36
|
|
35
37
|
Vagrant.configure('2') do |config|
|
@@ -19,7 +19,7 @@
|
|
19
19
|
# SOFTWARE.
|
20
20
|
|
21
21
|
require 'fileutils'
|
22
|
-
|
22
|
+
require 'pi_customizer/environment/vagrant/vagrant_file'
|
23
23
|
require 'pi_customizer/utils/logex'
|
24
24
|
require 'pi_customizer/environment/environment'
|
25
25
|
|
@@ -41,7 +41,7 @@ module PiCustomizer
|
|
41
41
|
|
42
42
|
def start
|
43
43
|
$logger.info '[Start] pi-image in local vagrant environment'
|
44
|
-
Dir.chdir(@config.
|
44
|
+
Dir.chdir(@config.workspace_directory) do
|
45
45
|
system 'vagrant destroy -f' # cleanup old environment
|
46
46
|
system 'vagrant up --provider=virtualbox --no-provision'
|
47
47
|
end
|
@@ -49,7 +49,7 @@ module PiCustomizer
|
|
49
49
|
|
50
50
|
def build_image
|
51
51
|
$logger.info '[Build] pi-image in local vagrant environment'
|
52
|
-
Dir.chdir(@config.
|
52
|
+
Dir.chdir(@config.workspace_directory) do
|
53
53
|
system 'vagrant provision'
|
54
54
|
end
|
55
55
|
end
|
@@ -60,7 +60,7 @@ module PiCustomizer
|
|
60
60
|
|
61
61
|
def stop
|
62
62
|
$logger.info '[Stop] pi-image in local vagrant environment'
|
63
|
-
Dir.chdir(@config.
|
63
|
+
Dir.chdir(@config.workspace_directory) do
|
64
64
|
system 'vagrant destroy -f'
|
65
65
|
end
|
66
66
|
end
|
@@ -27,7 +27,7 @@ module PiCustomizer
|
|
27
27
|
module Environment
|
28
28
|
|
29
29
|
##
|
30
|
-
# VagrantFile describes the dynamic attributes of
|
30
|
+
# VagrantFile describes the dynamic attributes of a Vagrantfile which is used to start up the vagrant environment
|
31
31
|
|
32
32
|
class VagrantFile
|
33
33
|
|
@@ -36,17 +36,17 @@ module PiCustomizer
|
|
36
36
|
def initialize(config, workspace)
|
37
37
|
@vagrant_template_path = File.join(File.dirname(__FILE__), '/templates/Vagrantfile.erb')
|
38
38
|
@disk_size = '40GB'
|
39
|
-
@config_file_destination = '/vagrant/
|
40
|
-
if config.nil?
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
if workspace.nil?
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
39
|
+
@config_file_destination = '/vagrant/config.json'
|
40
|
+
@config = if config.nil?
|
41
|
+
Workspace::LocalWorkspace.new
|
42
|
+
else
|
43
|
+
config
|
44
|
+
end
|
45
|
+
@workspace = if workspace.nil?
|
46
|
+
Workspace::RemoteWorkspace.new
|
47
|
+
else
|
48
|
+
workspace
|
49
|
+
end
|
50
50
|
end
|
51
51
|
|
52
52
|
def get_binding
|
@@ -85,8 +85,8 @@ module PiCustomizer
|
|
85
85
|
end
|
86
86
|
|
87
87
|
private def write_vagrantfile
|
88
|
-
FileUtils.mkdir_p @vagrant_file.config.
|
89
|
-
File.open(@vagrant_file.config.
|
88
|
+
FileUtils.mkdir_p @vagrant_file.config.workspace_directory
|
89
|
+
File.open(@vagrant_file.config.workspace_directory.to_s + '/Vagrantfile', 'w+') do |f|
|
90
90
|
f.write(render)
|
91
91
|
end
|
92
92
|
end
|
@@ -28,32 +28,32 @@ module PiCustomizer
|
|
28
28
|
##
|
29
29
|
# The default path which points to the configuration file
|
30
30
|
|
31
|
-
DEFAULT_CONFIG_PATH = File.join(File.dirname(__FILE__), '/../../../
|
31
|
+
DEFAULT_CONFIG_PATH = File.join(File.dirname(__FILE__), '/../../../resources/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
|
-
|
36
|
+
DEFAULT_LOCAL_WORKSPACE_DIRECTORY = Dir.pwd + '/tmp'
|
37
37
|
|
38
38
|
##
|
39
39
|
# The LocalWorkspace class encapsulates the configuration of the workspace on the machine where the build of the pi image is triggered
|
40
40
|
|
41
41
|
class LocalWorkspace
|
42
42
|
|
43
|
-
attr_reader :config_path, :
|
43
|
+
attr_reader :config_path, :workspace_directory, :modifier_gem_path
|
44
44
|
|
45
|
-
def initialize(config_path = '',
|
45
|
+
def initialize(config_path = '', workspace_directory = '', modifier_gem_path = '')
|
46
46
|
self.config_path = config_path
|
47
|
-
self.
|
47
|
+
self.workspace_directory = workspace_directory
|
48
48
|
self.modifier_gem_path = modifier_gem_path
|
49
|
-
$logger.debug "Local Workspace is at '#{@config_path}' with tmp directory '#{@
|
49
|
+
$logger.debug "Local Workspace is at '#{@config_path}' with tmp directory '#{@workspace_directory}' and modifier_gem_path '#{@modifier_gem_path}'"
|
50
50
|
end
|
51
51
|
|
52
52
|
##
|
53
53
|
# Checks for value equality between a pair of LocalWorkspace's attributes
|
54
54
|
|
55
55
|
def ==(other)
|
56
|
-
(@
|
56
|
+
(@workspace_directory == other.workspace_directory) && (@modifier_gem_path == other.modifier_gem_path) && (@config_path == other.config_path)
|
57
57
|
end
|
58
58
|
|
59
59
|
private def config_path=(config_path)
|
@@ -64,11 +64,11 @@ module PiCustomizer
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
private def
|
68
|
-
@
|
69
|
-
Pathname.new(
|
67
|
+
private def workspace_directory=(workspace_directory)
|
68
|
+
@workspace_directory = if workspace_directory.nil? or workspace_directory == ''
|
69
|
+
Pathname.new(DEFAULT_LOCAL_WORKSPACE_DIRECTORY)
|
70
70
|
else
|
71
|
-
absolute_path_name(
|
71
|
+
absolute_path_name(workspace_directory)
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
@@ -24,7 +24,7 @@ require 'pi_customizer/utils/logex'
|
|
24
24
|
module PiCustomizer
|
25
25
|
module Workspace
|
26
26
|
|
27
|
-
|
27
|
+
DEFAULT_REMOTE_WORKSPACE_DIRECTORY = '/build/pi-gen'
|
28
28
|
DEFAULT_GIT_PATH = 'https://github.com/ottenwbe/pi-gen.git'
|
29
29
|
|
30
30
|
##
|
@@ -35,9 +35,8 @@ module PiCustomizer
|
|
35
35
|
attr_reader :git_path, :workspace_directory
|
36
36
|
|
37
37
|
def initialize(workspace_dir = '', git_path = '')
|
38
|
-
$logger.debug "Workspace at '#{workspace_dir}' with source '#{git_path}'"
|
39
38
|
@workspace_directory = if workspace_dir.nil? or workspace_dir == ''
|
40
|
-
|
39
|
+
DEFAULT_REMOTE_WORKSPACE_DIRECTORY
|
41
40
|
else
|
42
41
|
workspace_dir.to_s
|
43
42
|
end
|
@@ -46,7 +45,7 @@ module PiCustomizer
|
|
46
45
|
else
|
47
46
|
git_path.to_s
|
48
47
|
end
|
49
|
-
$logger.debug "Workspace at '#{@workspace_directory}' with
|
48
|
+
$logger.debug "Workspace at '#{@workspace_directory}' with sources from '#{@git_path}'"
|
50
49
|
end
|
51
50
|
|
52
51
|
##
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pi_customizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0.pre.alpha
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Beate Ottenwälder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -111,11 +111,11 @@ files:
|
|
111
111
|
- envs/aws/outputs.tf
|
112
112
|
- envs/aws/pi-build-env.tf
|
113
113
|
- envs/aws/variables.tf
|
114
|
-
- envs/config.json
|
115
114
|
- envs/docker/Dockerfile
|
116
115
|
- envs/pi_build_modifier.gem
|
117
116
|
- envs/sh/build-pi-img.sh
|
118
117
|
- lib/pi_customizer.rb
|
118
|
+
- lib/pi_customizer/builder/build_executor.rb
|
119
119
|
- lib/pi_customizer/builder/builder.rb
|
120
120
|
- lib/pi_customizer/builder/prepare_start_execute_builder.rb
|
121
121
|
- lib/pi_customizer/builder/start_prepare_execute_builder.rb
|
@@ -131,6 +131,7 @@ files:
|
|
131
131
|
- lib/pi_customizer/workspace/local_workspace.rb
|
132
132
|
- lib/pi_customizer/workspace/remote_workspace.rb
|
133
133
|
- pi_customizer.gemspec
|
134
|
+
- resources/config.json
|
134
135
|
homepage: https://github.com/ottenwbe/pi-gen-environment.git
|
135
136
|
licenses:
|
136
137
|
- MIT
|