You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The file `depends` contains a list of tools needed. The format of this
20
+
package is `<tool>[:<debian-package>]`.
21
+
10
22
11
23
## Config
12
24
@@ -29,29 +41,117 @@ The following environment variables are supported:
29
41
will not be included in the image, making it safe to use an `apt-cacher` or
30
42
similar package for development.
31
43
44
+
If you have Docker installed, you can set up a local apt caching proxy to
45
+
like speed up subsequent builds like this:
46
+
47
+
docker-compose up -d
48
+
echo 'APT_PROXY=http://172.17.0.1:3142' >> config
49
+
50
+
*`BASE_DIR` (Default: location of `build.sh`)
51
+
52
+
**CAUTION**: Currently, changing this value will probably break build.sh
53
+
54
+
Top-level directory for `pi-gen`. Contains stage directories, build
55
+
scripts, and by default both work and deployment directories.
56
+
57
+
*`WORK_DIR` (Default: `"$BASE_DIR/work"`)
58
+
59
+
Directory in which `pi-gen` builds the target system. This value can be
60
+
changed if you have a suitably large, fast storage location for stages to
61
+
be built and cached. Note, `WORK_DIR` stores a complete copy of the target
62
+
system for each build stage, amounting to tens of gigabytes in the case of
63
+
Raspbian.
64
+
65
+
**CAUTION**: If your working directory is on an NTFS partition you probably won't be able to build. Make sure this is a proper Linux filesystem.
66
+
67
+
*`DEPLOY_DIR` (Default: `"$BASE_DIR/deploy"`)
68
+
69
+
Output directory for target system images and NOOBS bundles.
70
+
71
+
*`USE_QEMU` (Default: `"0"`)
72
+
73
+
This enable the Qemu mode and set filesystem and image suffix if set to 1.
74
+
75
+
32
76
A simple example for building Raspbian:
33
77
34
78
```bash
35
79
IMG_NAME='Raspbian'
36
80
```
37
81
82
+
83
+
## How the build process works
84
+
85
+
The following process is followed to build images:
86
+
87
+
* Loop through all of the stage directories in alphanumeric order
88
+
89
+
* Move on to the next directory if this stage directory contains a file called
90
+
"SKIP"
91
+
92
+
* Run the script ```prerun.sh``` which is generally just used to copy the build
93
+
directory between stages.
94
+
95
+
* In each stage directory loop through each subdirectory and then run each of the
96
+
install scripts it contains, again in alphanumeric order. These need to be named
97
+
with a two digit padded number at the beginning.
98
+
There are a number of different files and directories which can be used to
99
+
control different parts of the build process:
100
+
101
+
-**00-run.sh** - A unix shell script. Needs to be made executable for it to run
102
+
103
+
-**00-run-chroot.sh** - A unix shell script which will be run in the chroot
104
+
of the image build directory. Needs to be made executable for it to run.
105
+
106
+
-**00-debconf** - Contents of this file are passed to debconf-set-selections
107
+
to configure things like locale, etc.
108
+
109
+
-**00-packages** - A list of packages to install. Can have more than one, space
110
+
separated, per line.
111
+
112
+
-**00-packages-nr** - As 00-packages, except these will be installed using
113
+
the ```--no-install-recommends -y``` parameters to apt-get
114
+
115
+
-**00-patches** - A directory containing patch files to be applied
116
+
117
+
* If the stage directory contains files called "EXPORT_NOOBS" or "EXPORT_IMAGE" then
118
+
add this stage to a list of images to generate
119
+
120
+
* Generate the images for any stages that have specified them
121
+
122
+
It is recommended to examine build.sh for finer details.
123
+
124
+
38
125
## Docker Build
39
126
40
127
```bash
41
128
vi config # Edit your config file. See above.
42
129
./build-docker.sh
43
130
```
131
+
44
132
If everything goes well, your finished image will be in the `deploy/` folder.
45
-
You can then remove the build container with `docker rm pigen_work`
133
+
You can then remove the build container with `docker rm -v pigen_work`
46
134
47
135
If something breaks along the line, you can edit the corresponding scripts, and
48
136
continue:
49
137
50
-
```
138
+
```bash
51
139
CONTINUE=1 ./build-docker.sh
52
140
```
53
141
54
-
There is a possibility that even when running from a docker container, the installation of `qemu-user-static` will silently fail when building the image because `binfmt-support`_must be enabled on the underlying kernel_. An easy fix is to ensure `binfmt-support` is installed on the host machine before starting the `./build-docker.sh` script (or using your own docker build solution).
142
+
After successful build, the build container is by default removed. This may be undesired when making incremental changes to a customized build. To prevent the build script from remove the container add
143
+
144
+
```bash
145
+
PRESERVE_CONTAINER=1 ./build-docker.sh
146
+
```
147
+
148
+
There is a possibility that even when running from a docker container, the
149
+
installation of `qemu-user-static` will silently fail when building the image
150
+
because `binfmt-support`_must be enabled on the underlying kernel_. An easy
151
+
fix is to ensure `binfmt-support` is installed on the host machine before
152
+
starting the `./build-docker.sh` script (or using your own docker build
153
+
solution).
154
+
55
155
56
156
## Stage Anatomy
57
157
@@ -86,32 +186,62 @@ maintenance and allows for more easy customization.
86
186
standard console hardware permission groups.
87
187
88
188
There are a few tools that may not make a whole lot of sense here for
89
-
development purposes on a minimal system such as basic python and lua
189
+
development purposes on a minimal system such as basic Python and Lua
90
190
packages as well as the `build-essential` package. They are lumped right
91
191
in with more essential packages presently, though they need not be with
92
192
pi-gen. These are understandable for Raspbian's target audience, but if
93
-
you were looking for something between truly minimal and Raspbian-lite,
193
+
you were looking for something between truly minimal and Raspbian-Lite,
94
194
here's where you start trimming.
95
195
96
196
-**Stage 3** - desktop system. Here's where you get the full desktop system
97
197
with X11 and LXDE, web browsers, git for development, Raspbian custom UI
98
198
enhancements, etc. This is a base desktop system, with some development
99
199
tools installed.
100
200
101
-
-**Stage 4** - complete Raspbian system. More development tools, an email
102
-
client, learning tools like Scratch, specialized packages like sonic-pi and
103
-
wolfram-engine, system documentation, office productivity, etc. This is
104
-
the stage that installs all of the things that make Raspbian friendly to
105
-
new users.
201
+
-**Stage 4** - Raspbian system meant to fit on a 4GB card. More development
202
+
tools, an email client, learning tools like Scratch, specialized packages
203
+
like sonic-pi, system documentation, office productivity, etc. This is the
204
+
stage that installs all of the things that make Raspbian friendly to new
205
+
users.
206
+
207
+
-**Stage 5** - The official Raspbian Desktop image. Right now only adds
208
+
Mathematica.
106
209
107
210
### Stage specification
108
-
If you wish to build up to a specified stage (such as building up to stage 2 for a lite system), place an empty file named `SKIP` in each of the `./stage` directories you wish not to include.
109
211
110
-
Then remove the `EXPORT*` files from `./stage4` (if building up to stage 2) or from `./stage2` (if building a minimal system).
212
+
If you wish to build up to a specified stage (such as building up to stage 2
213
+
for a lite system), place an empty file named `SKIP` in each of the `./stage`
214
+
directories you wish not to include.
111
215
112
-
```
216
+
Then remove the `EXPORT*` files from `./stage4` (if building up to stage 2) or
217
+
from `./stage2` (if building a minimal system).
218
+
219
+
```bash
113
220
# Example for building a lite system
114
-
$ touch ./stage3/SKIP ./stage4/SKIP
115
-
$ rm stage4/EXPORT*
221
+
echo"IMG_NAME='Raspbian'"> config
222
+
touch ./stage3/SKIP ./stage4/SKIP ./stage5/SKIP
223
+
rm stage4/EXPORT* stage5/EXPORT*
224
+
sudo ./build.sh # or ./build-docker.sh
116
225
```
117
-
If you wish to build further configurations upon (for example) the lite system, you can also delete the contents of `./stage3` and `./stage4` and replace with your own contents in the same format.
226
+
227
+
If you wish to build further configurations upon (for example) the lite
228
+
system, you can also delete the contents of `./stage3` and `./stage4` and
229
+
replace with your own contents in the same format.
230
+
231
+
232
+
## Skipping stages to speed up development
233
+
234
+
If you're working on a specific stage the recommended development process is as
235
+
follows:
236
+
237
+
* Add a file called SKIP_IMAGES into the directories containing EXPORT_* files
238
+
(currently stage2, stage4 and stage5)
239
+
* Add SKIP files to the stages you don't want to build. For example, if you're
240
+
basing your image on the lite image you would add these to stages 3, 4 and 5.
241
+
* Run build.sh to build all stages
242
+
* Add SKIP files to the earlier successfully built stages
243
+
* Modify the last stage
244
+
* Rebuild just the last stage using ```sudo CLEAN=1 ./build.sh```
245
+
* Once you're happy with the image you can remove the SKIP_IMAGES files and
0 commit comments