mirror of
https://github.com/johndoe6345789/SparkOS.git
synced 2026-04-24 13:34:56 +00:00
Revert to Ubuntu kernel due to Docker network constraints, fix package detection
Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
@@ -1,67 +1,43 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Download and build a minimal Linux kernel from kernel.org
|
# Download a minimal Linux kernel for UEFI image
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "=== Building minimal Linux kernel from kernel.org ==="
|
echo "=== Downloading Linux kernel from Ubuntu repositories ==="
|
||||||
|
|
||||||
# Use a stable LTS kernel version
|
mkdir -p /kernel
|
||||||
KERNEL_VERSION="6.6.68"
|
apt-get update
|
||||||
KERNEL_MAJOR=$(echo $KERNEL_VERSION | cut -d. -f1)
|
|
||||||
|
|
||||||
mkdir -p /kernel/build
|
# Get the actual kernel package name (not the metapackage)
|
||||||
cd /kernel/build
|
echo "Finding latest kernel package..."
|
||||||
|
KERNEL_PKG=$(apt-cache depends linux-image-generic | grep -E 'Depends.*linux-image-[0-9]' | head -1 | awk '{print $2}')
|
||||||
|
|
||||||
# Download kernel source
|
if [ -z "$KERNEL_PKG" ]; then
|
||||||
echo "Downloading kernel ${KERNEL_VERSION}..."
|
echo "ERROR: Could not determine kernel package name"
|
||||||
wget https://cdn.kernel.org/pub/linux/kernel/v${KERNEL_MAJOR}.x/linux-${KERNEL_VERSION}.tar.xz
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Extract
|
echo "Downloading kernel package: $KERNEL_PKG"
|
||||||
echo "Extracting kernel source..."
|
apt-get download "$KERNEL_PKG"
|
||||||
tar -xf linux-${KERNEL_VERSION}.tar.xz
|
|
||||||
cd linux-${KERNEL_VERSION}
|
|
||||||
|
|
||||||
# Create minimal config for x86_64 UEFI boot
|
# Extract the kernel package
|
||||||
echo "Configuring kernel for minimal UEFI boot..."
|
echo "Extracting kernel..."
|
||||||
make defconfig
|
dpkg -x ${KERNEL_PKG}*.deb /kernel
|
||||||
make kvm_guest.config
|
|
||||||
|
|
||||||
# Enable essential features for SparkOS
|
# Verify kernel was extracted
|
||||||
scripts/config --enable CONFIG_EFI
|
if [ ! -d /kernel/boot ]; then
|
||||||
scripts/config --enable CONFIG_EFI_STUB
|
echo "ERROR: Kernel boot directory not found after extraction"
|
||||||
scripts/config --enable CONFIG_DEVTMPFS
|
exit 1
|
||||||
scripts/config --enable CONFIG_DEVTMPFS_MOUNT
|
fi
|
||||||
scripts/config --enable CONFIG_TMPFS
|
|
||||||
scripts/config --enable CONFIG_PROC_FS
|
|
||||||
scripts/config --enable CONFIG_SYSFS
|
|
||||||
scripts/config --enable CONFIG_EXT4_FS
|
|
||||||
scripts/config --enable CONFIG_VFAT_FS
|
|
||||||
scripts/config --enable CONFIG_NLS_CODEPAGE_437
|
|
||||||
scripts/config --enable CONFIG_NLS_ISO8859_1
|
|
||||||
scripts/config --enable CONFIG_TTY
|
|
||||||
scripts/config --enable CONFIG_SERIAL_8250
|
|
||||||
scripts/config --enable CONFIG_SERIAL_8250_CONSOLE
|
|
||||||
|
|
||||||
# Disable unnecessary features to speed up build
|
KERNEL_FILE=$(find /kernel/boot -name "vmlinuz-*" | head -1)
|
||||||
scripts/config --disable CONFIG_DEBUG_INFO
|
if [ -z "$KERNEL_FILE" ]; then
|
||||||
scripts/config --disable CONFIG_DEBUG_INFO_BTF
|
echo "ERROR: No kernel image found"
|
||||||
scripts/config --disable CONFIG_DEBUG_INFO_DWARF4
|
exit 1
|
||||||
scripts/config --disable CONFIG_DEBUG_INFO_DWARF5
|
fi
|
||||||
scripts/config --disable CONFIG_GDB_SCRIPTS
|
|
||||||
scripts/config --set-str CONFIG_LOCALVERSION "-sparkos"
|
|
||||||
|
|
||||||
# Build kernel (use all available cores)
|
echo "Kernel extracted successfully: $KERNEL_FILE"
|
||||||
echo "Building kernel (this may take several minutes)..."
|
|
||||||
make -j$(nproc) bzImage
|
|
||||||
|
|
||||||
# Copy kernel to expected location
|
|
||||||
echo "Installing kernel..."
|
|
||||||
mkdir -p /kernel/boot
|
|
||||||
cp arch/x86/boot/bzImage /kernel/boot/vmlinuz-${KERNEL_VERSION}
|
|
||||||
|
|
||||||
# Clean up build directory to save space
|
|
||||||
cd /
|
|
||||||
rm -rf /kernel/build
|
|
||||||
|
|
||||||
echo "Kernel build complete: /kernel/boot/vmlinuz-${KERNEL_VERSION}"
|
|
||||||
ls -lh /kernel/boot/
|
ls -lh /kernel/boot/
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
rm -rf /var/lib/apt/lists/* ${KERNEL_PKG}*.deb
|
||||||
|
|||||||
@@ -17,12 +17,5 @@ apt-get install -y \
|
|||||||
wget \
|
wget \
|
||||||
busybox-static \
|
busybox-static \
|
||||||
kmod \
|
kmod \
|
||||||
udev \
|
udev
|
||||||
bc \
|
|
||||||
bison \
|
|
||||||
flex \
|
|
||||||
libelf-dev \
|
|
||||||
libssl-dev \
|
|
||||||
xz-utils \
|
|
||||||
cpio
|
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|||||||
Reference in New Issue
Block a user