Pre-flight Check Output Path verification has been enhanced to check for unsupported paths such as Ram drives, UNC paths, and mapped drives. (Issue #96)

- Includes new PhoenixAPI command - DriveGetType
This commit is contained in:
Homes32
2024-07-07 18:43:50 -05:00
parent 849b8569e7
commit a72633c020
3 changed files with 149 additions and 23 deletions

View File

@@ -35,7 +35,7 @@ Author=Homes32
Level=2
Selected=True
Mandatory=True
Version=1.1.5.0
Version=1.2.0.0
Date=2024-06-29
[Variables]
@@ -46,32 +46,65 @@ Date=2024-06-29
Echo,"Starting Pre-Flight Check..."
Run,%ScriptFile%,CheckEngine
Run,%ScriptFile%,CheckPaths
If,%cb_CheckFreeSpace%,Equal,True,Run,%ScriptFile%,CheckDiskSpace
Run,%ScriptFile%,CheckTools
If,%cb_VerifyOutputPath%,Equal,True,Run,%ScriptFile%,CheckOutputPath
If,%cb_CheckFreeSpace%,Equal,True,Run,%ScriptFile%,CheckDiskSpace
If,%cb_CheckForSupportedBuildVer%,Equal,True,Run,%ScriptFile%,CheckVerifiedBuilds
Run,%ScriptFile%,CheckWinREVersion
[#CheckPaths#]
[#CheckOutputPath#]
// ===============================================================================================================================
// Name...........: CheckPaths
// Description....: Verify that %OutputDir% is not a root drive (ie. d:\). This will cause issues with creating/cleaning up
// the build environment.
// Name...........: CheckOutputPath
// Description....: Verify that %OutputDir% is not a root drive (ie. d:\), network drive (mapped or UNC path), ramdrive, etc.
// Syntax.........:
// Parameters.....:
// Return values..:
// Author.........: Homes32
// Remarks........:
// Remarks........: DISM and System,GetFreeSpace can't handle network paths (https://github.com/PhoenixPE/PhoenixPE/issues/96)
// DISM doesn't like RamDisks either (0x80071126 - ERROR_NOT_A_REPARSE_POINT https://theoven.org/viewtopic.php?p=1680#p1680)
// Root drives cause issues with creating/cleaning up the build environment.
// Related........: Called by [Process]
// ===============================================================================================================================
[CheckPaths]
[CheckOutputPath]
System,SetLocal
// Check if output is the root of a drive
StrFormat,SPLIT,%OutputDir%,"\",0,%NumSplits%
StrFormat,Split,%OutputDir%,"\",0,%NumSplits%
If,%NumSplits%,Equal,1,Begin
Message,"Setting the OutputDir to the root of a drive is not supported.",Error
Halt,"Error: Setting the OutputDir to the root of a drive is not supported."
Message,"Setting the Output directory to the root of a drive is not supported.#$x#$xPlace the PhoenixPE files in a sub-directory (eg. C:\PhoenixPE) or adjust the Output directory path in the 'Config Source' script and try again.",Error
Halt,"Error: Setting the OutputDir to the root of a drive is not supported.#$x#$xPlace the PhoenixPE files in a sub-directory (eg. C:\PhoenixPE) or adjust the Output directory path in the 'Config Source' script and try again."
End
// Check for network path
StrFormat,Left,%OutputDir%,2,%PathPrefix%
If,%PathPrefix%,Equal,"\\",Begin
Message,"Setting the Output directory to a network location is not supported. This includes UNC paths and mapped drives.#$x#$xPlace the PhoenixPE files on a physical disk (eg. C:\PhoenixPE) or adjust the Output directory path in the 'Config Source' script and try again.",Error
Halt,"Error: Setting the OutputDir to a network location is not supported."
End
// Check for relative paths
StrFormat,Left,%OutputDir%,1,%PathPrefix%
If,%PathPrefix%,Equal,".",Begin
Message,"Setting the Output directory to a relative path is not supported.#$x#$xAdjust the Output directory path in the 'Config Source' script and try again.",Error
Halt,"Error: Setting the OutputDir to a relative path is not supported."
End
// Check Output drive type
StrFormat,Left,%OutputDir%,3,%DriveLetter%
DriveGetType,%DriveLetter%
Set,%DriveType%,#r
If,%DriveType%,Equal,"",Begin
// Try to catch any invalid paths/drive letters
Message,"Error: Could not determine the drive type for [%DriveLetter%]. Make sure your path exists.",Error
Halt,"Error: Could not determine the drive type for [%DriveLetter%]."
End
Else,Begin
If,Not,%DriveType%,Equal,"Removable",If,Not,%DriveType%,Equal,"Fixed",Begin
Message,"Setting the Output directory to a %DriveType% drive is not supported.#$x#$xPlace the PhoenixPE files on a physical disk (eg. C:\PhoenixPE) or adjust the Output directory path in the 'Config Source' script and try again.",Error
Halt,"Error: Setting the OutputDir to a %DriveType% drive is not supported."
End
End
System,EndLocal
[#CheckEngine#]
@@ -216,7 +249,7 @@ Halt,"The build cannot continue because [ #1 ] is missing."
// Return values..:
// Author.........: Homes32
// Remarks........: Note: GetWaikTools has been discontinued as of v21.04. Will need to rewrite this function to use adksetup.exe
// Related........: Called by [CheckTools]
// Related........: Called by [CheckTools], btn_DownloadProgram
// ===============================================================================================================================
[GetWaikTools]
Echo,"Downloading required tools from Windows 10 ADK...#$x#$xThis will only need to be done once."
@@ -231,7 +264,6 @@ DirDeleteEx,"%Tools%\x86\BCDBOOT"
//DirDeleteEx,"%Tools%\x64\DISM"
DirDeleteEx,"%Tools%\x64\BCDBOOT"
[#CheckVerifiedBuilds#]
// ===============================================================================================================================
// Name...........: CheckVerifiedBuilds
@@ -359,8 +391,8 @@ System,GetFreeSpace,%TargetDir%,%FreeMegabytes%
Math,Mul,%FreeBytes%,%FreeMegabytes%,1048576
StrFormat,IntToBytes,%FreeBytes%,%HumanReadableFreeSpace%
If,%FreeMegabytes%,Smaller,%MinimumFreeMegabytes%,Begin
Echo,"Warning: You have less then %HumanReadableMinimumFreeSpace% of free disk space on your target drive [%TargetDir%]. This may result in build failures.",Warn
Message,"Warning: You only have [%HumanReadableFreeSpace%] free disk space on your target drive, which is less then the recommended %HumanReadableMinimumFreeSpace%. This may result in build failures.",Warning,10
Echo,"Warning: You have less then %HumanReadableMinimumFreeSpace% of free disk space on your target drive [%TargetDir%]. This may result in build failures.",Warn
Message,"Warning: You only have [%HumanReadableFreeSpace%] free disk space on your target drive, which is less then the recommended %HumanReadableMinimumFreeSpace%. This may result in build failures.",Warning,10
End
// Check %OutputDir%
@@ -368,12 +400,44 @@ System,GetFreeSpace,%OutputDir%,%FreeMegabytes%
Math,Mul,%FreeBytes%,%FreeMegabytes%,1048576
StrFormat,IntToBytes,%FreeBytes%,%HumanReadableFreeSpace%
If,%FreeMegabytes%,Smaller,%MinimumFreeMegabytes%,Begin
Echo,"Warning: You have less then %HumanReadableMinimumFreeSpace% of free disk space on your output drive [%OutputDir%]. This may result in build failures.",Warn
Message,"Warning: You only have [%HumanReadableFreeSpace%] free disk space on your output drive [%OutputDir%], which is less then the recommended %HumanReadableMinimumFreeSpace%. This may result in build failures.",Warning,10
Echo,"Warning: You have less then %HumanReadableMinimumFreeSpace% of free disk space on your output drive [%OutputDir%]. This may result in build failures.",Warn
Message,"Warning: You only have [%HumanReadableFreeSpace%] free disk space on your output drive [%OutputDir%], which is less then the recommended %HumanReadableMinimumFreeSpace%. This may result in build failures.",Warning,10
End
System,EndLocal
[#DownloadTools#]
// ===============================================================================================================================
// Name...........: DownloadTools
// Description....: Download Waik Tools
// Syntax.........:
// Parameters.....:
// Return values..:
// Author.........: Homes32
// Remarks........:
// Related........: btn_DownloadTools
// ===============================================================================================================================
[DownloadTools]
Run,%ScriptFile%,GetWaikTools
[#ClearDownloadCache#]
// ===============================================================================================================================
// Name...........: ClearDownloadCache
// Description....: Remove all downloaded setup and program files.
// Syntax.........: Run,%ScriptFile%,ClearDownloadCache
// Parameters.....:
// Return values..:
// Author.........: Homes32
// Remarks........:
// Related........: btn_PurgeCache
// ===============================================================================================================================
[ClearDownloadCache]
Echo,"Removing downloaded tools..."
DirDeleteEx,%Tools%\x86\DISM
DirDeleteEx,%Tools%\x64\DISM
DirDeleteEx,%Tools%\x86\Oscdimg
DirDeleteEx,%Tools%\x64\Oscdimg
[#SetDefaultOptions#]
// ===============================================================================================================================
// Name...........: SetDefaultOptions
@@ -386,8 +450,9 @@ System,EndLocal
// Related........: btn_SetDefaultOptions
// ===============================================================================================================================
[SetDefaultOptions]
WriteInterface,Value,%ScriptFile%,Interface,cb_CheckForSupportedBuildVer,True
WriteInterface,Value,%ScriptFile%,Interface,cb_VerifyOutputPath,True
WriteInterface,Value,%ScriptFile%,Interface,cb_CheckFreeSpace,True
WriteInterface,Value,%ScriptFile%,Interface,cb_CheckForSupportedBuildVer,True
[#ToggleAdvancedOptions#]
// ===============================================================================================================================
@@ -416,8 +481,9 @@ Else,Begin
WriteInterface,Tooltip,%ScriptFile%,Interface,btn_AdvancedOptions,"Show Advanced Options"
End
WriteInterface,Visible,%ScriptFile%,Interface,cb_CheckForSupportedBuildVer,%Toggle%
WriteInterface,Visible,%ScriptFile%,Interface,cb_VerifyOutputPath,%Toggle%
WriteInterface,Visible,%ScriptFile%,Interface,cb_CheckFreeSpace,%Toggle%
WriteInterface,Visible,%ScriptFile%,Interface,cb_CheckForSupportedBuildVer,%Toggle%
WriteInterface,Visible,%ScriptFile%,Interface,bvl_AdvancedOptions,%Toggle%
System,EndLocal
@@ -447,18 +513,23 @@ Message,"This script verifies that essential tools are available, PEBakery is co
// Related........:
// ===============================================================================================================================
[Interface]
btn_DownloadProgram=,1,8,448,5,25,25,DownloadTools,VistalcoDownload_16.png,False,"__Download WAIK tools."
btn_PurgeCache=,1,8,479,5,25,25,ClearDownloadCache,Trash.ico,True,"__Remove all downloaded tools."
btn_SetDefaultOptions=,1,8,543,5,25,25,SetDefaultOptions,SetDefaults_16.png,True,"__Restore Defaults"
btn_AdvancedOptions=,1,8,574,5,25,25,ToggleAdvancedOptions,Advanced_16.png,True,"__Show Advanced Options"
btn_ScriptInfo=,1,8,605,5,25,25,ShowScriptInfo,Help_16.png,True,"__Script Info"
bvl_AdvancedOptions="Advanced Options",0,12,5,50,200,115,8,Bold
cb_CheckForSupportedBuildVer="Verify Source Build Number",0,3,12,64,150,18,True,"__Check and see if the Win10 build version has been tested with this project."
cb_VerifyOutputPath="Verify Output Path",0,3,12,64,150,18,True
cb_CheckFreeSpace="Verify Free Disk Space",0,3,12,84,150,18,True,"__Verify we have the free disk space required to build this project."
cb_CheckForSupportedBuildVer="Verify Source Build Number",0,3,12,104,150,18,True,"__Check and see if the Win10 build version has been tested with this project."
[InterfaceEncoded]
Advanced_16.png=1722,2396
SetDefaults_16.png=2475,3404
Help_16.png=2830,3868
Advanced_Exit_16.png=705,1048
VistalcoDownload_16.png=927,1348
Trash.ico=1150,1228
[AuthorEncoded]
lists.png=10008,13436
@@ -486,3 +557,11 @@ lines=0
[EncodedFile-InterfaceEncoded-Advanced_Exit_16.png]
lines=0
0=i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G8fTdIdK2LjmVFpSYmTIG4sk0a328t5/zb+n+zk1cf44B3duzdq7O2FqyOfxeUkikXBcLpOBpLAQNBpN8Ayq1Wrg8/mQkZEOHA4H8vPzQSaTwanExKE9uxKmh7wwn+Q+evQQfJ2d8LjNAwMD/cAwDPT09EBtrR202itgNBrA1eSCzs4OUCoVP1LPJP/5GrUa9aqUlJR6hUIxjs95udkEprJSuFFqDJ59taoIpBIJWCoqQCwSQUZ6mjJ8/rgkhYVrOZmZgus63Ycyo9ErEhakZWdnXzt39mwmmZtbIeDnnCQFgl8/gwnFYyHkjPxH8Prv4GsmJRKht1MR+gkUry6xeJzjDClKLM7Qy0zOZxgFIxDUsUDoQGbs8iFCkXoMbAB+CQU+pPfbDwEAAAACAAAAJAAAAFEDAAAAAAAAAQAAAAAAAAAAAAAA

View File

@@ -32,8 +32,8 @@
Title=PhoenixPE API
Author=Homes32
Description=PhoenixPE scripting support library.
Version=1.9.4.0
Date=2024-06-28
Version=1.10.0.0
Date=2024-07-06
Level=0
Selected=None
@@ -55,6 +55,7 @@ BitToggle=Run,%API%,_PhoenixAPI_BitToggle
ConvertImage=Run,%API%,_PhoenixAPI_ConvertImage
DirDeleteEx=Run,%API%,_PhoenixAPI_DirDeleteEx
DISM=Run,%API%,_PhoenixAPI_DISM
DriveGetType=Run,%API%,_PhoenixAPI_DriveGetType
FileCopyEx=Run,%API%,_PhoenixAPI_FileCopyEx
FileDeleteEx=Run,%API%,_PhoenixAPI_FileDeleteEx
FileSearch=Run,%API%,_PhoenixAPI_FileSearch
@@ -735,6 +736,49 @@ Return,%ExitCode%
System,EndLocal
[#_PhoenixAPI_DriveGetType#]
// ===============================================================================================================================
// Name...........: DriveGetType
// Description....: Get the drive type.
// Syntax.........: DriveGetType,<DriveLetter>
// Parameters.....: #1 Drive Letter - The drive letter to query.
// Return values..: #r - Success - One of the following values:
// - Unknown
// - Removable
// - Fixed
// - Network
// - CDROM
// - RAMDisk
// Author.........: Homes32
// Remarks........: This command is a work in progress and may change without notice.
// Usage: PhoenixAPI-DriveGetType.a3x <DriveLetter> <OutputFile>
// DriveLetter - Drive Letter. Ex. B:
// OutputFile - A standard .ini formatted File
// [DriveType] contains key=value pairs in the format of <DriveLetter>=<DriveType> ex. C:=Fixed
// Exit codes: 0 - Success
// 1 - Syntax Error
// 2 - Invalid Path
// 3 - Failed to get drive type
// Related........:
// ===============================================================================================================================
[_PhoenixAPI_DriveGetType]
System,SetLocal
GetParam,1,%DriveLetter%
If,%DriveLetter%,Equal,"",Halt,"Syntax Error: Drive letter was not specified."
StrFormat,EndTrim,%DriveLetter%,"\",%DriveLetter%
ShellExecute,Hide,"%Tools%\%HostArch%\AutoIt3.exe","%Tools%\a3x\PhoenixAPI-DriveGetType.a3x #$q%DriveLetter%#$q #$q%ProjectTemp%\PhoenixAPI-DriveGetType.ini#$q"
If,Not,%ExitCode%,Equal,0,Halt,"DriveGetType Error: Unable get drive type for [%DriveLetter%]. The command returned [%ExitCode%]."
// Return the result as #r
IniRead,"%ProjectTemp%\PhoenixAPI-DriveGetType.ini","DriveType",%DriveLetter%,%DriveType%,"Default="
Return,%DriveType%
System,EndLocal
[#_PhoenixAPI_FileCopyEx#]
// ===============================================================================================================================
// Name...........: FileCopyEx
@@ -840,6 +884,9 @@ System,SetLocal
GetParam,1,%Path%
GetParam,2,%SearchFilter%
If,%Path%,Equal,"",Halt,"Syntax Error: Path was not specified."
If,%SearchFilter%,Equal,"",Halt,"Syntax Error: Search filter was not specified."
// Recurse the path looking for the specified file
ShellExecute,Hide,"%Tools%\%HostArch%\AutoIt3.exe","%Tools%\a3x\PhoenixAPI-FileSearch.a3x #$q%Path%#$q #$q%SearchFilter%#$q #$q%ProjectTemp%\PhoenixAPI-FileSearch.ini#$q"