Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ jobs:
pip install -U pip
pip install -e .[lint,scripts,check]

- name: Check black formatting
run: inv lint-black

- name: Check ruff
run: inv lint-ruff

Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Based on pi-gen `2025-10-01-raspios-trixie`
- Using offspot-config 2.x.x
- Data partition block-size now ~1Mib instead of 1KiB
- Data partition reserved blocks for root to 1% instead of 5%
- balena service to be started before offspot-runtime
- docker-compose service not started automatically (started by offspot-runtime)

### Removed

- Support for armhf. It's a soft removal, we just don't test it anymore. Use at own risk

## [1.3.1] - 2025-03-25

### Changed
Expand Down
14 changes: 10 additions & 4 deletions builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ def run(*args, **kwargs):
class Defaults:
supported_archs = ("armhf", "arm64")
# using supported_archs indexes
pigen_versions = ( # ~ 2023-05-03-raspios-buster
"2024-03-15-raspios-bookworm",
"2024-03-15-raspios-bookworm-arm64",
pigen_versions = (
"2025-10-01-raspios-trixie-armhf",
"2025-10-01-raspios-trixie-arm64",
)
arch: str = "arm64"
is_macos: bool = platform.system() == "Darwin"
Expand Down Expand Up @@ -62,6 +62,8 @@ class Defaults:
ENABLE_SSH: str = "0"
PUBKEY_SSH_FIRST_USER: str = ""
PUBKEY_ONLY_SSH: str = "0"
ENABLE_CLOUD_INIT: str = "0"
WPA_COUNTRY: str = "US"
STAGE_LIST: str = "stage0 stage1 stage2"

@property
Expand Down Expand Up @@ -98,6 +100,10 @@ class Builder:
def __init__(self, conf):
self.conf = conf

if self.conf.arch == "armhf":
message = f"WARN: arch {self.conf.arch} is not tested. Use at own risk"
print(f"\033[91m{message}\033[0m", flush=True) # noqa: T201

def run(self):
# stop builder right away if target file already exists
if self.conf.output.exists():
Expand All @@ -120,7 +126,7 @@ def run(self):
f"starting pi-gen build with {config_path}\n{config_path.read_text()}"
)

self.build()
return self.build()

def download_pigen(self):
"""clone requested version of Pi-gen"""
Expand Down
8 changes: 6 additions & 2 deletions packages
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
+ jq
+ tree

# replace netplan with ifupdown
- netplan.io
+ ifupdown

# docker stack: disabled in favor of balena (stage2/06-docker-tweaks)
# docker-ce docker-ce-cli containerd.io docker-compose-plugin

Expand All @@ -21,10 +25,10 @@
+ hostapd dnsmasq

# not needed on host
- pi-bluetooth v4l-utils python3-gpiozero python3-rpi.gpio python3-v4l2
- v4l-utils python3-gpiozero python3-rpi-lgpio

# disable swap
- dphys-swapfile
# - rpi-swap

# continue to use dhcpcd5 (replaced by network-manager in 2023-10)
# purposedly not using `dhcpcd5` as its a virtual package with conflict from raspberry-sys-mod
Expand Down
13 changes: 6 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,25 @@ build-backend = "hatchling.build"

[project]
name = "builder"
requires-python = ">=3.9,<3.13"
requires-python = ">=3.13,<3.14"
description = "Offspot Base Image Builder"
readme = "README.md"
dependencies = []
version = "1.0.0.dev0"

