pi_build_modifier 0.2.0.pre.alpha → 0.3.0.pre.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE.txt +1 -1
- data/bin/pi_build_modifier +20 -0
- data/lib/pi_build_modifier/boot-files/boot.rb +3 -3
- data/lib/pi_build_modifier/config/logex.rb +1 -1
- data/lib/pi_build_modifier/locale/locale_debconf.rb +1 -1
- data/lib/pi_build_modifier/locale/templates/00-debconf.erb +1 -1
- data/lib/pi_build_modifier/modifier/erb_mapper.rb +5 -1
- data/lib/pi_build_modifier/modifier/mapper.rb +8 -3
- data/lib/pi_build_modifier/modifier/pi_modifier.rb +13 -6
- data/lib/pi_build_modifier/modifier_task.rb +7 -1
- data/lib/pi_build_modifier/net-tweaks/wifi_network.rb +24 -8
- data/lib/pi_build_modifier/sys_tweaks/run_modifier.rb +6 -2
- data/lib/pi_build_modifier/sys_tweaks/ssh.rb +2 -2
- data/lib/pi_build_modifier/system/system_type.rb +1 -1
- data/lib/pi_build_modifier/version.rb +2 -2
- data/lib/pi_build_modifier.rb +5 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 73f4b122a82fabf9a45f80014362373898ea1ab674d582b0e5526c8df6a0a246
|
4
|
+
data.tar.gz: 7ccee60700c56c80fa4a29d2d6c20f751613f8a8507d37fcc25406ebe0c26c80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2252b2ec71bef888528a79d18a9ba225a29b2073aa08cce69f3d0bc23a06ceca5d4c11861abcdca0c4a647cdad840177b5e59d26ea30eda18841cfa239ac4cda
|
7
|
+
data.tar.gz: 485e73884692ffd73d3d8b350afeffe4b8dd5d569f8207bd6e35daa154a111e7c0ed674eb596939ad7b0cc8de840ead3cf051d36fe2ba630bc585de0db38fcd9
|
data/LICENSE.txt
CHANGED
data/bin/pi_build_modifier
CHANGED
@@ -1,5 +1,25 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
# Copyright (c) 2017-2018 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 all
|
13
|
+
# 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 THE
|
21
|
+
# SOFTWARE.
|
22
|
+
|
3
23
|
require 'pi_build_modifier'
|
4
24
|
|
5
25
|
PiBuildModifier::PiBuildModifier.start(ARGV)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2017 Beate Ottenwälder
|
1
|
+
# Copyright (c) 2017-2018 Beate Ottenwälder
|
2
2
|
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
4
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -24,7 +24,7 @@ require 'json'
|
|
24
24
|
module PiBuildModifier
|
25
25
|
|
26
26
|
##
|
27
|
-
# The Locale class is used to customize
|
27
|
+
# The Locale class is used to customize locales
|
28
28
|
|
29
29
|
class Boot
|
30
30
|
|
@@ -49,7 +49,7 @@ module PiBuildModifier
|
|
49
49
|
def map(json_data)
|
50
50
|
unless json_data.nil? || !json_data.has_key?(C_GROUPS)
|
51
51
|
if json_data[C_GROUPS].has_key?(C_GROUP_MEMORY) && json_data[C_GROUPS][C_GROUP_MEMORY]
|
52
|
-
@c_groups << 'cgroup_memory=1'
|
52
|
+
@c_groups << 'cgroup_enable=memory cgroup_memory=1 swapaccount=1'
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
@@ -3,4 +3,4 @@
|
|
3
3
|
locales locales/locales_to_be_generated multiselect <%= @gen_locales.join(', ') %>
|
4
4
|
# Default locale for the system environment:
|
5
5
|
# Choices: None, C.UTF-8, en_GB.UTF-8
|
6
|
-
locales locales/
|
6
|
+
locales locales/default_environmentg_locale <select name="" id=""></select> <%= @sys_locale %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2017 Beate Ottenwälder
|
1
|
+
# Copyright (c) 2017-2018 Beate Ottenwälder
|
2
2
|
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
4
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -35,6 +35,10 @@ module PiBuildModifier
|
|
35
35
|
@output_path = working_dir + '/' + @data.relative_output_path
|
36
36
|
end
|
37
37
|
|
38
|
+
def check(json_data)
|
39
|
+
@data.check(json_data)
|
40
|
+
end
|
41
|
+
|
38
42
|
def map(json_data)
|
39
43
|
@data.map(json_data)
|
40
44
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2017 Beate Ottenwälder
|
1
|
+
# Copyright (c) 2017-2018 Beate Ottenwälder
|
2
2
|
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
4
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -21,8 +21,9 @@
|
|
21
21
|
module PiBuildModifier
|
22
22
|
|
23
23
|
##
|
24
|
-
# Mapper represents
|
25
|
-
#
|
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.
|
26
27
|
|
27
28
|
class Mapper
|
28
29
|
|
@@ -32,6 +33,10 @@ module PiBuildModifier
|
|
32
33
|
@data = data
|
33
34
|
end
|
34
35
|
|
36
|
+
def check(json_data)
|
37
|
+
@data.check(json_data) unless @data.nil?
|
38
|
+
end
|
39
|
+
|
35
40
|
def map(json_data)
|
36
41
|
@data.map(json_data) unless @data.nil?
|
37
42
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2017 Beate Ottenwälder
|
1
|
+
# Copyright (c) 2017-2018 Beate Ottenwälder
|
2
2
|
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
4
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -43,8 +43,9 @@ module PiBuildModifier
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
def modify
|
46
|
+
def modify(do_check = false)
|
47
47
|
load_config
|
48
|
+
check_all if do_check
|
48
49
|
map_all
|
49
50
|
modify_all
|
50
51
|
end
|
@@ -59,15 +60,21 @@ module PiBuildModifier
|
|
59
60
|
end
|
60
61
|
end
|
61
62
|
|
63
|
+
private def check_all
|
64
|
+
@mappers.each do |mapper|
|
65
|
+
mapper.check(@json_data)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
62
69
|
private def map_all
|
63
|
-
@mappers.each do |
|
64
|
-
|
70
|
+
@mappers.each do |mapper|
|
71
|
+
mapper.map(@json_data)
|
65
72
|
end
|
66
73
|
end
|
67
74
|
|
68
75
|
private def modify_all
|
69
|
-
@mappers.each do |
|
70
|
-
|
76
|
+
@mappers.each do |mapper|
|
77
|
+
mapper.modify
|
71
78
|
end
|
72
79
|
end
|
73
80
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2017 Beate Ottenwälder
|
1
|
+
# Copyright (c) 2017-2018 Beate Ottenwälder
|
2
2
|
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
4
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -29,6 +29,12 @@ require 'pi_build_modifier/boot-files/boot'
|
|
29
29
|
|
30
30
|
module PiBuildModifier
|
31
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
|
+
|
32
38
|
class Modifier
|
33
39
|
|
34
40
|
attr_reader :pi_modifier
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2017 Beate Ottenwälder
|
1
|
+
# Copyright (c) 2017-2018 Beate Ottenwälder
|
2
2
|
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
4
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -50,14 +50,20 @@ module PiBuildModifier
|
|
50
50
|
|
51
51
|
class WPASupplicant
|
52
52
|
|
53
|
-
|
53
|
+
PASSPHRASE = 'passphrase'
|
54
54
|
|
55
|
-
|
55
|
+
WPA_PASSPHRASE = 'wpa_passphrase'
|
56
56
|
|
57
57
|
SSID = 'ssid'
|
58
58
|
|
59
59
|
attr_reader :template_path, :relative_output_path
|
60
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
|
+
|
61
67
|
def initialize
|
62
68
|
@networks = map_network(nil)
|
63
69
|
@wpa_country = 'DE'
|
@@ -69,6 +75,16 @@ module PiBuildModifier
|
|
69
75
|
ERBMapper.new(self, workspace)
|
70
76
|
end
|
71
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
|
+
|
72
88
|
def map(json_data)
|
73
89
|
unless json_data.nil?
|
74
90
|
@networks = map_network(json_data['wifi']) if json_data.has_key?('wifi')
|
@@ -77,7 +93,7 @@ module PiBuildModifier
|
|
77
93
|
end
|
78
94
|
|
79
95
|
private def map_network(json_data)
|
80
|
-
if json_data.nil?
|
96
|
+
if json_data.nil? or not json_data.has_key?('networks')
|
81
97
|
networks = Array.new(0)
|
82
98
|
else
|
83
99
|
networks = json_data['networks'].map do |rd|
|
@@ -86,10 +102,10 @@ module PiBuildModifier
|
|
86
102
|
else
|
87
103
|
'no_ssid'
|
88
104
|
end
|
89
|
-
psk = if rd.has_key?(
|
90
|
-
OpenSSL::PKCS5.pbkdf2_hmac_sha1(rd[
|
91
|
-
elsif rd.has_key?(
|
92
|
-
rd[
|
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]
|
93
109
|
else
|
94
110
|
'no_psk'
|
95
111
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2017 Beate Ottenwälder
|
1
|
+
# Copyright (c) 2017-2018 Beate Ottenwälder
|
2
2
|
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
4
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -25,7 +25,8 @@ require 'pi_build_modifier/modifier/mapper'
|
|
25
25
|
module PiBuildModifier
|
26
26
|
|
27
27
|
##
|
28
|
-
# RunModifier is a class which appends lines to the
|
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'.
|
29
30
|
|
30
31
|
class RunModifier < Mapper
|
31
32
|
|
@@ -46,6 +47,9 @@ module PiBuildModifier
|
|
46
47
|
@appender << appender
|
47
48
|
end
|
48
49
|
|
50
|
+
##
|
51
|
+
# modify the sys-tweaks run file by adding lines at the end of the file
|
52
|
+
|
49
53
|
def modify
|
50
54
|
open("#{@workspace}/#{@relative_output_path}", 'a') do |f|
|
51
55
|
f.puts ''
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2017 Beate Ottenwälder
|
1
|
+
# Copyright (c) 2017-2018 Beate Ottenwälder
|
2
2
|
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
4
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -49,7 +49,7 @@ module PiBuildModifier
|
|
49
49
|
unless json_data.nil?
|
50
50
|
@enable = 'disable' if json_data.has_key?('ssh') && json_data['ssh'].has_key?('enabled') && (not json_data['ssh']['enabled'])
|
51
51
|
else
|
52
|
-
$logger.error 'Invalid json data.'
|
52
|
+
$logger.error 'Ssh could not be configured: Invalid json data.'
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2017 Beate Ottenwälder
|
1
|
+
# Copyright (c) 2017-2018 Beate Ottenwälder
|
2
2
|
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
4
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -19,5 +19,5 @@
|
|
19
19
|
# SOFTWARE.
|
20
20
|
|
21
21
|
module PiBuildModifier
|
22
|
-
VERSION = '0.
|
22
|
+
VERSION = '0.3.0-alpha'
|
23
23
|
end
|
data/lib/pi_build_modifier.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2017 Beate Ottenwälder
|
1
|
+
# Copyright (c) 2017-2018 Beate Ottenwälder
|
2
2
|
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
4
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -34,11 +34,14 @@ module PiBuildModifier
|
|
34
34
|
|
35
35
|
desc 'modify CONFIG WORKSPACE', 'Modify the pi image sources at the specified WORKSPACE with the specified configuration file CONFIG.'
|
36
36
|
def modify(config, workspace)
|
37
|
-
$logger.debug "
|
37
|
+
$logger.debug "Modifying with a configuration read from '#{config}' in the workspace '#{workspace}'"
|
38
38
|
task = Task::Modifier.new(config, workspace)
|
39
39
|
task.execute
|
40
40
|
end
|
41
41
|
|
42
|
+
##
|
43
|
+
# The version command allows users to query for the current version of the pi_customizer gem. It is printed on the command line.
|
44
|
+
|
42
45
|
desc 'v, version', 'Show the version of the modifier.'
|
43
46
|
def version
|
44
47
|
puts VERSION
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pi_build_modifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.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:
|
11
|
+
date: 2018-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -175,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
175
|
version: 1.3.1
|
176
176
|
requirements: []
|
177
177
|
rubyforge_project:
|
178
|
-
rubygems_version: 2.6
|
178
|
+
rubygems_version: 2.7.6
|
179
179
|
signing_key:
|
180
180
|
specification_version: 4
|
181
181
|
summary: Modify builds of Raspbian images.
|