Make clean-clone OS rebuilds autonomous

A fresh clone can now bootstrap a complete armv7 rootfs, apply the Bananarchy overlay, regenerate boot artifacts, and produce a flashable image without local build artifacts.

- Add a shared package list and Docker-based rootfs bootstrap, wired into rebuild-image.sh and chroot-shell.sh.
- Add offline rebuild preflight checks and prebuilt-to-overlay artifact synchronization.
- Vendor the patched EDL client and provision host flashing dependencies.
- Remove the hardcoded credential from the power menu helper.
- Refresh documentation and changelog for the autonomous workflow.
This commit is contained in:
Luxferre committed 2026-11-05 13:40:53 +02:00
1 parent a9b72700ac
commit 0ab9367e28
31 files changed
+3809 -181

No files matched your search

+6
View File
@@ -307,6 +307,12 @@ ln -sf /usr/share/xsessions/sxmo.desktop "$TARGET_ROOTFS/var/lib/tinydm/default-
echo "[4/4] Installing deviceinfo for $DEVICE ($DTB_FILE)..."
if [ -f "$BASE_DIR/devices/$DEVICE_DIR/$DEVICEINFO_FILE" ]; then
cp -a "$BASE_DIR/devices/$DEVICE_DIR/$DEVICEINFO_FILE" "$TARGET_ROOTFS/etc/deviceinfo"
# mkinitfs sources /usr/share/deviceinfo/deviceinfo; pmbootstrap normally
# creates this link, so recreate it for rootfs builds done without it.
mkdir -p "$TARGET_ROOTFS/usr/share/deviceinfo"
cp -a "$BASE_DIR/devices/$DEVICE_DIR/$DEVICEINFO_FILE" \
"$TARGET_ROOTFS/usr/share/deviceinfo/device-$DEVICE"
ln -sf "device-$DEVICE" "$TARGET_ROOTFS/usr/share/deviceinfo/deviceinfo"
fi
if [ -f "$TARGET_ROOTFS/boot/extlinux/extlinux.conf" ]; then
sed -i "s|^[[:space:]]*fdt .*|\tfdt /$DTB_FILE|" "$TARGET_ROOTFS/boot/extlinux/extlinux.conf"
+24
View File
@@ -0,0 +1,24 @@
#!/bin/sh
# Install the host Python dependencies needed by flash-edl.py into a
# repository-local directory, so a clean clone can flash autonomously.
set -eu
BASE_DIR="$(cd "$(dirname "$0")/.." && pwd)"
PYTHON_BIN="${PYTHON_BIN:-python3}"
TARGET="$BASE_DIR/.flash-deps"
if "$PYTHON_BIN" -c 'import usb.core, serial' >/dev/null 2>&1; then
echo "[flash-deps] pyusb and pyserial are already available."
exit 0
fi
if ! "$PYTHON_BIN" -m pip --version >/dev/null 2>&1; then
echo "Error: python3 pip is required to install flashing dependencies." >&2
exit 1
fi
echo "[flash-deps] Installing pyusb and pyserial into $TARGET..."
mkdir -p "$TARGET"
"$PYTHON_BIN" -m pip install --disable-pip-version-check --no-input \
--target "$TARGET" pyusb pyserial
echo "[flash-deps] Done."
+240
View File
@@ -0,0 +1,240 @@
#!/bin/sh
# Bananarchy rootfs bootstrap, container side.
# Runs inside alpine:3.24 with the target rootfs mounted at /rootfs and the
# repository mounted read-only at /bananarchy. Invoked by bootstrap-rootfs.sh.
set -eu
ROOTFS="/rootfs"
REPO="/bananarchy"
PKGS_FILE="$REPO/scripts/rootfs-packages.txt"
DEVICE="${TARGET_DEVICE:-nokia-argon}"
PASSWORD="${BANANARCHY_USER_PASSWORD:-147147}"
HOST_UID="${HOST_UID:-0}"
HOST_GID="${HOST_GID:-0}"
BOOTSTRAP_VERSION="${BOOTSTRAP_VERSION:-1}"
PKG_HASH="${PKG_HASH:-unknown}"
echo "============================================================"
echo "Bootstrapping Bananarchy armv7 rootfs for $DEVICE"
echo "============================================================"
echo "[1/8] Configuring apk repositories and trusted keys..."
cat > /etc/apk/repositories <<EOF
https://mirror.nura.eco/postmarketos/v26.06
https://dl-cdn.alpinelinux.org/alpine/edge/main
https://dl-cdn.alpinelinux.org/alpine/edge/community
https://dl-cdn.alpinelinux.org/alpine/edge/testing
EOF
mkdir -p /etc/apk/keys
cp "$REPO"/keys/*.rsa.pub /etc/apk/keys/
mkdir -p "$ROOTFS/etc/apk/keys" "$ROOTFS/lib/apk/db" "$ROOTFS/var/cache/apk"
cp /etc/apk/repositories "$ROOTFS/etc/apk/repositories"
cp "$REPO"/keys/*.rsa.pub "$ROOTFS/etc/apk/keys/"
echo "[2/8] Installing host helper tools..."
apk add --no-cache python3 kmod openssl >/dev/null
echo "[3/8] Installing the Bananarchy armv7 package set..."
PKGS="$(grep -v '^[[:space:]]*#' "$PKGS_FILE" | grep -v '^[[:space:]]*$' | tr '\n' ' ')"
if [ ! -f "$ROOTFS/lib/apk/db/installed" ]; then
# shellcheck disable=SC2086
apk --root "$ROOTFS" --arch armv7 add --initdb --no-scripts $PKGS >/dev/null
else
# An existing rootfs only needs newly added packages, not a full reinstall.
# shellcheck disable=SC2086
apk --root "$ROOTFS" --arch armv7 add --no-scripts $PKGS >/dev/null
fi
ln -sf lua5.5 "$ROOTFS/usr/bin/lua"
ln -sf luac5.5 "$ROOTFS/usr/bin/luac"
echo "[4/8] Creating system accounts and default credentials..."
PW_HASH="$(openssl passwd -6 -salt bananarchy "$PASSWORD")"
python3 - "$ROOTFS" "$PW_HASH" <<'PYEOF'
import os
import sys
root = sys.argv[1]
pw_hash = sys.argv[2]
def load(name):
path = os.path.join(root, "etc", name)
with open(path, "r") as handle:
return [line.rstrip("\n") for line in handle if line.strip()]
def store(name, rows):
path = os.path.join(root, "etc", name)
with open(path, "w") as handle:
handle.write("\n".join(rows) + "\n")
passwd = load("passwd")
group = load("group")
shadow = load("shadow")
system_users = [
"klogd:x:100:101:klogd:/dev/null:/sbin/nologin",
"chrony:x:101:102:chrony:/dev/null:/sbin/nologin",
"messagebus:x:102:103:messagebus:/dev/null:/sbin/nologin",
"dnsmasq:x:103:104:dnsmasq:/dev/null:/sbin/nologin",
"geoclue:x:104:105::/var/lib/geoclue:/sbin/nologin",
"polkitd:x:105:110:polkitd:/var/empty:/sbin/nologin",
"colord:x:106:111:colord:/var/lib/colord:/sbin/nologin",
"greetd:x:107:112:greetd:/var/lib/greetd:/sbin/nologin",
"openvpn:x:108:113:OpenVPN:/dev/null:/sbin/nologin",
"tor:x:109:114:tor:/var/lib/tor:/sbin/nologin",
"user:x:10000:10000::/home/user:/bin/ash",
]
for entry in system_users:
name = entry.split(":")[0]
if not any(row.startswith(name + ":") for row in passwd):
passwd.append(entry)
system_groups = [
"avahi:x:86:avahi",
"klogd:x:101:klogd",
"chrony:x:102:chrony",
"messagebus:x:103:messagebus",
"dnsmasq:x:104:dnsmasq",
"geoclue:x:105:geoclue",
"plugdev:x:106:user",
"pipewire:x:107:user",
"seat:x:108:user",
"feedbackd:x:109:user",
"polkitd:x:110:polkitd",
"colord:x:111:colord",
"greetd:x:112:greetd",
"openvpn:x:113:openvpn",
"tor:x:114:tor",
"user:x:10000:",
]
for entry in system_groups:
name = entry.split(":")[0]
if not any(row.startswith(name + ":") for row in group):
group.append(entry)
member_groups = (
"wheel", "audio", "input", "netdev", "plugdev", "video", "seat",
"feedbackd", "dialout", "tty", "pipewire",
)
for index, row in enumerate(group):
fields = row.split(":")
if fields[0] not in member_groups:
continue
members = [item for item in fields[3].split(",") if item]
if "user" not in members:
members.append("user")
fields[3] = ",".join(members)
group[index] = ":".join(fields)
for entry in system_users:
name = entry.split(":")[0]
if name == "user":
continue
if not any(row.startswith(name + ":") for row in shadow):
shadow.append(name + ":!:::::::")
if not any(row.startswith("user:") for row in shadow):
shadow.append("user:" + pw_hash + ":::::::")
for index, row in enumerate(shadow):
if row.startswith("root:"):
fields = row.split(":")
if len(fields) > 1 and fields[1] == "":
fields[1] = pw_hash
shadow[index] = ":".join(fields)
store("passwd", passwd)
store("group", group)
store("shadow", shadow)
PYEOF
mkdir -p "$ROOTFS/home/user" "$ROOTFS/etc/bananarchy"
chown -R 10000:10000 "$ROOTFS/home/user"
chown 0:42 "$ROOTFS/etc/shadow"
chmod 640 "$ROOTFS/etc/shadow"
chown 0:0 "$ROOTFS/etc/bananarchy"
chmod 0700 "$ROOTFS/etc/bananarchy"
echo "[5/8] Writing base system configuration..."
printf '%s\n' "nokia-argon" > "$ROOTFS/etc/hostname"
cat > "$ROOTFS/etc/hosts" <<EOF
127.0.0.1 nokia-argon localhost.localdomain localhost
::1 localhost ipv6-localhost ipv6-loopback
fe00::0 ipv6-localnet
ff00::0 ipv6-mcastprefix
ff02::1 ipv6-allnodes
ff02::2 ipv6-allrouters
ff02::3 ipv6-allhosts
EOF
printf '%s\n' "LANG=C.UTF-8" > "$ROOTFS/etc/locale.conf"
if [ -f "$ROOTFS/usr/share/zoneinfo/UTC" ]; then
cp "$ROOTFS/usr/share/zoneinfo/UTC" "$ROOTFS/etc/localtime"
touch "$ROOTFS/etc/apk/interactive"
mkdir -p "$ROOTFS/run/openrc" "$ROOTFS/dev/pts" "$ROOTFS/dev/shm"
touch "$ROOTFS/run/openrc/shutdowntime"
# mkinitfs and boot-deploy run in a chroot and need /dev/null; devtmpfs
# replaces these placeholders on the device at boot time.
: > "$ROOTFS/dev/null"
chmod 666 "$ROOTFS/dev/null"
# mkinitfs expects losetup under /usr/sbin; the util-linux package only
# installs it under /sbin when package scripts are skipped.
if [ -e "$ROOTFS/sbin/losetup" ] && [ ! -e "$ROOTFS/usr/sbin/losetup" ]; then
ln -sf /sbin/losetup "$ROOTFS/usr/sbin/losetup"
fi
tr -d '-' < /proc/sys/kernel/random/uuid > "$ROOTFS/etc/machine-id"
printf '\n' >> "$ROOTFS/etc/machine-id"
fi
mkdir -p "$ROOTFS/etc/sysctl.d"
cat > "$ROOTFS/etc/sysctl.d/90-nokia-argon-lowram.conf" <<EOF
vm.swappiness = 180
vm.page-cluster = 0
vm.vfs_cache_pressure = 150
vm.min_free_kbytes = 16384
EOF
mkdir -p "$ROOTFS/etc/sudoers.d" "$ROOTFS/etc/doas.d"
cat > "$ROOTFS/etc/sudoers.d/wheel" <<EOF
%wheel ALL=(ALL:ALL) ALL
EOF
chmod 440 "$ROOTFS/etc/sudoers.d/wheel"
rm -f "$ROOTFS/etc/doas.d/wheel.conf"
touch "$ROOTFS/etc/apk/interactive"
mkdir -p "$ROOTFS/run/openrc"
touch "$ROOTFS/run/openrc/shutdowntime"
echo "[6/8] Enabling OpenRC runlevels..."
mkdir -p "$ROOTFS/etc/runlevels/sysinit" "$ROOTFS/etc/runlevels/boot" \
"$ROOTFS/etc/runlevels/default" "$ROOTFS/etc/runlevels/shutdown"
enable_service() {
runlevel="$1"
service="$2"
if [ -e "$ROOTFS/etc/init.d/$service" ]; then
ln -sf "/etc/init.d/$service" "$ROOTFS/etc/runlevels/$runlevel/$service"
fi
}
for svc in devfs dmesg msm-firmware-loader udev udev-trigger udev-settle; do
enable_service sysinit "$svc"
done
for svc in bootmisc hostname modules msm-firmware-loader-unpack osclock \
swclock-offset-boot sysctl tmpfs; do
enable_service boot "$svc"
done
for svc in bluetooth cgroups chronyd dbus elogind kill-plymouth local \
modemmanager msm8909-modem-wwan-port msm-modem-uim-selection networkmanager \
postmarketos-zram-swap q6voiced rfkill rmtfs sshd tinydm udev-postmount \
wpa_supplicant; do
enable_service default "$svc"
done
for svc in killprocs mount-ro savecache swclock-offset-shutdown; do
enable_service shutdown "$svc"
done
rm -f "$ROOTFS/etc/runlevels/boot/hwclock"
echo "[7/8] Applying the Bananarchy overlay and prebuilt artifacts..."
"$REPO/scripts/apply-bananarchy-overlay.sh" "$ROOTFS" "$DEVICE"
depmod -b "$ROOTFS" 6.12.1-msm8916
echo "[8/8] Finalizing rootfs ownership and bootstrap marker..."
printf '%s:%s\n' "$BOOTSTRAP_VERSION" "$PKG_HASH" > "$ROOTFS/etc/bananarchy/rootfs-bootstrap.done"
chown -R "$HOST_UID:$HOST_GID" "$ROOTFS"
echo "Bananarchy rootfs bootstrap completed for $DEVICE."
+76
View File
@@ -0,0 +1,76 @@
#!/bin/sh
# Autonomously create a complete armv7 Bananarchy rootfs from the repository.
# Safe to run repeatedly: an up-to-date rootfs is left untouched.
set -eu
BASE_DIR="$(cd "$(dirname "$0")/.." && pwd)"
PKGS_FILE="$BASE_DIR/scripts/rootfs-packages.txt"
CONTAINER_SCRIPT="$BASE_DIR/scripts/bootstrap-rootfs-container.sh"
BOOTSTRAP_VERSION="1"
MARKER_REL="etc/bananarchy/rootfs-bootstrap.done"
ROOTFS_DIR="${ROOTFS_DIR:-$BASE_DIR/rootfs}"
TARGET_DEVICE="nokia-argon"
FORCE=0
CHECK_ONLY=0
for arg in "$@"; do
case "$arg" in
--force|-f)
FORCE=1
;;
--check|-c)
CHECK_ONLY=1
;;
nokia-argon|nokia-beatles|nokia-tough|nokia-sparkler|nokia-leo)
TARGET_DEVICE="$arg"
;;
*)
if [ -z "${ROOTFS_DIR_SET:-}" ]; then
ROOTFS_DIR="$arg"
ROOTFS_DIR_SET=1
else
echo "Usage: $0 [rootfs-dir] [device] [--force|--check]" >&2
exit 1
fi
;;
esac
done
if [ ! -f "$PKGS_FILE" ] || [ ! -f "$CONTAINER_SCRIPT" ]; then
echo "Error: bootstrap inputs are missing from $BASE_DIR/scripts." >&2
exit 1
fi
mkdir -p "$ROOTFS_DIR"
ROOTFS_HOST="$(realpath "$ROOTFS_DIR")"
PKG_HASH="$(sha256sum "$PKGS_FILE" | awk '{print $1}')"
EXPECTED="$BOOTSTRAP_VERSION:$PKG_HASH"
MARKER="$ROOTFS_HOST/$MARKER_REL"
if [ "$FORCE" -eq 0 ] && [ -f "$MARKER" ] && [ "$(cat "$MARKER")" = "$EXPECTED" ]; then
echo "[bootstrap] Rootfs is already complete: $ROOTFS_HOST"
exit 0
fi
if [ "$CHECK_ONLY" -eq 1 ]; then
echo "[bootstrap] Rootfs needs bootstrapping: $ROOTFS_HOST"
exit 1
fi
if ! command -v docker >/dev/null 2>&1; then
echo "Error: Docker is required to bootstrap the armv7 rootfs." >&2
exit 1
fi
echo "[bootstrap] Building a complete rootfs at $ROOTFS_HOST for $TARGET_DEVICE..."
exec docker run --rm --network=host \
-e HOST_UID="$(id -u)" \
-e HOST_GID="$(id -g)" \
-e TARGET_DEVICE="$TARGET_DEVICE" \
-e BANANARCHY_USER_PASSWORD="${BANANARCHY_USER_PASSWORD:-147147}" \
-e BOOTSTRAP_VERSION="$BOOTSTRAP_VERSION" \
-e PKG_HASH="$PKG_HASH" \
-v "$ROOTFS_HOST:/rootfs" \
-v "$BASE_DIR:/bananarchy:ro" \
alpine:3.24 sh -eu /bananarchy/scripts/bootstrap-rootfs-container.sh
+101
View File
@@ -0,0 +1,101 @@
#!/bin/sh
# Fast offline preflight: verify that a clean clone can rebuild Bananarchy.
set -eu
BASE_DIR="$(cd "$(dirname "$0")/.." && pwd)"
FAILURES=0
fail() {
echo "FAIL: $1"
FAILURES=$((FAILURES + 1))
}
echo "[check] Shell syntax..."
for script in "$BASE_DIR"/*.sh "$BASE_DIR"/scripts/*.sh; do
if ! sh -n "$script" 2>/dev/null; then
fail "shell syntax: $script"
fi
done
echo "[check] Python syntax..."
python3 - "$BASE_DIR" <<'PYEOF' || exit 1
import ast
import glob
import os
import sys
base = sys.argv[1]
paths = sorted(glob.glob(os.path.join(base, "scripts", "*.py")) +
glob.glob(os.path.join(base, "*.py")) +
glob.glob(os.path.join(base, "vendor", "edl", "*.py")) +
glob.glob(os.path.join(base, "vendor", "edl", "Library", "*.py")))
for path in paths:
with open(path, "r", encoding="utf-8", errors="replace") as handle:
try:
ast.parse(handle.read(), filename=path)
except SyntaxError as exc:
print("FAIL: python syntax: %s: %s" % (path, exc))
sys.exit(1)
print(" %d Python file(s) parsed" % len(paths))
PYEOF
echo "[check] Rootfs package list..."
PKGS_FILE="$BASE_DIR/scripts/rootfs-packages.txt"
if [ ! -f "$PKGS_FILE" ]; then
fail "missing $PKGS_FILE"
else
PKG_COUNT="$(grep -v '^[[:space:]]*#' "$PKGS_FILE" | grep -cv '^[[:space:]]*$' || true)"
if [ "$PKG_COUNT" -lt 100 ]; then
fail "package list has only $PKG_COUNT entries"
else
echo " $PKG_COUNT packages"
fi
fi
echo "[check] Vendored EDL client library..."
for module in usb gpt sahara firehose utils; do
if [ ! -f "$BASE_DIR/vendor/edl/Library/$module.py" ]; then
fail "missing vendor/edl/Library/$module.py"
fi
done
if [ ! -f "$BASE_DIR/vendor/edl/LICENSE" ]; then
fail "missing vendor/edl/LICENSE"
fi
echo "[check] Plugin artifacts..."
for source in "$BASE_DIR"/src/dwm-plugins/*_plugin.cpp; do
name="$(basename "$source" _plugin.cpp)"
if [ ! -f "$BASE_DIR/prebuilt/sxmo-x11/usr/lib/dwm/plugins/$name.so" ]; then
fail "missing prebuilt plugin: $name.so"
fi
done
echo "[check] Overlay artifact sync..."
if ! "$BASE_DIR/scripts/sync-prebuilt-overlay.sh" --check; then
fail "overlay/rootfs artifacts differ from prebuilt/"
fi
echo "[check] Local agent config stays ignored..."
if [ -d "$BASE_DIR/.git" ]; then
if ! git -C "$BASE_DIR" check-ignore -q .bantam.cfg; then
fail ".bantam.cfg is no longer gitignored"
fi
elif ! grep -qxF '.bantam.cfg' "$BASE_DIR/.gitignore"; then
fail ".bantam.cfg ignore rule is missing"
fi
echo "[check] Docker availability..."
if ! command -v docker >/dev/null 2>&1; then
fail "docker is not installed"
fi
echo "[check] Version helper..."
if ! "$BASE_DIR/scripts/version.sh" --print >/dev/null 2>&1; then
fail "scripts/version.sh --print failed"
fi
if [ "$FAILURES" -ne 0 ]; then
echo "[check] $FAILURES check(s) failed."
exit 1
fi
echo "[check] All rebuild preflight checks passed."
+4
View File
@@ -1,4 +1,8 @@
#!/bin/sh
# Legacy pmbootstrap-era rootfs configurator (Wayland/Sway based).
# Superseded by scripts/bootstrap-rootfs.sh, which builds a complete X11
# rootfs from scratch. Kept only for historical reference; do not use it for
# new builds.
set -eu
BANANARCHY_DIR="${BANANARCHY_DIR:-/bananarchy}"
+105
View File
@@ -0,0 +1,105 @@
# Bananarchy armv7 rootfs package set.
# Single source of truth for scripts/bootstrap-rootfs.sh and rebuild-image.sh.
# One package per line; lines starting with '#' and blank lines are ignored.
# Keep this list synchronized with the packages used by the overlay and plugins.
adwaita-icon-theme
alpine-base
alsa-utils
bash
bc
brightnessctl
clickclack
coreutils
doas
ed
evtest
fcitx5
fcitx5-gtk3
font-droid
font-droid-nonlatin
font-fira-code
font-noto
font-noto-emoji
font-twemoji
frotz
g++
gcc
git
gst-libav
gst-plugins-bad
gst-plugins-good
harfbuzz
htop
i2c-tools
imv
ip6tables
iproute2
iptables
janet
janet-dev
jpm
lang
less
libwpe
libwpebackend-fdo
libxcvt
libxft
libxinerama
libxtst
linux-postmarketos-qcom-msm8916
lua5.4
lua5.4-dev
lua5.5
lua5.5-dev
make
mandoc
mesa-demos
mesa-utils
modemmanager
musl-dev
nano
openssh
openssh-server-pam
openvpn
perl
perl-io-socket-ssl
postmarketos-artwork-wallpapers
postmarketos-base
postmarketos-base-nofde
postmarketos-base-ui
postmarketos-base-ui-audio-backend-pipewire
postmarketos-base-ui-wifi-wpa_supplicant
postmarketos-ui-sxmo-de-dwm
postmarketos-ui-sxmo-de-dwm-openrc
qmi-utils
rlwrap
scrot
setxkbmap
sfeed
soc-qcom-msm8909
soc-qcom-msm8909-modem
soc-qcom-msm8909-modem-openrc
soc-qcom-msm8916
soc-qcom-msm8916-rproc
soc-qcom-msm8916-rproc-openrc
soc-qcom-msm8916-ucm
sqlite
sqlite-tcl
sudo-rs
tcl
tcl-lib
tcl-tls
tor
ttyescape
v4l-utils
w3m
webkit2gtk-4.1
wireguard-tools
wireguard-tools-wg
wireguard-tools-wg-quick
xf86-input-libinput
xf86-video-fbdev
yabasic
yabasic-doc
zram-init
zram-init-openrc
+83
View File
@@ -0,0 +1,83 @@
#!/bin/sh
# Keep the tracked overlay/rootfs snapshot in sync with prebuilt/ artifacts.
# prebuilt/ is the single source of truth; this script mirrors every artifact
# that also exists in overlay/rootfs back into the overlay.
set -eu
BASE_DIR="$(cd "$(dirname "$0")/.." && pwd)"
CHECK_ONLY=0
for arg in "$@"; do
case "$arg" in
--check|-c)
CHECK_ONLY=1
;;
*)
echo "Usage: $0 [--check]" >&2
exit 1
;;
esac
done
python3 - "$BASE_DIR" "$CHECK_ONLY" <<'PYEOF'
import hashlib
import os
import shutil
import sys
base = sys.argv[1]
check_only = sys.argv[2] == "1"
prebuilt_root = os.path.join(base, "prebuilt")
overlay_root = os.path.join(base, "overlay", "rootfs")
def digest(path):
with open(path, "rb") as handle:
return hashlib.sha256(handle.read()).hexdigest()
def regular_files(root):
result = []
for parent, _, names in os.walk(root):
for name in names:
path = os.path.join(parent, name)
if not os.path.islink(path) and os.path.isfile(path):
result.append(path)
return result
by_name = {}
for path in regular_files(prebuilt_root):
by_name.setdefault(os.path.basename(path), []).append(path)
drift = []
matched = 0
for target in regular_files(overlay_root):
rel = os.path.relpath(target, overlay_root)
candidates = by_name.get(os.path.basename(target), [])
source = None
for candidate in candidates:
stripped = os.path.relpath(candidate, prebuilt_root).split(os.sep, 1)[-1]
if stripped == rel:
source = candidate
break
if source is None and candidates:
source = candidates[0]
if source is None:
continue
matched += 1
if digest(source) == digest(target):
continue
drift.append((source, target))
if not check_only:
shutil.copy2(source, target)
if check_only:
for source, target in drift:
print("out of sync: " + os.path.relpath(target, base))
print("artifact drift: %d of %d mirrored file(s)" % (len(drift), matched))
sys.exit(1 if drift else 0)
print("synced %d artifact(s) into overlay/rootfs; %d already in sync" % (
len(drift), matched - len(drift)))
PYEOF