diff --git a/README.md b/README.md index 270b82c..454c55c 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,28 @@ sysbuild.sh ``` +## Building on Termux (Android) + +It is possible to build the system directly on an Android device using Termux and PRoot. + +1. Clone this repository in Termux. +2. Run the setup script to install `proot-distro`, `debian`, and build dependencies: + ```bash + ./setup_termux.sh + ``` +3. Enter the build environment (follow the instructions printed by the setup script): + ```bash + proot-distro login debian --bind ".:/root/LinuxFromScratch" --cwd /root/LinuxFromScratch + ``` +4. Proceed with the build as usual inside the PRoot environment: + ```bash + ./set_env.sh [TARGET_NAME] + sysbuild.sh + ``` + +Note: Generating the SD card image (`init_sd.sh`) inside Termux is not supported due to lack of root privileges and loop device support. You can copy the generated `root-fs` to a PC to create the image. + + ## Usage To setup the build environnement run from the repository root folder diff --git a/scripts/setup_proot_env.sh b/scripts/setup_proot_env.sh new file mode 100755 index 0000000..77763ce --- /dev/null +++ b/scripts/setup_proot_env.sh @@ -0,0 +1,10 @@ +#!/bin/bash +# Install dependencies inside PRoot (Debian/Ubuntu) + +# Update package lists +apt update + +# Install build dependencies +apt install -y build-essential git wget bzip2 file bc unzip rsync python3 cpio libncurses-dev gawk bison flex texinfo patch gzip perl sed tar diffutils grep coreutils make libssl-dev zlib1g-dev libelf-dev + +echo "Dependencies installed." diff --git a/setup_termux.sh b/setup_termux.sh new file mode 100755 index 0000000..0358ee1 --- /dev/null +++ b/setup_termux.sh @@ -0,0 +1,42 @@ +#!/data/data/com.termux/files/usr/bin/bash + +# Check if running in Termux +if [ -z "$TERMUX_VERSION" ]; then + echo "This script is intended for Termux environment." + exit 1 +fi + +echo "Setting up Termux build environment..." + +# Check if proot-distro is installed +if ! command -v proot-distro &> /dev/null; then + echo "Installing proot-distro..." + pkg install -y proot-distro +fi + +# Install debian if not already installed +# proot-distro install checks if it is installed, so we can just run it. +# However, to avoid redownloading/checking every time if it takes long, we can check. +if ! proot-distro list | grep -q "debian (installed)"; then + echo "Installing Debian..." + proot-distro install debian +else + echo "Debian is already installed." +fi + +# Determine repo directory +REPO_DIR=$(pwd) +SCRIPT_PATH="/root/LinuxFromScratch/scripts/setup_proot_env.sh" + +echo "Installing dependencies inside PRoot environment..." +# We bind mount the current directory to /root/LinuxFromScratch +# Run the setup script using bash explicitly +proot-distro login debian --bind "$REPO_DIR:/root/LinuxFromScratch" -- bash "$SCRIPT_PATH" + +echo "Setup complete." +echo "To enter the build environment, run:" +echo "proot-distro login debian --bind \"$REPO_DIR:/root/LinuxFromScratch\" --cwd /root/LinuxFromScratch" +echo "" +echo "Then inside the environment:" +echo "./set_env.sh " +echo "sysbuild.sh"