Skip to content

Commit

Permalink
Update Windows build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
twangboy committed Mar 3, 2025
1 parent 53a7e67 commit 2ebd346
Show file tree
Hide file tree
Showing 5 changed files with 718 additions and 565 deletions.
19 changes: 19 additions & 0 deletions pkg/windows/install_salt.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,25 @@ if ( $PKG ) {
}
}

# Create pywin32.pth file
if ( -not ( Test-Path -Path "$SCRIPTS_DIR\pywin32.pth" ) ) {
Write-Host "Creating pywin32.pth file: " -NoNewline
$content = "# .pth file for the PyWin32 extensions`n" + `
"win32`n" + `
"win32\lib" + `
"Pythonwin" + `
"# And some hackery to deal with environments where the post_install script`n" + `
"# isn't run." + `
"import pywin32_bootstrap"
Set-Content -Path "$SCRIPTS_DIR\pywin32.pth" -Value $content
if ( Test-Path -Path "$SCRIPTS_DIR\pywin32.pth") {
Write-Result "Success" -ForegroundColor Green
} else {
Write-Result "Failed" -ForegroundColor Red
exit 1
}
}

# Remove PyWin32 PostInstall & testall scripts
if ( Test-Path -Path "$SCRIPTS_DIR\pywin32_*" ) {
Write-Host "Removing pywin32 post-install scripts: " -NoNewline
Expand Down
75 changes: 1 addition & 74 deletions pkg/windows/msi/build_pkg.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,11 @@ function VerifyOrDownload ($local_file, $URL, $SHA256) {
$filename = Split-Path $local_file -leaf
if ( Test-Path -Path $local_file ) {
Write-Host "Verifying hash for $filename`: " -NoNewline
$hash = (Get-FileHash $local_file).Hash
if ( $hash -eq $SHA256 ) {
if ( (Get-FileHash $local_file).Hash -eq $SHA256 ) {
Write-Result "Verified" -ForegroundColor Green
return
} else {
Write-Result "Failed Hash" -ForegroundColor Red
Write-Host "Found Hash: $hash"
Write-Host "Expected Hash: $SHA256"
Remove-Item -Path $local_file -Force
}
}
Expand Down Expand Up @@ -90,11 +87,6 @@ $SCRIPT_DIR = (Get-ChildItem "$($myInvocation.MyCommand.Definition)").Direct
$RUNTIME_DIR = [System.Runtime.InteropServices.RuntimeEnvironment]::GetRuntimeDirectory()
$CSC_BIN = "$RUNTIME_DIR\csc.exe"

[DateTime]$origin = "1970-01-01 00:00:00"
$hash_time = $(git show -s --format=%at)
$TIME_STAMP = $origin.AddSeconds($hash_time)


if ( $BUILD_ARCH -eq "64bit" ) {
$BUILD_ARCH = "AMD64"
} else {
Expand Down Expand Up @@ -479,71 +471,6 @@ $states | ForEach-Object {
}
Write-Result "Success" -ForegroundColor Green

#-------------------------------------------------------------------------------
# Remove compiled files
#-------------------------------------------------------------------------------
# We have to do this again because we use the Relenv Python to get the build
# architecture. This recreates some of the pycache files that were removed
# in the prep_salt script
Write-Host "Removing __pycache__ directories: " -NoNewline
$found = Get-ChildItem -Path "$BUILDENV_DIR" -Filter "__pycache__" -Recurse
$found | ForEach-Object {
Remove-Item -Path "$($_.FullName)" -Recurse -Force
if ( Test-Path -Path "$($_.FullName)" ) {
Write-Result "Failed" -ForegroundColor Red
Write-Host "Failed to remove: $($_.FullName)"
exit 1
}
}
Write-Result "Success" -ForegroundColor Green

# If we try to remove *.pyc with the same Get-ChildItem that we used to remove
# __pycache__ directories, it won't be able to find them because they are no
# longer present
# This probably won't find any *.pyc files, but just in case
$remove = "*.pyc",
"*.chm"
$remove | ForEach-Object {
Write-Host "Removing unneeded $_ files: " -NoNewline
$found = Get-ChildItem -Path "$BUILDENV_DIR" -Filter $_ -Recurse
$found | ForEach-Object {
Remove-Item -Path "$($_.FullName)" -Recurse -Force
if ( Test-Path -Path "$($_.FullName)" ) {
Write-Result "Failed" -ForegroundColor Red
Write-Host "Failed to remove: $($_.FullName)"
exit 1
}
}
Write-Result "Success" -ForegroundColor Green
}

#-------------------------------------------------------------------------------
# Set timestamps on Files
#-------------------------------------------------------------------------------
# We're doing this on the dlls that were created above

Write-Host "Setting time stamp on all files: " -NoNewline
$found = Get-ChildItem -Path $BUILDENV_DIR -Recurse
$found | ForEach-Object {
$_.CreationTime = $TIME_STAMP
$_.LastAccessTime = $TIME_STAMP
$_.LastWriteTime = $TIME_STAMP
}
Write-Result "Success" -ForegroundColor Green

Write-Host "Setting time stamp on installer dlls: " -NoNewline
$found = Get-ChildItem -Path $SCRIPT_DIR -Filter "*.dll" -Recurse
$found | ForEach-Object {
$_.CreationTime = $TIME_STAMP
$_.LastAccessTime = $TIME_STAMP
$_.LastWriteTime = $TIME_STAMP
}
Write-Result "Success" -ForegroundColor Green

#-------------------------------------------------------------------------------
# Let's start building the MSI
#-------------------------------------------------------------------------------

# move conf folder up one dir because it must not be discovered twice and xslt is difficult
Write-Host "Remove configs from discovery: " -NoNewline
Move-Item -Path "$DISCOVER_CONFDIR" `
Expand Down
Loading

0 comments on commit 2ebd346

Please sign in to comment.