Files
BBeOS/scripts/build-rootfs.sh
Eliott 73fb76098e
Some checks failed
CI / markdown-lint (push) Failing after 14s
Reorganize BBeOS project structure for better maintainability
- Reorganized directory structure following open source best practices
- Created src/ directory for all source code components
- Moved build artifacts to build/ subdirectories
- Organized documentation into phases/, guides/, and api/ subdirectories
- Moved third-party code to vendor/ directory
- Moved downloads to downloads/ directory
- Updated all build scripts to reference new directory structure
- Created comprehensive PROJECT_STRUCTURE.md documentation
- Added DEVELOPMENT_GUIDE.md as main entry point
- Improved separation of concerns and maintainability
- Follows standard open source project conventions
2025-08-01 11:48:06 +02:00

128 lines
2.9 KiB
Bash
Executable File

#!/bin/bash
# BBeOS Minimal Root Filesystem Build Script
# Creates a BusyBox-based initramfs for BlackBerry Classic Q20
set -e
echo "Building minimal root filesystem for BBeOS..."
# Configuration
ROOTFS_DIR="build/rootfs"
BUSYBOX_VERSION="1.36.1"
BUSYBOX_URL="https://busybox.net/downloads/busybox-${BUSYBOX_VERSION}.tar.bz2"
BUSYBOX_DIR="busybox-${BUSYBOX_VERSION}"
# Set up environment
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabihf-
# Create directories
echo "Creating directories..."
rm -rf ${ROOTFS_DIR}
mkdir -p ${ROOTFS_DIR}/{bin,dev,etc,lib,proc,sys,tmp,usr/bin,usr/sbin}
# Download and build BusyBox
echo "Downloading BusyBox ${BUSYBOX_VERSION}..."
if [ ! -f "downloads/${BUSYBOX_DIR}.tar.bz2" ]; then
wget -O downloads/${BUSYBOX_DIR}.tar.bz2 ${BUSYBOX_URL}
fi
if [ ! -d "downloads/${BUSYBOX_DIR}" ]; then
tar xf downloads/${BUSYBOX_DIR}.tar.bz2 -C downloads/
fi
echo "Building BusyBox..."
cd downloads/${BUSYBOX_DIR}
# Configure BusyBox
make defconfig
sed -i 's/# CONFIG_STATIC is not set/CONFIG_STATIC=y/' .config
sed -i 's/# CONFIG_FEATURE_PREFER_APPLETS is not set/CONFIG_FEATURE_PREFER_APPLETS=y/' .config
sed -i 's/# CONFIG_FEATURE_SH_STANDALONE is not set/CONFIG_FEATURE_SH_STANDALONE=y/' .config
# Build BusyBox
make -j$(nproc)
make install
# Copy BusyBox to rootfs
echo "Installing BusyBox to rootfs..."
cp busybox ../../${ROOTFS_DIR}/bin/
cd ../..
# Create init script
echo "Creating init script..."
cat > ${ROOTFS_DIR}/init << 'EOF'
#!/bin/sh
# BBeOS Init Script
echo "BBeOS starting..."
# Mount essential filesystems
mount -t proc none /proc
mount -t sysfs none /sys
mount -t tmpfs none /tmp
# Create device nodes
mknod /dev/console c 5 1
mknod /dev/null c 1 3
mknod /dev/zero c 1 5
mknod /dev/tty c 5 0
mknod /dev/tty0 c 4 0
mknod /dev/ttyMSM0 c 251 0
# Set up console
exec 0</dev/console
exec 1>/dev/console
exec 2>/dev/console
echo "BBeOS root filesystem loaded"
echo "Welcome to BBeOS on BlackBerry Classic Q20!"
# Start shell
exec /bin/sh
EOF
chmod +x ${ROOTFS_DIR}/init
# Create basic configuration files
echo "Creating configuration files..."
# /etc/passwd
cat > ${ROOTFS_DIR}/etc/passwd << 'EOF'
root:x:0:0:root:/root:/bin/sh
EOF
# /etc/group
cat > ${ROOTFS_DIR}/etc/group << 'EOF'
root:x:0:
EOF
# /etc/hostname
echo "bbeos-q20" > ${ROOTFS_DIR}/etc/hostname
# /etc/hosts
cat > ${ROOTFS_DIR}/etc/hosts << 'EOF'
127.0.0.1 localhost
127.0.1.1 bbeos-q20
EOF
# Create symlinks for BusyBox
echo "Creating BusyBox symlinks..."
cd ${ROOTFS_DIR}/bin
for cmd in sh ls cat echo mount umount mknod chmod chown; do
ln -sf busybox $cmd
done
cd ../..
# Create initramfs
echo "Creating initramfs..."
cd ${ROOTFS_DIR}
find . | cpio -o -H newc | gzip > ../initramfs.img
cd ..
echo "Root filesystem build complete!"
echo "Files created:"
echo " - rootfs/ (root filesystem directory)"
echo " - initramfs.img (compressed initramfs)"
echo " - busybox-${BUSYBOX_VERSION}/ (BusyBox source and build)"