Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom persist locations #90

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
.PARAMETER ScoopCacheDir
Specifies cache directory.
If not specified, caches will be downloaded to '$ScoopDir\cache'.
.PARAMETER ScoopPersistDir
Specifies persist directory.
If not specified, persistent file will be saved to '$ScoopDir\persist'.
.PARAMETER ScoopPersistGlobalDir
Specifies persist directory for global apps.
If not specified, global persistent file will be saved to '$ScoopGlobalDir\persist'.
.PARAMETER NoProxy
Bypass system proxy during the installation.
.PARAMETER Proxy
Expand All @@ -59,6 +65,8 @@ param(
[String] $ScoopDir,
[String] $ScoopGlobalDir,
[String] $ScoopCacheDir,
[String] $ScoopPersistDir,
[String] $ScoopPersistGlobalDir,
[Switch] $NoProxy,
[Uri] $Proxy,
[System.Management.Automation.PSCredential] $ProxyCredential,
Expand Down Expand Up @@ -543,6 +551,28 @@ function Add-DefaultConfig {
}
}

# Use user-level SCOOP_PERSIST, or save to persist_path
if (!(Get-Env 'SCOOP_PERSIST')) {
if ($SCOOP_PERSIST_DIR -ne "$SCOOP_DIR\persist") {
Write-Verbose "Adding config persist_path: $SCOOP_PERSIST_DIR"
Add-Config -Name 'persist_path' -Value $SCOOP_PERSIST_DIR | Out-Null
}
}

# Use system SCOOP_PERSIST_GLOBAL, or set system SCOOP_PERSIST_GLOBAL
# with $env:SCOOP_PERSIST_GLOBAL if RunAsAdmin, otherwise save to global_persist_path
if (!(Get-Env 'SCOOP_PERSIST_GLOBAL' -global)) {
if ((Test-IsAdministrator) -and $env:SCOOP_PERSIST_GLOBAL) {
Write-Verbose "Setting System Environment Variable SCOOP_PERSIST_GLOBAL: $env:SCOOP_PERSIST_GLOBAL"
[Environment]::SetEnvironmentVariable('SCOOP_PERSIST_GLOBAL', $env:SCOOP_PERSIST_GLOBAL, 'Machine')
} else {
if ($SCOOP_PERSIST_GLOBAL_DIR -ne "$SCOOP_GLOBAL_DIR\persist") {
Write-Verbose "Adding config global_persist_path: $SCOOP_PERSIST_GLOBAL_DIR"
Add-Config -Name 'global_persist_path' -Value $SCOOP_PERSIST_GLOBAL_DIR | Out-Null
}
}
}

# save current datatime to last_update
Add-Config -Name 'last_update' -Value ([System.DateTime]::Now.ToString('o')) | Out-Null
}
Expand Down Expand Up @@ -654,10 +684,14 @@ function Write-DebugInfo {
Write-Verbose "`$env:ProgramData: $env:ProgramData"
Write-Verbose "`$env:SCOOP: $env:SCOOP"
Write-Verbose "`$env:SCOOP_CACHE: $SCOOP_CACHE"
Write-Verbose "`$env:SCOOP_PERSIST: $SCOOP_PERSIST"
Write-Verbose "`$env:SCOOP_PERSIST_GLOBAL: $SCOOP_CACHE"
Write-Verbose "`$env:SCOOP_GLOBAL: $env:SCOOP_GLOBAL"
Write-Verbose '-------- Selected Variables --------'
Write-Verbose "SCOOP_DIR: $SCOOP_DIR"
Write-Verbose "SCOOP_CACHE_DIR: $SCOOP_CACHE_DIR"
Write-Verbose "SCOOP_PERSIST_DIR: $SCOOP_PERSIST_DIR"
Write-Verbose "SCOOP_PERSIST_GLOBAL_DIR: $SCOOP_PERSIST_GLOBAL_DIR"
Write-Verbose "SCOOP_GLOBAL_DIR: $SCOOP_GLOBAL_DIR"
Write-Verbose "SCOOP_CONFIG_HOME: $SCOOP_CONFIG_HOME"
}
Expand All @@ -671,6 +705,9 @@ $SCOOP_DIR = $ScoopDir, $env:SCOOP, "$env:USERPROFILE\scoop" | Where-Object { -n
$SCOOP_GLOBAL_DIR = $ScoopGlobalDir, $env:SCOOP_GLOBAL, "$env:ProgramData\scoop" | Where-Object { -not [String]::IsNullOrEmpty($_) } | Select-Object -First 1
# Scoop cache directory
$SCOOP_CACHE_DIR = $ScoopCacheDir, $env:SCOOP_CACHE, "$SCOOP_DIR\cache" | Where-Object { -not [String]::IsNullOrEmpty($_) } | Select-Object -First 1
# Scoop persist directories
$SCOOP_PERSIST_DIR = $ScoopPersistDir, $env:SCOOP_PERSIST, "$SCOOP_DIR\persist" | Where-Object { -not [String]::IsNullOrEmpty($_) } | Select-Object -First 1
$SCOOP_PERSIST_GLOBAL_DIR = $ScoopPersistGlobalDir, $env:SCOOP_PERSIST_GLOBAL, "$SCOOP_GLOBAL_DIR\persist" | Where-Object { -not [String]::IsNullOrEmpty($_) } | Select-Object -First 1
# Scoop shims directory
$SCOOP_SHIMS_DIR = "$SCOOP_DIR\shims"
# Scoop itself directory
Expand Down