Skip to content

Commit

Permalink
resolved conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Fixstars-momoko committed Jul 17, 2024
2 parents 0f4490f + 1c888d3 commit 53f8940
Show file tree
Hide file tree
Showing 2 changed files with 133 additions and 9 deletions.
9 changes: 0 additions & 9 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ jobs:
working-directory: installer/build
run: cmake -G "Visual Studio 17 2022" -A x64 ../

- name: Create package msi
working-directory: installer/build
run: cpack -G "WIX"

- name: Create package zip
working-directory: installer/build
run: cpack -G "ZIP"
Expand All @@ -105,10 +101,6 @@ jobs:
working-directory: installer/build
run: cmake -G "Visual Studio 17 2022" -A x64 ../ -DOPENCV_ACTION="use_existing"

- name: Create package msi
working-directory: installer/build
run: cpack -G "WIX"

- name: Create package zip
working-directory: installer/build
run: cpack -G "ZIP"
Expand All @@ -118,7 +110,6 @@ jobs:
with:
files: |
installer/tools/installer*.ps1
installer/build/*.msi
installer/build/*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
133 changes: 133 additions & 0 deletions installer/tools/uninstaller.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
<#
.SYNOPSIS
Uninstalls the Sensing SDK.
.DESCRIPTION
This script remove all content of sensing-dev in the default install path and remove all related environment variables.
.PARAMETER Verbose
Specifies the version of the Sensing SDK to be installed. Default is 'latest'.
.EXAMPLE
PS C:\> .\uninstaller.ps1 -Verbose
.NOTES
Ensure that you have the necessary permissions to install software and write to the specified directories.
.LINK
https://sensing-dev.github.io/doc/
#>

[cmdletbinding()]
param()

$target_directory_exist = $true
$sensing_dev_root_exist = $true

# Check if SENSING_DEV_ROOT exist
$sensing_dev_root = [Environment]::GetEnvironmentVariable("SENSING_DEV_ROOT", "User")
if (-not $sensing_dev_root) {
Write-Verbose -Message "Environment variable SENSING_DEV_ROOT exist: NO (will check under AppData\Local)"
$sensing_dev_root = "$env:LOCALAPPDATA\sensing-dev"
$sensing_dev_root_exist = $false
}else{
Write-Verbose -Message "Environment variable SENSING_DEV_ROOT exist: YES ($sensing_dev_root)"
}

# Check if directory exist
if (Test-Path $sensing_dev_root){
Write-Verbose -Message "Directory $sensing_dev_root exist: YES"
}else{
Write-Verbose -Message "Directory $sensing_dev_root exist: NO --skip uninstall"
$target_directory_exist = $false
}

# Check if OpenCV exist only if v24.05 or later
## Check if version_info.json exist
if (Test-Path "$sensing_dev_root/version_info.json"){
Write-Verbose -Message "Found version_info.json i.e. v24.05 or later"
if (Test-Path "$sensing_dev_root/opencv"){
Write-Verbose -Message "OpenCV is installed under SENSING_DEV_ROOT, which will be also uninstalled"
}
}elseif ($target_directory_exist){
Write-Verbose -Message "SDK is v24.01 or earlier"
}

# Delete the directory

if ($target_directory_exist){
Write-Host "The following items will be deleted"
Get-ChildItem -Path $sensing_dev_root
Remove-Item -Recurse -Force -Path $sensing_dev_root
}

# Delete if PATH has 1. bin 2. OpenCV bin if OpenCV exists
$expected_sensing_dev_bin = "$sensing_dev_root\bin"
$currentPath = [Environment]::GetEnvironmentVariable("Path", "User")

if ($currentPath.Contains($expected_sensing_dev_bin)) {
Write-Verbose -Message "PATH contains Sensing-Dev dll path: YES"
$newPath = $currentPath -replace [regex]::Escape($expected_sensing_dev_bin), ""
[Environment]::SetEnvironmentVariable("Path", $newPath, "User")
Write-Output "Removed '$expected_sensing_dev_bin' from User Path environment variable."
}else{
Write-Verbose -Message "PATH contains Sensing-Dev dll path: NO --skip removal"
}

$currentPath = [Environment]::GetEnvironmentVariable("Path", "User")
$expected_opencv_bin_pattern = [regex]::Escape("$sensing_dev_root\opencv\build\x64\vc") + "\d{1,2}\\bin"
$matches = $currentPath -split ";" | Where-Object { $_ -match $expected_opencv_bin_pattern }

if ($matches.Count -gt 0) {
Write-Verbose -Message "PATH contains Sensing-Dev OpenCV dll path: YES"
foreach ($match in $matches) {
$expected_opencv_bin = $match
$newPath = $currentPath -replace [regex]::Escape($expected_opencv_bin), ""
$currentPath = $newPath
Write-Output "Removed '$expected_opencv_bin' from User Path environment variable."
}
[Environment]::SetEnvironmentVariable("Path", $newPath, "User")
} else {
Write-Verbose -Message "PATH contains Sensing-Dev OpenCV dll path: NO --skip removal"
}

# Delete if PYTHONPATH has sensing-dev related
$expected_pythonpath = "$sensing_dev_root\lib\site-packages"
$currentPythonPath = [Environment]::GetEnvironmentVariable("PYTHONPATH", "User")

if ($currentPythonPath -and $currentPythonPath.Contains($expected_pythonpath)) {
Write-Verbose -Message "PYTHONPATH contains Sensing-Dev sitepackages path: YES"
$newPath = $currentPythonPath -replace [regex]::Escape($expected_pythonpath), ""
[Environment]::SetEnvironmentVariable("PYTHONPATH", $newPath, "User")
Write-Output "Removed '$expected_pythonpath' from User PYTHONPATH environment variable."
}else{
Write-Verbose -Message "PYTHONPATH contains Sensing-Dev sitepackages path: NO --skip removal"
}

# Delete if GST_PLUGIN_PATH has sensing-dev related
$currentGSTPATH = [Environment]::GetEnvironmentVariable("GST_PLUGIN_PATH", "User")
$expected_gst_plugin_pattern = [regex]::Escape("$sensing_dev_root")

$matches = $currentGSTPATH -split ";" | Where-Object { $_ -match $expected_gst_plugin_pattern }

if ($matches.Count -gt 0) {
Write-Verbose -Message "GST_PLUGIN_PATH contains Sensing-Dev gst-plugin path: YES"
foreach ($match in $matches) {
$expected_gst_plugin = $match
$newPath = $currentGSTPATH -replace [regex]::Escape($expected_gst_plugin), ""
$currentGSTPATH = $newPath
Write-Output "Removed '$expected_gst_plugin' from User Path environment variable."
}
[Environment]::SetEnvironmentVariable("GST_PLUGIN_PATH", $newPath, "User")
} else {
Write-Verbose -Message "GST_PLUGIN_PATH contains Sensing-Dev gst-plugin path: NO --skip removal"
}

# Delete if SENSING_DEV_ROOT
if ($sensing_dev_root_exist){
[Environment]::SetEnvironmentVariable("SENSING_DEV_ROOT", "", "User")
Write-Output "Removed '$sensing_dev_root' from User SENSING_DEV_ROOT environment variable."
}else{
Write-Verbose -Message "SENSING_DEV_ROOT exists: NO --skip removal"
}

0 comments on commit 53f8940

Please sign in to comment.