pi_build_modifier 0.1.1.pre.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +6 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +3 -0
- data/Rakefile +13 -0
- data/bin/pi_build_modifier +5 -0
- data/lib/pi_build_modifier.rb +41 -0
- data/lib/pi_build_modifier/modifier/erb_mapper.rb +68 -0
- data/lib/pi_build_modifier/modifier/mapper.rb +44 -0
- data/lib/pi_build_modifier/modifier/pi_modifier.rb +74 -0
- data/lib/pi_build_modifier/modifier_task.rb +49 -0
- data/lib/pi_build_modifier/net-tweaks/templates/wpa_supplicant.conf.erb +7 -0
- data/lib/pi_build_modifier/net-tweaks/wifi_network.rb +68 -0
- data/lib/pi_build_modifier/sys_tweaks/run_modifier.rb +58 -0
- data/lib/pi_build_modifier/sys_tweaks/ssh.rb +53 -0
- data/lib/pi_build_modifier/sys_tweaks/templates/ssh.sh.erb +8 -0
- data/lib/pi_build_modifier/system/system_type.rb +80 -0
- data/lib/pi_build_modifier/version.rb +23 -0
- data/pi_build_modifier.gemspec +31 -0
- metadata +163 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f1caec8f16b318afe28de0761d2ec6095114cd20
|
4
|
+
data.tar.gz: 2115fd2138d16d95f30e648d4a11f778cf8ed48d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9af6f92c78bec16c33d337d9186a6d1277a1aa2a76489ffbe06f8eb6fe8fd6c5fc254ea09ff649e1dae10dc4b02ae88c8edb99921636597b3b47dae2d71618e9
|
7
|
+
data.tar.gz: 1fb2bf4dfa3fa21a2dac4974aa2057bc4142e428562b5fd52e2be422a9ec250fa0e1b91124e37f9068235366e273b791dfa130818a38fd9364d3326d5dc16840
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Beate Ottenwälder
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
lib = File.join(File.dirname(__FILE__), '/lib')
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'bundler/gem_tasks'
|
6
|
+
require 'rspec/core/rake_task'
|
7
|
+
|
8
|
+
RSpec::Core::RakeTask.new(:spec)
|
9
|
+
|
10
|
+
task :default => :spec
|
11
|
+
rescue LoadError
|
12
|
+
puts 'RSpec or Bundler is not installed. This means rake is not able to execute tests!'
|
13
|
+
end
|
@@ -0,0 +1,41 @@
|
|
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 'thor'
|
22
|
+
require 'pi_build_modifier/net-tweaks/wifi_network'
|
23
|
+
require 'pi_build_modifier/modifier/erb_mapper'
|
24
|
+
require 'pi_build_modifier/version'
|
25
|
+
require 'pi_build_modifier/modifier_task'
|
26
|
+
|
27
|
+
module PiBuildModifier
|
28
|
+
class PiBuildModifier < Thor
|
29
|
+
|
30
|
+
desc 'modify CONFIG WORKSPACE', 'Modify the pi image sources at the specified WORKSPACE with the specified configuration file.'
|
31
|
+
def modify(config, workspace)
|
32
|
+
task = Task::Modifier.new(config, workspace)
|
33
|
+
task.execute
|
34
|
+
end
|
35
|
+
|
36
|
+
desc 'version', 'Show the version of the modifier.'
|
37
|
+
def version
|
38
|
+
puts VERSION
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,68 @@
|
|
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 '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 map(json_data)
|
39
|
+
@data.map(json_data)
|
40
|
+
end
|
41
|
+
|
42
|
+
def modify
|
43
|
+
read_template
|
44
|
+
create_conf
|
45
|
+
end
|
46
|
+
|
47
|
+
private def read_template
|
48
|
+
File.open(@template_path.to_s, 'r+') do |f|
|
49
|
+
@template = f.read
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def render
|
54
|
+
ERB.new(@template).result(@data.get_binding)
|
55
|
+
end
|
56
|
+
|
57
|
+
private def create_conf
|
58
|
+
|
59
|
+
puts "create dir at #{@output_path}"
|
60
|
+
|
61
|
+
FileUtils.mkdir_p File.dirname @output_path
|
62
|
+
|
63
|
+
File.open(@output_path, 'w+') do |f|
|
64
|
+
f.write(render)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,44 @@
|
|
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
|
+
module PiBuildModifier
|
22
|
+
|
23
|
+
##
|
24
|
+
# Mapper represents an abstract class that is used by the modifier to call the necessary steps in order to map values
|
25
|
+
# to an object and then modify it
|
26
|
+
|
27
|
+
class Mapper
|
28
|
+
|
29
|
+
attr_reader :data
|
30
|
+
|
31
|
+
def initialize(data)
|
32
|
+
@data = data
|
33
|
+
end
|
34
|
+
|
35
|
+
def map(json_data)
|
36
|
+
@data.map(json_data) unless @data.nil?
|
37
|
+
end
|
38
|
+
|
39
|
+
def modify
|
40
|
+
@data.map unless @data.nil?
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,74 @@
|
|
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 '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
|
47
|
+
load_config
|
48
|
+
map
|
49
|
+
modify_mapper
|
50
|
+
end
|
51
|
+
|
52
|
+
private def load_config
|
53
|
+
if File.file?(@json_path)
|
54
|
+
File.open(@json_path, 'r+') do |f|
|
55
|
+
@json_data = JSON.parse(f.read)
|
56
|
+
end
|
57
|
+
else
|
58
|
+
raise "Json configuration file does not exist at '#{@json_path}!'"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
private def map
|
63
|
+
@mappers.each do |c|
|
64
|
+
c.map(@json_data)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
private def modify_mapper
|
69
|
+
@mappers.each do |c|
|
70
|
+
c.modify
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,49 @@
|
|
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_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
|
+
|
28
|
+
module PiBuildModifier
|
29
|
+
module Task
|
30
|
+
class Modifier
|
31
|
+
|
32
|
+
attr_reader :pi_modifier
|
33
|
+
|
34
|
+
def initialize(config, workspace, pi_modifier = PiModifier.new)
|
35
|
+
@pi_modifier = pi_modifier
|
36
|
+
@pi_modifier.with_json_configuration(config)
|
37
|
+
|
38
|
+
@pi_modifier.with_mapper(ERBMapper.new(WPASupplicant.new, workspace))
|
39
|
+
@pi_modifier.with_mapper(System.new(workspace))
|
40
|
+
@pi_modifier.with_mapper(ERBMapper.new(Ssh.new, workspace))
|
41
|
+
@pi_modifier.with_mapper(RunModifier.new(workspace))
|
42
|
+
end
|
43
|
+
|
44
|
+
def execute
|
45
|
+
@pi_modifier.modify
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,68 @@
|
|
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 'erb'
|
22
|
+
require 'json'
|
23
|
+
|
24
|
+
module PiBuildModifier
|
25
|
+
class WifiNetwork
|
26
|
+
|
27
|
+
attr_accessor :ssid, :psk, :template
|
28
|
+
|
29
|
+
attr_reader :file
|
30
|
+
|
31
|
+
def initialize(ssid = 'no_ssid', psk = 'no_psk')
|
32
|
+
@ssid = ssid
|
33
|
+
@psk = psk
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_s
|
37
|
+
sprintf('{
|
38
|
+
ssid="%s"
|
39
|
+
psk="%s"
|
40
|
+
}', ssid, psk)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
class WPASupplicant
|
45
|
+
|
46
|
+
attr_reader :template_path, :relative_output_path
|
47
|
+
|
48
|
+
def initialize(networks = Array.new(0), wpa_country = 'DE')
|
49
|
+
@networks = networks
|
50
|
+
@wpa_country = wpa_country
|
51
|
+
@template_path = File.join(File.dirname(__FILE__), '/templates/wpa_supplicant.conf.erb').to_s
|
52
|
+
@relative_output_path = 'stage2/02-net-tweaks/files/wpa_supplicant.conf'
|
53
|
+
end
|
54
|
+
|
55
|
+
def map(json_data)
|
56
|
+
unless json_data.nil?
|
57
|
+
@networks = json_data['wifi']['networks'].map {|rd| WifiNetwork.new(rd['ssid'], rd['wpsk'])} if json_data.has_key?('wifi') && json_data['wifi'].has_key?('networks')
|
58
|
+
@wpa_country = json_data['wifi']['wpa_country'] if json_data.has_key?('wifi') && json_data['wifi'].has_key?('wpa_country')
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def get_binding
|
63
|
+
binding
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
@@ -0,0 +1,58 @@
|
|
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 'fileutils'
|
22
|
+
require 'pi_build_modifier/modifier/mapper'
|
23
|
+
|
24
|
+
module PiBuildModifier
|
25
|
+
|
26
|
+
class RunModifier < Mapper
|
27
|
+
|
28
|
+
attr_reader :relative_output_path
|
29
|
+
|
30
|
+
@@append_lines = Array.new
|
31
|
+
def self.append_lines
|
32
|
+
@@append_lines
|
33
|
+
end
|
34
|
+
|
35
|
+
def initialize(workspace)
|
36
|
+
@workspace = workspace
|
37
|
+
@relative_output_path = 'stage2/01-sys-tweaks/01-run.sh'
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.append(append_line)
|
41
|
+
@@append_lines << append_line
|
42
|
+
end
|
43
|
+
|
44
|
+
def map(json_data)
|
45
|
+
end
|
46
|
+
|
47
|
+
def modify
|
48
|
+
puts @@append_lines.to_s
|
49
|
+
open("#{@workspace}/#{@relative_output_path}", 'a') do |f|
|
50
|
+
f.puts ''
|
51
|
+
@@append_lines.each do |a|
|
52
|
+
f.puts "source #{@workspace}/#{a}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,53 @@
|
|
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 'fileutils'
|
22
|
+
require 'pi_build_modifier/modifier/mapper'
|
23
|
+
require 'pi_build_modifier/sys_tweaks/run_modifier'
|
24
|
+
|
25
|
+
module PiBuildModifier
|
26
|
+
|
27
|
+
class Ssh
|
28
|
+
|
29
|
+
attr_accessor :enable
|
30
|
+
|
31
|
+
attr_reader :template_path, :relative_output_path
|
32
|
+
|
33
|
+
def initialize
|
34
|
+
@enable = 'enable'
|
35
|
+
@template_path = File.join(File.dirname(__FILE__), '/templates/ssh.sh.erb').to_s
|
36
|
+
@relative_output_path = 'stage2/01-sys-tweaks/ssh.sh'
|
37
|
+
RunModifier.append("#{@relative_output_path}")
|
38
|
+
end
|
39
|
+
|
40
|
+
def map(json_data)
|
41
|
+
unless json_data.nil?
|
42
|
+
@enable = 'disable' if json_data.has_key?('ssh') && json_data['ssh'].has_key?('enabled') && (not json_data['ssh']['enabled'])
|
43
|
+
else
|
44
|
+
# TODO: log error
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def get_binding
|
49
|
+
binding
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,80 @@
|
|
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 'fileutils'
|
22
|
+
require 'pi_build_modifier/modifier/mapper'
|
23
|
+
|
24
|
+
module PiBuildModifier
|
25
|
+
|
26
|
+
module Type
|
27
|
+
FULL = 'full'
|
28
|
+
LITE = 'lite'
|
29
|
+
end
|
30
|
+
|
31
|
+
class System < Mapper
|
32
|
+
|
33
|
+
attr_reader :name, :type
|
34
|
+
|
35
|
+
def initialize(workspace)
|
36
|
+
@workspace = workspace
|
37
|
+
@name = 'chiipi'
|
38
|
+
@type = Type::FULL
|
39
|
+
@relative_output_path = @workspace
|
40
|
+
end
|
41
|
+
|
42
|
+
def map(json_data)
|
43
|
+
unless json_data.nil?
|
44
|
+
@name = json_data['system']['name'] if json_data.has_key?('system') && json_data['system'].has_key?('name')
|
45
|
+
@type = json_data['system']['type'] if json_data.has_key?('system') && json_data['system'].has_key?('type')
|
46
|
+
else
|
47
|
+
# TODO: log error
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def modify
|
52
|
+
write_name
|
53
|
+
modify_type
|
54
|
+
end
|
55
|
+
|
56
|
+
private def modify_type
|
57
|
+
if @type.nil? || @type == Type::LITE
|
58
|
+
make_lite
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
private def write_name
|
63
|
+
FileUtils.mkdir_p "#{@workspace}"
|
64
|
+
File.open("#{@workspace}/config", 'w') do |file|
|
65
|
+
file.write("IMG_NAME='#{@name}'")
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
private def make_lite
|
70
|
+
directory = @workspace
|
71
|
+
%W(#{directory}/stage3/SKIP #{directory}/stage4/SKIP #{directory}/stage5/SKIP).each do |skip_file|
|
72
|
+
FileUtils.mkdir_p File.dirname(skip_file)
|
73
|
+
FileUtils.touch skip_file
|
74
|
+
end
|
75
|
+
%W(#{directory}/stage4/EXPORT* #{directory}/stage5/EXPORT*).each do |export_file|
|
76
|
+
FileUtils.rm_f export_file if File.exist?(export_file)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,23 @@
|
|
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
|
+
module PiBuildModifier
|
22
|
+
VERSION = '0.1.1-alpha'
|
23
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
|
6
|
+
require 'pi_build_modifier/version'
|
7
|
+
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
spec.name = 'pi_build_modifier'
|
10
|
+
spec.version = PiBuildModifier::VERSION
|
11
|
+
spec.license = 'MIT'
|
12
|
+
spec.author = 'Beate Ottenwälder'
|
13
|
+
spec.email = 'ottenwbe.public@gmail.com'
|
14
|
+
spec.homepage = 'https://github.com/ottenwbe/pi-gen-environment.git'
|
15
|
+
spec.summary = 'Modify Rapbian image builds.'
|
16
|
+
spec.description = 'Modifies the build process of a Rapbian image.'
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
19
|
+
f.match(%r{^(test|spec|features)/})
|
20
|
+
end
|
21
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ['lib']
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.15'
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
27
|
+
spec.add_development_dependency 'simplecov', '~> 0'
|
28
|
+
spec.add_development_dependency 'rdoc', '~> 5.1'
|
29
|
+
spec.add_runtime_dependency 'thor', '~> 0.20'
|
30
|
+
spec.add_runtime_dependency 'json', '~> 2.1'
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,163 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pi_build_modifier
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1.pre.alpha
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Beate Ottenwälder
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-11-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.15'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.15'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: simplecov
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rdoc
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '5.1'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '5.1'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: thor
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.20'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.20'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: json
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '2.1'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '2.1'
|
111
|
+
description: Modifies the build process of a Rapbian image.
|
112
|
+
email: ottenwbe.public@gmail.com
|
113
|
+
executables:
|
114
|
+
- pi_build_modifier
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- ".rspec"
|
120
|
+
- ".travis.yml"
|
121
|
+
- Gemfile
|
122
|
+
- LICENSE.txt
|
123
|
+
- README.md
|
124
|
+
- Rakefile
|
125
|
+
- bin/pi_build_modifier
|
126
|
+
- lib/pi_build_modifier.rb
|
127
|
+
- lib/pi_build_modifier/modifier/erb_mapper.rb
|
128
|
+
- lib/pi_build_modifier/modifier/mapper.rb
|
129
|
+
- lib/pi_build_modifier/modifier/pi_modifier.rb
|
130
|
+
- lib/pi_build_modifier/modifier_task.rb
|
131
|
+
- lib/pi_build_modifier/net-tweaks/templates/wpa_supplicant.conf.erb
|
132
|
+
- lib/pi_build_modifier/net-tweaks/wifi_network.rb
|
133
|
+
- lib/pi_build_modifier/sys_tweaks/run_modifier.rb
|
134
|
+
- lib/pi_build_modifier/sys_tweaks/ssh.rb
|
135
|
+
- lib/pi_build_modifier/sys_tweaks/templates/ssh.sh.erb
|
136
|
+
- lib/pi_build_modifier/system/system_type.rb
|
137
|
+
- lib/pi_build_modifier/version.rb
|
138
|
+
- pi_build_modifier.gemspec
|
139
|
+
homepage: https://github.com/ottenwbe/pi-gen-environment.git
|
140
|
+
licenses:
|
141
|
+
- MIT
|
142
|
+
metadata: {}
|
143
|
+
post_install_message:
|
144
|
+
rdoc_options: []
|
145
|
+
require_paths:
|
146
|
+
- lib
|
147
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
154
|
+
- - ">"
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: 1.3.1
|
157
|
+
requirements: []
|
158
|
+
rubyforge_project:
|
159
|
+
rubygems_version: 2.6.13
|
160
|
+
signing_key:
|
161
|
+
specification_version: 4
|
162
|
+
summary: Modify Rapbian image builds.
|
163
|
+
test_files: []
|