diff --git a/CHANGELOG.md b/CHANGELOG.md index 0262ceac1c..308e424702 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - **scoop-search:** Use SQLite for caching apps to speed up local search ([#5851](https://github.com/ScoopInstaller/Scoop/issues/5851), [#5918](https://github.com/ScoopInstaller/Scoop/issues/5918), [#5946](https://github.com/ScoopInstaller/Scoop/issues/5946), [#5949](https://github.com/ScoopInstaller/Scoop/issues/5949), [#5955](https://github.com/ScoopInstaller/Scoop/issues/5955), [#5966](https://github.com/ScoopInstaller/Scoop/issues/5966), [#5967](https://github.com/ScoopInstaller/Scoop/issues/5967), [#5981](https://github.com/ScoopInstaller/Scoop/issues/5981)) - **core:** New cache filename format ([#5929](https://github.com/ScoopInstaller/Scoop/issues/5929)) +- **core** Scoop is now able to be installed in a directory independent of the global and local apps directory - **install:** Added the ability to install specific version of app from URL/file link ([#5988](https://github.com/ScoopInstaller/Scoop/issues/5988)) ### Bug Fixes diff --git a/bin/uninstall.ps1 b/bin/uninstall.ps1 index 2e2dc36ea8..e52318d367 100644 --- a/bin/uninstall.ps1 +++ b/bin/uninstall.ps1 @@ -93,9 +93,11 @@ if ($errors) { if ($purge) { rm_dir $scoopdir + rm_dir $localdir if ($global) { rm_dir $globaldir } } else { keep_onlypersist $scoopdir + keep_onlypersist $localdir if ($global) { keep_onlypersist $globaldir } } diff --git a/lib/core.ps1 b/lib/core.ps1 index 2ecde7ae5a..2a859bb944 100644 --- a/lib/core.ps1 +++ b/lib/core.ps1 @@ -194,7 +194,7 @@ function Complete-ConfigChange { $Value.ToUpperInvariant() } info "Turn on Scoop isolated path ('$newPathEnvVar')... This may take a while, please wait." - $movedPath = Remove-Path -Path "$scoopdir\apps\*" -TargetEnvVar $currPathEnvVar -Quiet -PassThru + $movedPath = Remove-Path -Path "$localdir\apps\*" -TargetEnvVar $currPathEnvVar -Quiet -PassThru if ($movedPath) { Add-Path -Path $movedPath -TargetEnvVar $newPathEnvVar -Quiet Add-Path -Path ('%' + $newPathEnvVar + '%') -Quiet @@ -386,7 +386,7 @@ function filesize($length) { } # dirs -function basedir($global) { if($global) { return $globaldir } $scoopdir } +function basedir($global) { if($global) { return $globaldir } $localdir } function appsdir($global) { "$(basedir $global)\apps" } function shimdir($global) { "$(basedir $global)\shims" } function modulesdir($global) { "$(basedir $global)\modules" } @@ -1081,10 +1081,10 @@ function shim($path, $global, $name, $arg) { function get_shim_path() { $shim_version = get_config SHIM 'kiennq' $shim_path = switch ($shim_version) { - 'scoopcs' { "$(versiondir 'scoop' 'current')\supporting\shims\scoopcs\shim.exe" } - '71' { "$(versiondir 'scoop' 'current')\supporting\shims\71\shim.exe" } - 'kiennq' { "$(versiondir 'scoop' 'current')\supporting\shims\kiennq\shim.exe" } - 'default' { "$(versiondir 'scoop' 'current')\supporting\shims\scoopcs\shim.exe" } + 'scoopcs' { "$($scoopdir)\apps\scoop\current\supporting\shims\scoopcs\shim.exe" } + '71' { "$($scoopdir)\apps\scoop\current\supporting\shims\71\shim.exe" } + 'kiennq' { "$($scoopdir)\apps\scoop\current\supporting\shims\kiennq\shim.exe" } + 'default' { "$($scoopdir)\apps\scoop\current\supporting\shims\scoopcs\shim.exe" } default { warn "Unknown shim version: '$shim_version'" } } return $shim_path @@ -1401,6 +1401,20 @@ function Out-UTF8File { } } +function getOldRootPath() { + $configRootPath = (get_config ROOT_PATH) + if ($configRootPath -ne $null) { + (set_config ROOT_PATH $null) + (set_config LOCAL_PATH $configRootPath) + return $configRootPath + } + $userProfileScoop = "$([System.Environment]::GetFolderPath('UserProfile'))\scoop" + if (Test-Path -Path $userProfileScoop) { + return $userProfileScoop + } + return $null +} + ################## # Core Bootstrap # ################## @@ -1409,36 +1423,15 @@ function Out-UTF8File { # for all communication with api.github.com Optimize-SecurityProtocol +# Scoop root directory +$scoopdir = "$PSScriptRoot\..\..\..\.." + # Load Scoop config -$configHome = $env:XDG_CONFIG_HOME, "$env:USERPROFILE\.config" | Select-Object -First 1 -$configFile = "$configHome\scoop\config.json" -# Check if it's the expected install path for scoop: /apps/scoop/current -$coreRoot = Split-Path $PSScriptRoot -$pathExpected = ($coreRoot -replace '\\','/') -like '*apps/scoop/current*' -if ($pathExpected) { - # Portable config is located in root directory: - # .\current\scoop\apps\\config.json <- a reversed path - # Imagine `/apps/scoop/current/` in a reversed format, - # and the directory tree: - # - # ``` - # : - # ├─apps - # ├─buckets - # ├─cache - # ├─persist - # ├─shims - # ├─config.json - # ``` - $configPortablePath = Get-AbsolutePath "$coreRoot\..\..\..\config.json" - if (Test-Path $configPortablePath) { - $configFile = $configPortablePath - } -} +$configFile = "$scoopdir\config.json" $scoopConfig = load_cfg $configFile -# Scoop root directory -$scoopdir = $env:SCOOP, (get_config ROOT_PATH), "$PSScriptRoot\..\..\..\..", "$([System.Environment]::GetFolderPath('UserProfile'))\scoop" | Where-Object { $_ } | Select-Object -First 1 | Get-AbsolutePath +# Scoop local directory +$localdir = $env:SCOOP_LOCAL, (get_config LOCAL_PATH), "$([System.Environment]::GetFolderPath('LocalApplicationData'))\scoop", (getOldRootPath) | Where-Object { $_ } | Select-Object -First 1 | Get-AbsolutePath # Scoop global apps directory $globaldir = $env:SCOOP_GLOBAL, (get_config GLOBAL_PATH), "$([System.Environment]::GetFolderPath('CommonApplicationData'))\scoop" | Where-Object { $_ } | Select-Object -First 1 | Get-AbsolutePath diff --git a/lib/diagnostic.ps1 b/lib/diagnostic.ps1 index e4cc97e6a2..b8177b3a77 100644 --- a/lib/diagnostic.ps1 +++ b/lib/diagnostic.ps1 @@ -9,7 +9,7 @@ function check_windows_defender($global) { if ((Get-MpPreference).DisableRealtimeMonitoring) { return $true } if ($defender -and $defender.Status) { if ($defender.Status -eq [System.ServiceProcess.ServiceControllerStatus]::Running) { - $installPath = $scoopdir; + $installPath = $localdir; if ($global) { $installPath = $globaldir; } $exclusionPath = (Get-MpPreference).ExclusionPath diff --git a/libexec/scoop-checkup.ps1 b/libexec/scoop-checkup.ps1 index 32b0ef4a5a..137123c2b7 100644 --- a/libexec/scoop-checkup.ps1 +++ b/libexec/scoop-checkup.ps1 @@ -36,13 +36,13 @@ if (!(Test-HelperInstalled -Helper Dark)) { $globaldir = New-Object System.IO.DriveInfo($globaldir) if ($globaldir.DriveFormat -ne 'NTFS') { - error "Scoop requires an NTFS volume to work! Please point `$env:SCOOP_GLOBAL or 'global_path' variable in '~/.config/scoop/config.json' to another Drive." + error "Scoop requires an NTFS volume to work! Please point `$env:SCOOP_GLOBAL or 'global_path' variable in '$scoopdir/config.json' to another Drive." $issues++ } -$scoopdir = New-Object System.IO.DriveInfo($scoopdir) -if ($scoopdir.DriveFormat -ne 'NTFS') { - error "Scoop requires an NTFS volume to work! Please point `$env:SCOOP or 'root_path' variable in '~/.config/scoop/config.json' to another Drive." +$localdir = New-Object System.IO.DriveInfo($localdir) +if ($localdir.DriveFormat -ne 'NTFS') { + error "Scoop requires an NTFS volume to work! Please point `$env:SCOOP_LOCAL or 'local_path' variable in '$scoopdir/config.json' to another Drive." $issues++ } diff --git a/libexec/scoop-config.ps1 b/libexec/scoop-config.ps1 index 6007bd6434..be3777c77e 100644 --- a/libexec/scoop-config.ps1 +++ b/libexec/scoop-config.ps1 @@ -74,8 +74,8 @@ # shim: kiennq|scoopcs|71 # Choose scoop shim build. # -# root_path: $Env:UserProfile\scoop -# Path to Scoop root directory. +# local_path: $Env:LocalAppData\scoop +# Path to Scoop root directory for local apps. # # global_path: $Env:ProgramData\scoop # Path to Scoop root directory for global apps. diff --git a/libexec/scoop-export.ps1 b/libexec/scoop-export.ps1 index 8eff8db0c5..84f8809765 100644 --- a/libexec/scoop-export.ps1 +++ b/libexec/scoop-export.ps1 @@ -10,7 +10,7 @@ $export = @{} if ($args[0] -eq '-c' -or $args[0] -eq '--config') { $export.config = $scoopConfig # Remove machine-specific properties - foreach ($prop in 'last_update', 'root_path', 'global_path', 'cache_path', 'alias') { + foreach ($prop in 'last_update', 'local_path', 'global_path', 'cache_path', 'alias') { $export.config.PSObject.Properties.Remove($prop) } }