#!/usr/bin/env bash set -Eeuo pipefail exec > >(tee -a /var/log/rk1-media-provision.log) 2>&1 export DEBIAN_FRONTEND=noninteractive install -d -m 0755 /var/lib/rk1-media seed_archives=/opt/rk1-seed/debs # APT's --no-download mode only accepts dependency archives from its configured # cache, even when every package is also named as an absolute local path. Make # the immutable image seed that cache rather than copying it into /var/cache. install -d -o root -g root -m 0755 "$seed_archives" install -d -o _apt -g root -m 0700 "$seed_archives/partial" mapfile -d '' debs < <(find "$seed_archives" -maxdepth 1 -type f -name '*.deb' -print0 | sort -z) ((${#debs[@]} > 0)) || { echo 'Offline package bundle is empty' >&2; exit 1; } apt-get \ -o Dir::Cache::archives="$seed_archives" \ -o APT::Keep-Downloaded-Packages=true \ --no-download --no-install-recommends --yes install "${debs[@]}" ldconfig udevadm control --reload-rules # MODE/GROUP assignments for device nodes are applied on add events. The misc # trigger covers the vendor MPP, RGA, and RKNN control nodes. udevadm trigger --action=add --subsystem-match=drm || true udevadm trigger --action=add --subsystem-match=dma_heap || true udevadm trigger --action=add --subsystem-match=misc || true udevadm settle install -d -m 0755 /usr/share/rk1-media held_packages=() while IFS= read -r package_name; do case "$package_name" in linux-image-*|linux-dtb-*|linux-u-boot-*|armbian-bsp-*) apt-mark hold "$package_name" >/dev/null held_packages+=("$package_name") ;; esac done < <(dpkg-query --show --showformat='${binary:Package}\n') printf '%s\n' "${held_packages[@]}" | LC_ALL=C sort -u \ >/usr/share/rk1-media/held-packages.txt dpkg-query --show --showformat='${binary:Package}\t${Version}\t${Architecture}\n' \ | LC_ALL=C sort >/usr/share/rk1-media/package-manifest.tsv systemctl disable --now kodi-pulse.service pulseaudio.service 2>/dev/null || true systemctl daemon-reload systemctl enable avahi-daemon.service kodi-rk.service # kodi-rk is ordered after this oneshot. Queue it without waiting so systemd # can start it as soon as provisioning exits instead of deadlocking here. systemctl --no-block start avahi-daemon.service kodi-rk.service touch /var/lib/rk1-media/provisioned