#!/bin/sh # ShiMeta Python 环境一键安装 # 用法: wget .../install_python.sh -O - | sh # sh install_python.sh [mirror] [version] # sh install_python.sh -v 1.0.2 VERSION="" MIRROR="https://mirrors.shimetapi.cn/repos/GK7206/shimeta-py" case "$1" in -v) VERSION="$2"; shift 2 ;; esac case "$2" in -v) VERSION="$3"; shift 2 ;; esac case "$2" in [0-9]*.*) VERSION="$2" ;; esac if [ -n "$1" ] && [ "$1" != "-v" ]; then MIRROR="$1"; fi DEST="/mnt" # 未指定版本时从服务器获取最新 if [ -z "${VERSION}" ]; then echo "[version] 获取最新版本号..." VERSION=$(wget -qO- "${MIRROR}/LATEST" 2>/dev/null || echo "") if [ -z "${VERSION}" ]; then VERSION="1.0.3" echo "无法获取最新版本,回退到 v${VERSION}" else echo "[version] 最新: ${VERSION}" fi fi echo "=== ShiMeta Python Environment Installer v${VERSION} ===" echo "Mirror: ${MIRROR}" echo "" DL="${DEST}/python-gk7206.tar.gz" URL="${MIRROR}/python-gk7206_${VERSION}_arm.tar.gz" echo "[1/2] Downloading Python 3.11 for GK7206 (18MB)..." if ! command -v wget >/dev/null 2>&1; then echo "ERROR: 未找到 wget,无法下载" exit 1 fi wget "${URL}" -O "${DL}" if [ ! -f "${DL}" ]; then echo "ERROR: download failed" exit 1 fi echo "[2/2] Extracting to ${DEST}..." cd "${DEST}" && tar xzf "${DL}" && rm -f "${DL}" rm -rf ${DEST}/python/lib/python3.11/site-packages/shimeta_py/__pycache__ 2>/dev/null echo "" grep -q "mount /dev/mmcblk1p1" /etc/profile 2>/dev/null || echo "mount /dev/mmcblk1p1 /mnt 2>/dev/null" >> /etc/profile grep -q "python/setup.sh" /etc/profile 2>/dev/null || echo ". /mnt/python/setup.sh 2>/dev/null" >> /etc/profile echo "Done. Python 3.11 installed." echo "Run: . /mnt/python/setup.sh" echo " python3 -c 'print(1+1)'"