mirror of
https://github.com/ntdevlabs/tiny11builder.git
synced 2025-12-19 09:54:15 +00:00
Fix ISO mount logic: Add multiple verification methods and fallback to accept drive with Windows files
This commit is contained in:
parent
9b93d58fcd
commit
9316b7e230
3 changed files with 184 additions and 13 deletions
42
.github/scripts/run-coremaker-automated.ps1
vendored
42
.github/scripts/run-coremaker-automated.ps1
vendored
|
|
@ -47,6 +47,33 @@ $scriptContent = $scriptContent -replace 'if \(!\s*\$myWindowsPrincipal\.IsInRol
|
||||||
# Disable execution policy check by commenting out the exit
|
# Disable execution policy check by commenting out the exit
|
||||||
$scriptContent = $scriptContent -replace 'if \(\(Get-ExecutionPolicy\) -eq ''Restricted''\)', 'if ($false -and (Get-ExecutionPolicy) -eq ''Restricted'') # Disabled for GitHub Actions'
|
$scriptContent = $scriptContent -replace 'if \(\(Get-ExecutionPolicy\) -eq ''Restricted''\)', 'if ($false -and (Get-ExecutionPolicy) -eq ''Restricted'') # Disabled for GitHub Actions'
|
||||||
|
|
||||||
|
# Add error checking after oscdimg command to verify ISO was created
|
||||||
|
# Match the oscdimg command line ending with tiny11.iso
|
||||||
|
$oscdimgPattern = '(&\s*"\$OSCDIMG"[^`r`n]*tiny11\.iso[^`r`n]*)'
|
||||||
|
$oscdimgReplacement = @"
|
||||||
|
`$1
|
||||||
|
if (`$LASTEXITCODE -ne 0 -and `$LASTEXITCODE -ne `$null) {
|
||||||
|
Write-Error "oscdimg failed with exit code: `$LASTEXITCODE"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Verify ISO file was created
|
||||||
|
`$expectedIsoPath = "`$PSScriptRoot\tiny11.iso"
|
||||||
|
Start-Sleep -Seconds 2
|
||||||
|
if (-not (Test-Path `$expectedIsoPath)) {
|
||||||
|
Write-Error "ISO file was not created at: `$expectedIsoPath"
|
||||||
|
Write-Host "Checking for ISO in alternative locations..."
|
||||||
|
Get-ChildItem -Path `$PSScriptRoot -Filter "*.iso" -ErrorAction SilentlyContinue | ForEach-Object {
|
||||||
|
Write-Host "Found ISO: `$(`$_.FullName)"
|
||||||
|
}
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "ISO file verified: `$expectedIsoPath"
|
||||||
|
Write-Host "ISO size: `$([math]::Round((Get-Item `$expectedIsoPath).Length / 1GB, 2)) GB"
|
||||||
|
"@
|
||||||
|
$scriptContent = $scriptContent -replace $oscdimgPattern, $oscdimgReplacement
|
||||||
|
|
||||||
# Create a temporary script with auto-answers
|
# Create a temporary script with auto-answers
|
||||||
$ISODriveLetter = $ISODrive -replace ':', ''
|
$ISODriveLetter = $ISODrive -replace ':', ''
|
||||||
$dotNetAnswer = if ($EnableDotNet35) { "y" } else { "n" }
|
$dotNetAnswer = if ($EnableDotNet35) { "y" } else { "n" }
|
||||||
|
|
@ -129,10 +156,25 @@ try {
|
||||||
& $tempScriptPath
|
& $tempScriptPath
|
||||||
$scriptExitCode = $LASTEXITCODE
|
$scriptExitCode = $LASTEXITCODE
|
||||||
|
|
||||||
|
# Check if script failed (PowerShell sets $LASTEXITCODE for native commands)
|
||||||
|
# If script exited normally, $LASTEXITCODE might be null or 0
|
||||||
if ($scriptExitCode -ne 0 -and $scriptExitCode -ne $null) {
|
if ($scriptExitCode -ne 0 -and $scriptExitCode -ne $null) {
|
||||||
Write-Error "Script exited with code: $scriptExitCode"
|
Write-Error "Script exited with code: $scriptExitCode"
|
||||||
exit $scriptExitCode
|
exit $scriptExitCode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Verify ISO was actually created (double-check)
|
||||||
|
$expectedIsoPath = Join-Path $scriptRoot "tiny11.iso"
|
||||||
|
if (-not (Test-Path $expectedIsoPath)) {
|
||||||
|
Write-Error "Script completed but ISO file not found at: $expectedIsoPath"
|
||||||
|
Write-Host "Searching for ISO files..."
|
||||||
|
Get-ChildItem -Path $scriptRoot -Filter "*.iso" -Recurse -ErrorAction SilentlyContinue | ForEach-Object {
|
||||||
|
Write-Host "Found: $($_.FullName)"
|
||||||
|
}
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Build completed successfully. ISO found at: $expectedIsoPath"
|
||||||
} catch {
|
} catch {
|
||||||
Write-Error "Error running script: $_"
|
Write-Error "Error running script: $_"
|
||||||
Write-Error "Exception: $($_.Exception.Message)"
|
Write-Error "Exception: $($_.Exception.Message)"
|
||||||
|
|
|
||||||
42
.github/scripts/run-maker-automated.ps1
vendored
42
.github/scripts/run-maker-automated.ps1
vendored
|
|
@ -48,6 +48,33 @@ $scriptContent = $scriptContent -replace 'if \(!\s*\$myWindowsPrincipal\.IsInRol
|
||||||
# Disable execution policy check by commenting out the exit
|
# Disable execution policy check by commenting out the exit
|
||||||
$scriptContent = $scriptContent -replace 'if \(\(Get-ExecutionPolicy\) -eq ''Restricted''\)', 'if ($false -and (Get-ExecutionPolicy) -eq ''Restricted'') # Disabled for GitHub Actions'
|
$scriptContent = $scriptContent -replace 'if \(\(Get-ExecutionPolicy\) -eq ''Restricted''\)', 'if ($false -and (Get-ExecutionPolicy) -eq ''Restricted'') # Disabled for GitHub Actions'
|
||||||
|
|
||||||
|
# Add error checking after oscdimg command to verify ISO was created
|
||||||
|
# Match the oscdimg command line ending with tiny11.iso
|
||||||
|
$oscdimgPattern = '(&\s*"\$OSCDIMG"[^`r`n]*tiny11\.iso[^`r`n]*)'
|
||||||
|
$oscdimgReplacement = @"
|
||||||
|
`$1
|
||||||
|
if (`$LASTEXITCODE -ne 0 -and `$LASTEXITCODE -ne `$null) {
|
||||||
|
Write-Error "oscdimg failed with exit code: `$LASTEXITCODE"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Verify ISO file was created
|
||||||
|
`$expectedIsoPath = "`$PSScriptRoot\tiny11.iso"
|
||||||
|
Start-Sleep -Seconds 2
|
||||||
|
if (-not (Test-Path `$expectedIsoPath)) {
|
||||||
|
Write-Error "ISO file was not created at: `$expectedIsoPath"
|
||||||
|
Write-Host "Checking for ISO in alternative locations..."
|
||||||
|
Get-ChildItem -Path `$PSScriptRoot -Filter "*.iso" -ErrorAction SilentlyContinue | ForEach-Object {
|
||||||
|
Write-Host "Found ISO: `$(`$_.FullName)"
|
||||||
|
}
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "ISO file verified: `$expectedIsoPath"
|
||||||
|
Write-Host "ISO size: `$([math]::Round((Get-Item `$expectedIsoPath).Length / 1GB, 2)) GB"
|
||||||
|
"@
|
||||||
|
$scriptContent = $scriptContent -replace $oscdimgPattern, $oscdimgReplacement
|
||||||
|
|
||||||
# Create a temporary script with auto-answers for image index
|
# Create a temporary script with auto-answers for image index
|
||||||
$tempScriptHeader = @"
|
$tempScriptHeader = @"
|
||||||
`$ErrorActionPreference = 'Continue' # Continue on errors to see full output
|
`$ErrorActionPreference = 'Continue' # Continue on errors to see full output
|
||||||
|
|
@ -127,10 +154,25 @@ try {
|
||||||
& $tempScriptPath
|
& $tempScriptPath
|
||||||
$scriptExitCode = $LASTEXITCODE
|
$scriptExitCode = $LASTEXITCODE
|
||||||
|
|
||||||
|
# Check if script failed (PowerShell sets $LASTEXITCODE for native commands)
|
||||||
|
# If script exited normally, $LASTEXITCODE might be null or 0
|
||||||
if ($scriptExitCode -ne 0 -and $scriptExitCode -ne $null) {
|
if ($scriptExitCode -ne 0 -and $scriptExitCode -ne $null) {
|
||||||
Write-Error "Script exited with code: $scriptExitCode"
|
Write-Error "Script exited with code: $scriptExitCode"
|
||||||
exit $scriptExitCode
|
exit $scriptExitCode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Verify ISO was actually created (double-check)
|
||||||
|
$expectedIsoPath = Join-Path $scriptRoot "tiny11.iso"
|
||||||
|
if (-not (Test-Path $expectedIsoPath)) {
|
||||||
|
Write-Error "Script completed but ISO file not found at: $expectedIsoPath"
|
||||||
|
Write-Host "Searching for ISO files..."
|
||||||
|
Get-ChildItem -Path $scriptRoot -Filter "*.iso" -Recurse -ErrorAction SilentlyContinue | ForEach-Object {
|
||||||
|
Write-Host "Found: $($_.FullName)"
|
||||||
|
}
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Build completed successfully. ISO found at: $expectedIsoPath"
|
||||||
} catch {
|
} catch {
|
||||||
Write-Error "Error running script: $_"
|
Write-Error "Error running script: $_"
|
||||||
Write-Error "Exception: $($_.Exception.Message)"
|
Write-Error "Exception: $($_.Exception.Message)"
|
||||||
|
|
|
||||||
113
.github/workflows/build-tiny11.yml
vendored
113
.github/workflows/build-tiny11.yml
vendored
|
|
@ -113,20 +113,22 @@ jobs:
|
||||||
if ($partition.DriveLetter) {
|
if ($partition.DriveLetter) {
|
||||||
Write-Host "Found partition with drive letter: $($partition.DriveLetter)"
|
Write-Host "Found partition with drive letter: $($partition.DriveLetter)"
|
||||||
if ($partition.DriveLetter -ne $systemDrive) {
|
if ($partition.DriveLetter -ne $systemDrive) {
|
||||||
$driveLetter = $partition.DriveLetter
|
$potentialDrive = $partition.DriveLetter
|
||||||
Write-Host "Found drive letter via partition: $driveLetter"
|
Write-Host "Checking partition $potentialDrive for Windows files..."
|
||||||
|
|
||||||
# Verify this drive has Windows installation files
|
# 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") {
|
if (Test-Path "$potentialDrive`:\sources\boot.wim" -or Test-Path "$potentialDrive`:\sources\install.wim" -or Test-Path "$potentialDrive`:\sources\install.esd") {
|
||||||
|
$driveLetter = $potentialDrive
|
||||||
Write-Host "Verified: Drive $driveLetter contains Windows installation files"
|
Write-Host "Verified: Drive $driveLetter contains Windows installation files"
|
||||||
break
|
break
|
||||||
} else {
|
} else {
|
||||||
Write-Host "Warning: Drive $driveLetter does not contain Windows files, continuing search..."
|
Write-Host "Warning: Drive $potentialDrive does not contain Windows files, continuing search..."
|
||||||
$driveLetter = $null
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Write-Host "Skipping system drive: $($partition.DriveLetter)"
|
Write-Host "Skipping system drive: $($partition.DriveLetter)"
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Write-Host "Found partition without drive letter (partition number: $($partition.PartitionNumber))"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -140,6 +142,9 @@ jobs:
|
||||||
|
|
||||||
Write-Host "Checking drives: $($allDrives -join ', ')"
|
Write-Host "Checking drives: $($allDrives -join ', ')"
|
||||||
|
|
||||||
|
# Get mounted disk info once
|
||||||
|
$mountedDiskInfo = Get-DiskImage -ImagePath $isoPath -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
foreach ($letter in $allDrives) {
|
foreach ($letter in $allDrives) {
|
||||||
$bootPath = "$letter`:\sources\boot.wim"
|
$bootPath = "$letter`:\sources\boot.wim"
|
||||||
$installPath = "$letter`:\sources\install.wim"
|
$installPath = "$letter`:\sources\install.wim"
|
||||||
|
|
@ -147,16 +152,83 @@ jobs:
|
||||||
|
|
||||||
if ((Test-Path $bootPath) -or (Test-Path $installPath) -or (Test-Path $esdPath)) {
|
if ((Test-Path $bootPath) -or (Test-Path $installPath) -or (Test-Path $esdPath)) {
|
||||||
Write-Host "Found Windows files on drive: $letter"
|
Write-Host "Found Windows files on drive: $letter"
|
||||||
# Verify this is actually our mounted ISO
|
|
||||||
$testDiskImage = Get-DiskImage -ImagePath $isoPath -ErrorAction SilentlyContinue
|
# Method 1: Check if this partition belongs to mounted disk
|
||||||
if ($testDiskImage) {
|
$testPartition = Get-Partition -DriveLetter $letter -ErrorAction SilentlyContinue
|
||||||
$testPartition = Get-Partition -DriveLetter $letter -ErrorAction SilentlyContinue
|
if ($testPartition -and $mountedDiskInfo -and $testPartition.DiskNumber -eq $mountedDiskInfo.Number) {
|
||||||
if ($testPartition -and $testPartition.DiskNumber -eq $testDiskImage.Number) {
|
$driveLetter = $letter
|
||||||
$driveLetter = $letter
|
Write-Host "Verified: Drive $driveLetter belongs to mounted ISO disk (disk number: $($testPartition.DiskNumber))"
|
||||||
Write-Host "Verified: Found drive letter by checking Windows files: $driveLetter"
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
# Method 2: Check if this drive's disk image matches our ISO
|
||||||
|
$driveDiskImage = Get-DiskImage | Where-Object {
|
||||||
|
$_.Attached -eq $true -and
|
||||||
|
(Get-Partition -DiskNumber $_.Number -ErrorAction SilentlyContinue | Where-Object { $_.DriveLetter -eq $letter })
|
||||||
|
} | Select-Object -First 1
|
||||||
|
|
||||||
|
if ($driveDiskImage -and $mountedDiskInfo -and $driveDiskImage.ImagePath -eq $isoPath) {
|
||||||
|
$driveLetter = $letter
|
||||||
|
Write-Host "Verified: Drive $driveLetter matches mounted ISO by image path"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
# Method 3: If mounted disk has partitions, check if this letter matches a non-system partition
|
||||||
|
if ($mountedDiskInfo -and $mountedDiskInfo.Number -ne $null) {
|
||||||
|
$isoPartitions = Get-Partition -DiskNumber $mountedDiskInfo.Number -ErrorAction SilentlyContinue
|
||||||
|
foreach ($isoPartition in $isoPartitions) {
|
||||||
|
if ($isoPartition.DriveLetter -eq $letter -and $letter -ne $systemDrive) {
|
||||||
|
$driveLetter = $letter
|
||||||
|
Write-Host "Verified: Drive $driveLetter is partition on mounted ISO disk"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($driveLetter) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Method 4: If ISO is mounted and this is the only drive with Windows files (besides system), accept it
|
||||||
|
# This is a safe fallback since on GitHub runner, only one ISO is typically mounted
|
||||||
|
if (-not $driveLetter) {
|
||||||
|
$otherDrivesWithWindows = @()
|
||||||
|
foreach ($otherLetter in $allDrives) {
|
||||||
|
if ($otherLetter -ne $letter) {
|
||||||
|
$otherBootPath = "$otherLetter`:\sources\boot.wim"
|
||||||
|
$otherInstallPath = "$otherLetter`:\sources\install.wim"
|
||||||
|
$otherEsdPath = "$otherLetter`:\sources\install.esd"
|
||||||
|
if ((Test-Path $otherBootPath) -or (Test-Path $otherInstallPath) -or (Test-Path $otherEsdPath)) {
|
||||||
|
$otherDrivesWithWindows += $otherLetter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($otherDrivesWithWindows.Count -eq 0) {
|
||||||
|
$driveLetter = $letter
|
||||||
|
Write-Host "Accepted: Drive $driveLetter is the only non-system drive with Windows files (ISO is mounted)"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Final fallback: If we found Windows files on a drive but couldn't verify,
|
||||||
|
# and it's the only non-system drive with Windows files, accept it
|
||||||
|
if (-not $driveLetter) {
|
||||||
|
$drivesWithWindowsFiles = @()
|
||||||
|
foreach ($letter in $allDrives) {
|
||||||
|
$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)) {
|
||||||
|
$drivesWithWindowsFiles += $letter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($drivesWithWindowsFiles.Count -eq 1) {
|
||||||
|
$driveLetter = $drivesWithWindowsFiles[0]
|
||||||
|
Write-Host "Fallback: Accepting drive $driveLetter as it's the only non-system drive with Windows files"
|
||||||
|
Write-Host "Note: ISO is mounted, this is likely the correct drive"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -324,10 +396,25 @@ jobs:
|
||||||
$exitCode = $LASTEXITCODE
|
$exitCode = $LASTEXITCODE
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($exitCode -ne 0) {
|
if ($exitCode -ne 0 -and $exitCode -ne $null) {
|
||||||
Write-Error "Script failed with exit code: $exitCode"
|
Write-Error "Script failed with exit code: $exitCode"
|
||||||
exit $exitCode
|
exit $exitCode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Verify ISO was created (double-check, wrapper should have done this)
|
||||||
|
$expectedIsoPath = Join-Path $scriptRoot "tiny11.iso"
|
||||||
|
if (-not (Test-Path $expectedIsoPath)) {
|
||||||
|
Write-Error "Script completed but ISO file not found at: $expectedIsoPath"
|
||||||
|
Write-Host "Searching for ISO files in script root..."
|
||||||
|
Get-ChildItem -Path $scriptRoot -Filter "*.iso" -Recurse -ErrorAction SilentlyContinue | ForEach-Object {
|
||||||
|
Write-Host "Found ISO: $($_.FullName)"
|
||||||
|
Write-Host "ISO_PATH=$($_.FullName)" >> $env:GITHUB_ENV
|
||||||
|
}
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "ISO verified at: $expectedIsoPath"
|
||||||
|
Write-Host "ISO_PATH=$expectedIsoPath" >> $env:GITHUB_ENV
|
||||||
} catch {
|
} catch {
|
||||||
Write-Error "Error running script: $_"
|
Write-Error "Error running script: $_"
|
||||||
Write-Error "Exception: $($_.Exception.Message)"
|
Write-Error "Exception: $($_.Exception.Message)"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue