Combine poky (Yocto scarthgap), meta-openembedded (scarthgap), and meta-openwrt into a single repository. Components: - poky/ Yocto core framework (BitBake + OE-Core) - meta-openembedded/ Community layers (meta-oe, meta-python, meta-networking) - meta-openwrt/ OpenWrt customization layer - setup-env.sh One-click build environment setup - README.md Project documentation
69 lines
2.3 KiB
Bash
Executable File
69 lines
2.3 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# OpenWrt-Yocto Build Environment Setup Script
|
|
#
|
|
# Usage: source ./setup-env.sh [builddir]
|
|
# builddir defaults to poky/build-x86-openwrt
|
|
#
|
|
# This script:
|
|
# 1. Sources oe-init-build-env to set up the bitbake environment
|
|
# 2. Adds required meta layers (if not already present)
|
|
# 3. Appends OpenWrt-specific configuration to conf/local.conf
|
|
#
|
|
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
BUILD_DIR="${1:-$SCRIPT_DIR/build-x86-openwrt}"
|
|
|
|
# ─── Step 1: Source the Yocto build environment ──────────────────────────────
|
|
if [ ! -f "$SCRIPT_DIR/poky/oe-init-build-env" ]; then
|
|
echo "ERROR: oe-init-build-env not found at $SCRIPT_DIR/poky/oe-init-build-env"
|
|
return 1 2>/dev/null || exit 1
|
|
fi
|
|
|
|
echo "=== Setting up Yocto build environment ==="
|
|
echo "Build directory: $BUILD_DIR"
|
|
echo ""
|
|
|
|
# shellcheck source=./poky/oe-init-build-env
|
|
source "$SCRIPT_DIR/poky/oe-init-build-env" "$BUILD_DIR"
|
|
|
|
# ─── Step 2: Add required meta layers ────────────────────────────────────────
|
|
add_layer_if_missing() {
|
|
local layer_path="$1"
|
|
if ! bitbake-layers show-layers 2>/dev/null | grep -q "$layer_path"; then
|
|
echo "Adding layer: $layer_path"
|
|
bitbake-layers add-layer "$layer_path"
|
|
else
|
|
echo "Layer already present: $layer_path"
|
|
fi
|
|
}
|
|
|
|
echo ""
|
|
echo "=== Adding meta layers ==="
|
|
add_layer_if_missing "$SCRIPT_DIR/meta-openembedded/meta-oe"
|
|
add_layer_if_missing "$SCRIPT_DIR/meta-openembedded/meta-python"
|
|
add_layer_if_missing "$SCRIPT_DIR/meta-openembedded/meta-networking"
|
|
add_layer_if_missing "$SCRIPT_DIR/meta-openwrt"
|
|
|
|
# ─── Step 3: Append OpenWrt configuration to local.conf ──────────────────────
|
|
append_config_if_missing() {
|
|
local key="$1"
|
|
if ! grep -q "^${key}" "$BUILD_DIR/conf/local.conf" 2>/dev/null; then
|
|
echo "${key}" >> "$BUILD_DIR/conf/local.conf"
|
|
echo "Added config: ${key}"
|
|
else
|
|
echo "Config already present: ${key}"
|
|
fi
|
|
}
|
|
|
|
echo ""
|
|
echo "=== Configuring local.conf ==="
|
|
append_config_if_missing 'INHERIT += "openwrt-distro-defaults"'
|
|
append_config_if_missing 'IMAGE_FSTYPES = "iso"'
|
|
|
|
echo ""
|
|
echo "=== Setup complete ==="
|
|
echo "You can now run: bitbake openwrt-image-base"
|