Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions scripts/setup_proot_env.sh
Original file line number Diff line number Diff line change
@@ -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."
42 changes: 42 additions & 0 deletions setup_termux.sh
Original file line number Diff line number Diff line change
@@ -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 <target>"
echo "sysbuild.sh"