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.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/CODE_OF_CONDUCT.md +1 -1
  4. data/README.md +55 -20
  5. data/Rakefile +6 -5
  6. data/docs/concept.md +0 -18
  7. data/docs/incubation.md +3 -14
  8. data/pi_build_modifier/Gemfile.lock +50 -0
  9. data/pi_build_modifier/lib/pi_build_modifier.rb +4 -7
  10. data/pi_build_modifier/lib/pi_build_modifier/modify/configs.rb +335 -0
  11. data/pi_build_modifier/lib/pi_build_modifier/modify/modifiers.rb +281 -0
  12. data/pi_build_modifier/lib/pi_build_modifier/{locale → modify}/templates/00-debconf.erb +1 -1
  13. data/pi_build_modifier/lib/pi_build_modifier/{boot-files → modify}/templates/07-resize-init.diff.erb +1 -1
  14. data/pi_build_modifier/lib/pi_build_modifier/{net-tweaks → modify}/templates/wpa_supplicant.conf.erb +1 -1
  15. data/pi_build_modifier/lib/pi_build_modifier/{config → utils}/logex.rb +5 -1
  16. data/pi_build_modifier/lib/pi_build_modifier/version.rb +1 -1
  17. data/pi_build_modifier/spec/pi_build_modifier/modify/modify_spec.rb +306 -0
  18. data/pi_build_modifier/spec/pi_build_modifier_spec.rb +3 -3
  19. data/pi_build_modifier/spec/spec_helper.rb +1 -0
  20. data/pi_customizer/Gemfile.lock +47 -0
  21. data/pi_customizer/lib/pi_customizer.rb +15 -9
  22. data/pi_customizer/lib/pi_customizer/build/builder/build_executor.rb +12 -24
  23. data/pi_customizer/lib/pi_customizer/build/builder/builder.rb +17 -13
  24. data/pi_customizer/{spec/pi_customizer/environment/environment_builder_factory_spec.rb → lib/pi_customizer/build/config/build_config.rb} +27 -18
  25. data/pi_customizer/lib/pi_customizer/build/{workspace → config}/local_workspace.rb +8 -8
  26. data/pi_customizer/lib/pi_customizer/build/{workspace → config}/remote_workspace.rb +1 -1
  27. data/pi_customizer/lib/pi_customizer/build/environment/docker/docker.rb +1 -1
  28. data/pi_customizer/lib/pi_customizer/build/environment/environment.rb +1 -1
  29. data/pi_customizer/lib/pi_customizer/build/{builder/start_prepare_execute_builder.rb → environment/environment_factory.rb} +27 -16
  30. data/pi_customizer/lib/pi_customizer/build/environment/vagrant/templates/Vagrantfile.erb +2 -2
  31. data/pi_customizer/lib/pi_customizer/build/environment/vagrant/vagrant.rb +3 -8
  32. data/pi_customizer/lib/pi_customizer/build/environment/vagrant/vagrant_file.rb +3 -3
  33. data/pi_customizer/lib/pi_customizer/version.rb +1 -1
  34. data/pi_customizer/lib/pi_customizer/write/image_writer.rb +3 -2
  35. data/pi_customizer/spec/pi_customizer/build/builder/builder_spec.rb +122 -0
  36. data/pi_customizer/spec/pi_customizer/{environment/aws_spec.rb → build/config/build_config_spec.rb} +20 -25
  37. data/pi_customizer/spec/pi_customizer/{workspace/local_workspace_spec.rb → build/config/local_workspace_config_spec.rb} +10 -10
  38. data/pi_customizer/spec/pi_customizer/{workspace → build/config}/remote_workspace_spec.rb +2 -2
  39. data/pi_customizer/spec/pi_customizer/{environment/vagrant/vagrant_spec.rb → build/environment/environment_builder_factory_spec.rb} +17 -13
  40. data/pi_customizer/spec/pi_customizer/{environment → build/environment}/environment_spec.rb +1 -1
  41. data/pi_customizer/spec/pi_customizer/{environment → build/environment}/vagrant/vagrant_file_spec.rb +7 -7
  42. data/pi_customizer/spec/pi_customizer/build/environment/vagrant/vagrant_spec.rb +80 -0
  43. data/pi_customizer/spec/pi_customizer_spec.rb +19 -14
  44. data/pi_customizer/spec/spec_helper.rb +21 -0
  45. data/version.rb +1 -1
  46. metadata +23 -42
  47. data/Vagrantfile +0 -27
  48. data/pi_build_modifier/.gitignore +0 -12
  49. data/pi_build_modifier/lib/pi_build_modifier/boot-files/boot.rb +0 -64
  50. data/pi_build_modifier/lib/pi_build_modifier/locale/locale_debconf.rb +0 -66
  51. data/pi_build_modifier/lib/pi_build_modifier/modifier/erb_mapper.rb +0 -72
  52. data/pi_build_modifier/lib/pi_build_modifier/modifier/mapper.rb +0 -49
  53. data/pi_build_modifier/lib/pi_build_modifier/modifier/pi_modifier.rb +0 -81
  54. data/pi_build_modifier/lib/pi_build_modifier/modifier_task.rb +0 -79
  55. data/pi_build_modifier/lib/pi_build_modifier/net-tweaks/wifi_network.rb +0 -124
  56. data/pi_build_modifier/lib/pi_build_modifier/sys_tweaks/run_modifier.rb +0 -63
  57. data/pi_build_modifier/lib/pi_build_modifier/sys_tweaks/ssh.rb +0 -61
  58. data/pi_build_modifier/lib/pi_build_modifier/sys_tweaks/templates/ssh.sh.erb +0 -8
  59. data/pi_build_modifier/lib/pi_build_modifier/system/system_type.rb +0 -84
  60. data/pi_build_modifier/spec/pi_build_modifier/boot/boot_spec.rb +0 -103
  61. data/pi_build_modifier/spec/pi_build_modifier/locale/locale_spec.rb +0 -87
  62. data/pi_build_modifier/spec/pi_build_modifier/modifier/mapper_spec.rb +0 -105
  63. data/pi_build_modifier/spec/pi_build_modifier/modifier/modifier_spec.rb +0 -83
  64. data/pi_build_modifier/spec/pi_build_modifier/modifier_task_spec.rb +0 -63
  65. data/pi_build_modifier/spec/pi_build_modifier/net-tweaks/wifi_network_spec.rb +0 -91
  66. data/pi_build_modifier/spec/pi_build_modifier/sys_tweaks/run_modifier_spec.rb +0 -74
  67. data/pi_build_modifier/spec/pi_build_modifier/sys_tweaks/ssh_spec.rb +0 -73
  68. data/pi_build_modifier/spec/pi_build_modifier/system/system_spec.rb +0 -66
  69. data/pi_customizer/lib/pi_customizer/build/builder/prepare_start_execute_builder.rb +0 -43
  70. data/pi_customizer/lib/pi_customizer/build/environment/aws/aws.rb +0 -76
  71. data/pi_customizer/lib/pi_customizer/build/environment/environment_builder_factory.rb +0 -81
  72. data/pi_customizer/spec/pi_customizer/builder/build_executor_spec.rb +0 -64
