Skip to content

Commit 501d03c

Browse files
committed
Merge branch 'RPi-Distro-dev' into dev
2 parents 1fe50b6 + 89ea4f1 commit 501d03c

File tree

20 files changed

+115
-36
lines changed

20 files changed

+115
-36
lines changed

README.md

Lines changed: 71 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,18 @@ Build instructions:
1616
- Retrieve your freshly built Raspberry Pi image from the `rpi_gen\deploy` folder.
1717

1818

19-
### Dependencies
19+
## Dependencies
20+
21+
On Debian-based systems:
22+
23+
```bash
24+
apt-get install quilt parted realpath qemu-user-static debootstrap zerofree pxz zip \
25+
dosfstools bsdtar libcap2-bin grep rsync
26+
```
27+
28+
The file `depends` contains a list of tools needed. The format of this
29+
package is `<tool>[:<debian-package>]`.
2030

21-
`quilt parted realpath qemu-user-static debootstrap zerofree pxz zip dosfstools bsdtar libcap2-bin grep rsync`
2231

2332
## Config
2433

@@ -28,34 +37,73 @@ environment variables.
2837

2938
The following environment variables are supported:
3039

31-
* `IMG_NAME`, the name of the distribution to build (required)
3240
* `APT_PROXY`, proxy/cache URL to be included in the build
3341

42+
* `IMG_NAME`, the name of the distribution to build (required)
43+
The name of the image to build with the current stage directories. Setting
44+
`IMG_NAME=Raspbian` is logical for an unmodified RPi-Distro/pi-gen build,
45+
but you should use something else for a customized version. Export files
46+
in stages may add suffixes to `IMG_NAME`.
47+
48+
* `APT_PROXY` (Default: unset)
49+
50+
If you require the use of an apt proxy, set it here. This proxy setting
51+
will not be included in the image, making it safe to use an `apt-cacher` or
52+
similar package for development.
53+
54+
* `BASE_DIR` (Default: location of `build.sh`)
55+
56+
**CAUTION**: Currently, changing this value will probably break build.sh
57+
58+
Top-level directory for `pi-gen`. Contains stage directories, build
59+
scripts, and by default both work and deployment directories.
60+
61+
* `WORK_DIR` (Default: `"$BASE_DIR/work"`)
62+
63+
Directory in which `pi-gen` builds the target system. This value can be
64+
changed if you have a suitably large, fast storage location for stages to
65+
be built and cached. Note, `WORK_DIR` stores a complete copy of the target
66+
system for each build stage, amounting to tens of gigabytes in the case of
67+
Raspbian.
68+
69+
* `DEPLOY_DIR` (Default: `"$BASE_DIR/deploy"`)
70+
71+
Output directory for target system images and NOOBS bundles.
72+
3473
A simple example for building Hassbian:
74+
=======
3575

3676
```bash
3777
IMG_NAME='Hassbian'
3878
```
3979

80+
4081
## Docker Build
4182

4283
```bash
4384
nano config # Edit your config file. See above.
4485
./build-docker.sh
4586
```
87+
4688
If everything goes well, your finished image will be in the `deploy/` folder.
47-
You can then remove the build container with `docker rm pigen_work`
89+
You can then remove the build container with `docker rm -v pigen_work`
4890

4991
If something breaks along the line, you can edit the corresponding scripts, and
5092
continue:
5193

