From 3298dd12b8d3eca919a12a9088756be5d5308f93 Mon Sep 17 00:00:00 2001 From: Rohan Barar Date: Wed, 24 Jul 2024 18:27:02 +1000 Subject: [PATCH 1/7] Added support for 'Scoop Package Manager'. --- install/ExtractPrograms.ps1 | 351 ++++++++++++++++++++++-------------- 1 file changed, 217 insertions(+), 134 deletions(-) diff --git a/install/ExtractPrograms.ps1 b/install/ExtractPrograms.ps1 index 16284fd..d2ce267 100644 --- a/install/ExtractPrograms.ps1 +++ b/install/ExtractPrograms.ps1 @@ -1,153 +1,161 @@ +<# +'Get-Icon' Source: +https://github.com/proxb/PowerShell_Scripts/blob/master/Get-Icon.ps1 + +'Get-Icon' License: +The MIT License (MIT) +Copyright (c) +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#> Function Get-Icon { <# - Get-Icon License: + .SYNOPSIS + Gets the icon from a file - License + .DESCRIPTION + Gets the icon from a file and displays it in a variety formats. - The MIT License (MIT) + .PARAMETER Path + The path to a file to get the icon - Copyright (c) + .PARAMETER ToBytes + Displays outputs as a byte array - Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + .PARAMETER ToBitmap + Display the icon as a bitmap object - The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + .PARAMETER ToBase64 + Displays the icon in Base64 encoded format - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - #> - <# - .SYNOPSIS - Gets the icon from a file + .NOTES + Name: Get-Icon + Author: Boe Prox + Version History: + 1.0 //Boe Prox - 11JAN2016 + - Initial version - .DESCRIPTION - Gets the icon from a file and displays it in a variety formats. + .OUTPUT + System.Drawing.Icon + System.Drawing.Bitmap + System.String + System.Byte[] - .PARAMETER Path - The path to a file to get the icon + .EXAMPLE + Get-Icon -Path 'C:\windows\system32\WindowsPowerShell\v1.0\PowerShell.exe' - .PARAMETER ToBytes - Displays outputs as a byte array + FullName : C:\windows\system32\WindowsPowerShell\v1.0\PowerShell.exe + Handle : 164169893 + Height : 32 + Size : {Width=32, Height=32} + Width : 32 - .PARAMETER ToBitmap - Display the icon as a bitmap object + Description + ----------- + Returns the System.Drawing.Icon representation of the icon - .PARAMETER ToBase64 - Displays the icon in Base64 encoded format + .EXAMPLE + Get-Icon -Path 'C:\windows\system32\WindowsPowerShell\v1.0\PowerShell.exe' -ToBitmap - .NOTES - Name: Get-Icon - Author: Boe Prox - Version History: - 1.0 //Boe Prox - 11JAN2016 - - Initial version + Tag : + PhysicalDimension : {Width=32, Height=32} + Size : {Width=32, Height=32} + Width : 32 + Height : 32 + HorizontalResolution : 96 + VerticalResolution : 96 + Flags : 2 + RawFormat : [ImageFormat: b96b3caa-0728-11d3-9d7b-0000f81ef32e] + PixelFormat : Format32bppArgb + Palette : System.Drawing.Imaging.ColorPalette + FrameDimensionsList : {7462dc86-6180-4c7e-8e3f-ee7333a7a483} + PropertyIdList : {} + PropertyItems : {} - .OUTPUT - System.Drawing.Icon - System.Drawing.Bitmap - System.String - System.Byte[] + Description + ----------- + Returns the System.Drawing.Bitmap representation of the icon - .EXAMPLE - Get-Icon -Path 'C:\windows\system32\WindowsPowerShell\v1.0\PowerShell.exe' + .EXAMPLE + $FileName = 'C:\Temp\PowerShellIcon.png' + $Format = [System.Drawing.Imaging.ImageFormat]::Png + (Get-Icon -Path 'C:\windows\system32\WindowsPowerShell\v1.0\PowerShell.exe' -ToBitmap).Save($FileName,$Format) - FullName : C:\windows\system32\WindowsPowerShell\v1.0\PowerShell.exe - Handle : 164169893 - Height : 32 - Size : {Width=32, Height=32} - Width : 32 + Description + ----------- + Saves the icon as a file. - Description - ----------- - Returns the System.Drawing.Icon representation of the icon + .EXAMPLE + Get-Icon -Path 'C:\windows\system32\WindowsPowerShell\v1.0\PowerShell.exe' -ToBase64 - .EXAMPLE - Get-Icon -Path 'C:\windows\system32\WindowsPowerShell\v1.0\PowerShell.exe' -ToBitmap + AAABAAEAICAQHQAAAADoAgAAFgAAACgAAAAgAAAAQAAAAAEABAAAAAAAgAIAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAgICAAMDAwAAAAP8AAP8AAAD//wD/AAAA/wD/AP + //AAD///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABmZmZmZmZmZmZmZgAAAAAAaId3d3d3d4iIiIdgAA + AHdmhmZmZmZmZmZmZoZAAAB2ZnZmZmZmZmZmZmZ3YAAAdmZ3ZmiHZniIiHZmaGAAAHZmd2Zv/4eIiIi + GZmhgAAB2ZmdmZ4/4eIh3ZmZnYAAAd2ZnZmZo//h2ZmZmZ3YAAHZmaGZmZo//h2ZmZmd2AAB3Zmd2Zm + Znj/h2ZmZmhgAAd3dndmZmZuj/+GZmZoYAAHd3dod3dmZuj/9mZmZ2AACHd3aHd3eIiP/4ZmZmd2AAi + Hd2iIiIiI//iId2ZndgAIiIhoiIiIj//4iIiIiIYACIiId4iIiP//iIiIiIiGAAiIiIaIiI//+IiIiI + iIhkAIiIiGiIiP/4iIiIiIiIdgCIiIhoiIj/iIiIiIiIiIYAiIiIeIiIiIiIiIiIiIiGAAiIiIaP/// + ////////4hgAAAAAGZmZmZmZmZmZmZmYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD////////////////gA + AAf4AAAD+AAAAfgAAAHAAAABwAAAAcAAAAHAAAAAwAAAAMAAAADAAAAAwAAAAMAAAABAAAAAQAAAAEA + AAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAP4AAAH//////////////////////////w== - Tag : - PhysicalDimension : {Width=32, Height=32} - Size : {Width=32, Height=32} - Width : 32 - Height : 32 - HorizontalResolution : 96 - VerticalResolution : 96 - Flags : 2 - RawFormat : [ImageFormat: b96b3caa-0728-11d3-9d7b-0000f81ef32e] - PixelFormat : Format32bppArgb - Palette : System.Drawing.Imaging.ColorPalette - FrameDimensionsList : {7462dc86-6180-4c7e-8e3f-ee7333a7a483} - PropertyIdList : {} - PropertyItems : {} + Description + ----------- + Returns the Base64 encoded representation of the icon - Description - ----------- - Returns the System.Drawing.Bitmap representation of the icon + .EXAMPLE + Get-Icon -Path 'C:\windows\system32\WindowsPowerShell\v1.0\PowerShell.exe' -ToBase64 | Clip - .EXAMPLE - $FileName = 'C:\Temp\PowerShellIcon.png' - $Format = [System.Drawing.Imaging.ImageFormat]::Png - (Get-Icon -Path 'C:\windows\system32\WindowsPowerShell\v1.0\PowerShell.exe' -ToBitmap).Save($FileName,$Format) + Description + ----------- + Returns the Base64 encoded representation of the icon and saves it to the clipboard. - Description - ----------- - Saves the icon as a file. + .EXAMPLE + (Get-Icon -Path 'C:\windows\system32\WindowsPowerShell\v1.0\PowerShell.exe' -ToBytes) -Join '' - .EXAMPLE - Get-Icon -Path 'C:\windows\system32\WindowsPowerShell\v1.0\PowerShell.exe' -ToBase64 - - AAABAAEAICAQHQAAAADoAgAAFgAAACgAAAAgAAAAQAAAAAEABAAAAAAAgAIAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAgICAAMDAwAAAAP8AAP8AAAD//wD/AAAA/wD/AP - //AAD///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABmZmZmZmZmZmZmZgAAAAAAaId3d3d3d4iIiIdgAA - AHdmhmZmZmZmZmZmZoZAAAB2ZnZmZmZmZmZmZmZ3YAAAdmZ3ZmiHZniIiHZmaGAAAHZmd2Zv/4eIiIi - GZmhgAAB2ZmdmZ4/4eIh3ZmZnYAAAd2ZnZmZo//h2ZmZmZ3YAAHZmaGZmZo//h2ZmZmd2AAB3Zmd2Zm - Znj/h2ZmZmhgAAd3dndmZmZuj/+GZmZoYAAHd3dod3dmZuj/9mZmZ2AACHd3aHd3eIiP/4ZmZmd2AAi - Hd2iIiIiI//iId2ZndgAIiIhoiIiIj//4iIiIiIYACIiId4iIiP//iIiIiIiGAAiIiIaIiI//+IiIiI - iIhkAIiIiGiIiP/4iIiIiIiIdgCIiIhoiIj/iIiIiIiIiIYAiIiIeIiIiIiIiIiIiIiGAAiIiIaP/// - ////////4hgAAAAAGZmZmZmZmZmZmZmYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD////////////////gA - AAf4AAAD+AAAAfgAAAHAAAABwAAAAcAAAAHAAAAAwAAAAMAAAADAAAAAwAAAAMAAAABAAAAAQAAAAEA - AAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAP4AAAH//////////////////////////w== - - Description - ----------- - Returns the Base64 encoded representation of the icon - - .EXAMPLE - Get-Icon -Path 'C:\windows\system32\WindowsPowerShell\v1.0\PowerShell.exe' -ToBase64 | Clip - - Description - ----------- - Returns the Base64 encoded representation of the icon and saves it to the clipboard. - - .EXAMPLE - (Get-Icon -Path 'C:\windows\system32\WindowsPowerShell\v1.0\PowerShell.exe' -ToBytes) -Join '' - - 0010103232162900002322002200040000320006400010400000128200000000000000000000000 - 0128001280001281280128000128012801281280012812812801921921920002550025500025525 - 5025500025502550255255002552552550000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000006102102102102102102102102102102960000613611 - 9119119119119120136136136118000119102134102102102102102102102102102134640011810 - 2118102102102102102102102102102119960011810211910210413510212013613611810210496 - 0011810211910211125513513613613613410210496001181021031021031432481201361191021 - 0210396001191021031021021042552481181021021021031180011810210410210210214325513 - 5102102102103118001191021031181021021031432481181021021021340011911910311810210 - 2102232255248102102102134001191191181351191181021101432551021021021180013511911 - 8135119119136136255248102102102119960136119118136136136136143255136135118102119 - 9601361361341361361361362552551361361361361369601361361351201361361432552481361 - 3613613613696013613613610413613625525513613613613613613610001361361361041361362 - 5524813613613613613613611801361361361041361362551361361361361361361361340136136 - 1361201361361361361361361361361361361340813613613414325525525525525525525525524 - 8134000061021021021021021021021021021021020000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000025525525525525525525525525525525525 - 5224003122400152240072240070007000700070003000300030003000300010001000100010000 - 0000000000000000000012800025400125525525525525525525525525525525525525525525525 - 5255255255255 - - Description - ----------- - Returns the bytes representation of the icon. -Join was used in this for the sake - of displaying all of the data. + 0010103232162900002322002200040000320006400010400000128200000000000000000000000 + 0128001280001281280128000128012801281280012812812801921921920002550025500025525 + 5025500025502550255255002552552550000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000006102102102102102102102102102102960000613611 + 9119119119119120136136136118000119102134102102102102102102102102102134640011810 + 2118102102102102102102102102102119960011810211910210413510212013613611810210496 + 0011810211910211125513513613613613410210496001181021031021031432481201361191021 + 0210396001191021031021021042552481181021021021031180011810210410210210214325513 + 5102102102103118001191021031181021021031432481181021021021340011911910311810210 + 2102232255248102102102134001191191181351191181021101432551021021021180013511911 + 8135119119136136255248102102102119960136119118136136136136143255136135118102119 + 9601361361341361361361362552551361361361361369601361361351201361361432552481361 + 3613613613696013613613610413613625525513613613613613613610001361361361041361362 + 5524813613613613613613611801361361361041361362551361361361361361361361340136136 + 1361201361361361361361361361361361361340813613613414325525525525525525525525524 + 8134000061021021021021021021021021021021020000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000025525525525525525525525525525525525 + 5224003122400152240072240070007000700070003000300030003000300010001000100010000 + 0000000000000000000012800025400125525525525525525525525525525525525525525525525 + 5255255255255 + Description + ----------- + Returns the bytes representation of the icon. -Join was used in this for the sake + of displaying all of the data. #> [cmdletbinding( DefaultParameterSetName = '__DefaultParameterSetName' @@ -204,23 +212,98 @@ Function Get-Icon { } } +### SEQUENTIAL LOGIC ### +# Print bash commands to define three new arrays. "NAMES=()" "ICONS=()" "EXES=()" + +# Search for installed applications. +# WINDOWS REGISTRY. Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\*" | Select-Object -Property "(default)" -Unique | Where-Object {$_."(default)" -ne $null} | ForEach-Object { - $Exe = $_."(default)".Trim('"') - $Item = Get-Item $Exe - if ($Item.VersionInfo.FileDescription) { - $Name = $Item.VersionInfo.FileDescription.Trim() -replace " ", " " + # Remove leading and trailing double quotation marks from the path. + $exePath = $_."(default)".Trim('"') + + # Get the application name. + if ((Get-Item $exePath).VersionInfo.FileDescription) { + # Remove leading/trailing whitespace and replace multiple spaces with a single space. + $exeName = (Get-Item $exePath).VersionInfo.FileDescription.Trim() -replace '\s+', ' ' } else { - $Name = [System.IO.Path]::GetFileNameWithoutExtension($Exe) + # Get the executable file name without the file extension. + $exeName = [System.IO.Path]::GetFileNameWithoutExtension($exePath) } - $Icon = Get-Icon -Path $Exe -ToBase64 - #Get-ItemProperty $Exe -Name VersionInfo - "NAMES+=(""$Name"")" - "EXES+=(""$Exe"")" - "ICONS+=(""$Icon"")" + + # Store the application icon as a base-64 string. + $exeIcon = Get-Icon -Path $exePath -ToBase64 + + # Output the results as bash commands that append the results to several bash arrays. + "NAMES+=(""$exeName"")" + "EXES+=(""$exePath"")" + "ICONS+=(""$exeIcon"")" } + +# SCOOP PACKAGE MANAGER +# Specify the 'scoop' shims directory. +$scoopDir = "$HOME\scoop\shims" + +# Check if the 'scoop' shims directory exists. +if (Test-Path -Path $scoopDir -PathType Container) { + # Initialise an empty array to store executable paths. + $exePaths = @() + + # Get all '.shim' files. + $shimFiles = Get-ChildItem -Path $scoopDir -Filter *.shim + + # Loop through each '.shim' file to extract the executable path. + foreach ($shimFile in $shimFiles) { + # Read the content of the '.shim' file. + $shimFileContent = Get-Content -Path $shimFile.FullName + + # Extract the path using regex, exiting the loop after the first match is found. + $exePath = "" + + foreach ($line in $shimFileContent) { + # '^\s*path\s*=\s*"([^"]+)"' + # ^ --> Asserts the start of the line. + # \s* --> Matches any whitespace characters (zero or more times). + # path --> Matches the literal string "path". + # \s*=\s* --> Matches an equal sign = surrounded by optional whitespace characters. + # " --> Matches an initial double quote. + # ([^"]+) --> Captures one or more characters that are not ", representing the path inside the double quotes. + # " --> Matches a final double quote. + if ($line -match '^\s*path\s*=\s*"([^"]+)"') { + $exePath = $matches[1] + break + } + } + + # Add extracted path to the array + $exePaths += $exePath + } + + # Loop through the extracted executable file paths. + foreach ($exePath in $exePaths) { + # Get the application name. + if ((Get-Item $exePath).VersionInfo.FileDescription) { + # Remove leading/trailing whitespace and replace multiple spaces with a single space. + $exeName = (Get-Item $exePath).VersionInfo.FileDescription.Trim() -replace '\s+', ' ' + } else { + # Get the executable file name without the file extension. + $exeName = [System.IO.Path]::GetFileNameWithoutExtension($exePath) + } + + # Add the 'scoop' tag to the application name. + $exeName = "[Scoop] " + $exeName + + # Store the application icon as a base-64 string. + $exeIcon = Get-Icon -Path $exePath -ToBase64 + + # Output the results as bash commands that append the results to several bash arrays. + "NAMES+=(""$exeName"")" + "EXES+=(""$exePath"")" + "ICONS+=(""$exeIcon"")" + } +} From 4806232d8563420ff11e5b50d23864dec3dc2736 Mon Sep 17 00:00:00 2001 From: Rohan Barar Date: Wed, 24 Jul 2024 21:52:52 +1000 Subject: [PATCH 2/7] Added support for 'Chocolatey' shims. --- install/ExtractPrograms.ps1 | 190 ++++++++++++++++++++++-------------- 1 file changed, 119 insertions(+), 71 deletions(-) diff --git a/install/ExtractPrograms.ps1 b/install/ExtractPrograms.ps1 index d2ce267..c014399 100644 --- a/install/ExtractPrograms.ps1 +++ b/install/ExtractPrograms.ps1 @@ -212,80 +212,23 @@ Function Get-Icon { } } -### SEQUENTIAL LOGIC ### -# Print bash commands to define three new arrays. -"NAMES=()" -"ICONS=()" -"EXES=()" +function PrintArrayData { + param ( + [string[]]$Paths, + [string]$Source + ) -# Search for installed applications. -# WINDOWS REGISTRY. -Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\*" | - Select-Object -Property "(default)" -Unique | - Where-Object {$_."(default)" -ne $null} | - ForEach-Object { - # Remove leading and trailing double quotation marks from the path. - $exePath = $_."(default)".Trim('"') + # Remove leading and trailing double quotes from all paths. + $Paths = $Paths -replace '^"*|"*$' - # Get the application name. - if ((Get-Item $exePath).VersionInfo.FileDescription) { - # Remove leading/trailing whitespace and replace multiple spaces with a single space. - $exeName = (Get-Item $exePath).VersionInfo.FileDescription.Trim() -replace '\s+', ' ' - } else { - # Get the executable file name without the file extension. - $exeName = [System.IO.Path]::GetFileNameWithoutExtension($exePath) - } - - # Store the application icon as a base-64 string. - $exeIcon = Get-Icon -Path $exePath -ToBase64 - - # Output the results as bash commands that append the results to several bash arrays. - "NAMES+=(""$exeName"")" - "EXES+=(""$exePath"")" - "ICONS+=(""$exeIcon"")" - } - -# SCOOP PACKAGE MANAGER -# Specify the 'scoop' shims directory. -$scoopDir = "$HOME\scoop\shims" - -# Check if the 'scoop' shims directory exists. -if (Test-Path -Path $scoopDir -PathType Container) { - # Initialise an empty array to store executable paths. - $exePaths = @() - - # Get all '.shim' files. - $shimFiles = Get-ChildItem -Path $scoopDir -Filter *.shim - - # Loop through each '.shim' file to extract the executable path. - foreach ($shimFile in $shimFiles) { - # Read the content of the '.shim' file. - $shimFileContent = Get-Content -Path $shimFile.FullName - - # Extract the path using regex, exiting the loop after the first match is found. - $exePath = "" - - foreach ($line in $shimFileContent) { - # '^\s*path\s*=\s*"([^"]+)"' - # ^ --> Asserts the start of the line. - # \s* --> Matches any whitespace characters (zero or more times). - # path --> Matches the literal string "path". - # \s*=\s* --> Matches an equal sign = surrounded by optional whitespace characters. - # " --> Matches an initial double quote. - # ([^"]+) --> Captures one or more characters that are not ", representing the path inside the double quotes. - # " --> Matches a final double quote. - if ($line -match '^\s*path\s*=\s*"([^"]+)"') { - $exePath = $matches[1] - break - } - } - - # Add extracted path to the array - $exePaths += $exePath + # Sort the array of paths based on the filename at the end of each path. + $Paths = $Paths | Sort-Object { + # Extract the filename from the path + [System.IO.Path]::GetFileName($_) } # Loop through the extracted executable file paths. - foreach ($exePath in $exePaths) { + foreach ($exePath in $Paths) { # Get the application name. if ((Get-Item $exePath).VersionInfo.FileDescription) { # Remove leading/trailing whitespace and replace multiple spaces with a single space. @@ -295,8 +238,17 @@ if (Test-Path -Path $scoopDir -PathType Container) { $exeName = [System.IO.Path]::GetFileNameWithoutExtension($exePath) } - # Add the 'scoop' tag to the application name. - $exeName = "[Scoop] " + $exeName + # Remove undesirable suffix for chocolatey shims. + if ($Source -eq "choco") { + if ($exeName.EndsWith(" - Chocolatey Shim")) { + $exeName = $exeName.Substring(0, $exeName.Length - " - Chocolatey Shim".Length) + } + } + + # Add the appropriate tag to the application name. + if ($Source -ne "winreg") { + $exeName = $exeName + " [" + $Source + "]" + } # Store the application icon as a base-64 string. $exeIcon = Get-Icon -Path $exePath -ToBase64 @@ -307,3 +259,99 @@ if (Test-Path -Path $scoopDir -PathType Container) { "ICONS+=(""$exeIcon"")" } } + +function AppSearchWinReg { + # Initialise an empty array to store executable paths. + $exePaths = @() + + # Query windows registry for unique installed executable files. + $exePaths = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\*" | + ForEach-Object { $_."(default)" } | # Extract the value of the (default) property + Where-Object { $_ -ne $null } | # Filter out null values + Sort-Object -Unique # Ensure uniqueness + + # Process extracted executable file paths. + PrintArrayData -Paths $exePaths -Source "winreg" +} + +function AppSearchChocolatey { + # Note: This will only look for chocolatey shims! + # Initialise an empty array to store executable paths. + $exePaths = @() + + # Specify the 'chocolatey' shims directory. + $chocoDir = "C:\ProgramData\chocolatey\bin" + + # Check if the 'chocolatey' shims directory exists. + if (Test-Path -Path $chocoDir -PathType Container) { + # Get all shim '.exe' files. + $shimExeFiles = Get-ChildItem -Path $chocoDir -Filter *.exe + + # Loop through each '.shim' file to extract the executable path. + foreach ($shimExeFile in $shimExeFiles) { + # Resolve the shim to the actual executable path. + $exePath = (Get-Command $shimExeFile).Source + + # Add the extracted path to the array. + $exePaths += $exePath + } + + # Process extracted executable file paths. + PrintArrayData -Paths $exePaths -Source "choco" + } +} + +function AppSearchScoop { + # Initialise an empty array to store executable paths. + $exePaths = @() + + # Specify the 'scoop' shims directory. + $scoopDir = "$HOME\scoop\shims" + + # Check if the 'scoop' shims directory exists. + if (Test-Path -Path $scoopDir -PathType Container) { + # Get all '.shim' files. + $shimFiles = Get-ChildItem -Path $scoopDir -Filter *.shim + + # Loop through each '.shim' file to extract the executable path. + foreach ($shimFile in $shimFiles) { + # Read the content of the '.shim' file. + $shimFileContent = Get-Content -Path $shimFile.FullName + + # Extract the path using regex, exiting the loop after the first match is found. + $exePath = "" + + foreach ($line in $shimFileContent) { + # '^\s*path\s*=\s*"([^"]+)"' + # ^ --> Asserts the start of the line. + # \s* --> Matches any whitespace characters (zero or more times). + # path --> Matches the literal string "path". + # \s*=\s* --> Matches an equal sign = surrounded by optional whitespace characters. + # " --> Matches an initial double quote. + # ([^"]+) --> Captures one or more characters that are not ", representing the path inside the double quotes. + # " --> Matches a final double quote. + if ($line -match '^\s*path\s*=\s*"([^"]+)"') { + $exePath = $matches[1] + break + } + } + + # Add the extracted path to the array. + $exePaths += $exePath + } + + # Process extracted executable file paths. + PrintArrayData -Paths $exePaths -Source "scoop" + } +} + +### SEQUENTIAL LOGIC ### +# Print bash commands to define three new arrays. +"NAMES=()" +"ICONS=()" +"EXES=()" + +# Search for installed applications. +AppSearchWinReg +AppSearchChocolatey +AppSearchScoop From f4a63d45a152b3733778f1b888c151c018014569 Mon Sep 17 00:00:00 2001 From: Rohan Barar Date: Thu, 25 Jul 2024 09:56:54 +1000 Subject: [PATCH 3/7] Fixed #163 via updated hyperlink to 'RDPApps.reg' in 'libvirt.md'. --- docs/libvirt.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/libvirt.md b/docs/libvirt.md index 27d2fae..f41049f 100644 --- a/docs/libvirt.md +++ b/docs/libvirt.md @@ -620,7 +620,7 @@ You can then test whether the host GNU/Linux system can communicate with Windows {"return":{"version":"107.0.1","supported_commands":[{"enabled":true,"name":"guest-get-cpustats","success-response":true},{"enabled":true,"name":"guest-get-diskstats","success-response":true},{"enabled":true,"name":"guest-get-devices","success-response":true},{"enabled":true,"name":"guest-get-osinfo","success-response":true},{"enabled":true,"name":"guest-get-timezone","success-response":true},{"enabled":true,"name":"guest-get-users","success-response":true},{"enabled":true,"name":"guest-get-host-name","success-response":true},{"enabled":true,"name":"guest-exec","success-response":true},{"enabled":true,"name":"guest-exec-status","success-response":true},{"enabled":false,"name":"guest-get-memory-block-info","success-response":true},{"enabled":false,"name":"guest-set-memory-blocks","success-response":true},{"enabled":false,"name":"guest-get-memory-blocks","success-response":true},{"enabled":true,"name":"guest-set-user-password","success-response":true},{"enabled":true,"name":"guest-get-fsinfo","success-response":true},{"enabled":true,"name":"guest-get-disks","success-response":true},{"enabled":false,"name":"guest-set-vcpus","success-response":true},{"enabled":true,"name":"guest-get-vcpus","success-response":true},{"enabled":true,"name":"guest-network-get-interfaces","success-response":true},{"enabled":false,"name":"guest-suspend-hybrid","success-response":false},{"enabled":true,"name":"guest-suspend-ram","success-response":false},{"enabled":true,"name":"guest-suspend-disk","success-response":false},{"enabled":true,"name":"guest-fstrim","success-response":true},{"enabled":true,"name":"guest-fsfreeze-thaw","success-response":true},{"enabled":true,"name":"guest-fsfreeze-freeze-list","success-response":true},{"enabled":true,"name":"guest-fsfreeze-freeze","success-response":true},{"enabled":true,"name":"guest-fsfreeze-status","success-response":true},{"enabled":true,"name":"guest-file-flush","success-response":true},{"enabled":true,"name":"guest-file-seek","success-response":true},{"enabled":true,"name":"guest-file-write","success-response":true},{"enabled":true,"name":"guest-file-read","success-response":true},{"enabled":true,"name":"guest-file-close","success-response":true},{"enabled":true,"name":"guest-file-open","success-response":true},{"enabled":true,"name":"guest-shutdown","success-response":false},{"enabled":true,"name":"guest-info","success-response":true},{"enabled":true,"name":"guest-set-time","success-response":true},{"enabled":true,"name":"guest-get-time","success-response":true},{"enabled":true,"name":"guest-ping","success-response":true},{"enabled":true,"name":"guest-sync","success-response":true},{"enabled":true,"name":"guest-sync-delimited","success-response":true}]}} ``` -Next, you will need to make some registry changes to enable RDP Applications to run on the system. Start by downloading the [RDPApps.reg](/install/RDPApps.reg) file, right-clicking on the `Raw` button, and clicking on `Save target as`. +Next, you will need to make some registry changes to enable RDP Applications to run on the system. Start by downloading the [RDPApps.reg](https://github.com/winapps-org/winapps/blob/main/oem/RDPApps.reg) file, right-clicking on the `Raw` button, and clicking on `Save target as`.

