From f97eeae96e4f774a30039b4d417bf31b5da01485 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 28 Dec 2025 19:27:50 +0000 Subject: [PATCH] Improve setup script with offline fallback and update gitignore Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com> --- .gitignore | 9 +++ scripts/setup-deps.sh | 134 ++++++++++++++++++++++++++++++++---------- 2 files changed, 112 insertions(+), 31 deletions(-) diff --git a/.gitignore b/.gitignore index 74d9e49..4dc89a3 100644 --- a/.gitignore +++ b/.gitignore @@ -84,4 +84,13 @@ ui_*.h # Don't ignore example files !docs/examples/*.bin +# Dependencies (downloaded/generated files) +deps/firmware/*.bin +deps/firmware/STATUS +deps/firmware/VERSION +deps/ovmf/*.fd +deps/ovmf/VERSION +deps/mesa-radv/STATUS +deps/qt6/STATUS + _codeql_detected_source_root diff --git a/scripts/setup-deps.sh b/scripts/setup-deps.sh index cb01e0f..e0d1510 100755 --- a/scripts/setup-deps.sh +++ b/scripts/setup-deps.sh @@ -21,16 +21,8 @@ setup_firmware() { echo "=== Setting up AMD GPU Firmware Blobs ===" FIRMWARE_DIR="$DEPS_DIR/firmware" - TEMP_DIR=$(mktemp -d) - cd "$TEMP_DIR" - - # Clone linux-firmware repository (shallow clone for speed) - echo "Downloading linux-firmware repository..." - git clone --depth 1 https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git - - # Copy required Navi 23 (dimgrey_cavefish) firmware files - echo "Copying Navi 23 firmware files..." + # Check if firmware files already exist FIRMWARE_FILES=( "dimgrey_cavefish_ce.bin" "dimgrey_cavefish_me.bin" @@ -41,22 +33,47 @@ setup_firmware() { "dimgrey_cavefish_vcn.bin" ) + ALL_EXIST=true for file in "${FIRMWARE_FILES[@]}"; do - if [ -f "linux-firmware/amdgpu/$file" ]; then - cp "linux-firmware/amdgpu/$file" "$FIRMWARE_DIR/" - echo " ✓ Copied $file" - else - echo " ⚠ Warning: $file not found" + if [ ! -f "$FIRMWARE_DIR/$file" ]; then + ALL_EXIST=false + break fi done - # Get commit hash for version tracking - cd linux-firmware - COMMIT_HASH=$(git rev-parse HEAD) - COMMIT_DATE=$(git log -1 --format=%cd --date=short) + if [ "$ALL_EXIST" = true ]; then + echo "✓ Firmware files already present:" + for file in "${FIRMWARE_FILES[@]}"; do + echo " ✓ $file" + done + echo "" + return 0 + fi - # Create VERSION file - cat > "$FIRMWARE_DIR/VERSION" </dev/null; then + cd "$TEMP_DIR/linux-firmware" + + # Copy required Navi 23 (dimgrey_cavefish) firmware files + echo "Copying Navi 23 firmware files..." + for file in "${FIRMWARE_FILES[@]}"; do + if [ -f "amdgpu/$file" ]; then + cp "amdgpu/$file" "$FIRMWARE_DIR/" + echo " ✓ Copied $file" + else + echo " ⚠ Warning: $file not found" + fi + done + + # Get commit hash for version tracking + COMMIT_HASH=$(git rev-parse HEAD) + COMMIT_DATE=$(git log -1 --format=%cd --date=short) + + # Create VERSION file + cat > "$FIRMWARE_DIR/VERSION" <> "$FIRMWARE_DIR/VERSION" + fi + done + + cd "$METALOS_ROOT" + rm -rf "$TEMP_DIR" + + echo "✓ Firmware blobs setup complete" + else + echo "⚠ Warning: Unable to download linux-firmware repository" + echo " This may be due to network restrictions or the repository being unavailable." + echo "" + echo "To manually download firmware files:" + echo " 1. Visit: https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git" + echo " 2. Download the following files from the amdgpu/ directory:" + for file in "${FIRMWARE_FILES[@]}"; do + echo " - $file" + done + echo " 3. Copy them to: $FIRMWARE_DIR/" + echo "" + echo "Alternatively, on a system with linux-firmware installed:" + echo " cp /lib/firmware/amdgpu/dimgrey_cavefish_*.bin $FIRMWARE_DIR/" + + # Create placeholder STATUS file + cat > "$FIRMWARE_DIR/STATUS" <> "$FIRMWARE_DIR/VERSION" - fi - done - - cd "$METALOS_ROOT" - rm -rf "$TEMP_DIR" - - echo "✓ Firmware blobs setup complete" echo "" } @@ -85,6 +138,13 @@ setup_ovmf() { OVMF_DIR="$DEPS_DIR/ovmf" + # Check if OVMF already exists + if [ -f "$OVMF_DIR/OVMF_CODE.fd" ]; then + echo "✓ OVMF firmware already present" + echo "" + return 0 + fi + # Check for OVMF in system locations if [ -f /usr/share/OVMF/OVMF_CODE.fd ]; then echo "Copying OVMF from /usr/share/OVMF/..." @@ -136,6 +196,12 @@ setup_mesa_radv() { MESA_DIR="$DEPS_DIR/mesa-radv" + if [ -f "$MESA_DIR/STATUS" ]; then + echo "ℹ Mesa RADV setup already documented" + echo "" + return 0 + fi + cat > "$MESA_DIR/STATUS" < "$QT6_DIR/STATUS" <