pi_build_modifier 0.3.0.pre.alpha → 0.3.1.pre.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +24 -12
- data/.travis.yml +26 -4
- data/CODE_OF_CONDUCT.md +74 -0
- data/LICENSE +21 -0
- data/README.md +208 -2
- data/Rakefile +134 -6
- data/Vagrantfile +27 -0
- data/docs/concept.md +27 -0
- data/docs/incubation.md +38 -0
- data/pi_build_modifier/.gitignore +12 -0
- data/{.rspec → pi_build_modifier/.rspec} +0 -0
- data/{Gemfile → pi_build_modifier/Gemfile} +0 -0
- data/{LICENSE.txt → pi_build_modifier/LICENSE.txt} +1 -1
- data/pi_build_modifier/README.md +3 -0
- data/pi_build_modifier/Rakefile +13 -0
- data/{bin → pi_build_modifier/bin}/pi_build_modifier +1 -1
- data/{lib → pi_build_modifier/lib}/pi_build_modifier/boot-files/boot.rb +1 -1
- data/{lib → pi_build_modifier/lib}/pi_build_modifier/boot-files/templates/07-resize-init.diff.erb +0 -0
- data/{lib → pi_build_modifier/lib}/pi_build_modifier/config/logex.rb +1 -1
- data/{lib → pi_build_modifier/lib}/pi_build_modifier/locale/locale_debconf.rb +1 -1
- data/{lib → pi_build_modifier/lib}/pi_build_modifier/locale/templates/00-debconf.erb +1 -1
- data/{lib → pi_build_modifier/lib}/pi_build_modifier/modifier/erb_mapper.rb +1 -1
- data/{lib → pi_build_modifier/lib}/pi_build_modifier/modifier/mapper.rb +1 -1
- data/{lib → pi_build_modifier/lib}/pi_build_modifier/modifier/pi_modifier.rb +1 -1
- data/{lib → pi_build_modifier/lib}/pi_build_modifier/modifier_task.rb +10 -3
- data/{lib → pi_build_modifier/lib}/pi_build_modifier/net-tweaks/templates/wpa_supplicant.conf.erb +0 -0
- data/{lib → pi_build_modifier/lib}/pi_build_modifier/net-tweaks/wifi_network.rb +1 -1
- data/{lib → pi_build_modifier/lib}/pi_build_modifier/sys_tweaks/run_modifier.rb +1 -1
- data/{lib → pi_build_modifier/lib}/pi_build_modifier/sys_tweaks/ssh.rb +1 -1
- data/{lib → pi_build_modifier/lib}/pi_build_modifier/sys_tweaks/templates/ssh.sh.erb +0 -0
- data/{lib → pi_build_modifier/lib}/pi_build_modifier/system/system_type.rb +1 -1
- data/{lib → pi_build_modifier/lib}/pi_build_modifier/version.rb +2 -2
- data/{lib → pi_build_modifier/lib}/pi_build_modifier.rb +4 -1
- data/{pi_build_modifier.gemspec → pi_build_modifier/pi_build_modifier.gemspec} +7 -7
- data/pi_build_modifier/spec/fixtures/config.json +26 -0
- data/pi_build_modifier/spec/pi_build_modifier/boot/boot_spec.rb +103 -0
- data/pi_build_modifier/spec/pi_build_modifier/locale/locale_spec.rb +87 -0
- data/pi_build_modifier/spec/pi_build_modifier/modifier/mapper_spec.rb +105 -0
- data/pi_build_modifier/spec/pi_build_modifier/modifier/modifier_spec.rb +83 -0
- data/pi_build_modifier/spec/pi_build_modifier/modifier_task_spec.rb +63 -0
- data/pi_build_modifier/spec/pi_build_modifier/net-tweaks/wifi_network_spec.rb +91 -0
- data/pi_build_modifier/spec/pi_build_modifier/sys_tweaks/run_modifier_spec.rb +74 -0
- data/pi_build_modifier/spec/pi_build_modifier/sys_tweaks/ssh_spec.rb +73 -0
- data/pi_build_modifier/spec/pi_build_modifier/system/system_spec.rb +66 -0
- data/pi_build_modifier/spec/pi_build_modifier_spec.rb +73 -0
- data/pi_build_modifier/spec/spec_helper.rb +10 -0
- data/pi_customizer/.rspec +2 -0
- data/pi_customizer/Gemfile +3 -0
- data/pi_customizer/LICENSE +21 -0
- data/pi_customizer/README.md +3 -0
- data/pi_customizer/Rakefile +13 -0
- data/pi_customizer/Vagrantfile +16 -0
- data/pi_customizer/bin/pi_customizer +25 -0
- data/pi_customizer/envs/aws/outputs.tf +3 -0
- data/pi_customizer/envs/aws/pi-build-env.tf +160 -0
- data/pi_customizer/envs/aws/variables.tf +55 -0
- data/pi_customizer/envs/docker/Dockerfile +6 -0
- data/pi_customizer/envs/sh/build-pi-img.sh +28 -0
- data/pi_customizer/lib/pi_customizer/build/builder/build_executor.rb +149 -0
- data/pi_customizer/lib/pi_customizer/build/builder/builder.rb +59 -0
- data/pi_customizer/lib/pi_customizer/build/builder/prepare_start_execute_builder.rb +43 -0
- data/pi_customizer/lib/pi_customizer/build/builder/start_prepare_execute_builder.rb +43 -0
- data/pi_customizer/lib/pi_customizer/build/environment/aws/aws.rb +76 -0
- data/pi_customizer/lib/pi_customizer/build/environment/docker/docker.rb +94 -0
- data/pi_customizer/lib/pi_customizer/build/environment/environment.rb +73 -0
- data/pi_customizer/lib/pi_customizer/build/environment/environment_builder_factory.rb +81 -0
- data/pi_customizer/lib/pi_customizer/build/environment/vagrant/templates/Vagrantfile.erb +61 -0
- data/pi_customizer/lib/pi_customizer/build/environment/vagrant/vagrant.rb +77 -0
- data/pi_customizer/lib/pi_customizer/build/environment/vagrant/vagrant_file.rb +95 -0
- data/pi_customizer/lib/pi_customizer/build/workspace/local_workspace.rb +92 -0
- data/pi_customizer/lib/pi_customizer/build/workspace/remote_workspace.rb +79 -0
- data/pi_customizer/lib/pi_customizer/utils/logex.rb +25 -0
- data/pi_customizer/lib/pi_customizer/version.rb +27 -0
- data/pi_customizer/lib/pi_customizer/write/image_writer.rb +67 -0
- data/pi_customizer/lib/pi_customizer.rb +84 -0
- data/pi_customizer/pi_customizer.gemspec +30 -0
- data/pi_customizer/spec/fixtures/TestVagrantfile +61 -0
- data/pi_customizer/spec/fixtures/image.img +1 -0
- data/pi_customizer/spec/fixtures/image.zip +0 -0
- data/pi_customizer/spec/pi_customizer/builder/build_executor_spec.rb +64 -0
- data/pi_customizer/spec/pi_customizer/environment/aws_spec.rb +57 -0
- data/pi_customizer/spec/pi_customizer/environment/environment_builder_factory_spec.rb +48 -0
- data/pi_customizer/spec/pi_customizer/environment/environment_spec.rb +75 -0
- data/pi_customizer/spec/pi_customizer/environment/vagrant/vagrant_file_spec.rb +63 -0
- data/pi_customizer/spec/pi_customizer/environment/vagrant/vagrant_spec.rb +41 -0
- data/pi_customizer/spec/pi_customizer/version_spec.rb +29 -0
- data/pi_customizer/spec/pi_customizer/workspace/local_workspace_spec.rb +74 -0
- data/pi_customizer/spec/pi_customizer/workspace/remote_workspace_spec.rb +51 -0
- data/pi_customizer/spec/pi_customizer/write/image_writer_spec.rb +59 -0
- data/pi_customizer/spec/pi_customizer_spec.rb +93 -0
- data/pi_customizer/spec/spec_helper.rb +10 -0
- data/version.rb +21 -0
- metadata +106 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 757874dc334e676e557fcdad1dcc1cc0c3fd28cf7ff9e0a9e287efac58c254a9
|
4
|
+
data.tar.gz: '031418d529c5f97bc685c8f02d68576d5899dbb899a0fb9a0872be84fe6d95ec'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03cb6d2d223e79914aeaa9fc122f5f322848d7ef8db88ef4eb5ae9050f4bb7f35282c737257a850049e0cb455eaf3c6914b88d307068efd8eadb1ba19eb81f6d
|
7
|
+
data.tar.gz: d19e96ddbfc43140a526ff924d3d93c95813225f8a61a9e58e8222ba294f17f315219581e99176ef03c5d1b0e1cba99d7bb94c293d32bc614c67d3a4d9547e7b
|
data/.gitignore
CHANGED
@@ -1,12 +1,24 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
/
|
8
|
-
/
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
1
|
+
# Compiled files
|
2
|
+
*.tfstate
|
3
|
+
*.tfstate.backup
|
4
|
+
*.tfvars
|
5
|
+
|
6
|
+
# Module directory
|
7
|
+
.terraform/
|
8
|
+
.idea/
|
9
|
+
|
10
|
+
# Project files and direcotires
|
11
|
+
*iml
|
12
|
+
ssh/
|
13
|
+
|
14
|
+
*.conf
|
15
|
+
wpa_supplicant.json
|
16
|
+
.vagrant/
|
17
|
+
Gemfile.lock
|
18
|
+
*gem
|
19
|
+
|
20
|
+
cid
|
21
|
+
coverage/
|
22
|
+
tmp/
|
23
|
+
*.log
|
24
|
+
doc/
|
data/.travis.yml
CHANGED
@@ -1,6 +1,28 @@
|
|
1
|
-
sudo: false
|
2
1
|
language: ruby
|
3
2
|
rvm:
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
- 2.6.3
|
4
|
+
- 2.5.5
|
5
|
+
- 2.4.6
|
6
|
+
before_script:
|
7
|
+
- gem install bundler
|
8
|
+
- cd pi_customizer/ && bundle install && cd ..
|
9
|
+
- cd pi_build_modifier/ && bundle install && cd ..
|
10
|
+
script:
|
11
|
+
- rake spec
|
12
|
+
deploy:
|
13
|
+
- provider: rubygems
|
14
|
+
gem: pi_customizer
|
15
|
+
gemspec: pi_customizer/pi_customizer.gemspec
|
16
|
+
on:
|
17
|
+
branch: development
|
18
|
+
ruby: 2.6.3
|
19
|
+
api_key:
|
20
|
+
secure: V2bkBW+4UT/8Pt+MK6XZwDL5dPF3bkTL1RevI3UCIGmHSoKPPT918DpXhfVg6cRdOhMyYTbTjkQIyP9LEW5Uy8Nozp15kKa2nZbWIuDIIhUPopuymSW1x+g7c7VBU7nU7KL2XsYKwY2+PGp5WUycsWrKyM0U/4tn5wKK4u8lHz6fjmsIldl2/6nEsN23voat2LoftFzG3bng07v/mREjkiLtMzXnZ/sQ/uvC+4W5h3xJUf+KQ86JwoaBrisms5ETkOt3ox3/J56VFcTHi3QbpSW6MXnuKkiohTRkz1CI7V5jLyNKxJn/ZUSZmmKkCvOC2g9J9KzaTey36Iy+eKo2mYBNj59qrUzxChwpcU2peFhpIYfVx+9vQ2ki6h3FtAuTDQ7civ+s/BLAwTPdA64JoLjkYdIhOzsSN61rxsEQOXOz/mih21cPDADWiPOawvC8w6fW3Vf6Pg9etux9pzTpFr41F45e54ZOg074KpUCwk3vMMfZnyF0UbAR/wW5YjAEMA3VYffyT34uisrsmhHjbk3EhpuHIZeJy5ukOeKC2SDmOY6fIbi+rKGLwExj/okIpxVhhBp/bl59Qk4fNvBM81WbxqiuOGafTNWty5Hz1pLqO/1xllDU9eFEpd0jVcBTAAFvSmzYllBg/7R3BXDJyawmhVQZDFAkqtCQ6VOnOl0=
|
21
|
+
- provider: rubygems
|
22
|
+
gem: pi_build_modifier
|
23
|
+
gemspec: pi_build_modifier/pi_build_modifier.gemspec
|
24
|
+
on:
|
25
|
+
branch: development
|
26
|
+
ruby: 2.6.3
|
27
|
+
api_key:
|
28
|
+
secure: V2bkBW+4UT/8Pt+MK6XZwDL5dPF3bkTL1RevI3UCIGmHSoKPPT918DpXhfVg6cRdOhMyYTbTjkQIyP9LEW5Uy8Nozp15kKa2nZbWIuDIIhUPopuymSW1x+g7c7VBU7nU7KL2XsYKwY2+PGp5WUycsWrKyM0U/4tn5wKK4u8lHz6fjmsIldl2/6nEsN23voat2LoftFzG3bng07v/mREjkiLtMzXnZ/sQ/uvC+4W5h3xJUf+KQ86JwoaBrisms5ETkOt3ox3/J56VFcTHi3QbpSW6MXnuKkiohTRkz1CI7V5jLyNKxJn/ZUSZmmKkCvOC2g9J9KzaTey36Iy+eKo2mYBNj59qrUzxChwpcU2peFhpIYfVx+9vQ2ki6h3FtAuTDQ7civ+s/BLAwTPdA64JoLjkYdIhOzsSN61rxsEQOXOz/mih21cPDADWiPOawvC8w6fW3Vf6Pg9etux9pzTpFr41F45e54ZOg074KpUCwk3vMMfZnyF0UbAR/wW5YjAEMA3VYffyT34uisrsmhHjbk3EhpuHIZeJy5ukOeKC2SDmOY6fIbi+rKGLwExj/okIpxVhhBp/bl59Qk4fNvBM81WbxqiuOGafTNWty5Hz1pLqO/1xllDU9eFEpd0jVcBTAAFvSmzYllBg/7R3BXDJyawmhVQZDFAkqtCQ6VOnOl0=
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at b.ottenwaelder@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017-2019 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.
|
data/README.md
CHANGED
@@ -1,3 +1,209 @@
|
|
1
|
-
#
|
1
|
+
# pi-customizer
|
2
2
|
|
3
|
-
|
3
|
+
[![Build Status](https://travis-ci.org/ottenwbe/pi-gen-environment.svg?branch=master)](https://travis-ci.org/ottenwbe/pi-gen-environment)
|
4
|
+
|
5
|
+
|Gem |Badge |
|
6
|
+
|:-:|:-:|
|
7
|
+
| pi_customizer | [![Gem Version](https://badge.fury.io/rb/pi_customizer.svg)](https://badge.fury.io/rb/pi_customizer) |
|
8
|
+
| pi_build_modifier | [![Gem Version](https://badge.fury.io/rb/pi_build_modifier.svg)](https://badge.fury.io/rb/pi_build_modifier) |
|
9
|
+
|
10
|
+
|
11
|
+
The _pi_customizer_ allows you to adapt Raspbian images to your needs.
|
12
|
+
To this end, the Raspbian image is be built from [scratch](https://github.com/ottenwbe/pi-gen.git)
|
13
|
+
with all customizations baked into the image.
|
14
|
+
|
15
|
+
The image is built in an isolated [build environment](#environments), e.g.,
|
16
|
+
a vagrant box, which is orchestrated by the pi_customizer.
|
17
|
+
The customization is performed by a Ruby Gem (_pi_build_modifier_) in the build environment by adapting the [pi-gen](https://github.com/RPi-Distro/pi-gen) build scripts.
|
18
|
+
|
19
|
+
|
20
|
+
# WIP Notice
|
21
|
+
|
22
|
+
This project is still under construction and in a pre release phase.
|
23
|
+
|
24
|
+
# Install
|
25
|
+
|
26
|
+
## Prerequisites
|
27
|
+
|
28
|
+
To customize the build process the following prerequisites are expected:
|
29
|
+
* The _pi_customizer_ gem is installed (see the [__Deploy Gem__](#deploy_gem) section for details)
|
30
|
+
* One of the supported build environments is accessible (see the [__Environments__](#environments) section):
|
31
|
+
* Vagrant
|
32
|
+
* Docker (feature is still in development)
|
33
|
+
|
34
|
+
<a name="deploy_gem"></a>
|
35
|
+
## Deploy Gem
|
36
|
+
|
37
|
+
To customize your Raspbian image the pi_customizer gem must be installed on the machine that coordinates the build process.
|
38
|
+
This is typically your local machine.
|
39
|
+
|
40
|
+
1. Install the latest (pre) release. For all prerequisites see the corresponding section.
|
41
|
+
|
42
|
+
```bash
|
43
|
+
gem install pi_customizer --pre
|
44
|
+
```
|
45
|
+
|
46
|
+
1. Verify the installation
|
47
|
+
|
48
|
+
```bash
|
49
|
+
pi_customizer version
|
50
|
+
```
|
51
|
+
<a name="environments"></a>
|
52
|
+
## Environments
|
53
|
+
|
54
|
+
You may choose to build your pi image in a Vagrant box.
|
55
|
+
In the future Docker containers will also be supported.
|
56
|
+
|
57
|
+
### Vagrant
|
58
|
+
|
59
|
+
1. Install Vagrant. For instance, on Fedora:
|
60
|
+
|
61
|
+
```bash
|
62
|
+
sudo dnf install vagrant
|
63
|
+
```
|
64
|
+
|
65
|
+
1. Verify that vagrant is installed
|
66
|
+
|
67
|
+
```
|
68
|
+
vagrant -v
|
69
|
+
```
|
70
|
+
|
71
|
+
1. Install the `vagrant-disksize` plugin
|
72
|
+
|
73
|
+
```
|
74
|
+
vagrant plugin install vagrant-disksize
|
75
|
+
```
|
76
|
+
|
77
|
+
### Docker
|
78
|
+
|
79
|
+
Note: feature still in development
|
80
|
+
|
81
|
+
Docker uses a temporary folder as volume to build the image.
|
82
|
+
The folder location can be changed with the build option __tmp-folder__, which is set to "${PWD}/tmp" by default.
|
83
|
+
|
84
|
+
Note: the type of the tmp directory needs to be changed on SELinux
|
85
|
+
|
86
|
+
chcon -Rt svirt_sandbox_file_t "${PWD}/tmp"
|
87
|
+
|
88
|
+
After the image is built, undo the changes.
|
89
|
+
|
90
|
+
restorecon -v "${PWD}/tmp"
|
91
|
+
|
92
|
+
|
93
|
+
# Usage
|
94
|
+
|
95
|
+
To build a default image in a Vagrant box, simply execute on the command line
|
96
|
+
|
97
|
+
pi_customizer build VAGRANT -c <your-config-file>
|
98
|
+
|
99
|
+
|
100
|
+
To customize your build:
|
101
|
+
1. All customizations have to be specified in a json configuration file (see the [__Config File__](#config_file) section for details).
|
102
|
+
1. The build process itself is then configured with command line options (see `pi_customizer help build` for details)
|
103
|
+
|
104
|
+
|
105
|
+
<a name="config_file"></a>
|
106
|
+
## Config File
|
107
|
+
|
108
|
+
An example of the json config file with all current configuration options
|
109
|
+
|
110
|
+
{
|
111
|
+
"system": {
|
112
|
+
"name" : "custompi",
|
113
|
+
"type" : "lite"
|
114
|
+
},
|
115
|
+
"ssh" : {
|
116
|
+
"enabled" : true
|
117
|
+
},
|
118
|
+
"locale": {
|
119
|
+
"gen" : ["en_GB.UTF-8 UTF-8", "de_DE.UTF-8 UTF-8"],
|
120
|
+
"sys" : "en_GB.UTF-8"
|
121
|
+
},
|
122
|
+
"cgroups": {
|
123
|
+
"memory": true
|
124
|
+
},
|
125
|
+
"wifi": {
|
126
|
+
"networks": [
|
127
|
+
{
|
128
|
+
"ssid": "your_ssid",
|
129
|
+
"passphrase": "your_secret_psk" // Alternative: "wpa_passphrase": "your_wpa_passpharse"
|
130
|
+
}
|
131
|
+
],
|
132
|
+
"wpa_country": "DE"
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
### The system section
|
137
|
+
|
138
|
+
* To choose a custom name for your pi image, specify the __name__ value. The default is _custompi_.
|
139
|
+
|
140
|
+
* To build a lite version of the pi image, specify the __type__ as lite, otherwise specify it as full. The default is _full_.
|
141
|
+
|
142
|
+
### The ssh section
|
143
|
+
|
144
|
+
* To disable ssh by default, set __enabled__ to false.
|
145
|
+
|
146
|
+
### The locale section
|
147
|
+
|
148
|
+
* Select one or more locales to be generated: e.g., "en_GB.UTF-8 UTF-8", "de_DE.UTF-8 UTF-8", ...
|
149
|
+
* Select the default locale, typically en_GB.UTF-8, which is the default.
|
150
|
+
|
151
|
+
### The cgroups section
|
152
|
+
|
153
|
+
* To enable the cgroup memory, enable __memory__, otherwise leave it out.
|
154
|
+
|
155
|
+
### The wifi section
|
156
|
+
|
157
|
+
* The wifi section allows you to specify networks and passphrase __OR__ wpa_passpharse as well as the wpa_country.
|
158
|
+
|
159
|
+
# Development
|
160
|
+
|
161
|
+
### Prerequisites
|
162
|
+
|
163
|
+
* Make sure Ruby is installed (and dependencies to build native extensions). See, https://github.com/rbenv/rbenv and https://github.com/rbenv/ruby-build.
|
164
|
+
|
165
|
+
* On Fedora with zsh, this means sth. along the lines of:
|
166
|
+
|
167
|
+
```
|
168
|
+
sudo dnf group install "C Development Tools and Libraries"
|
169
|
+
sudo dnf install redhat-rpm-config git openssl-devel readline-devel
|
170
|
+
|
171
|
+
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
|
172
|
+
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
|
173
|
+
~/.rbenv/bin/rbenv init
|
174
|
+
exec $SHELL
|
175
|
+
|
176
|
+
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
|
177
|
+
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.zshrc
|
178
|
+
exec $SHELL
|
179
|
+
|
180
|
+
rbenv install 2.5.5
|
181
|
+
rbenv global 2.5.5
|
182
|
+
```
|
183
|
+
|
184
|
+
|
185
|
+
* Install Gems
|
186
|
+
|
187
|
+
```
|
188
|
+
gem install bundler rake rspec rdoc
|
189
|
+
```
|
190
|
+
|
191
|
+
## Test
|
192
|
+
|
193
|
+
RSpec tests can be executed for all modules by calling the following rake command in the project root.
|
194
|
+
|
195
|
+
rake spec
|
196
|
+
|
197
|
+
## Structure
|
198
|
+
|
199
|
+
For now, the sources of both gems (pi_customizer and pi_build_modifier) are versioned in one repository.
|
200
|
+
This might change if their versions run out of sync.
|
201
|
+
|
202
|
+
## Contributing
|
203
|
+
|
204
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ottenwbe/pi-gen-environment. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
205
|
+
|
206
|
+
## License
|
207
|
+
|
208
|
+
The gems are available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
209
|
+
|
data/Rakefile
CHANGED
@@ -1,13 +1,141 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
PI_CUSTOMIZER = 'pi_customizer'
|
2
|
+
PI_BUILD_MODIFIER = 'pi_build_modifier'
|
3
|
+
|
4
|
+
build_projects = [PI_BUILD_MODIFIER]
|
5
|
+
install_projects = [PI_CUSTOMIZER]
|
6
|
+
all_gems = (build_projects + install_projects).uniq
|
7
|
+
files = %w(pi_build_modifier/lib/**/*.rb pi_customizer/lib/**/*.rb)
|
8
|
+
|
9
|
+
##
|
10
|
+
# The spec task executes rspec tests for all gems of the pi_customizer project.
|
11
|
+
# This task is executed by default when 'rake' is called on the command line
|
3
12
|
|
4
13
|
begin
|
5
|
-
require 'bundler/gem_tasks'
|
6
14
|
require 'rspec/core/rake_task'
|
7
15
|
|
8
|
-
RSpec::Core::RakeTask.new(:spec)
|
16
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
17
|
+
# find all spec files (for all gems)
|
18
|
+
pattern = ''
|
19
|
+
all_gems.each do |gem|
|
20
|
+
if pattern == ''
|
21
|
+
pattern = "#{gem}/spec/**{,/*/**}/*_spec.rb"
|
22
|
+
else
|
23
|
+
pattern = pattern + ',' + "#{gem}/spec/**{,/*/**}/*_spec.rb"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
# tell rspec to execute tests on all spec files
|
27
|
+
t.pattern = pattern
|
28
|
+
end
|
29
|
+
rescue LoadError
|
30
|
+
puts 'RSpec is not installed. This means rake is not able to execute tests! '
|
31
|
+
puts '* Try: gem install rspec'
|
32
|
+
end
|
33
|
+
|
34
|
+
task :default => :spec
|
35
|
+
|
36
|
+
|
37
|
+
# release task
|
38
|
+
|
39
|
+
desc 'Release and upload to Rubygems.org'
|
40
|
+
task :release do
|
41
|
+
all_gems.each do |p|
|
42
|
+
Dir.chdir p do
|
43
|
+
system 'rake release'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# doc tasks
|
49
|
+
|
50
|
+
begin
|
51
|
+
require 'rdoc/task'
|
9
52
|
|
10
|
-
|
53
|
+
RDoc::Task.new do |rdoc|
|
54
|
+
rdoc.rdoc_dir = File.join(File.dirname(__FILE__), '/doc')
|
55
|
+
rdoc.rdoc_files.include(files)
|
56
|
+
end
|
11
57
|
rescue LoadError
|
12
|
-
puts 'RSpec
|
58
|
+
puts 'RSpec is not installed. This means rake is not able to build the documentation!'
|
59
|
+
puts '* Try: gem install rdoc'
|
13
60
|
end
|
61
|
+
|
62
|
+
# version tasks
|
63
|
+
|
64
|
+
desc "Show the gem's versions"
|
65
|
+
task :versions do
|
66
|
+
require_relative "#{PI_CUSTOMIZER}/lib/#{PI_CUSTOMIZER}/version"
|
67
|
+
puts "#{PI_CUSTOMIZER} Versions"
|
68
|
+
puts ' '
|
69
|
+
puts '*** Dev VERSION ***'
|
70
|
+
puts ' '
|
71
|
+
puts "#{PI_CUSTOMIZER}: #{PiCustomizer::VERSION} "
|
72
|
+
system "gem list #{PI_CUSTOMIZER} --pre --remote"
|
73
|
+
puts ' '
|
74
|
+
require_relative "#{PI_BUILD_MODIFIER}/lib/#{PI_BUILD_MODIFIER}/version"
|
75
|
+
puts "#{PI_BUILD_MODIFIER} Versions"
|
76
|
+
puts ' '
|
77
|
+
puts '*** Dev VERSION ***'
|
78
|
+
puts ' '
|
79
|
+
puts "#{PI_BUILD_MODIFIER}: #{PiBuildModifier::VERSION}"
|
80
|
+
system "gem list #{PI_BUILD_MODIFIER} --pre --remote"
|
81
|
+
end
|
82
|
+
|
83
|
+
# build tasks
|
84
|
+
|
85
|
+
desc "Build all gems (i.e., #{PI_BUILD_MODIFIER} and #{PI_CUSTOMIZER})"
|
86
|
+
task :build do
|
87
|
+
all_gems.each do |p|
|
88
|
+
Dir.chdir p do
|
89
|
+
system 'rake build'
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
namespace :uninstall do
|
95
|
+
desc 'remove the locally required gems'
|
96
|
+
task :local do
|
97
|
+
install_projects.each do |p|
|
98
|
+
Dir.chdir p do
|
99
|
+
system "gem uninstall #{p} -a -x"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
namespace :install do
|
106
|
+
|
107
|
+
require 'fileutils'
|
108
|
+
|
109
|
+
desc 'install the locally required gems'
|
110
|
+
task :local do
|
111
|
+
build_projects.each do |p|
|
112
|
+
Dir.chdir p do
|
113
|
+
system 'rake build'
|
114
|
+
end
|
115
|
+
end
|
116
|
+
install_projects.each do |p|
|
117
|
+
Dir.chdir p do
|
118
|
+
system 'rake install:local'
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
task :local => [:spec, :rdoc, 'uninstall:local']
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
# run the pi_customizer from source
|
128
|
+
|
129
|
+
namespace :run do
|
130
|
+
|
131
|
+
desc 'run the pi_customizer and build the pi image in a vagrant box'
|
132
|
+
task :vagrant, [:resources] do |t, args|
|
133
|
+
system ("ruby pi_customizer/bin/pi_customizer build VAGRANT #{args[:resources]}")
|
134
|
+
end
|
135
|
+
|
136
|
+
desc 'run the pi_customizer and build the pi image in a docker container'
|
137
|
+
task :docker, [:resources] do |t, args|
|
138
|
+
system ("ruby pi_customizer/bin/pi_customizer build DOCKER #{args[:resources]}")
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
data/Vagrantfile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
|
4
|
+
# Vagrantbox to execute unit tests in a clean environment
|
5
|
+
|
6
|
+
Vagrant.configure('2') do |config|
|
7
|
+
|
8
|
+
config.vm.box = "ubuntu/xenial64"
|
9
|
+
|
10
|
+
config.vm.provision 'shell', inline: <<-SHELL
|
11
|
+
sudo apt update
|
12
|
+
sudo apt -y upgrade
|
13
|
+
sudo apt -y install build-essential ruby-full
|
14
|
+
|
15
|
+
gem install bundler
|
16
|
+
|
17
|
+
cd /vagrant/pi_customizer
|
18
|
+
bundle install
|
19
|
+
|
20
|
+
cd /vagrant/pi_build_modifier
|
21
|
+
bundle install
|
22
|
+
|
23
|
+
cd /vagrant
|
24
|
+
|
25
|
+
rake spec
|
26
|
+
SHELL
|
27
|
+
end
|
data/docs/concept.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# Concepts
|
2
|
+
* The pi_customizer defines and orchestrates an __environment__ to run the build of an RasPi image in (e.g., in a VAGRANT box).
|
3
|
+
* To store the configuration for the environment and to define a place for the finished image, pi_customizer defines a __local workspace__.
|
4
|
+
* Once the environment is up and running, it hosts a __remote workspace__.
|
5
|
+
* The __remote workspace__ comprises all files needed to __modify__ and __build__ a RasPi image
|
6
|
+
* The workspace is populated by default from a forked git repo of the official raspbian build tool
|
7
|
+
|
8
|
+
* __Modification__ steps change files in the remote workspace based on a user defined configuration file
|
9
|
+
* __Build__ steps are all executed in the environment
|
10
|
+
|
11
|
+
# Build Steps
|
12
|
+
|
13
|
+
1. Environment creation and selection
|
14
|
+
1. Environment startup
|
15
|
+
1. Workspace creation
|
16
|
+
1. Load sources to workspace
|
17
|
+
1. Load modification sources
|
18
|
+
1. Modify sources in workspace
|
19
|
+
1. Build pi image
|
20
|
+
1. Ship pi image to destination
|
21
|
+
1. Delete Environment
|
22
|
+
|
23
|
+
# Modes
|
24
|
+
1. Prepare and Run - Prepare everything for the environment (e.g., a Vagrantfile) and then simply run the Vagrantfile to build the image
|
25
|
+
1. Example: Vagrant
|
26
|
+
1. Start and Adapt - Start an Environment (e.g., a VM in AWS) and then simply run then configure the environment to build it afterwards
|
27
|
+
1. Examples: Docker
|
data/docs/incubation.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
Potential improvements:
|
2
|
+
|
3
|
+
|
4
|
+
* As a builder of a pi image I want to add ssh-keys and bake them into the image (hostkey, admin users public key, ...) to avoid adding it afterwards manually
|
5
|
+
* As a builder of a pi image I want to be able to disable the swap file for my image, e.g., to be able to install kubernetes on it
|
6
|
+
* sudo systemctl disable dphys-swapfile
|
7
|
+
* As a maintainer of the pi image build sources fork I want to be informed if the templates used for the pi_build_modifier are out of date, to avoid inconsistencies
|
8
|
+
|
9
|
+
* Add users
|
10
|
+
|
11
|
+
* Change hostname
|
12
|
+
|
13
|
+
* Install Docker
|
14
|
+
* echo deb https://apt.dockerproject.org/repo debian-stretch main > /etc/apt/sources.list.d/docker.list; apt update
|
15
|
+
* apt install docker-ce
|
16
|
+
* ------------ or:
|
17
|
+
apt-get update
|
18
|
+
apt-get install \
|
19
|
+
apt-transport-https \
|
20
|
+
ca-certificates \
|
21
|
+
curl \
|
22
|
+
gnupg2 \
|
23
|
+
software-properties-common
|
24
|
+
curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | sudo apt-key add -
|
25
|
+
echo "deb [arch=armhf] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
|
26
|
+
$(lsb_release -cs) stable" | \
|
27
|
+
tee /etc/apt/sources.list.d/docker.list
|
28
|
+
|
29
|
+
apt-get update && apt-get install -y docker-ce=$(apt-cache madison docker-ce | grep 17.09 | head -1 | awk '{print $3}')
|
30
|
+
|
31
|
+
* Install Kubernetes
|
32
|
+
* curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
|
33
|
+
* echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list
|
34
|
+
* apt-get update && apt-get install -y kubelet kubeadm kubectl
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
|
File without changes
|
File without changes
|
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2017-
|
3
|
+
Copyright (c) 2017-2019 Beate Ottenwälder
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
@@ -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
|