From dbc71357ce33e52c256458e4c2d5fdb8d80e2138 Mon Sep 17 00:00:00 2001 From: Rohan Barar Date: Thu, 25 Jul 2024 10:12:59 +1000 Subject: [PATCH 4/7] Fixed #164 by replacing with in installation script. --- installer.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/installer.sh b/installer.sh index bb2c31b..8d2480c 100755 --- a/installer.sh +++ b/installer.sh @@ -594,7 +594,7 @@ function waCheckInstallDependencies() { return "$EC_MISSING_DEPS" fi - # 'libvirt'/'virt-manager' + 'Address Resolution Protocol'. + # 'libvirt'/'virt-manager' + 'iproute2'. if [ "$WAFLAVOR" = "libvirt" ]; then if ! command -v virsh &>/dev/null; then # Complete the previous line. @@ -622,7 +622,7 @@ function waCheckInstallDependencies() { return "$EC_MISSING_DEPS" fi - if ! command -v arp &>/dev/null; then + if ! command -v ip &>/dev/null; then # Complete the previous line. echo -e "${FAIL_TEXT}Failed!${CLEAR_TEXT}\n" @@ -630,18 +630,18 @@ function waCheckInstallDependencies() { echo -e "${ERROR_TEXT}ERROR:${CLEAR_TEXT} ${BOLD_TEXT}MISSING DEPENDENCIES.${CLEAR_TEXT}" # Display the error details. - echo -e "${INFO_TEXT}Please install 'net-tools' to proceed.${CLEAR_TEXT}" + echo -e "${INFO_TEXT}Please install 'iproute2' to proceed.${CLEAR_TEXT}" # Display the suggested action(s). echo "--------------------------------------------------------------------------------" echo "Debian/Ubuntu-based systems:" - echo -e " ${COMMAND_TEXT}sudo apt install net-tools${CLEAR_TEXT}" + echo -e " ${COMMAND_TEXT}sudo apt install iproute2${CLEAR_TEXT}" echo "Red Hat/Fedora-based systems:" - echo -e " ${COMMAND_TEXT}sudo dnf install net-tools${CLEAR_TEXT}" + echo -e " ${COMMAND_TEXT}sudo dnf install iproute${CLEAR_TEXT}" echo "Arch Linux systems:" - echo -e " ${COMMAND_TEXT}sudo pacman -S net-tools${CLEAR_TEXT}" + echo -e " ${COMMAND_TEXT}sudo pacman -S iproute2${CLEAR_TEXT}" echo "Gentoo Linux systems:" - echo -e " ${COMMAND_TEXT}sudo emerge --ask sys-apps/net-tools${CLEAR_TEXT}" + echo -e " ${COMMAND_TEXT}sudo emerge --ask net-misc/iproute2${CLEAR_TEXT}" echo "--------------------------------------------------------------------------------" # Terminate the script. @@ -859,7 +859,7 @@ function waCheckPortOpen() { # Note: 'RDP_IP' should not be empty if 'WAFLAVOR' is 'docker', since it is set to localhost before this function is called. if [ -z "$RDP_IP" ] && [ "$WAFLAVOR" = "libvirt" ]; then VM_MAC=$(virsh domiflist "$VM_NAME" | grep -oE "([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})") # VM MAC address. - RDP_IP=$(arp -n | grep "$VM_MAC" | grep -oE "([0-9]{1,3}\.){3}[0-9]{1,3}") # VM IP address. + RDP_IP=$(ip neigh show | grep "$VM_MAC" | grep -oE "([0-9]{1,3}\.){3}[0-9]{1,3}") # VM IP address. if [ -z "$RDP_IP" ]; then # Complete the previous line. From 0264a8971c619922768be64ad9aba774b17fd948 Mon Sep 17 00:00:00 2001 From: Rohan Barar Date: Thu, 25 Jul 2024 13:50:02 +1000 Subject: [PATCH 5/7] Updated virtualisation stack diagram + Removed unnecessary files as per #152. --- docs/libvirt_images/Virtualisation_Stack.svg | 712 ++++++++++++++----- kvm/RDPWindows.qcow2 | Bin 204800 -> 0 bytes kvm/RDPWindows.xml | 210 ------ 3 files changed, 547 insertions(+), 375 deletions(-) delete mode 100644 kvm/RDPWindows.qcow2 delete mode 100644 kvm/RDPWindows.xml diff --git a/docs/libvirt_images/Virtualisation_Stack.svg b/docs/libvirt_images/Virtualisation_Stack.svg index b522006..9ebb272 100644 --- a/docs/libvirt_images/Virtualisation_Stack.svg +++ b/docs/libvirt_images/Virtualisation_Stack.svg @@ -1,180 +1,562 @@ - - Open-source-virtualization-stack -