update prepare env script
This commit is contained in:
@@ -5,7 +5,7 @@ This repository contains shell scripts that streamline preparing, configuring, a
|
||||
|
||||
## What’s included
|
||||
- prepare-openwrt-env.sh
|
||||
- Installs required build dependencies via apt on Ubuntu 22.04/24.04 and Debian 12/13+.
|
||||
- Installs required build dependencies via apt on Ubuntu 22.04/24.04/26.04 and Debian 12/13+.
|
||||
- Handles x86_64 and ARM64 differences (Python/distutils, multilib notes, Go on ARM64).
|
||||
- prepare-openwrt.sh
|
||||
- Clones or updates the OpenWrt source repo.
|
||||
@@ -29,7 +29,7 @@ This repository contains shell scripts that streamline preparing, configuring, a
|
||||
- Fixes MAX macro naming collisions in multiple DAHDI modules for OpenWrt 24.10.4 builds.
|
||||
|
||||
## System requirements
|
||||
- OS: Ubuntu 22.04/24.04 or Debian 12/13+ (others may work with adjustments)
|
||||
- OS: Ubuntu 22.04/24.04/26.04 or Debian 12/13+ (others may work with adjustments)
|
||||
- Architectures: x86_64/amd64 and aarch64/arm64
|
||||
- Tools: git, wget, curl, bash
|
||||
- Internet access for feeds and package downloads
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
# Automatically prepare OpenWRT build dependencies for Debian/Ubuntu
|
||||
# Supports both x86_64 and arm64
|
||||
# Detects Ubuntu 22.04, 24.04, Debian 12/13 and newer
|
||||
# Detects Ubuntu 22.04, 24.04, 26.04, Debian 12/13 and newer
|
||||
# Author: Zhe Yuan
|
||||
|
||||
set -e
|
||||
@@ -27,21 +27,55 @@ fi
|
||||
|
||||
echo "[INFO] Detected distribution: $DISTRO $VERSION_ID"
|
||||
|
||||
# --- Determine if Python 3.12+ is installed (no distutils) ---
|
||||
PY_VER=$(python3 -V 2>/dev/null | awk '{print $2}' | cut -d. -f1,2)
|
||||
HAS_DISTUTILS=$(apt-cache search python3-distutils 2>/dev/null | grep -c distutils || true)
|
||||
# --- Version helpers ---
|
||||
version_ge() {
|
||||
local current="${1:-unknown}"
|
||||
local minimum="$2"
|
||||
|
||||
if [[ "$current" == "unknown" ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if command -v dpkg >/dev/null 2>&1; then
|
||||
dpkg --compare-versions "$current" ge "$minimum"
|
||||
else
|
||||
[[ "$(printf '%s\n%s\n' "$minimum" "$current" | sort -V | head -n1)" == "$minimum" ]]
|
||||
fi
|
||||
}
|
||||
|
||||
IS_UBUNTU_24_OR_NEWER=false
|
||||
IS_UBUNTU_26_OR_NEWER=false
|
||||
IS_DEBIAN_13_OR_NEWER=false
|
||||
|
||||
if [[ "$DISTRO" == "ubuntu" ]] && version_ge "$VERSION_ID" "24.04"; then
|
||||
IS_UBUNTU_24_OR_NEWER=true
|
||||
fi
|
||||
|
||||
if [[ "$DISTRO" == "ubuntu" ]] && version_ge "$VERSION_ID" "26.04"; then
|
||||
IS_UBUNTU_26_OR_NEWER=true
|
||||
fi
|
||||
|
||||
if [[ "$DISTRO" == "debian" ]] && version_ge "$VERSION_ID" "13"; then
|
||||
IS_DEBIAN_13_OR_NEWER=true
|
||||
fi
|
||||
|
||||
# --- Base packages (common to all) ---
|
||||
COMMON_PACKAGES="build-essential clang flex bison g++ gawk \
|
||||
gettext git libssl-dev rsync swig unzip zlib1g-dev file wget"
|
||||
gettext git libssl-dev rsync swig unzip zlib1g-dev file wget bzip2"
|
||||
|
||||
# --- Determine specific package set ---
|
||||
if [[ "$ARCH" == "x86_64" || "$ARCH" == "amd64" ]]; then
|
||||
echo "[INFO] Preparing environment for x86_64."
|
||||
|
||||
if [[ "$VERSION_ID" == "24.04" || ( "$DISTRO" == "debian" && "${VERSION_ID%%.*}" -ge 13 ) ]]; then
|
||||
echo "[INFO] Detected new environment (Python 3.12+, no python3-distutils)."
|
||||
if [[ "$IS_UBUNTU_26_OR_NEWER" == "true" ]]; then
|
||||
echo "[INFO] Detected Ubuntu 26.04+ (no python3-distutils; OpenWrt docs use libncurses-dev)."
|
||||
EXTRA_PACKAGES="gcc-multilib g++-multilib glibc-source libncurses-dev python3-setuptools"
|
||||
elif [[ "$IS_UBUNTU_24_OR_NEWER" == "true" ]]; then
|
||||
echo "[INFO] Detected Ubuntu 24.04+ (Python 3.12+, no python3-distutils)."
|
||||
EXTRA_PACKAGES="gcc-multilib g++-multilib libncurses5-dev python3-setuptools"
|
||||
elif [[ "$IS_DEBIAN_13_OR_NEWER" == "true" ]]; then
|
||||
echo "[INFO] Detected Debian 13+ (no python3-distutils)."
|
||||
EXTRA_PACKAGES="gcc-multilib g++-multilib libncurses-dev python3-setuptools"
|
||||
else
|
||||
echo "[INFO] Detected older Ubuntu/Debian (with python3-distutils)."
|
||||
EXTRA_PACKAGES="gcc-multilib g++-multilib libncurses-dev python3-distutils python3-setuptools"
|
||||
@@ -60,8 +94,12 @@ elif [[ "$ARCH" == "aarch64" || "$ARCH" == "arm64" ]]; then
|
||||
g++-multilib-x86-64-linux-gnu g++-multilib-x86-64-linux-gnux32 \
|
||||
libc6-dev-i386-amd64-cross libc6-dev-i386-cross libc6-dev-i386-x32-cross"
|
||||
|
||||
if [[ "$VERSION_ID" == "24.04" || ( "$DISTRO" == "debian" && "${VERSION_ID%%.*}" -ge 13 ) ]]; then
|
||||
if [[ "$IS_UBUNTU_26_OR_NEWER" == "true" ]]; then
|
||||
EXTRA_PACKAGES="glibc-source libncurses-dev python3-setuptools"
|
||||
elif [[ "$IS_UBUNTU_24_OR_NEWER" == "true" ]]; then
|
||||
EXTRA_PACKAGES="libncurses5-dev python3-setuptools"
|
||||
elif [[ "$IS_DEBIAN_13_OR_NEWER" == "true" ]]; then
|
||||
EXTRA_PACKAGES="libncurses-dev python3-setuptools"
|
||||
else
|
||||
EXTRA_PACKAGES="libncurses-dev python3-distutils python3-setuptools"
|
||||
fi
|
||||
@@ -71,7 +109,11 @@ elif [[ "$ARCH" == "aarch64" || "$ARCH" == "arm64" ]]; then
|
||||
else
|
||||
echo "[WARN] Unknown architecture: $ARCH"
|
||||
echo "[WARN] Attempting to use x86_64 package list."
|
||||
INSTALL_PACKAGES="$COMMON_PACKAGES gcc-multilib g++-multilib libncurses-dev python3-setuptools"
|
||||
if [[ "$IS_UBUNTU_26_OR_NEWER" == "true" ]]; then
|
||||
INSTALL_PACKAGES="$COMMON_PACKAGES gcc-multilib g++-multilib glibc-source libncurses-dev python3-setuptools"
|
||||
else
|
||||
INSTALL_PACKAGES="$COMMON_PACKAGES gcc-multilib g++-multilib libncurses-dev python3-setuptools"
|
||||
fi
|
||||
fi
|
||||
|
||||
# --- Display package list ---
|
||||
|
||||
Reference in New Issue
Block a user