mirror of
https://github.com/johndoe6345789/SparkOS.git
synced 2026-04-24 13:34:56 +00:00
Address code review feedback: fix C/C++ typo, remove unused constant, add cleanup traps
Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
@@ -4,7 +4,7 @@ A minimal Linux distribution designed for simplicity and portability. SparkOS fe
|
|||||||
|
|
||||||
- **Minimal footprint**: Barebones Linux system with bash shell
|
- **Minimal footprint**: Barebones Linux system with bash shell
|
||||||
- **Portable**: dd-able disk image for USB flash drives
|
- **Portable**: dd-able disk image for USB flash drives
|
||||||
- **Custom init**: Lightweight C++ init system
|
- **Custom init**: Lightweight C init system
|
||||||
- **Future-ready**: Designed to support Qt6/QML GUI and Wayland
|
- **Future-ready**: Designed to support Qt6/QML GUI and Wayland
|
||||||
- **Root elevation**: Uses sudo for privilege management
|
- **Root elevation**: Uses sudo for privilege management
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,37 @@ IMAGE_FILE="$PROJECT_ROOT/sparkos.img"
|
|||||||
IMAGE_SIZE="512M"
|
IMAGE_SIZE="512M"
|
||||||
MOUNT_POINT="/tmp/sparkos_mount"
|
MOUNT_POINT="/tmp/sparkos_mount"
|
||||||
ROOTFS_DIR="$PROJECT_ROOT/rootfs"
|
ROOTFS_DIR="$PROJECT_ROOT/rootfs"
|
||||||
|
LOOP_DEV=""
|
||||||
|
|
||||||
|
# Cleanup function
|
||||||
|
cleanup() {
|
||||||
|
local exit_code=$?
|
||||||
|
echo "Cleaning up..."
|
||||||
|
|
||||||
|
# Unmount if mounted
|
||||||
|
if mountpoint -q "$MOUNT_POINT" 2>/dev/null; then
|
||||||
|
umount "$MOUNT_POINT" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove mount point
|
||||||
|
if [ -d "$MOUNT_POINT" ]; then
|
||||||
|
rmdir "$MOUNT_POINT" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Detach loop device
|
||||||
|
if [ -n "$LOOP_DEV" ] && losetup "$LOOP_DEV" &>/dev/null; then
|
||||||
|
losetup -d "$LOOP_DEV" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $exit_code -ne 0 ]; then
|
||||||
|
echo "ERROR: Image creation failed"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit $exit_code
|
||||||
|
}
|
||||||
|
|
||||||
|
# Set trap for cleanup on exit, interrupt, or error
|
||||||
|
trap cleanup EXIT INT TERM
|
||||||
|
|
||||||
echo "SparkOS Image Builder"
|
echo "SparkOS Image Builder"
|
||||||
echo "====================="
|
echo "====================="
|
||||||
@@ -91,11 +122,6 @@ dd if=/usr/lib/syslinux/mbr/mbr.bin of="$LOOP_DEV" bs=440 count=1 conv=notrunc 2
|
|||||||
dd if=/usr/share/syslinux/mbr.bin of="$LOOP_DEV" bs=440 count=1 conv=notrunc 2>/dev/null || \
|
dd if=/usr/share/syslinux/mbr.bin of="$LOOP_DEV" bs=440 count=1 conv=notrunc 2>/dev/null || \
|
||||||
echo "WARNING: Could not install MBR, you may need to do this manually"
|
echo "WARNING: Could not install MBR, you may need to do this manually"
|
||||||
|
|
||||||
echo "Cleaning up..."
|
|
||||||
umount "$MOUNT_POINT"
|
|
||||||
rmdir "$MOUNT_POINT"
|
|
||||||
losetup -d "$LOOP_DEV"
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "SUCCESS! Bootable image created: $IMAGE_FILE"
|
echo "SUCCESS! Bootable image created: $IMAGE_FILE"
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
@@ -12,8 +12,6 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#define INIT_PATH "/sbin/init"
|
|
||||||
|
|
||||||
static void signal_handler(int sig) {
|
static void signal_handler(int sig) {
|
||||||
if (sig == SIGCHLD) {
|
if (sig == SIGCHLD) {
|
||||||
// Reap zombie processes
|
// Reap zombie processes
|
||||||
|
|||||||
Reference in New Issue
Block a user