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

Option to not add shortcuts to startmenu when installing a package #6031

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- **core:** New cache filename format ([#5929](https://github.com/ScoopInstaller/Scoop/issues/5929), [#5944](https://github.com/ScoopInstaller/Scoop/issues/5944))
- **decompress:** Use innounp-unicode as default Inno Setup Unpacker ([#6028](https://github.com/ScoopInstaller/Scoop/issues/6028))
- **install:** Added the ability to install specific version of app from URL/file link ([#5988](https://github.com/ScoopInstaller/Scoop/issues/5988))
- **install** Option to not add shortcuts to startmenu when installing a package ([#6031](https://github.com/ScoopInstaller/Scoop/issues/6031))

### Bug Fixes

Expand Down
8 changes: 5 additions & 3 deletions lib/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function nightly_version($quiet = $false) {
return "nightly-$(Get-Date -Format 'yyyyMMdd')"
}

function install_app($app, $architecture, $global, $suggested, $use_cache = $true, $check_hash = $true) {
function install_app($app, $architecture, $global, $suggested, $use_cache = $true, $check_hash = $true, $add_startmenu = $true) {
$app, $manifest, $bucket, $url = Get-Manifest $app

if (!$manifest) {
Expand Down Expand Up @@ -57,7 +57,9 @@ function install_app($app, $architecture, $global, $suggested, $use_cache = $tru
ensure_install_dir_not_in_path $dir $global
$dir = link_current $dir
create_shims $manifest $dir $global $architecture
create_startmenu_shortcuts $manifest $dir $global $architecture
if ($add_startmenu) {
create_startmenu_shortcuts $manifest $dir $global $architecture
}
install_psmodule $manifest $dir $global
env_add_path $manifest $dir $global $architecture
env_set $manifest $global $architecture
Expand All @@ -70,7 +72,7 @@ function install_app($app, $architecture, $global, $suggested, $use_cache = $tru

# save info for uninstall
save_installed_manifest $app $bucket $dir $url
save_install_info @{ 'architecture' = $architecture; 'url' = $url; 'bucket' = $bucket } $dir
save_install_info @{ 'architecture' = $architecture; 'url' = $url; 'bucket' = $bucket; 'no_add_startmenu' = !($add_startmenu) } $dir

if ($manifest.suggest) {
$suggested[$app] = $manifest.suggest
Expand Down
3 changes: 3 additions & 0 deletions libexec/scoop-import.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ foreach ($item in $import.apps) {
} elseif ('arm64' -in $info -and 'arm64' -ne $def_arch) {
$instArgs += '--arch', 'arm64'
}
if ('No start menu' -in $info) {
$instArgs += '--no-startmenu'
}

$app = if ($item.Source -in $bucket_names) {
"$($item.Source)/$($item.Name)"
Expand Down
6 changes: 4 additions & 2 deletions libexec/scoop-install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
# -i, --independent Don't install dependencies automatically
# -k, --no-cache Don't use the download cache
# -s, --skip-hash-check Skip hash validation (use with caution!)
# -m, --no-startmenu Don't add the shortcut to the startmenu
# -u, --no-update-scoop Don't update Scoop before installing if it's outdated
# -a, --arch <32bit|64bit|arm64> Use the specified architecture, if the app supports it

Expand All @@ -42,13 +43,14 @@ if (get_config USE_SQLITE_CACHE) {
. "$PSScriptRoot\..\lib\database.ps1"
}

$opt, $apps, $err = getopt $args 'giksua:' 'global', 'independent', 'no-cache', 'skip-hash-check', 'no-update-scoop', 'arch='
$opt, $apps, $err = getopt $args 'giksmua:' 'global', 'independent', 'no-cache', 'skip-hash-check', 'no-startmenu', 'no-update-scoop', 'arch='
if ($err) { "scoop install: $err"; exit 1 }

$global = $opt.g -or $opt.global
$check_hash = !($opt.s -or $opt.'skip-hash-check')
$independent = $opt.i -or $opt.independent
$use_cache = !($opt.k -or $opt.'no-cache')
$add_startmenu = !($opt.m -or $opt.'no-startmenu')
$architecture = Get-DefaultArchitecture
try {
$architecture = Format-ArchitectureString ($opt.a + $opt.arch)
Expand Down Expand Up @@ -131,7 +133,7 @@ if ((Test-Aria2Enabled) -and (get_config 'aria2-warning-enabled' $true)) {
warn "Should it cause issues, run 'scoop config aria2-enabled false' to disable it."
warn "To disable this warning, run 'scoop config aria2-warning-enabled false'."
}
$apps | ForEach-Object { install_app $_ $architecture $global $suggested $use_cache $check_hash }
$apps | ForEach-Object { install_app $_ $architecture $global $suggested $use_cache $check_hash $add_startmenu }

show_suggestions $suggested

Expand Down
1 change: 1 addition & 0 deletions libexec/scoop-list.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ $apps | Where-Object { !$query -or ($_.name -match $query) } | ForEach-Object {
if ($install_info.architecture -and $def_arch -ne $install_info.architecture) {
$info += $install_info.architecture
}
if ($install_info.no_add_startmenu) { $info += "No start menu" }
$item.Info = $info -join ', '

$list += [PSCustomObject]$item
Expand Down
4 changes: 3 additions & 1 deletion libexec/scoop-reset.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ $apps | ForEach-Object {

$dir = link_current $dir
create_shims $manifest $dir $global $architecture
create_startmenu_shortcuts $manifest $dir $global $architecture
if (!$install.no_add_startmenu){
create_startmenu_shortcuts $manifest $dir $global $architecture
}
# unset all potential old env before re-adding
env_rm_path $manifest $dir $global $architecture
env_rm $manifest $global $architecture
Expand Down
4 changes: 3 additions & 1 deletion libexec/scoop-uninstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ if (!$apps) { exit 0 }

Invoke-Installer -Path $dir -Manifest $manifest -ProcessorArchitecture $architecture -Uninstall
rm_shims $app $manifest $global $architecture
rm_startmenu_shortcuts $manifest $global $architecture
if (!$install.no_add_startmenu){
rm_startmenu_shortcuts $manifest $global $architecture
}

# If a junction was used during install, that will have been used
# as the reference directory. Otherwise it will just be the version
Expand Down
4 changes: 2 additions & 2 deletions libexec/scoop-update.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,12 @@ function update($app, $global, $quiet = $false, $independent, $suggested, $use_c
}

if ($independent) {
install_app $app $architecture $global $suggested $use_cache $check_hash
install_app $app $architecture $global $suggested $use_cache $check_hash ($True -ne $install.no_add_startmenu)
} else {
# Also add missing dependencies
$apps = @(Get-Dependency $app $architecture) -ne $app
ensure_none_failed $apps
$apps.Where({ !(installed $_) }) + $app | ForEach-Object { install_app $_ $architecture $global $suggested $use_cache $check_hash }
$apps.Where({ !(installed $_) }) + $app | ForEach-Object { install_app $_ $architecture $global $suggested $use_cache $check_hash ($True -ne $install.no_add_startmenu) }
}
}

Expand Down