52-
```
94+
```bash
5395
CONTINUE=1 ./build-docker.sh
5496
```
5597

56-
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).
98+
There is a possibility that even when running from a docker container, the
99+
installation of `qemu-user-static` will silently fail when building the image
100+
because `binfmt-support` _must be enabled on the underlying kernel_. An easy
101+
fix is to ensure `binfmt-support` is installed on the host machine before
102+
starting the `./build-docker.sh` script (or using your own docker build
103+
solution).
104+
57105

58-
### Raspbian Stage Anatomy
106+
### Hasspbian Stage Anatomy
59107

60108
The build of Hassbian is divided up into several stages for logical clarity
61109
and modularity. This causes some initial complexity, but it simplifies
@@ -101,15 +149,26 @@ maintenance and allows for more easy customization.
101149
The original **Stage 4** and **Stage 5** are removed since they are not
102150
used on the HASSbian image.
103151

104-
### Stage specification
105-
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.
106152

107-
Then remove the `EXPORT*` files from `./stage3` (if building up to stage 2) and add them to `./stage2`.
108-
109-
```
110153
## Example for building a lite system without Home Assistant
111154
$ touch ./stage3/SKIP
112155
$ rm stage3/EXPORT*
113156
$ touch stage3/EXPORT_IMAGE
114157
```
115158
If you wish to build further configurations upon (for example) the lite system, you can also delete the contents of `./stage3` and replace with your own contents in the same format.
159+
160+
=======
161+
If you wish to build up to a specified stage (such as building up to stage 2
162+
for a lite system), place an empty file named `SKIP` in each of the `./stage`
163+
directories you wish not to include.
164+
165+
Then remove the `EXPORT*` files from `./stage4` (if building up to stage 2) or
166+
from `./stage2` (if building a minimal system).
167+
168+
```bash
169+
# Example for building a lite system
170+
echo "IMG_NAME='Raspbian'" > config
171+
touch ./stage3/SKIP ./stage4/SKIP ./stage5/SKIP
172+
rm stage4/EXPORT*
173+
sudo ./build.sh # or ./build-docker.sh
174+
```

build-docker.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ if ! $DOCKER ps >/dev/null; then
1212
fi
1313
set -e
1414

15-
config_mount=
15+
config_mount="/dev/null:/dev/null"
1616
if [ -f config ]; then
17-
config_mount="-v $(pwd)/config:/pi-gen/config:ro"
17+
config_mount="$(pwd)/config:/pi-gen/config:ro"
1818
source config
1919
fi
2020

@@ -45,7 +45,7 @@ fi
4545
if [ "$CONTAINER_EXISTS" != "" ] && [ "$CONTINUE" != "1" ]; then
4646
echo "Container $CONTAINER_NAME already exists and you did not specify CONTINUE=1. Aborting."
4747
echo "You can delete the existing container like this:"
48-
echo " docker rm $CONTAINER_NAME"
48+
echo " docker rm -v $CONTAINER_NAME"
4949
exit 1
5050
fi
5151

@@ -54,6 +54,7 @@ if [ "$CONTAINER_EXISTS" != "" ]; then
5454
trap "echo 'got CTRL+C... please wait 5s';docker stop -t 5 ${CONTAINER_NAME}_cont" SIGINT SIGTERM
5555
time $DOCKER run --rm --privileged \
5656
--volumes-from="${CONTAINER_NAME}" --name "${CONTAINER_NAME}_cont" \
57+
-e IMG_NAME=${IMG_NAME}\
5758
pi-gen \
5859
bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static &&
5960
cd /pi-gen; ./build.sh;
@@ -62,8 +63,9 @@ if [ "$CONTAINER_EXISTS" != "" ]; then
6263
else
6364
trap "echo 'got CTRL+C... please wait 5s'; docker stop -t 5 ${CONTAINER_NAME}" SIGINT SIGTERM
6465
$DOCKER run --name "${CONTAINER_NAME}" --privileged \
65-
-v $(pwd)/deploy:/pi-gen/deploy \
66-
${config_mount} \
66+
-e IMG_NAME=${IMG_NAME}\
67+
-v "$(pwd)/deploy:/pi-gen/deploy" \
68+
-v "${config_mount}" \
6769
pi-gen \
6870
bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static &&
6971
cd /pi-gen; ./build.sh &&

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ if [ -z "${IMG_NAME}" ]; then
128128
exit 1
129129
fi
130130

131-
export IMG_DATE=${IMG_DATE:-"$(date -u +%Y-%m-%d)"}
131+
export IMG_DATE=${IMG_DATE:-"$(date +%Y-%m-%d)"}
132132

133133
export BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
134134
export SCRIPT_DIR="${BASE_DIR}/scripts"

export-image/04-finalise/01-run.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ rm -f ${ROOTFS_DIR}/var/lib/dbus/machine-id
3535

3636
true > ${ROOTFS_DIR}/etc/machine-id
3737

38+
ln -nsf /proc/mounts ${ROOTFS_DIR}/etc/mtab
39+
3840
for _FILE in $(find ${ROOTFS_DIR}/var/log/ -type f); do
3941
true > ${_FILE}
4042
done

export-image/prerun.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ rm -f ${IMG_FILE}
88
rm -rf ${ROOTFS_DIR}
99
mkdir -p ${ROOTFS_DIR}
1010

11-
BOOT_SIZE=$(du -s ${EXPORT_ROOTFS_DIR}/boot --block-size=1 | cut -f 1)
12-
TOTAL_SIZE=$(du -s ${EXPORT_ROOTFS_DIR} --exclude var/cache/apt/archives --block-size=1 | cut -f 1)
11+
BOOT_SIZE=$(du --apparent-size -s ${EXPORT_ROOTFS_DIR}/boot --block-size=1 | cut -f 1)
12+
TOTAL_SIZE=$(du --apparent-size -s ${EXPORT_ROOTFS_DIR} --exclude var/cache/apt/archives --block-size=1 | cut -f 1)
1313

14-
IMG_SIZE=$((BOOT_SIZE + TOTAL_SIZE + (400 * 1024 * 1024)))
14+
IMG_SIZE=$((BOOT_SIZE + TOTAL_SIZE + (800 * 1024 * 1024)))
1515

16-
fallocate -l ${IMG_SIZE} ${IMG_FILE}
16+
truncate -s ${IMG_SIZE} ${IMG_FILE}
1717
fdisk -H 255 -S 63 ${IMG_FILE} <<EOF
1818
o
1919
n
@@ -51,7 +51,7 @@ echo "/boot: offset $BOOT_OFFSET, length $BOOT_LENGTH"
5151
echo "/: offset $ROOT_OFFSET, length $ROOT_LENGTH"
5252

5353
mkdosfs -n boot -F 32 -v $BOOT_DEV > /dev/null
54-
mkfs.ext4 -O ^huge_file $ROOT_DEV > /dev/null
54+
mkfs.ext4 -O ^metadata_csum,^huge_file $ROOT_DEV > /dev/null
5555

5656
mount -v $ROOT_DEV ${ROOTFS_DIR} -t ext4
5757
mkdir -p ${ROOTFS_DIR}/boot

export-noobs/00-release/files/os.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"description": "NOOBS_DESCRIPTION",
33
"feature_level": 35120124,
4-
"kernel": "4.4",
4+
"kernel": "4.9",
55
"name": "NOOBS_NAME",
66
"password": "raspberry",
77
"release_date": "UNRELEASED",

export-noobs/00-release/files/release_notes.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11
UNRELEASED:
2+
*
3+
2017-07-05:
4+
* New kernel and firmware
5+
* Filesystem created without the metadata_csum feature
6+
2017-06-21:
7+
* Scratch 2 application included
8+
* Thonny Python IDE included
9+
* New icons with thinner outlines
10+
* Volume control more linear in behaviour
11+
* Updated Flash player
12+
* Updated RealVNC server and viewer
13+
* Various tweaks and bugfixes
14+
* New kernel and firmware
15+
2017-04-10:
216
* Wolfram Mathematica updated to version 11.0.1
317
* Adobe Flash Player updated to version 25.0.0.127
418
* Use PARTUUID to support USB boot

scripts/common

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ bootstrap(){
1616
fi
1717

1818
capsh --drop=cap_setfcap -- -c "${BOOTSTRAP_CMD} --components=main,contrib,non-free \
19-
--arch armhf\
20-
--no-check-gpg \
21-
$1 $2 $3"
19+
--arch armhf \
20+
--keyring "${STAGE_DIR}/files/raspberrypi.gpg" \
21+
$1 $2 $3" || rmdir "$2/debootstrap"
2222
}
2323
export -f bootstrap
2424

0 commit comments

Comments
 (0)