Skip to content

Commit f4bb3e2

Browse files
Add changelog and update scripts removed tls bundle handling
1 parent 8b38b65 commit f4bb3e2

File tree

7 files changed

+100
-111
lines changed

7 files changed

+100
-111
lines changed

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic
7+
Versioning](https://semver.org/spec/v2.0.0.html).
8+
9+
Unreleased changes should be tracked under the anticipated version header, with
10+
a date of UNRELEASED (e.g. `[1.2.0] - UNRELEASED`). This will allow the release
11+
action to catch the correct changelog section even if the release date hasn't
12+
been set yet.
13+
14+
## [1.1.0] - 2025-08-11
15+
16+
### Fixed
17+
- run-elevated-first.bat more reliable by adding '-ExecutionPolicy Bypass'
18+
19+
### Changed
20+
- Removed ability to use tls_bundle, instead conda is setup to use the system
21+
truststore. This is generally prefferd.
22+
23+
- Latest versions of National Instruments pkgs in Setup-NationalInstruments.ps1
24+
25+
- versioning scheme: 1 version for project instead of individual versions for
26+
each script
27+
28+
## [1.0.0] - 2025-01-06
29+
### initial release
30+

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ applications:
7474
**********************************************
7575
**********************************************
7676
-----END OPENSSH PRIVATE KEY-----
77-
# optional, needed for HTTPS inspection compatability (usually corporate environments)
78-
tls_bundle: "https://raw.githubusercontent.com/<org/user>/<repo>/main/tls-ca-bundle.txt"
7977
```
8078
8179
4. upload 3 files somewhere your users can access

gitpyup/Deploy-gitpyup.ps1

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ param(
1414
)
1515

1616
# variables
17-
$scriptVersion = "v1"
17+
18+
$version = "1.1.0"
1819
$gpun = "gitpyup"
1920
$installConfigFile = "installConfig.yaml"
2021

@@ -194,7 +195,7 @@ function Write-LogOrHost {
194195
}
195196
}
196197

197-
Write-LogOrHost "Hi you are running Deploy-gitpyup version: $scriptVersion"
198+
Write-LogOrHost "Hi you are running Deploy-gitpyup version: $version"
198199
if ($DebugMode) {
199200
Write-LogOrHost "Debug mode is enabled"
200201
$Env:GITPYUP_DEPLOY_DEBUG = $true
@@ -625,7 +626,6 @@ if ($installConfigPathObject.Exists) {
625626
$toAdd = @() # initialize shortcuts to add array
626627
$appNames = @() # used to check for duplicate
627628
$appConfigs = @() # used to accumulate all the configs
628-
$tlsBundleURL = $null # used to store the tls bundle path
629629

630630
# load the yml files
631631
foreach ($file in $yamlFiles) {
@@ -634,11 +634,6 @@ foreach ($file in $yamlFiles) {
634634
$configRoot = ConvertFrom-Yaml $fileContent
635635
$apps = $configRoot.applications
636636

637-
# update tls-bundle URL if it exists and is not already set
638-
if (($null -eq $tlsBundleURL) -and $configRoot.ContainsKey("tls_bundle")) {
639-
$tlsBundleURL = $configRoot.tls_bundle
640-
}
641-
642637
# loop through each application
643638
foreach ($application in $apps) {
644639
$name = $application.name
@@ -730,7 +725,6 @@ $installConfig = @{
730725
"applications" = $appConfigs
731726
"created_shortcuts" = $toAdd
732727
"install" = $install
733-
"tls_bundle" = $tlsBundleURL
734728
}
735729

736730
# save the config to a file
@@ -759,7 +753,6 @@ if ($Install.type -eq "AllUsers") {
759753
)
760754
}
761755

762-
$Env:GITPYUP_BUNDLE_URL = $tlsBundleURL
763756
$Env:GITPYUP_INSTALL_PARENT = Split-Path -Path $install.path -Parent
764757

765758
$confirm = ""

gitpyup/Setup-Application.ps1

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ param(
1515
. "./Utility-Functions.ps1"
1616
Start-Logging
1717

18-
Write-Log "Setup-Application v1"
19-
2018
if ($Name) {
2119
$appName = $Name
2220
} else {

gitpyup/Setup-NationalInstruments.ps1

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,15 @@ function Write-LogOrHost {
2222
}
2323
}
2424

25-
Write-LogOrHost "Setup-NationalInstruments v1"
26-
2725
$ProgressPreference = 'SilentlyContinue' # speeds up Invoke-WebRequest
2826

2927
$nipm = "$Env:Programfiles\National Instruments\NI Package Manager\nipkg.exe"
3028

29+
$ni4882Version = "25.0.0"
30+
$visaVersion = "25.3.0"
3131
$pkg_root = "https://download.ni.com/support/nipkg/products"
32-
$ni4882Version = "23.5"
33-
$visaVersion = "24.0"
3432

35-
# array to configure packages
33+
# array to loop packages
3634
$packages = @(
3735
[pscustomobject]@{
3836
installID = "ni-488.2";
@@ -48,7 +46,7 @@ $packages = @(
4846
if (!(Test-Path $nipm)) {
4947
Write-LogOrHost "NI package manager not installed, downloading..."
5048
# Download NIPM. The URL can be passed as an argument.
51-
$nipmUrl ="https://download.ni.com/support/nipkg/products/ni-package-manager/installers/NIPackageManager24.3.0.exe"
49+
$nipmUrl = "https://download.ni.com/support/nipkg/products/ni-package-manager/installers/NIPackageManager25.5.0.exe"
5250
powershell.exe -Command `
5351
$ErrorActionPreference = 'Stop'; `
5452
Invoke-WebRequest -Uri $nipmUrl -OutFile NIPM_installer.exe ; `

gitpyup/Setup-Python.ps1

Lines changed: 57 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
<#
22
Copyright (c) 2024 3M Company
3-
This script installs Miniforge3 for the 3M corporate environment.
3+
This script installs Miniforge3.
44
It can be run as part of gitpyup for now.
55
#>
66

77
# run Utility-Functions.ps1 to get the utility functions
88
. "./Utility-Functions.ps1"
99
Start-Logging
1010

11-
Write-Log "Setup-Python v1"
12-
13-
# check if admin and warn
11+
# check if admin and exit if true
1412
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
1513
$RunningAsAdmin = $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
1614
if ($RunningAsAdmin) {
1715
if (Test-Path "$Env:TEMP\gitpyup-as-admin") {
1816
Remove-Item -Force "$Env:TEMP\gitpyup-as-admin"
1917
} else {
2018
Write-Log "Please run this script as a regular user"
19+
Wait-Logging
2120
Read-Host -Prompt "Press enter key to exit" | Out-Null
2221
exit
2322
}
@@ -78,12 +77,29 @@ $MiniforgeInstall = {
7877
Write-Log "...Miniforge folder removed"
7978
}
8079

81-
Write-Log "Miniforge not installed, downloading..."
82-
$Link = "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Windows-x86_64.exe"
83-
Invoke-WebRequest $Link -OutFile "$env:UserProfile\Downloads\Miniforge3-Windows-x86_64.exe"
80+
# check current folder for Miniforge exe
81+
$InstallerName = "Miniforge3-Windows-x86_64.exe"
82+
$DownloadLocation = "$env:UserProfile\Downloads\$InstallerName"
83+
84+
if (Test-Path $InstallerName) {
85+
Write-Log "Miniforge already downloaded"
86+
$Installer = "$PWD\$InstallerName"
87+
} else {
88+
if (Test-Path $DownloadLocation) {
89+
Write-Log "Miniforge already downloaded"
90+
} else {
91+
Write-Log "Miniforge downloading..."
92+
$Link = "https://github.com/conda-forge/miniforge/releases/latest/download/$InstallerName"
93+
Invoke-WebRequest $Link -OutFile $DownloadLocation
8494
Write-Log "...Miniforge downloaded"
95+
}
96+
$Installer = $DownloadLocation
97+
}
98+
99+
# unblock the installer
100+
Unblock-File $Installer
101+
85102
Write-Log "Installing Miniforge..."
86-
$Installer = "$env:UserProfile\Downloads\Miniforge3-Windows-x86_64.exe"
87103
$ArgumentList = "/InstallationType=JustMe /RegisterPython=1 /AddToPath=0 /S /D=$MiniforgeInstallPath"
88104
$Proc = Start-Process $Installer -Wait -ArgumentList $ArgumentList -PassThru
89105
if ($Proc.ExitCode -ne 0) {
@@ -100,16 +116,30 @@ $MiniforgeInstall = {
100116
$Proc = Start-Process @Conda -ArgumentList init
101117
Write-Log "...Miniforge initialized"
102118
}
119+
$MiniforgeInstallArgs = $MiniforgeInstallPath, $InstallType, $Conda
120+
$MiniforgeInstallEncoded, $MiniforgeInstallArgsEncoded = ConvertTo-Base64String $MiniforgeInstall $MiniforgeInstallArgs
103121

104122
# Check if miniforge's conda.bat runs
105-
$CondaVersion = conda --version
106-
if (!($CondaVersion)) {
123+
$CondaVersion = Get-StandardOutput -Command "conda --version"
124+
if ($CondaVersion | Select-String -Pattern "CommandNotFoundException") {
125+
if ($InstallType -eq "AllUsers") {
126+
# Start-Process -FilePath "powershell" -Verb RunAs -Wait -ArgumentList (
127+
Start-Process -FilePath "powershell" -Wait -NoNewWindow -ArgumentList (
128+
"-EncodedCommand $MiniforgeInstallEncoded",
129+
"-EncodedArguments $MiniforgeInstallArgsEncoded"
130+
)
131+
} else {
107132
& $MiniforgeInstall $MiniforgeInstallPath $InstallType $Conda
133+
}
108134
} else {
109135
Write-Log "Miniforge3 already available"
110136
Write-Log "version: $CondaVersion"
111137
}
112138

139+
# need to update to recent conda version for truststore support
140+
Write-Log "updating conda base env..."
141+
$Proc = Start-Process @Conda -ArgumentList "update -n base -c conda-forge conda -y"
142+
113143
$EnvSetupScript = {
114144
param(
115145
[string]$EnvName,
@@ -124,90 +154,29 @@ $EnvSetupScript = {
124154
# this prevents a halts due to an interactive conda message about reporting errors
125155
conda config --set report_errors false
126156

127-
# this sections is needed if the device is subject to SSL inspection
128-
# currently Minforge/conda does not have a way to use the system certs
129-
# The bundle URL is set by an environment variable
130-
if ($Env:GITPYUP_BUNDLE_URL) {
131-
132-
# remove existing gitpyup-tls-ca-bundle.pem if it exists
133-
$BundlePath = "$env:ProgramData\gitpyup-tls-ca-bundle.pem"
134-
if (Test-Path $BundlePath) {
135-
Remove-Item -Force $BundlePath
136-
}
137-
138-
# download the tls bundle
139-
$URL = $Env:GITPYUP_BUNDLE_URL
140-
Write-Log "downloading tls bundle from $URL"
141-
Invoke-WebRequest $URL -OutFile $BundlePath
142-
# are these redundant because setting the .condarc file?
143-
conda config --set ssl_verify True
144-
conda config --set ssl_verify $BundlePath
145-
146-
# Check for existing conda environment
147-
# TODO get any existing conda environment directories
157+
# set conda to use the system truststore
158+
conda config --set ssl_verify truststore
148159

149-
# configure path to save environments depending on installation type
150-
if ($InstallType -eq "AllUsers") {
151-
$EnvDir = "$env:ProgramData\.conda\envs"
152-
} else {
153-
$EnvDir = "$env:UserProfile\.conda\envs"
154-
}
155-
156-
# Create a .condarc file in the root dir of the MiniForge installation
157-
$CondarcPath = "$MiniforgeInstallPath\.condarc"
158-
$CondarcContent =
160+
# Check for existing conda environment
161+
# configure path to save environments depending on installation type
162+
if ($InstallType -eq "AllUsers") {
163+
$EnvDir = "$env:ProgramData\.conda\envs"
164+
} else {
165+
$EnvDir = "$env:UserProfile\.conda\envs"
166+
}
167+
# make sure the envs directory exists
168+
New-Item -Path $EnvDir -ItemType Directory -Force
169+
# Create a .condarc file in the root dir of the MiniForge installation
170+
$CondarcPath = "$MiniforgeInstallPath\.condarc"
171+
$CondarcContent =
159172
"channels:
160173
- conda-forge
161-
ssl_verify: $BundlePath
174+
ssl_verify: truststore
162175
envs_dirs:
163176
- $EnvDir
164177
"
165-
Set-Content -Force -Path $CondarcPath -Value $CondarcContent
178+
Set-Content -Force -Path $CondarcPath -Value $CondarcContent
166179

167-
} else {
168-
Write-Log "No bundle URL provided"
169-
}
170-
171-
# function to check if pip has SSL errors, return true if error detected
172-
function Test-PipTlsError {
173-
# Define the command
174-
$Command = "conda run -n $EnvName python -m pip install --dry-run tiny"
175-
Write-Log "Running SSL test command: $Command"
176-
# Create a temporary file for output
177-
$TempFile = [System.IO.Path]::GetTempFileName()
178-
# Execute the command and redirect output to the temporary file
179-
Start-Process -FilePath "powershell.exe" -ArgumentList "-Command", $Command -RedirectStandardOutput $TempFile -NoNewWindow -Wait
180-
# Read the output from the temporary file
181-
$TlsTest = Get-Content -Path $TempFile
182-
# Clean up the temporary file
183-
Remove-Item -Path $TempFile
184-
185-
# $TlsTest = conda run -n $EnvName python -m pip install --dry-run tiny
186-
if ($TlsTest | Select-String -Pattern "SSL: CERTIFICATE_VERIFY_FAILED") {
187-
Write-Log "pip SSL error detected"
188-
return $true
189-
} else {
190-
Write-Log "pip SSL error not detected"
191-
return $false
192-
}
193-
}
194-
195-
# check if pip has SSL errors, install or uninstall pip-system-certs
196-
if (Test-PipTlsError) {
197-
# check if pip-system-certs is installed
198-
if (!(conda run -n $EnvName python -m pip list | Select-String -Pattern pip-system-certs)) {
199-
# patch pip and requests to use system certs
200-
Write-Log "installing pip-system-certs..."
201-
conda install -n $EnvName pip-system-certs -y
202-
# conda run -n $EnvName python -m pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org pip-system-certs
203-
}
204-
205-
# check if pip still has SSL errors, set pip to use the tls-ca-bundle.pem
206-
if (Test-PipTlsError) {
207-
Write-Log "pip still has SSL errors, setting pip to use tls-ca-bundle.pem"
208-
conda run -n $EnvName python -m pip config set global.cert $BundlePath
209-
}
210-
}
211180

212181
# attempt to update conda base environment
213182
Write-Log "updating conda base env..."
@@ -216,6 +185,7 @@ envs_dirs:
216185

217186
# only wait if in debug mode
218187
if ($Env:GITPYUP_DEPLOY_DEBUG) {
188+
Wait-Logging
219189
Read-Host -Prompt "Press enter key to exit" | Out-Null
220190
}
221191
}

gitpyup/run-elevated-first.bat

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@echo off
22

3-
echo run-elevated-v1
3+
echo run-elevated-v3
44

55
pushd %~dp0
66

@@ -23,9 +23,11 @@ if exist Deploy-gitpyup.ps1 goto check_Permissions
2323
)
2424

2525
:set_Policies_Unblock
26-
echo Attempting to set execution policies and unblock Deploy-gitpyup.ps1...
27-
powershell -Command "Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force"
28-
powershell -Command "Set-ExecutionPolicy RemoteSigned -Scope LocalMachine -Force"
26+
echo Attempting to set execution policies and unblock deploy script...
27+
powershell -ExecutionPolicy Bypass -Command "Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force"
28+
powershell -ExecutionPolicy Bypass -Command "Set-ExecutionPolicy RemoteSigned -Scope LocalMachine -Force"
29+
echo There may be errors above. They can be ignored if 'CurrentUser' and 'LocalMachine' ExecutionPolicies are set to 'RemoteSigned' in the table below.
30+
powershell -Command "Get-ExecutionPolicy -list"
2931
powershell -Command "Unblock-File Deploy-gitpyup.ps1"
3032
echo Next step: right click Deploy-gitpyup.ps1 and select 'Run with PowerShell'
3133

0 commit comments

Comments
 (0)