diff --git a/.github/workflows/build-tiny11.yml b/.github/workflows/build-tiny11.yml index 00a1196..90bb1e6 100644 --- a/.github/workflows/build-tiny11.yml +++ b/.github/workflows/build-tiny11.yml @@ -65,10 +65,11 @@ jobs: Write-Host "ISO file size: $((Get-Item $isoPath).Length / 1GB) GB" - # Mount ISO + # Mount ISO with StorageType option to ensure proper mounting Write-Host "Mounting disk image..." try { - $mountResult = Mount-DiskImage -ImagePath $isoPath -PassThru -ErrorAction Stop + # Mount with StorageType ISO to ensure it mounts as a CD/DVD drive + $mountResult = Mount-DiskImage -ImagePath $isoPath -PassThru -StorageType ISO -ErrorAction Stop Write-Host "Mount command executed successfully" Write-Host "Mount result: $mountResult" } catch { @@ -76,12 +77,18 @@ jobs: exit 1 } + # Wait a bit longer for mount to complete + Start-Sleep -Seconds 3 + # Wait for mount to complete and drive letter to be assigned Write-Host "Waiting for drive letter assignment..." $maxWaitTime = 30 # 30 seconds max wait $waitInterval = 1 # Check every second $elapsed = 0 $driveLetter = $null + $systemDrive = $env:SystemDrive -replace ':', '' + + Write-Host "System drive: $systemDrive" while ($elapsed -lt $maxWaitTime -and -not $driveLetter) { Start-Sleep -Seconds $waitInterval @@ -94,33 +101,59 @@ jobs: # Get disk number $diskNumber = $diskImage.Number + Write-Host "Mounted disk number: $diskNumber" + # Get partitions on this disk $partitions = Get-Partition -DiskNumber $diskNumber -ErrorAction SilentlyContinue if ($partitions) { - # Get drive letter from partition + Write-Host "Found $($partitions.Count) partition(s) on mounted disk" + # Get drive letter from partition, but exclude system drive foreach ($partition in $partitions) { if ($partition.DriveLetter) { - $driveLetter = $partition.DriveLetter - Write-Host "Found drive letter via partition: $driveLetter" - break + Write-Host "Found partition with drive letter: $($partition.DriveLetter)" + if ($partition.DriveLetter -ne $systemDrive) { + $driveLetter = $partition.DriveLetter + Write-Host "Found drive letter via partition: $driveLetter" + + # Verify this drive has Windows installation files + if (Test-Path "$driveLetter`:\sources\boot.wim" -or Test-Path "$driveLetter`:\sources\install.wim" -or Test-Path "$driveLetter`:\sources\install.esd") { + Write-Host "Verified: Drive $driveLetter contains Windows installation files" + break + } else { + Write-Host "Warning: Drive $driveLetter does not contain Windows files, continuing search..." + $driveLetter = $null + } + } else { + Write-Host "Skipping system drive: $($partition.DriveLetter)" + } } } } } - # Fallback: Check all drives for Windows installation files + # Fallback: Check all drives for Windows installation files (excluding system drive) if (-not $driveLetter) { - $allDrives = Get-Volume | Where-Object { $_.DriveLetter -ne $null } | Select-Object -ExpandProperty DriveLetter + $allDrives = Get-Volume | Where-Object { + $_.DriveLetter -ne $null -and $_.DriveLetter -ne $systemDrive + } | Select-Object -ExpandProperty DriveLetter + + Write-Host "Checking drives: $($allDrives -join ', ')" + foreach ($letter in $allDrives) { - if (Test-Path "$letter`:\sources\boot.wim" -or Test-Path "$letter`:\sources\install.wim" -or Test-Path "$letter`:\sources\install.esd") { + $bootPath = "$letter`:\sources\boot.wim" + $installPath = "$letter`:\sources\install.wim" + $esdPath = "$letter`:\sources\install.esd" + + if ((Test-Path $bootPath) -or (Test-Path $installPath) -or (Test-Path $esdPath)) { + Write-Host "Found Windows files on drive: $letter" # Verify this is actually our mounted ISO $testDiskImage = Get-DiskImage -ImagePath $isoPath -ErrorAction SilentlyContinue if ($testDiskImage) { $testPartition = Get-Partition -DriveLetter $letter -ErrorAction SilentlyContinue if ($testPartition -and $testPartition.DiskNumber -eq $testDiskImage.Number) { $driveLetter = $letter - Write-Host "Found drive letter by checking Windows files: $driveLetter" + Write-Host "Verified: Found drive letter by checking Windows files: $driveLetter" break } } @@ -140,9 +173,40 @@ jobs: Write-Host "Mount result: $mountResult" Write-Host "Disk image info:" Get-DiskImage -ImagePath $isoPath | Format-List - Write-Host "Available volumes:" - Get-Volume | Format-List - exit 1 + Write-Host "Available volumes (excluding system drive):" + Get-Volume | Where-Object { $_.DriveLetter -ne $null -and $_.DriveLetter -ne $systemDrive } | Format-List + Write-Host "All partitions on mounted disk:" + if ($diskImage) { + $allPartitions = Get-Partition -DiskNumber $diskImage.Number -ErrorAction SilentlyContinue + $allPartitions | Format-List + + # Try to assign drive letter manually if partition exists but has no letter + foreach ($partition in $allPartitions) { + if (-not $partition.DriveLetter) { + Write-Host "Found partition without drive letter. Attempting to assign..." + # Find next available drive letter + $usedLetters = Get-Volume | Where-Object { $_.DriveLetter -ne $null } | Select-Object -ExpandProperty DriveLetter + $availableLetters = ('D'..'Z') | Where-Object { $_ -notin $usedLetters } + if ($availableLetters) { + $newLetter = $availableLetters[0] + Write-Host "Assigning drive letter $newLetter to partition..." + try { + Set-Partition -InputObject $partition -NewDriveLetter $newLetter -ErrorAction Stop + Start-Sleep -Seconds 2 + $driveLetter = $newLetter + Write-Host "Successfully assigned drive letter: $driveLetter" + break + } catch { + Write-Host "Failed to assign drive letter: $_" + } + } + } + } + } + + if (-not $driveLetter) { + exit 1 + } } Write-Host "ISO mounted successfully to drive: $driveLetter" @@ -165,8 +229,37 @@ jobs: if (Test-Path "$driveLetter`:\sources") { Write-Host "Contents of $driveLetter`:\sources:" Get-ChildItem "$driveLetter`:\sources" | Select-Object -First 10 + } else { + Write-Host "sources folder does not exist in $driveLetter`:\" + } + + # Check all drives to find where ISO actually mounted + Write-Host "Searching all drives for Windows installation files..." + $allDrives = Get-Volume | Where-Object { $_.DriveLetter -ne $null } | Select-Object -ExpandProperty DriveLetter + foreach ($letter in $allDrives) { + if ($letter -ne $systemDrive) { + $bootPath = "$letter`:\sources\boot.wim" + $installPath = "$letter`:\sources\install.wim" + $esdPath = "$letter`:\sources\install.esd" + if ((Test-Path $bootPath) -or (Test-Path $installPath) -or (Test-Path $esdPath)) { + Write-Host "Found Windows files on drive $letter`!" + $testDiskImage = Get-DiskImage -ImagePath $isoPath -ErrorAction SilentlyContinue + if ($testDiskImage) { + $testPartition = Get-Partition -DriveLetter $letter -ErrorAction SilentlyContinue + if ($testPartition -and $testPartition.DiskNumber -eq $testDiskImage.Number) { + Write-Host "This is the correct ISO drive! Updating drive letter..." + $driveLetter = $letter + Write-Host "ISO_DRIVE=$driveLetter" >> $env:GITHUB_ENV + break + } + } + } + } + } + + if (-not (Test-Path $bootWim) -and -not (Test-Path $installWim) -and -not (Test-Path $installEsd)) { + exit 1 } - exit 1 } Write-Host "Windows installation files verified successfully"