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
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@
/build/*
!/build/conf/
!/build/meta-*/
# The core layer has NO dash, so "meta-*" above does not match it: its classes
# (base, patch, utils, logging, terminal) and conf/ were tracked only because
# they predate the rule, and any file added there since would have been ignored
# in silence — a new class simply never reaching the repository.
!/build/meta/

# Per-machine bitbake overrides (see build/meta/conf/bitbake.conf). The rule
# just above re-includes all of build/conf/, so this one file needs its own.
# The TEZI feed published by deploy.sh lives in build/deploy/ (along with the
# feed server's pid/log) and is already covered by the /build/* rule.
/build/conf/site.conf

# The rpi4 BSP deploys Broadcom's prebuilt bcm27xx device trees onto the boot
# partition, alongside start4.elf & co. Unlike every other .dtb in the tree they
Expand Down
19 changes: 17 additions & 2 deletions build/conf/local.conf
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,23 @@ IB_STORAGE_MODE:verdin-imx8mp ?= "http"
# IB_STORAGE_DEVICE:rpi4_64 = "mmcblk0"
# IB_STORAGE_DEVICE:verdin-imx8mp = "sda"

# HTTP deploy path: TEZI files are placed here for TEZI network auto-install
IB_HTTP_DEPLOY_PATH:verdin-imx8mp = "/var/www/html/verdin-imx8mp-prod"
# HTTP deploy path: TEZI files are placed here for TEZI network auto-install,
# and scripts/tezi-feed-serve.sh serves this directory over HTTP.
#
# Tree-relative on purpose: this file is tracked, so it must not carry a
# machine-specific absolute path. Keeping the feed inside the tree also means
# it is already visible to the build container (dbuild.sh bind-mounts the
# tree) and writable by the calling user, so publishing needs no sudo.
# Under build/deploy/ rather than build/tmp/ so a clean does not wipe a feed
# a board may be about to pull from.
#
# To publish elsewhere on one machine, override this in build/conf/site.conf
# (untracked, loaded after this file).
IB_HTTP_DEPLOY_PATH ?= "${IB_DIR}/build/deploy/tezi/${IB_PLATFORM}"

# Port scripts/tezi-feed-serve.sh listens on. Unprivileged so the feed server
# runs as your user; override in site.conf when two trees share a machine.
IB_HTTP_FEED_PORT ?= "8080"

# Size of the rootfs partition
IB_ROOTFS_SIZE ?= "2G"
Expand Down
26 changes: 24 additions & 2 deletions build/meta-bsp/recipes-bsp/bsp/files/bsp_verdin-imx8mp.inc
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def __fetch_torizon_tezi_image(d, dest_dir):
def __do_platform_deploy(d):
"""Stage a flashable TEZI image: our imx-boot (flash.bin) + boot.scr + the
AVZ+SO3 ITB, with image.json patched to auto-install them."""
import json
import os
import subprocess

Expand Down Expand Up @@ -169,8 +170,29 @@ def __do_platform_deploy(d):
if not final_dest:
bb.fatal("verdin: no deploy destination (set IB_HTTP_DEPLOY_PATH or use the default)")

utils_sudo(["mkdir", "-p", final_dest], check=True)
utils_sudo(["rsync", "-a", "--delete", f"{staging}/", f"{final_dest}/"], check=True)
# TEZI feed index. Written next to image.json so the feed directory is
# self-contained: whatever serves it (scripts/tezi-feed-serve.sh, or a
# web server on another machine) can use it as its document root, and
# the board's feed URL is always <root>/image_list.json. Kept relative
# for the same reason — no absolute path, no directory prefix.
with open(f"{staging}/image_list.json", "w") as f:
json.dump({"config_format": 1,
"autoinstall": "image.json",
"images": ["image.json"]}, f, indent=4)

# Publish. The default IB_HTTP_DEPLOY_PATH lives inside the tree and is
# owned by the calling user, so no privilege is needed; a site.conf that
# points somewhere root-owned (e.g. a web server document root) still
# works through the sudo fallback.
try:
os.makedirs(final_dest, exist_ok=True)
subprocess.run(["rsync", "-a", "--delete",
f"{staging}/", f"{final_dest}/"], check=True)
except (PermissionError, subprocess.CalledProcessError) as e:
bb.note(f"publishing to {final_dest} unprivileged failed ({e}); retrying with sudo")
utils_sudo(["mkdir", "-p", final_dest], check=True)
utils_sudo(["rsync", "-a", "--delete",
f"{staging}/", f"{final_dest}/"], check=True)

