diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 459d02d..8c0a304 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -26,7 +26,7 @@ Follows the Filesystem Hierarchy Standard (FHS): ``` / -├── bin/ Essential user binaries (bash, ls, cp, etc.) +├── bin/ Essential user binaries (busybox with symlinks) ├── sbin/ System binaries (init, mount, etc.) ├── etc/ System configuration files ├── proc/ Kernel process information (virtual) @@ -71,7 +71,7 @@ Init System (/sbin/init) [PID 1] ↓ Mount filesystems ↓ -Spawn bash shell +Spawn busybox sh shell ↓ User interaction ``` @@ -91,11 +91,12 @@ User interaction - **Portability**: Works on any Linux system - **Reliability**: No missing library issues -### Why Bash? +### Why Busybox? -- **Familiar**: Most users know bash -- **Powerful**: Full scripting capabilities -- **Standard**: Available on virtually all Linux systems +- **Minimal**: Single binary provides dozens of utilities +- **Small footprint**: Typically <1MB for full feature set +- **Efficient**: Less memory and storage overhead than full GNU coreutils +- **Standard**: De facto standard for embedded Linux systems ## Future Architecture @@ -132,7 +133,7 @@ User interaction ## Performance - Fast boot time (seconds, not minutes) -- Low memory footprint (~100MB base system) +- Low memory footprint (~50MB base system with busybox) - No unnecessary background services - Efficient init system diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f8d7d2b..b87919d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -39,7 +39,8 @@ SparkOS aims to be: - Comment complex logic - **Shell Scripts**: Follow Google Shell Style Guide - - Use `#!/bin/bash` shebang + - Use `#!/bin/sh` for POSIX-compliant scripts (preferred for busybox compatibility) + - Use `#!/bin/bash` only when bash-specific features are required - Quote variables - Use meaningful variable names diff --git a/README.md b/README.md index 43e330a..779bf0e 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ A minimal Linux distribution designed for simplicity and portability. SparkOS features: -- **Minimal footprint**: Barebones Linux system with bash shell +- **Minimal footprint**: Barebones Linux system with busybox shell - **Portable**: dd-able disk image for USB flash drives - **Custom init**: Lightweight C init system - **Future-ready**: Designed to support Qt6/QML GUI and Wayland @@ -12,7 +12,7 @@ A minimal Linux distribution designed for simplicity and portability. SparkOS fe The current MVP provides: - ✅ Custom init system written in C -- ✅ Working bash shell environment +- ✅ Working busybox shell environment - ✅ dd-able AMD64 image creation scripts - ✅ Minimal root filesystem structure - ✅ Build system (Makefile) @@ -99,7 +99,7 @@ SparkOS/ SparkOS uses a custom init system (`/sbin/init`) that: - Mounts essential filesystems (proc, sys, dev, tmp) -- Spawns a bash login shell +- Spawns a busybox sh login shell - Handles process reaping - Respawns shell on exit @@ -138,14 +138,18 @@ make help To create a fully functional system, you need to populate the rootfs with binaries: ```bash -# Example: Add bash (statically linked is best) -cp /bin/bash rootfs/bin/ +# Example: Add busybox (statically linked is best) +cp /bin/busybox rootfs/bin/ -# Example: Add essential utilities -cp /bin/{ls,cat,mkdir,rm,cp,mount} rootfs/bin/ +# Create busybox symlinks for common utilities +cd rootfs/bin +for cmd in sh ls cat mkdir rm cp mount umount chmod chown ln; do + ln -sf busybox $cmd +done +cd ../.. -# Copy required libraries if not static -ldd rootfs/bin/bash # Check dependencies +# If using dynamically linked busybox, copy required libraries +ldd rootfs/bin/busybox # Check dependencies # Copy libraries to rootfs/lib or rootfs/lib64 ``` @@ -184,7 +188,7 @@ To create a fully bootable system, you'll also need: - Bootloader installation (handled by scripts) A single binary on top of Linux / Wayland that manages the OS, C++ CLI and Qt6/QML Full screen GUI. Android like design but more desktop orientated. A distribution that can be dd'ed to a USB flash drive. Root elevation powered by sudo. This project will need to set up a barebones distro (doesn't really need to be based on another, to keep things clean) -MVP is just a to get to a bash prompt with sudo support. Install minimum on system, maybe even use busybox. +MVP is just a to get to a shell prompt with sudo support. Install minimum on system using busybox for minimal footprint. We should try to build the system with github actions if possible. diff --git a/config/build.conf b/config/build.conf index 84d4e95..ff49c18 100644 --- a/config/build.conf +++ b/config/build.conf @@ -17,7 +17,7 @@ BOOTLOADER=syslinux INIT=sparkos-init # Default shell -SHELL=/bin/bash +SHELL=/bin/sh # Compiler flags CFLAGS=-Wall -O2 -static diff --git a/rootfs/README.txt b/rootfs/README.txt index 5e3f7f4..9faa705 100644 --- a/rootfs/README.txt +++ b/rootfs/README.txt @@ -14,5 +14,5 @@ Directory Structure: /home - User home directories Note: This is a minimal system. You'll need to populate /bin and /usr/bin -with actual binaries (bash, coreutils, etc.) from a proper Linux system +with actual binaries (busybox, etc.) from a proper Linux system or by cross-compiling. diff --git a/rootfs/etc/passwd b/rootfs/etc/passwd index aebc492..eb85a55 100644 --- a/rootfs/etc/passwd +++ b/rootfs/etc/passwd @@ -1 +1 @@ -root:x:0:0:root:/root:/bin/bash +root:x:0:0:root:/root:/bin/sh diff --git a/rootfs/root/.bashrc b/rootfs/root/.profile similarity index 68% rename from rootfs/root/.bashrc rename to rootfs/root/.profile index 208e46f..145c5c5 100644 --- a/rootfs/root/.bashrc +++ b/rootfs/root/.profile @@ -1,10 +1,9 @@ -# SparkOS Root Bash Configuration +# SparkOS Root Shell Configuration # Set prompt PS1='SparkOS:\w# ' # Aliases -alias ls='ls --color=auto' alias ll='ls -lah' alias ..='cd ..' diff --git a/scripts/build.sh b/scripts/build.sh index 97c0e2c..6762c0e 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -28,9 +28,10 @@ echo "" echo "Build complete!" echo "" echo "Next steps to create a full bootable system:" -echo " 1. Populate rootfs/bin with bash and essential utilities" -echo " (cp /bin/bash rootfs/bin/, etc.)" -echo " 2. Copy required libraries to rootfs/usr/lib and rootfs/lib" +echo " 1. Copy busybox to rootfs/bin/" +echo " (cp /bin/busybox rootfs/bin/)" +echo " 2. Create symlinks in rootfs/bin for common utilities" +echo " (cd rootfs/bin && for cmd in sh ls cat mkdir rm cp mount; do ln -sf busybox \$cmd; done)" echo " 3. Add a Linux kernel to rootfs/boot/vmlinuz" echo " 4. Run: sudo make image" echo "" diff --git a/scripts/setup_rootfs.sh b/scripts/setup_rootfs.sh index 05b1cb4..a19499a 100755 --- a/scripts/setup_rootfs.sh +++ b/scripts/setup_rootfs.sh @@ -1,6 +1,6 @@ #!/bin/bash # SparkOS Setup Script -# Sets up a minimal rootfs with bash and essential utilities +# Sets up a minimal rootfs with busybox and essential utilities set -e @@ -37,7 +37,7 @@ EOF # /etc/passwd cat > "$ROOTFS_DIR/etc/passwd" << 'EOF' -root:x:0:0:root:/root:/bin/bash +root:x:0:0:root:/root:/bin/sh EOF # /etc/group @@ -69,15 +69,14 @@ echo "Type 'help' for available commands" echo "" EOF -# Create .bashrc for root -cat > "$ROOTFS_DIR/root/.bashrc" << 'EOF' -# SparkOS Root Bash Configuration +# Create .profile for root (busybox uses .profile instead of .bashrc) +cat > "$ROOTFS_DIR/root/.profile" << 'EOF' +# SparkOS Root Shell Configuration # Set prompt PS1='SparkOS:\w# ' # Aliases -alias ls='ls --color=auto' alias ll='ls -lah' alias ..='cd ..' @@ -131,7 +130,7 @@ Directory Structure: /home - User home directories Note: This is a minimal system. You'll need to populate /bin and /usr/bin -with actual binaries (bash, coreutils, etc.) from a proper Linux system +with actual binaries (busybox, etc.) from a proper Linux system or by cross-compiling. EOF @@ -141,8 +140,8 @@ echo "" echo "Next steps:" echo " 1. Build init: make init" echo " 2. Install init: make install" -echo " 3. Copy bash and essential binaries to rootfs/bin/" +echo " 3. Copy busybox to rootfs/bin/ and create symlinks" echo " 4. Create bootable image: sudo make image" echo "" -echo "Note: You'll need to populate the rootfs with actual binaries" +echo "Note: You'll need to populate the rootfs with busybox binary" echo " before creating a bootable image." diff --git a/src/init.c b/src/init.c index 503d199..758ecc5 100644 --- a/src/init.c +++ b/src/init.c @@ -29,7 +29,7 @@ static void spawn_shell() { if (pid == 0) { // Child process - exec shell - char *argv[] = {"/bin/bash", "--login", NULL}; + char *argv[] = {"/bin/sh", "-l", NULL}; char *envp[] = { "HOME=/root", "PATH=/bin:/sbin:/usr/bin:/usr/sbin", @@ -38,11 +38,7 @@ static void spawn_shell() { NULL }; - execve("/bin/bash", argv, envp); - - // If bash fails, try sh - char *sh_argv[] = {"/bin/sh", NULL}; - execve("/bin/sh", sh_argv, envp); + execve("/bin/sh", argv, envp); perror("failed to exec shell"); exit(1);