@@ -1,72 +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 'json'
22
- require 'pathname'
23
- require 'fileutils'
24
- require 'pi_build_modifier/modifier/mapper'
25
-
26
- module PiBuildModifier
27
- class ERBMapper < Mapper
28
-
29
- def initialize(data, working_dir)
30
- if data.nil?
31
- raise 'Cannot initialize ERBMapper, since no valid object for mapping is given.'
32
- end
33
- @data = data
34
- @template_path = @data.template_path
35
- @output_path = working_dir + '/' + @data.relative_output_path
36
- end
37
-
38
- def check(json_data)
39
- @data.check(json_data)
40
- end
41
-
42
- def map(json_data)
43
- @data.map(json_data)
44
- end
45
-
46
- def modify
47
- read_template
48
- create_conf
49
- end
50
-
51
- private def read_template
52
- File.open(@template_path.to_s, 'r+') do |f|
53
- @template = f.read
54
- end
55
- end
56
-
57
- def render
58
- ERB.new(@template).result(@data.get_binding)
59
- end
60
-
61
- private def create_conf
62
-
63
- puts "create dir at #{@output_path}"
64
-
65
- FileUtils.mkdir_p File.dirname @output_path
66
-
67
- File.open(@output_path, 'w+') do |f|
68
- f.write(render)
69
- end
70
- end
71
- end
72
- end
@@ -1,49 +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
- module PiBuildModifier
22
-
23
- ##
24
- # Mapper represents a container that is used by the pi_build_modifier to call
25
- # the necessary steps to modify a build configuration.
26
- # It triggers check, mapping, and modification steps for one build configuration.
27
-
28
- class Mapper
29
-
30
- attr_reader :data
31
-
32
- def initialize(data)
33
- @data = data
34
- end
35
-
36
- def check(json_data)
37
- @data.check(json_data) unless @data.nil?
38
- end
39
-
40
- def map(json_data)
41
- @data.map(json_data) unless @data.nil?
42
- end
43
-
44
- def modify
45
- @data.modify unless @data.nil?
46
- end
47
-
48
- end
49
- 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 'json'
22
-
23
- module PiBuildModifier
24
- class PiModifier
25
-
26
- attr_reader :mappers
27
-
28
- def initialize
29
- @mappers = Array.new
30
- @json_path = nil
31
- @json_data = nil
32
- end
33
-
34
- def with_json_configuration(json_file)
35
- @json_path = json_file
36
- end
37
-
38
- def with_mapper(mapper)
39
- if mapper.is_a? Mapper
40
- @mappers << mapper
41
- else
42
- raise 'Parameter must be of type Mapper'
43
- end
44
- end
45
-
46
- def modify(do_check = false)
47
- load_config
48
- check_all if do_check
49
- map_all
50
- modify_all
51
- end
52
-
53
- private def load_config
54
- if File.file?(@json_path)
55
- File.open(@json_path, 'r+') do |f|
56
- @json_data = JSON.parse(f.read)
57
- end
58
- else
59
- raise "Json configuration file does not exist at '#{@json_path}!'"
60
- end
61
- end
62
-
63
- private def check_all
64
- @mappers.each do |mapper|
65
- mapper.check(@json_data)
66
- end
67
- end
68
-
69
- private def map_all
70
- @mappers.each do |mapper|
71
- mapper.map(@json_data)
72
- end
73
- end
74
-
75
- private def modify_all
76
- @mappers.each do |mapper|
77
- mapper.modify
78
- end
79
- end
80
- end
81
- end
@@ -1,79 +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_build_modifier/modifier/pi_modifier'
22
- require 'pi_build_modifier/modifier/erb_mapper'
23
- require 'pi_build_modifier/net-tweaks/wifi_network'
24
- require 'pi_build_modifier/system/system_type'
25
- require 'pi_build_modifier/sys_tweaks/run_modifier'
26
- require 'pi_build_modifier/sys_tweaks/ssh'
27
- require 'pi_build_modifier/locale/locale_debconf'
28
- require 'pi_build_modifier/boot-files/boot'
29
-
30
- module PiBuildModifier
31
- module Task
32
-
33
- ##
34
- # Modifier triggers all changes specified in the config. To this end,
35
- # it configures and calls specialized mappers which map the config to
36
- # the the individual pi-gen build scripts.
37
-
38
- class Modifier
39
-
40
- attr_reader :pi_modifier
41
-
42
- ##
43
- # Initialization and configuration of the mappers that are used to change in the pi-gen build sources
44
-
45
- def initialize(config, workspace, pi_modifier = PiModifier.new)
46
- @mappers = create_mappers
47
- @pi_modifier = pi_modifier
48
- configure_pi_modifier(config, workspace)
49
- end
50
-
51
- ##
52
- # Defines all mappers
53
-
54
- private def create_mappers
55
- mappers = {
56
- :wpa_supplicant => WPASupplicant.new,
57
- :system => System.new,
58
- :ssh => Ssh.new,
59
- :run_modifier => RunModifier.new,
60
- :locale => Locale.new,
61
- :boot => Boot.new
62
- }
63
- mappers[:run_modifier].append(mappers[:ssh]) #TODO: This connection has to be established somewhere else
64
- mappers
65
- end
66
-
67
- private def configure_pi_modifier(config, workspace)
68
- @pi_modifier.with_json_configuration(config)
69
- @mappers.each do |*, mapper_data|
70
- @pi_modifier.with_mapper(mapper_data.mapper(workspace))
71
- end
72
- end
73
-
74
- def execute
75
- @pi_modifier.modify
76
- end
77
- end
78
- end
79
- end
@@ -1,124 +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 'erb'
22
- require 'json'
23
- require 'openssl'
24
- require 'pi_build_modifier/modifier/erb_mapper'
25
-
26
- module PiBuildModifier
27
-
28
- ##
29
- # WifiNetwork represents a network in the wpa_supplicant configuration
30
-
31
- class WifiNetwork
32
-
33
- attr_reader :ssid, :psk
34
-
35
- def initialize(ssid, psk)
36
- @ssid = ssid
37
- @psk = psk
38
- end
39
-
40
- def to_s
41
- sprintf('{
42
- ssid="%s"
43
- psk=%s
44
- }', ssid, psk)
45
- end
46
- end
47
-
48
- ##
49
- # WPASupplicant represents the wpa_supplicant's configuration
50
-
51
- class WPASupplicant
52
-
53
- PASSPHRASE = 'passphrase'
54
-
55
- WPA_PASSPHRASE = 'wpa_passphrase'
56
-
57
- SSID = 'ssid'
58
-
59
- attr_reader :template_path, :relative_output_path
60
-
61
- ##
62
- # By default, WPASupplicant is configured with:
63
- # wpa_country: DE
64
- # template: './templates/wpa_supplicant.conf.erb'
65
- # output path: 'stage2/02-net-tweaks/files/wpa_supplicant.conf'
66
-
67
- def initialize
68
- @networks = map_network(nil)
69
- @wpa_country = 'DE'
70
- @template_path = File.join(File.dirname(__FILE__), '/templates/wpa_supplicant.conf.erb').to_s
71
- @relative_output_path = 'stage2/02-net-tweaks/files/wpa_supplicant.conf'
72
- end
73
-
74
- def mapper(workspace)
75
- ERBMapper.new(self, workspace)
76
- end
77
-
78
- #TODO: test
79
- def check(json_data)
80
- unless File.file?(@relative_output_path)
81
- raise "File #{relative_output_path} does not exist"
82
- end
83
- end
84
-
85
- ##
86
- # map the 'wifi' section in the json configuration to the instance variables.
87
-
88
- def map(json_data)
89
- unless json_data.nil?
90
- @networks = map_network(json_data['wifi']) if json_data.has_key?('wifi')
91
- @wpa_country = json_data['wifi']['wpa_country'] if json_data.has_key?('wifi') && json_data['wifi'].has_key?('wpa_country')
92
- end
93
- end
94
-
95
- private def map_network(json_data)
96
- if json_data.nil? or not json_data.has_key?('networks')
97
- networks = Array.new(0)
98
- else
99
- networks = json_data['networks'].map do |rd|
100
- ssid = if rd.has_key?(SSID)
101
- rd[SSID]
102
- else
103
- 'no_ssid'
104
- end
105
- psk = if rd.has_key?(PASSPHRASE)
106
- OpenSSL::PKCS5.pbkdf2_hmac_sha1(rd[PASSPHRASE], ssid, 4096, 32).unpack("H*").first
107
- elsif rd.has_key?(WPA_PASSPHRASE)
108
- rd[WPA_PASSPHRASE]
109
- else
110
- 'no_psk'
111
- end
112
- WifiNetwork.new(ssid, psk)
113
- end
114
- end
115
- networks
116
- end
117
-
118
- def get_binding
119
- binding
120
- end
121
-
122
- end
123
- end
124
-
@@ -1,63 +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_build_modifier/modifier/mapper'
23
-
24
-
25
- module PiBuildModifier
26
-
27
- ##
28
- # RunModifier is a class which appends lines to the sys-tweaks run file in the pi-gen build directory.
29
- # By default this is the file 'stage2/01-sys-tweaks/01-run.sh'.
30
-
31
- class RunModifier < Mapper
32
-
33
- attr_reader :relative_output_path, :appender
34
-
35
- def initialize
36
- @appender = Array.new
37
- @workspace = nil
38
- @relative_output_path = 'stage2/01-sys-tweaks/01-run.sh'
39
- end
40
-
41
- def mapper(workspace)
42
- @workspace = workspace
43
- self
44
- end
45
-
46
- def append(appender)
47
- @appender << appender
48
- end
49
-
50
- ##
51
- # modify the sys-tweaks run file by adding lines at the end of the file
52
-
53
- def modify
54
- open("#{@workspace}/#{@relative_output_path}", 'a') do |f|
55
- f.puts ''
56
- @appender.each do |a|
57
- f.puts "source #{@workspace}/#{a.append_line}"
58
- end
59
- end
60
- end
61
-
62
- end
63
- end