#!/usr/bin/env bash # ============================================================================= # vendor.sh — 폐쇄망 설치용 사전 다운로드 (미니 표시기, Pi Zero 2 W / aarch64) # 인터넷 되는 빌드 머신에서 실행 → wheelhouse/(pip), debs/(apt) 산출 → USB 로 이송. # 무거운 바이너리(Pillow/numpy/RPi.GPIO/spidev)는 .deb 로 해결하므로 # wheel 은 순수 파이썬(requests 계열)만 필요 — 플랫폼 핀 부담이 없다. # .deb 는 대상과 동일 OS/아키텍처(Bookworm aarch64)에서 받는 것이 가장 안전. # ============================================================================= set -euo pipefail cd "$(dirname "$0")" echo "[vendor] (1/2) Python wheel → wheelhouse/" mkdir -p wheelhouse python3 -m pip download -r requirements.txt -d wheelhouse \ || echo "[WARN] 일부 다운로드 실패(순수 파이썬 패키지만 필요 — 아래 개수 확인)" WHEEL_COUNT="$(ls -A wheelhouse 2>/dev/null | wc -l)" echo " wheelhouse 파일 수: ${WHEEL_COUNT}" [ "${WHEEL_COUNT}" -gt 0 ] || { echo "[ERROR] wheelhouse 비어 있음"; exit 1; } echo "[vendor] (2/2) apt .deb → debs/" mkdir -p debs # nftables/unattended-upgrades 포함 → harden_pi.sh 도 오프라인 실행 가능. BASE_PKGS="python3-requests python3-venv python3-pil python3-numpy python3-rpi.gpio python3-spidev fonts-dejavu-core nftables unattended-upgrades" DEPS="$(apt-cache depends --recurse --no-recommends --no-suggests \ --no-conflicts --no-breaks --no-replaces --no-enhances ${BASE_PKGS} \ | awk '/^\w/{print $1}' | sort -u)" ( cd debs && apt-get download ${BASE_PKGS} ${DEPS} ) 2>/dev/null \ || echo "[WARN] 일부 .deb 다운로드 실패(가상/전이 의존일 수 있음 — 필수 패키지는 아래에서 검증)" MISS=0 for p in ${BASE_PKGS}; do if ! ls debs/"${p}"_*.deb >/dev/null 2>&1; then echo "[ERROR] 필수 패키지 .deb 누락: ${p}" MISS=1 fi done [ "${MISS}" = "0" ] || exit 1 echo "" echo "[vendor] 완료 — wheelhouse/ + debs/ 를 이 폴더째 USB 로 옮기면 install.sh 가 자동 오프라인 설치."