Skip to content

Commit ebdfbe5

Browse files
committed
examples: Add slim example
examples/slim creates an image containing a small set of base packages + rpi firmware and v8 kernel. The rootfs has no apt or dpkg functionality and it has very little in the way of usable utilities installed. This is mainly to demonstrate what's needed for a small footprint image that can be installed via Debian means while providing a systemd init and initramfs. Add new base profile meta/debian/bookworm/arm64/base-slim.yaml which has a custom package list sufficient for a bootable bookworm image plus initramfs.
1 parent 25e3577 commit ebdfbe5

File tree

11 files changed

+185
-0
lines changed

11 files changed

+185
-0
lines changed

examples/slim/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Build a small system with minimum base packages.
2+
3+
Contains a custom image layout and a custom board dir.
4+
5+
```text
6+
examples/slim/
7+
|-- board
8+
| `-- mypi5
9+
| |-- post-build.sh
10+
| `-- rootfs-overlay
11+
| |-- boot
12+
| | `-- firmware
13+
| | `-- cmdline.txt
14+
| `-- etc
15+
| `-- fstab
16+
|-- config
17+
| `-- pi5-slim.cfg
18+
|-- image
19+
| `-- compact
20+
| |-- genimage.cfg.in
21+
| `-- pre-image.sh
22+
|-- meta
23+
| `-- slim-customisations.yaml
24+
|-- my.options
25+
|-- profile
26+
| `-- v8-svelte
27+
`-- README.md
28+
```
29+
30+
```bash
31+
./build.sh -D ./examples/slim/ -c pi5-slim -o ./examples/slim/my.options
32+
```
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
3+
set -eu
4+
5+
rootfs="$1"
6+
7+
# Clean up stuff we don't need
8+
rm -rf $1/etc/apt
9+
rm -rf $1/etc/dpkg
10+
rm -rf $1/usr/bin/dpkg
11+
rm -rf $1/var/cache/*
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console=ttyAMA10,115200 root=/dev/disk/by-label/ROOT rootfstype=ext4 fsck.repair=yes rootwait
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/dev/disk/by-label/ROOT / ext4 rw,relatime,errors=remount-ro 0 1
2+
/dev/disk/by-label/BOOT /boot/firmware vfat rw,noatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro 0 2

examples/slim/config/pi5-slim.cfg

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[target]
2+
board=mypi5
3+
4+
[image]
5+
layout=compact
6+
name=deb12-slim
7+
8+
[system]
9+
profile=v8-svelte
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
image <IMAGE_DIR>/<IMAGE_NAME>.<IMAGE_SUFFIX> {
2+
hdimage {
3+
partition-table-type = "mbr"
4+
}
5+
6+
partition boot {
7+
in-partition-table = true
8+
partition-type = 0xC
9+
image = boot.vfat
10+
bootable = true
11+
}
12+
13+
partition root {
14+
in-partition-table = true
15+
partition-type = 0x83
16+
image = root.ext4
17+
}
18+
}
19+
20+
image boot.vfat {
21+
vfat {
22+
label = "BOOT"
23+
}
24+
size = <FW_SIZE>
25+
mountpoint = "/boot/firmware"
26+
}
27+
28+
image root.ext4 {
29+
ext4 {
30+
use-mke2fs = true
31+
label = "ROOT"
32+
}
33+
size = <ROOT_SIZE>
34+
mountpoint = "/"
35+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
3+
set -eu
4+
5+
rootfs=$1
6+
genimg_in=$2
7+
8+
FW_SIZE=100%
9+
ROOT_SIZE=100%
10+
11+
cat genimage.cfg.in | sed \
12+
-e "s|<IMAGE_DIR>|$IGconf_image_outputdir|g" \
13+
-e "s|<IMAGE_NAME>|$IGconf_image_name|g" \
14+
-e "s|<IMAGE_SUFFIX>|$IGconf_image_suffix|g" \
15+
-e "s|<FW_SIZE>|$FW_SIZE|g" \
16+
-e "s|<ROOT_SIZE>|$ROOT_SIZE|g" \
17+
> ${genimg_in}/genimage.cfg
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
name: example-slim
3+
mmdebstrap:
4+
customize-hooks:
5+
- chroot $1 sh -c "useradd -m -s /bin/bash -u 4000 $IGconf_first_user_name"
6+
- |-
7+
if [ -n "$IGconf_first_user_pass" ] ; then
8+
chroot $1 sh -c "echo ${IGconf_first_user_name}:${IGconf_first_user_pass} | chpasswd"
9+
fi
10+
- chroot $1 usermod --pass='*' root

examples/slim/my.options

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FIRST_USER_PASS=removeme

examples/slim/profile/v8-svelte

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Minimum Debian footprint system with v8 kernel
2+
3+
debian/bookworm/arm64/base-slim
4+
rpi/debian/bookworm/apt
5+
rpi/arm64/linux-image-v8
6+
rpi/boot-firmware
7+
rpi/misc-skel
8+
sys-apps/systemd-net-min
9+
slim-customisations
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
name: bookworm-arm64-slim
3+
mmdebstrap:
4+
architectures:
5+
- arm64
6+
mode: auto
7+
variant: custom
8+
suite: bookworm
9+
mirrors:
10+
- deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
11+
- deb http://deb.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
12+
- deb http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware
13+
packages:
14+
- perl
15+
- findutils
16+
- dpkg
17+
- libc-bin
18+
- base-files
19+
- base-passwd
20+
- debianutils
21+
- bash
22+
- diffutils
23+
- util-linux
24+
- sed
25+
- grep
26+
- gzip
27+
- udev
28+
- e2fsprogs
29+
- login
30+
setup-hooks:
31+
- mkdir -p $1/bin
32+
- ln -s bash $1/bin/sh
33+
essential-hooks:
34+
- echo tzdata tzdata/Areas select "$IGconf_timezone_area"
35+
| chroot $1 debconf-set-selections
36+
- echo tzdata tzdata/Zones/$IGconf_timezone_area select "$IGconf_timezone_city"
37+
| chroot $1 debconf-set-selections
38+
- echo locales locales/locales_to_be_generated multiselect "$IGconf_locale_default"
39+
| chroot $1 debconf-set-selections
40+
- echo locales locales/default_environment_locale select "$IGconf_locale_default"
41+
| chroot $1 debconf-set-selections
42+
- echo keyboard-configuration keyboard-configuration/variant select "$IGconf_keyboard_layout"
43+
| chroot $1 debconf-set-selections
44+
- echo keyboard-configuration keyboard-configuration/xkb-keymap select "$IGconf_keyboard_keymap"
45+
| chroot $1 debconf-set-selections
46+
aptopts:
47+
- APT::Install-Suggests "false"
48+
- APT::Install-Recommends "false"
49+
dpkgopts:
50+
- path-exclude=/usr/share/man/*
51+
- path-include=/usr/share/man/man[1-9]/*
52+
- path-exclude=/usr/share/locale/*
53+
- path-include=/usr/share/locale/locale.alias
54+
- path-exclude=/usr/share/doc/*
55+
- path-include=/usr/share/doc/*/copyright
56+
- path-include=/usr/share/doc/*/changelog.Debian.*
57+
- path-exclude=/usr/share/{doc,info,man,omf,help,gnome/help}/*
58+
- path-exclude=/usr/share/lintian/*

0 commit comments

Comments
 (0)