From 02aa981d927c11caba4730d623b2e6b66caec669 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 29 Dec 2025 15:59:12 +0000 Subject: [PATCH 1/2] Initial plan From 30fefdae04800301d370f72021ff7d5b13f6b83c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 29 Dec 2025 16:04:00 +0000 Subject: [PATCH 2/2] Optimize build scripts for performance and reliability Co-authored-by: Hiburger <180202879+Hiburger@users.noreply.github.com> --- 04-customize-desktop.sh | 5 ++--- 05-install-ai.sh | 4 ++-- build.sh | 24 ++++++++++++------------ 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/04-customize-desktop.sh b/04-customize-desktop.sh index e574d78..beaa2a6 100755 --- a/04-customize-desktop.sh +++ b/04-customize-desktop.sh @@ -4,9 +4,8 @@ export DEBIAN_FRONTEND=noninteractive echo "--> Removing unwanted packages..." PACKAGES_TO_REMOVE="kmahjongg kmines kpat ksnake kmail kontact akregator" -for pkg in $PACKAGES_TO_REMOVE; do - apt-get purge -y "$pkg" || true -done +# Batch removal is more efficient than sequential +apt-get purge -y $PACKAGES_TO_REMOVE || true apt-get autoremove -y echo "--> Setting up global assets..." diff --git a/05-install-ai.sh b/05-install-ai.sh index 11762bc..284dc85 100755 --- a/05-install-ai.sh +++ b/05-install-ai.sh @@ -17,7 +17,7 @@ chmod 444 "${MODELFILE}" cat > /usr/local/bin/luminos-reassemble.sh << "EOF" #!/bin/bash # Find files marked as split -find /usr/share/ollama/.ollama -name "*.is_split" | while read marker; do +while IFS= read -r -d '' marker; do ORIG_FILE="${marker%.is_split}" if [ ! -f "$ORIG_FILE" ]; then echo "Reassembling $ORIG_FILE..." @@ -25,7 +25,7 @@ find /usr/share/ollama/.ollama -name "*.is_split" | while read marker; do cat "${ORIG_FILE}.part"* > "$ORIG_FILE" chown ollama:ollama "$ORIG_FILE" fi -done +done < <(find /usr/share/ollama/.ollama -name "*.is_split" -print0) EOF chmod +x /usr/local/bin/luminos-reassemble.sh diff --git a/build.sh b/build.sh index a9e6da1..e8c4ec9 100755 --- a/build.sh +++ b/build.sh @@ -13,10 +13,10 @@ AI_BUILD_DIR="${WORK_DIR}/ai_build" ISO_NAME="LuminOS-0.2.1-amd64.iso" # Cleanup -sudo umount "${CHROOT_DIR}/sys" &>/dev/null || true -sudo umount "${CHROOT_DIR}/proc" &>/dev/null || true -sudo umount "${CHROOT_DIR}/dev/pts" &>/dev/null || true -sudo umount "${CHROOT_DIR}/dev" &>/dev/null || true +# Unmount in reverse order if they exist +for mount_point in "${CHROOT_DIR}/sys" "${CHROOT_DIR}/proc" "${CHROOT_DIR}/dev/pts" "${CHROOT_DIR}/dev"; do + mountpoint -q "$mount_point" 2>/dev/null && sudo umount "$mount_point" || true +done pkill -f "ollama serve" || true sudo rm -rf "${WORK_DIR}" sudo rm -f "${BASE_DIR}/${ISO_NAME}" @@ -69,7 +69,7 @@ fi # 3b. CUT LARGE FILES (The Key Fix) echo "--> Cutting large AI files into 1GB chunks..." # Find files > 900MB (safety margin) inside the models directory -find "${TARGET_MODEL_DIR}" -type f -size +900M | while read file; do +while IFS= read -r -d '' file; do echo "Splitting $file ..." # Split into chunks named .partaa, .partab, etc. split -b 900M "$file" "$file.part" @@ -77,7 +77,7 @@ find "${TARGET_MODEL_DIR}" -type f -size +900M | while read file; do touch "$file.is_split" # Remove the original giant file so it doesn't get into the ISO rm "$file" -done +done < <(find "${TARGET_MODEL_DIR}" -type f -size +900M -print0) # --- 4. Bootstrap System --- echo "--> Bootstrapping Debian..." @@ -131,7 +131,7 @@ echo "--> Creating Layers..." # Layer 1: OS (Excluding models path) echo " Layer 1 (OS)..." -mksquashfs "${CHROOT_DIR}" "${ISO_DIR}/live/01-filesystem.squashfs" -e boot -e usr/share/ollama/.ollama -comp zstd +mksquashfs "${CHROOT_DIR}" "${ISO_DIR}/live/01-filesystem.squashfs" -e boot -e usr/share/ollama/.ollama -comp zstd -processors "$(nproc)" # Prepare distribution directories L2="${WORK_DIR}/layer2" @@ -152,7 +152,7 @@ mkdir -p "$L3/usr/share/ollama/.ollama/blobs" mkdir -p "$L4/usr/share/ollama/.ollama/blobs" COUNT=0 -find "${TARGET_MODEL_DIR}/blobs" -type f | while read file; do +while IFS= read -r -d '' file; do MOD=$((COUNT % 3)) if [ $MOD -eq 0 ]; then cp "$file" "$L2/usr/share/ollama/.ollama/blobs/" @@ -162,14 +162,14 @@ find "${TARGET_MODEL_DIR}/blobs" -type f | while read file; do cp "$file" "$L4/usr/share/ollama/.ollama/blobs/" fi COUNT=$((COUNT + 1)) -done +done < <(find "${TARGET_MODEL_DIR}/blobs" -type f -print0) echo " Layer 2..." -mksquashfs "$L2" "${ISO_DIR}/live/02-ai-part1.squashfs" -comp zstd +mksquashfs "$L2" "${ISO_DIR}/live/02-ai-part1.squashfs" -comp zstd -processors "$(nproc)" echo " Layer 3..." -mksquashfs "$L3" "${ISO_DIR}/live/03-ai-part2.squashfs" -comp zstd +mksquashfs "$L3" "${ISO_DIR}/live/03-ai-part2.squashfs" -comp zstd -processors "$(nproc)" echo " Layer 4..." -mksquashfs "$L4" "${ISO_DIR}/live/04-ai-part3.squashfs" -comp zstd +mksquashfs "$L4" "${ISO_DIR}/live/04-ai-part3.squashfs" -comp zstd -processors "$(nproc)" # --- 7. Bootloader & Final ISO --- echo "--> Bootloader..."