bb.plain("verdin: TEZI image staged at %s (imx-boot + boot.scr + ITB(s) for %s)"
% (final_dest, IB_TARGET_ITS))
7 changes: 7 additions & 0 deletions build/meta/conf/bitbake.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@
# Necessary to retrieve global variables from there
include conf/local.conf

# Optional per-machine overrides, loaded after local.conf so they win.
# Untracked (see .gitignore): this is where a machine deviates from the
# tree defaults — e.g. publishing the TEZI feed somewhere else than
# ${IB_HTTP_DEPLOY_PATH}. Absent on most machines; `include` is silent
# when the file does not exist.
include conf/site.conf

# its own in staging
ASSUME_PROVIDED = "\
patch-native \
Expand Down
42 changes: 40 additions & 2 deletions scripts/dbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ set -- -e IB_TREE="$IB_ROOT" -e IB_CWD="$cwd" "$@"
# bind-mounted and the container is privileged (it writes the HOST's
# device, so double-check IB_STORAGE_DEVICE).
#
# The DEFAULT feed lives inside the tree (IB_HTTP_DEPLOY_PATH in
# local.conf), which is already bind-mounted, so this loop does nothing
# for it. It only matters for a build/conf/site.conf that redirects the
# feed out of the tree.
#
# A snap-packaged Docker cannot do this: the confined daemon only reaches
# $HOME (and a few allowed paths), so bind-mounting e.g. /var/www/html
# fails with "mkdir /var/www: read-only file system". Skip the mount
Expand All @@ -137,8 +142,27 @@ case "$(command -v docker)" in
/snap/*) _snap_docker=1 ;;
esac

# The client path is not proof either way: the docker snap also ships a
# /usr/bin/docker wrapper, so a confined daemon can hide behind an
# ordinary-looking binary. Ask the daemon itself — a snap daemon keeps
# its root under /var/snap. Only worth doing when the path check missed.

if [ "$_snap_docker" = "0" ]; then
case "$(docker info --format '{{.DockerRootDir}}' 2>/dev/null)" in
/var/snap/*|/snap/*) _snap_docker=1 ;;
esac
fi

for _feed in $(sed -n 's/^[[:space:]]*IB_HTTP_DEPLOY_PATH[^=]*=[[:space:]]*"\([^"]*\)".*/\1/p' \
"$IB_ROOT/build/conf/local.conf" 2>/dev/null | sort -u); do
"$IB_ROOT/build/conf/local.conf" "$IB_ROOT/build/conf/site.conf" \
2>/dev/null | sort -u); do
# Tree-relative defaults are already inside the bind-mounted tree, and
# ${...} references are not expanded here — skip both.
case "$_feed" in
*'${'*) continue ;;
"$IB_ROOT"|"$IB_ROOT"/*) continue ;;
esac

[ -d "$_feed" ] || continue

case "$_feed" in
Expand Down Expand Up @@ -217,4 +241,18 @@ set -- --rm \
-e TERM="${TERM:-xterm}" \
"$@"

exec docker run "$@"
docker run "$@"
_rc=$?

# The TEZI feed server has to run on the HOST: the container is --rm, so a
# server started inside it dies with the command that started it. It shares
# the host network namespace (--network host above), but not its lifetime.
#
# Run this after the container rather than before, so the very first
# `dbuild.sh deploy.sh ...` — which creates the feed inside the container —
# leaves a serving feed behind too. Idempotent, and a no-op when nothing has
# been published yet or a server is already up.

"$IB_ROOT/scripts/tezi-feed-serve.sh" --ensure

exit $_rc
7 changes: 7 additions & 0 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,11 @@ then
then
exit 1
fi

# Make the freshly published TEZI feed reachable without a manual
# step. Idempotent and quiet when a server is already up; a no-op
# when the deploy did not publish an HTTP feed, in CI, and inside
# the build container (dbuild.sh does it on the host instead —
# a server started in the container would die with it).
./scripts/tezi-feed-serve.sh --ensure
fi
Loading
Loading