[project.optional-dependencies]
scripts = [
"invoke==2.2.0",
"invoke==2.2.1",
]
lint = [
"black==24.4.0",
"ruff==0.4.1",
"ruff==0.14.0",
]
check = [
"pyright==1.1.359",
"pyright==1.1.406",
]
dev = [
"pre-commit==3.7.0",
"ipython==8.23.0",
"pre-commit==4.3.0",
"ipython==9.6.0",
"builder[scripts]",
"builder[lint]",
"builder[check]",
Expand Down
21 changes: 3 additions & 18 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def report_cov(ctx: Context, *, html: bool = False):
"""report coverage"""
ctx.run("coverage combine", warn=True, pty=use_pty)
ctx.run("coverage report --show-missing", pty=use_pty)
ctx.run("coverage xml", pty=use_pty)
if html:
ctx.run("coverage html", pty=use_pty)

Expand All @@ -41,13 +42,6 @@ def coverage(ctx: Context, args: str = "", *, html: bool = False):
report_cov(ctx, html=html)


@task(optional=["args"], help={"args": "black additional arguments"})
def lint_black(ctx: Context, args: str = "."):
args = args or "." # needed for hatch script
ctx.run("black --version", pty=use_pty)
ctx.run(f"black --check --diff {args}", pty=use_pty)


@task(optional=["args"], help={"args": "ruff additional arguments"})
def lint_ruff(ctx: Context, args: str = "."):
args = args or "." # needed for hatch script
Expand All @@ -58,13 +52,12 @@ def lint_ruff(ctx: Context, args: str = "."):
@task(
optional=["args"],
help={
"args": "linting tools (black, ruff) additional arguments, typically a path",
"args": "linting tools (ruff) additional arguments, typically a path",
},
)
def lintall(ctx: Context, args: str = "."):
"""Check linting"""
args = args or "." # needed for hatch script
lint_black(ctx, args)
lint_ruff(ctx, args)


Expand All @@ -81,13 +74,6 @@ def checkall(ctx: Context, args: str = ""):
check_pyright(ctx, args)


@task(optional=["args"], help={"args": "black additional arguments"})
def fix_black(ctx: Context, args: str = "."):
"""fix black formatting"""
args = args or "." # needed for hatch script
ctx.run(f"black {args}", pty=use_pty)


@task(optional=["args"], help={"args": "ruff additional arguments"})
def fix_ruff(ctx: Context, args: str = "."):
"""fix all ruff rules"""
Expand All @@ -98,12 +84,11 @@ def fix_ruff(ctx: Context, args: str = "."):
@task(
optional=["args"],
help={
"args": "linting tools (black, ruff) additional arguments, typically a path",
"args": "linting tools (ruff) additional arguments, typically a path",
},
)
def fixall(ctx: Context, args: str = "."):
"""Fix everything automatically"""
args = args or "." # needed for hatch script
fix_black(ctx, args)
fix_ruff(ctx, args)
lintall(ctx, args)
5 changes: 4 additions & 1 deletion tree/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ pi-gen tree replacements

```sh
diff -u path/to/original path/to/updated > tree/path/to/original.patch
```

# or, if working from a git copy of the original tree (I use tree-arm54.orig)
git diff --no-prefix path/to/original > ../tree/path/to/original.patch
```
72 changes: 36 additions & 36 deletions tree/build-docker.sh.patch-arm64
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
*** tree-arm64.orig/build-docker.sh 2023-10-26 17:06:34
--- tree/build-docker.sh 2023-10-26 17:14:07
*************** esac
*** 105,135 ****
;;
esac
- # Check if qemu-aarch64-static and /proc/sys/fs/binfmt_misc are present
- if [[ "${binfmt_misc_required}" == "1" ]]; then
- if ! qemu_arm=$(which qemu-aarch64-static) ; then
- echo "qemu-aarch64-static not found (please install qemu-user-static)"
- exit 1
- fi
- if [ ! -f /proc/sys/fs/binfmt_misc/register ]; then
- echo "binfmt_misc required but not mounted, trying to mount it..."
- if ! mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc ; then
- echo "mounting binfmt_misc failed"
- exit 1
- fi
- echo "binfmt_misc mounted"
- fi
- if ! grep -q "^interpreter ${qemu_arm}" /proc/sys/fs/binfmt_misc/qemu-aarch64* ; then
- # Register qemu-aarch64 for binfmt_misc
- reg="echo ':qemu-aarch64-rpi:M::"\
- "\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00:"\
- "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:"\
- "${qemu_arm}:F' > /proc/sys/fs/binfmt_misc/register"
- echo "Registering qemu-aarch64 for binfmt_misc..."
- sudo bash -c "${reg}" 2>/dev/null || true
- fi
- fi
-
trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${DOCKER_CMDLINE_NAME}' SIGINT SIGTERM
time ${DOCKER} run \
$DOCKER_CMDLINE_PRE \
--- 105,110 ----
diff --git build-docker.sh build-docker.sh
index 53f8cf7..b53fd9c 100755
--- build-docker.sh
+++ build-docker.sh
@@ -105,31 +105,6 @@ case $(uname -m) in
;;
esac
-# Check if qemu-aarch64-static and /proc/sys/fs/binfmt_misc are present
-if [[ "${binfmt_misc_required}" == "1" ]]; then
- if ! qemu_arm=$(which qemu-aarch64-static) ; then
- echo "qemu-aarch64-static not found (please install qemu-user-static)"
- exit 1
- fi
- if [ ! -f /proc/sys/fs/binfmt_misc/register ]; then
- echo "binfmt_misc required but not mounted, trying to mount it..."
- if ! mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc ; then
- echo "mounting binfmt_misc failed"
- exit 1
- fi
- echo "binfmt_misc mounted"
- fi
- if ! grep -q "^interpreter ${qemu_arm}" /proc/sys/fs/binfmt_misc/qemu-aarch64* ; then
- # Register qemu-aarch64 for binfmt_misc
- reg="echo ':qemu-aarch64-rpi:M::"\
-"\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00:"\
-"\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:"\
-"${qemu_arm}:F' > /proc/sys/fs/binfmt_misc/register"
- echo "Registering qemu-aarch64 for binfmt_misc..."
- sudo bash -c "${reg}" 2>/dev/null || true
- fi
-fi
-
trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${DOCKER_CMDLINE_NAME}' SIGINT SIGTERM
time ${DOCKER} run \
$DOCKER_CMDLINE_PRE \
72 changes: 36 additions & 36 deletions tree/build-docker.sh.patch-armhf
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
*** tree-armhf.orig/build-docker.sh 2023-10-26 17:07:21
--- tree/build-docker.sh 2023-10-26 17:15:32
*************** esac
*** 114,144 ****
;;
esac
- # Check if qemu-arm-static and /proc/sys/fs/binfmt_misc are present
- if [[ "${binfmt_misc_required}" == "1" ]]; then
- if ! qemu_arm=$(which qemu-arm-static) ; then
- echo "qemu-arm-static not found (please install qemu-user-static)"
- exit 1
- fi
- if [ ! -f /proc/sys/fs/binfmt_misc/register ]; then
- echo "binfmt_misc required but not mounted, trying to mount it..."
- if ! mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc ; then
- echo "mounting binfmt_misc failed"
- exit 1
- fi
- echo "binfmt_misc mounted"
- fi
- if ! grep -q "^interpreter ${qemu_arm}" /proc/sys/fs/binfmt_misc/qemu-arm* ; then
- # Register qemu-arm for binfmt_misc
- reg="echo ':qemu-arm-rpi:M::"\
- "\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:"\
- "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:"\
- "${qemu_arm}:F' > /proc/sys/fs/binfmt_misc/register"
- echo "Registering qemu-arm for binfmt_misc..."
- sudo bash -c "${reg}" 2>/dev/null || true
- fi
- fi
-
trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${DOCKER_CMDLINE_NAME}' SIGINT SIGTERM
time ${DOCKER} run \
$DOCKER_CMDLINE_PRE \
--- 114,119 ----
diff --git build-docker.sh build-docker.sh
index 9c04651..71ced83 100755
--- build-docker.sh
+++ build-docker.sh
@@ -114,31 +114,6 @@ case $(uname -m) in
;;
esac
-# Check if qemu-arm-static and /proc/sys/fs/binfmt_misc are present
-if [[ "${binfmt_misc_required}" == "1" ]]; then
- if ! qemu_arm=$(which qemu-arm-static) ; then
- echo "qemu-arm-static not found (please install qemu-user-static)"
- exit 1
- fi
- if [ ! -f /proc/sys/fs/binfmt_misc/register ]; then
- echo "binfmt_misc required but not mounted, trying to mount it..."
- if ! mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc ; then
- echo "mounting binfmt_misc failed"
- exit 1
- fi
- echo "binfmt_misc mounted"
- fi
- if ! grep -q "^interpreter ${qemu_arm}" /proc/sys/fs/binfmt_misc/qemu-arm* ; then
- # Register qemu-arm for binfmt_misc
- reg="echo ':qemu-arm-rpi:M::"\
-"\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:"\
-"\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:"\
-"${qemu_arm}:F' > /proc/sys/fs/binfmt_misc/register"
- echo "Registering qemu-arm for binfmt_misc..."
- sudo bash -c "${reg}" 2>/dev/null || true
- fi
-fi
-
trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${DOCKER_CMDLINE_NAME}' SIGINT SIGTERM
time ${DOCKER} run \
$DOCKER_CMDLINE_PRE \
11 changes: 0 additions & 11 deletions tree/export-image/05-finalise/01-run.sh.patch

This file was deleted.

4 changes: 2 additions & 2 deletions tree/export-image/prerun.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ rm -rf "${ROOTFS_DIR}"
mkdir -p "${ROOTFS_DIR}"

BOOT_SIZE="$((512 * 1024 * 1024))"
ROOT_SIZE=$(du --apparent-size -s "${EXPORT_ROOTFS_DIR}" --exclude var/cache/apt/archives --exclude boot/firmware --block-size=1 | cut -f 1)
ROOT_SIZE=$(du -x --apparent-size -s "${EXPORT_ROOTFS_DIR}" --exclude var/cache/apt/archives --exclude boot/firmware --block-size=1 | cut -f 1)
# use ~256Mi for data. shall be recreated by final-image creator tool
DATA_SIZE="$((256 * 1024 * 1024))"

# All partition sizes and starts will be aligned to this size
ALIGN="$((4 * 1024 * 1024))"
ALIGN="$((8 * 1024 * 1024))"
# Add this much space to the calculated file size. This allows for
# some overhead (since actual space usage is usually rounded up to the
# filesystem block size) and gives some free space on the resulting
Expand Down
Loading