-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbase-pack.yaml
148 lines (125 loc) · 4.39 KB
/
base-pack.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
{{- $architecture := or .architecture "arm64" -}}
{{- $firmware_version := or .firmware_version "1.20241008" -}}
{{- $mirror := or .mirror "http://deb.debian.org/debian" -}}
{{- $suite := or .suite "bookworm" -}}
{{- $username := or .username "user" -}}
{{- $hostname := or .hostname "raspberrypi" -}}
{{- $pack := or .pack "true" }}
{{- $basepack := or .basepack "base-pack-debian-rpi4" -}}
architecture: {{ $architecture }}
actions:
{{ if ne $firmware_version "debian" }}
# Download all needed proprietary stuff first
- action: download
description: Download latest version of the firmware from GitHub
url: http://github.com/raspberrypi/firmware/archive/refs/tags/{{ $firmware_version }}.tar.gz
unpack: true # Unpack downloaded file
name: firmware # name for usage directory with unpacked content in other actions
{{ end }}
- action: debootstrap
suite: {{ $suite }}
components:
- main
- non-free
- non-free-firmware
mirror: {{ $mirror }}
variant: minbase
- action: apt
description: Install extra packages
packages:
- adduser
- bluetooth
- ca-certificates
- dbus-user-session
- iproute2
- i2c-tools
- libnss-resolve
- openssh-server
- sudo
- systemd-sysv
- u-boot-menu
- u-boot-rpi
- vim-tiny
- systemd-timesyncd
- zstd
- action: overlay
description: Install U-Boot menu configuration
source: overlays/u-boot-menu
- action: apt
description: Install kernel and firmware packages for RPi
packages:
- linux-image-{{ $architecture}}
- firmware-brcm80211
- rpi.gpio-common
- action: overlay
description: Copy config.txt
source: overlays/fw-config
destination: /boot/firmware
- action: run
description: Install U-Boot
chroot: false
command: sh -c "cp -av ${ROOTDIR}/usr/lib/u-boot/rpi_arm64/u-boot.bin ${ROOTDIR}/boot/firmware/"
- action: run
description: Copy DTBs for the kernel
chroot: false
command: sh -c "mkdir -p ${ROOTDIR}/boot/dtbs; cp -rav ${ROOTDIR}/usr/lib/linux-image-*-arm64/broadcom ${ROOTDIR}/boot/dtbs/"
{{ if ne $firmware_version "debian" }}
- action: overlay
description: Install RPi boot firmware ({{ $firmware_version }})
origin: firmware
source: firmware-{{ $firmware_version }}/boot
destination: /boot/firmware
{{ else }}
- action: apt
description: Install RPi firmware package
packages:
- raspi-firmware
- action: run
description: Install RPi boot firmware (Debian)
chroot: false
command: sh -c "cp -av ${ROOTDIR}/usr/lib/raspi-firmware/* ${ROOTDIR}/boot/firmware/"
- action: run
description: Copy DTBs from the kernel
chroot: false
command: sh -c "cp -av ${ROOTDIR}/usr/lib/linux-image-*-arm64/broadcom/* ${ROOTDIR}/boot/firmware/"
- action: run
description: Use upstream DTBs naming
chroot: false
command: sh -c "echo upstream_kernel=1 >> ${ROOTDIR}/boot/firmware/config.txt"
# Do not need to keep firmware package after firmware partition setup.
# raspi-firmware contains kernel postinstall script incompatible with U-Boot
- action: run
description: Remove RPi firmware package
chroot: true
command: dpkg -P raspi-firmware
{{ end }}
- action: run
description: Cleanup firmware partition
chroot: false
command: sh -c "rm -rf ${ROOTDIR}/boot/firmware/kernel* ${ROOTDIR}/boot/firmware/vmlinuz* ${ROOTDIR}/boot/firmware/initrd.img*"
- action: run
description: Set up user {{ $username }}
chroot: true
command: adduser --gecos {{ $username }} --disabled-password --shell /bin/bash {{ $username }}; echo "{{ $username }}:{{ $username }}" | chpasswd
- action: run
description: Add user {{ $username }} to sudoers
chroot: true
command: /usr/sbin/usermod -a -G sudo {{ $username }}; mkdir -p /etc/sudoers.d; echo "{{ $username }} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/{{ $username }}
- action: run
description: Add hostname
chroot: true
command: echo {{ $hostname }} > /etc/hostname
- action: overlay
description: Autoload modules
source: overlays/modules
- action: overlay
source: overlays/networkd
- action: run
chroot: true
script: scripts/setup_networking.sh
{{- if eq $pack "true" }}
- action: pack
description: Compress base pack into {{ $basepack }}
compression: gz
file: {{ $basepack }}.tar.gz
{{- end }}