StupidSynth/setup-dev-env.sh

78 lines
3.0 KiB
Bash
Executable File

#!/bin/bash
#
# Self-documenting setup script for the Raspberry Pi 1 Bare-Metal Synth
# development environment.
#
# This script is tailored for immutable operating systems like Bazzite or
# Fedora Atomic, but will work on any system with Distrobox installed.
# It creates a clean, containerized Ubuntu 24.04 environment
# without altering your host system.
#
# --- Configuration ---
CONTAINER_NAME="pi-synth-dev"
CONTAINER_IMAGE="ubuntu:24.04"
BOLD=$(tput bold)
GREEN=$(tput setaf 2)
NORMAL=$(tput sgr0)
# --- Helper Functions ---
print_header() {
echo -e "\n${BOLD}${GREEN}=======================================================${NORMAL}"
echo -e "${BOLD}${GREEN} $1 ${NORMAL}"
echo -e "${BOLD}${GREEN}=======================================================${NORMAL}"
}
# --- Start of Script ---
clear
print_header "Pi 1 Bare-Metal Synth Dev Environment Setup"
echo "This script will set up a containerized development environment"
echo "to build the bare-metal kernel.img for the Raspberry Pi 1."
echo
echo "It uses Distrobox to create an Ubuntu 24.04 container named '${BOLD}$CONTAINER_NAME${NORMAL}'."
echo "This keeps your host system clean and is ideal for immutable OSes."
# --- 1. Check for Distrobox ---
print_header "Step 1: Checking for Distrobox"
if ! command -v distrobox &> /dev/null; then
echo "Error: 'distrobox' command not found." >&2
echo "Please install Distrobox to continue." >&2
echo "See: https://github.com/89luca89/distrobox" >&2
exit 1
fi
echo "Distrobox found."
# --- 2. Check if Container Already Exists ---
print_header "Step 2: Checking for existing container"
if distrobox list | grep -q " ${CONTAINER_NAME} "; then
echo "Container '${BOLD}$CONTAINER_NAME${NORMAL}' already exists. Skipping creation."
else
echo "Container not found. Creating a new one from image '${BOLD}$CONTAINER_IMAGE${NORMAL}'..."
distrobox create --name "$CONTAINER_NAME" --image "$CONTAINER_IMAGE"
if [ $? -ne 0 ]; then
echo "Error: Failed to create Distrobox container." >&2
exit 1
fi
echo "Container '${BOLD}$CONTAINER_NAME${NORMAL}' created successfully."
fi
# --- 3. Install Dependencies in Container ---
print_header "Step 3: Installing Build Tools inside the Container"
echo "Entering the container to install 'make', 'gcc-arm-none-eabi', and 'binutils-arm-none-eabi'..."
echo "You may be prompted for your password for 'sudo'."
distrobox enter "$CONTAINER_NAME" -- sudo apt-get update && sudo apt-get install -y make gcc-arm-none-eabi binutils-arm-none-eabi
if [ $? -ne 0 ]; then
echo "Error: Failed to install dependencies inside the container." >&2
exit 1
fi
echo "Build tools installed successfully."
# --- 4. Final Instructions ---
print_header "Setup Complete!"
echo "Your development environment is ready."
echo -e "\nTo build the project, run the following commands:"
echo -e "1. Enter the container: ${GREEN}distrobox enter $CONTAINER_NAME${NORMAL}"
echo -e "2. Navigate to the project directory: ${GREEN}cd '$(pwd)'${NORMAL}"
echo -e "3. Run the build script: ${GREEN}./build.sh${NORMAL}"