diff --git a/.vscode/settings.json b/.vscode/settings.json index 9e8244717d..666210a98a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,14 +8,6 @@ "powershell.codeFormatting.preset": "OTBS", "powershell.codeFormatting.alignPropertyValuePairs": true, "powershell.codeFormatting.ignoreOneLineBlock": true, - "json.schemas": [ - { - "url": "https://raw.githubusercontent.com/lukesampson/scoop/master/schema.json", - "fileMatch": [ - "bucket/*.json" - ] - } - ], "files.exclude": { "**/.git": true, "**/.svn": true, diff --git a/bin/auto-pr.ps1 b/bin/auto-pr.ps1 index c15b70cf94..e662e07700 100644 --- a/bin/auto-pr.ps1 +++ b/bin/auto-pr.ps1 @@ -22,27 +22,32 @@ .PARAMETER SkipUpdated Updated manifests will not be shown. .EXAMPLE - PS REPODIR > .\bin\auto-pr.ps1 'someUsername/repository:branch' -Request + PS BUCKETROOT > .\bin\auto-pr.ps1 'someUsername/repository:branch' -Request .EXAMPLE - PS REPODIR > .\bin\auto-pr.ps1 -Push + PS BUCKETROOT > .\bin\auto-pr.ps1 -Push Update all manifests inside 'bucket/' directory. #> + param( + [Parameter(Mandatory = $true)] [ValidateScript( { if (!($_ -match '^(.*)\/(.*):(.*)$')) { throw 'Upstream must be in this format: /:' } $true })] - [String] $Upstream = 'lukesampson/scoop:master', + [String] $Upstream, [String] $App = '*', + [Parameter(Mandatory = $true)] [ValidateScript( { if (!(Test-Path $_ -Type Container)) { throw "$_ is not a directory!" + } else { + $true } - $true })] - [String] $Dir = "$PSScriptRoot\..\bucket", + [Alias('Path')] + [String] $Dir, [Switch] $Push, [Switch] $Request, [Switch] $Help, diff --git a/bin/checkhashes.ps1 b/bin/checkhashes.ps1 index d03c2e0549..03c591ebbd 100644 --- a/bin/checkhashes.ps1 +++ b/bin/checkhashes.ps1 @@ -16,14 +16,15 @@ Downloaded files will not be deleted after script finish. Should not be used, because check should be used for downloading actual version of file (as normal user, not finding in some document from vendors, which could be damaged / wrong (Example: Slack@3.3.1 lukesampson/scoop-extras#1192)), not some previously downloaded. .EXAMPLE - PS BUCKETDIR> .\bin\checkhashes.ps1 + PS BUCKETROOT> .\bin\checkhashes.ps1 Check all manifests for hash mismatch. .EXAMPLE - PS BUCKETDIR> .\bin\checkhashes.ps1 MANIFEST -Update + PS BUCKETROOT> .\bin\checkhashes.ps1 MANIFEST -Update Check MANIFEST and Update if there are some wrong hashes. #> param( [String] $App = '*', + [Parameter(Mandatory = $true)] [ValidateScript( { if (!(Test-Path $_ -Type Container)) { throw "$_ is not a directory!" @@ -31,7 +32,8 @@ param( $true } })] - [String] $Dir = "$PSScriptRoot\..\bucket", + [Alias('Path')] + [String] $Dir, [Switch] $Update, [Switch] $ForceUpdate, [Switch] $SkipCorrect, diff --git a/bin/checkurls.ps1 b/bin/checkurls.ps1 index 883a4f55ad..222dc382b7 100644 --- a/bin/checkurls.ps1 +++ b/bin/checkurls.ps1 @@ -13,6 +13,7 @@ #> param( [String] $App = '*', + [Parameter(Mandatory = $true)] [ValidateScript( { if (!(Test-Path $_ -Type Container)) { throw "$_ is not a directory!" @@ -20,7 +21,8 @@ param( $true } })] - [String] $Dir = "$PSScriptRoot\\..\bucket", + [Alias('Path')] + [String] $Dir, [Int] $Timeout = 5, [Switch] $SkipValid ) diff --git a/bin/checkver.ps1 b/bin/checkver.ps1 index 500668e79a..53e5198b13 100644 --- a/bin/checkver.ps1 +++ b/bin/checkver.ps1 @@ -16,49 +16,52 @@ .PARAMETER SkipUpdated Updated manifests will not be shown. .EXAMPLE - PS BUCKETDIR > .\bin\checkver.ps1 + PS BUCKETROOT > .\bin\checkver.ps1 Check all manifest inside default directory. .EXAMPLE - PS BUCKETDIR > .\bin\checkver.ps1 -s + PS BUCKETROOT > .\bin\checkver.ps1 -s Check all manifest inside default directory (list only outdated manifests). .EXAMPLE - PS BUCKETDIR > .\bin\checkver.ps1 -u + PS BUCKETROOT > .\bin\checkver.ps1 -u Check all manifests and update All outdated manifests. .EXAMPLE - PS BUCKETDIR > .\bin\checkver.ps1 MAN + PS BUCKETROOT > .\bin\checkver.ps1 MAN Check manifest MAN.json inside default directory. .EXAMPLE - PS BUCKETDIR > .\bin\checkver.ps1 MAN -u + PS BUCKETROOT > .\bin\checkver.ps1 MAN -u Check manifest MAN.json and update, if there is newer version. .EXAMPLE - PS BUCKETDIR > .\bin\checkver.ps1 MAN -f + PS BUCKETROOT > .\bin\checkver.ps1 MAN -f Check manifest MAN.json and update, even if there is no new version. .EXAMPLE - PS BUCKETDIR > .\bin\checkver.ps1 MAN -u -v VER + PS BUCKETROOT > .\bin\checkver.ps1 MAN -u -v VER Check manifest MAN.json and update, using version VER .EXAMPLE - PS BUCKETDIR > .\bin\checkver.ps1 MAN DIR + PS BUCKETROOT > .\bin\checkver.ps1 MAN DIR Check manifest MAN.json inside ./DIR directory. .EXAMPLE - PS BUCKETDIR > .\bin\checkver.ps1 -Dir DIR + PS BUCKETROOT > .\bin\checkver.ps1 -Dir DIR Check all manifests inside ./DIR directory. .EXAMPLE - PS BUCKETDIR > .\bin\checkver.ps1 MAN DIR -u - Check manifest MAN.json inside ./DIR directory and update if there is newer version. + PS BUCKETROOT > .\bin\checkver.ps1 MAN DIR -u + Check manifest MAN.json inside ./DIR directory and update if there is newer version. #> param( [String] $App = '*', + [Parameter(Mandatory = $true)] [ValidateScript( { if (!(Test-Path $_ -Type Container)) { throw "$_ is not a directory!" + } else { + $true } - $true })] - [String] $Dir = "$psscriptroot\..\bucket", + [Alias('Path')] + [String] $Dir, [Switch] $Update, [Switch] $ForceUpdate, [Switch] $SkipUpdated, - [String] $Version = "" + [String] $Version = '' ) . "$psscriptroot\..\lib\core.ps1" diff --git a/bin/describe.ps1 b/bin/describe.ps1 index 272f61c128..4c029e4f45 100644 --- a/bin/describe.ps1 +++ b/bin/describe.ps1 @@ -9,13 +9,16 @@ #> param( [String] $App = '*', + [Parameter(Mandatory = $true)] [ValidateScript( { if (!(Test-Path $_ -Type Container)) { throw "$_ is not a directory!" + } else { + $true } - $true })] - [String] $Dir = "$PSScriptRoot\..\bucket" + [Alias('Path')] + [String] $Dir ) . "$PSScriptRoot\..\lib\core.ps1" @@ -34,7 +37,7 @@ $Queue | ForEach-Object { $name, $manifest = $_ Write-Host "$name`: " -NoNewline - if(!$manifest.homepage) { + if (!$manifest.homepage) { Write-Host "`nNo homepage set." -ForegroundColor Red return } @@ -49,7 +52,7 @@ $Queue | ForEach-Object { } $description, $descr_method = find_description $manifest.homepage $home_html - if(!$description) { + if (!$description) { Write-Host "`nDescription not found ($($manifest.homepage))" -ForegroundColor Red return } diff --git a/bin/formatjson.ps1 b/bin/formatjson.ps1 index c178451eeb..469825b9ae 100644 --- a/bin/formatjson.ps1 +++ b/bin/formatjson.ps1 @@ -16,14 +16,16 @@ #> param( [String] $App = '*', + [Parameter(Mandatory = $true)] [ValidateScript( { if (!(Test-Path $_ -Type Container)) { throw "$_ is not a directory!" + } else { + $true } - $true })] [Alias('Path')] - [String] $Dir = "$PSScriptRoot\..\bucket" + [String] $Dir ) . "$PSScriptRoot\..\lib\core.ps1" diff --git a/bin/install.ps1 b/bin/install.ps1 index 00fd18f62e..dbc44d54ae 100644 --- a/bin/install.ps1 +++ b/bin/install.ps1 @@ -1,4 +1,4 @@ -# requires -v 3 +#Requires -Version 3 # remote install: # iex (new-object net.webclient).downloadstring('https://get.scoop.sh') @@ -42,23 +42,37 @@ $dir = ensure (versiondir 'scoop' 'current') # download scoop zip $zipurl = 'https://github.com/lukesampson/scoop/archive/master.zip' $zipfile = "$dir\scoop.zip" -Write-Output 'Downloading...' +Write-Output 'Downloading scoop...' dl $zipurl $zipfile -'Extracting...' +Write-Output 'Extracting...' Add-Type -Assembly "System.IO.Compression.FileSystem" [IO.Compression.ZipFile]::ExtractToDirectory($zipfile,"$dir\_tmp") -Copy-Item "$dir\_tmp\scoop-master\*" $dir -r -force -Remove-Item "$dir\_tmp" -r -force -Remove-Item $zipfile +Copy-Item "$dir\_tmp\*master\*" $dir -Recurse -Force +Remove-Item "$dir\_tmp", $zipfile -Recurse -Force Write-Output 'Creating shim...' shim "$dir\bin\scoop.ps1" $false +# download main bucket +$dir = "$scoopdir\buckets\main" +$zipurl = 'https://github.com/scoopinstaller/scoop-main/archive/master.zip' +$zipfile = "$dir\main-bucket.zip" +Write-Output 'Downloading main bucket...' +New-Item $dir -Type Directory -Force | Out-Null +dl $zipurl $zipfile + +Write-Output 'Extracting...' +[IO.Compression.ZipFile]::ExtractToDirectory($zipfile, "$dir\_tmp") +Copy-Item "$dir\_tmp\*-master\*" $dir -Recurse -Force +Remove-Item "$dir\_tmp", $zipfile -Recurse -Force + ensure_robocopy_in_path ensure_scoop_in_path + scoop config lastupdate ([System.DateTime]::Now.ToString('o')) success 'Scoop was installed successfully!' + Write-Output "Type 'scoop help' for instructions." $erroractionpreference = $old_erroractionpreference # Reset $erroractionpreference to original value diff --git a/bin/missing-checkver.ps1 b/bin/missing-checkver.ps1 index 99e04cd472..129b9a73ae 100644 --- a/bin/missing-checkver.ps1 +++ b/bin/missing-checkver.ps1 @@ -11,7 +11,16 @@ #> param( [String] $App = '*', - [String] $Dir = "$PSScriptRoot\..\bucket", + [Parameter(Mandatory = $true)] + [ValidateScript( { + if (!(Test-Path $_ -Type Container)) { + throw "$_ is not a directory!" + } else { + $true + } + })] + [Alias('Path')] + [String] $Dir, [Switch] $SkipSupported ) diff --git a/bin/scoop.ps1 b/bin/scoop.ps1 index 1d7662cefd..9d8aacdf90 100644 --- a/bin/scoop.ps1 +++ b/bin/scoop.ps1 @@ -20,7 +20,7 @@ if ('--version' -contains $cmd -or (!$cmd -and '-v' -contains $args)) { Pop-Location Get-LocalBucket | ForEach-Object { - Push-Location $(bucketdir $_) + Push-Location (Find-BucketDirectory $_ -Root) if(test-path '.git') { write-host "'$_' bucket:" git_log --oneline HEAD -n 1 diff --git a/buckets.json b/buckets.json index 88f2dbf020..a59f4715e6 100644 --- a/buckets.json +++ b/buckets.json @@ -1,4 +1,5 @@ { + "main": "https://github.com/scoopinstaller/scoop-main", "extras": "https://github.com/lukesampson/scoop-extras", "versions": "https://github.com/scoopinstaller/versions", "nightlies": "https://github.com/scoopinstaller/nightlies", diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000..6480e7e541 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +version: '3.6' + +services: + scoop: + image: microsoft/windowsservercore:1803 + container_name: scoop_debug + command: powershell.exe -NoLogo -NoExit + working_dir: C:\SCOOP\apps\scoop\current\bin + environment: + SCOOP: C:\SCOOP + SCOOP_HOME: C:\SCOOP\apps\scoop\current + volumes: + - .:C:\SCOOP\apps\scoop\current diff --git a/lib/autoupdate.ps1 b/lib/autoupdate.ps1 index aab6efde21..64842d549b 100644 --- a/lib/autoupdate.ps1 +++ b/lib/autoupdate.ps1 @@ -1,7 +1,5 @@ <# TODO - - add a github release autoupdate type - - tests (single arch, without hashes etc.) - clean up #> . "$psscriptroot\..\lib\json.ps1" @@ -141,15 +139,6 @@ function find_hash_in_headers([String] $url) { function get_hash_for_app([String] $app, $config, [String] $version, [String] $url, [Hashtable] $substitutions) { $hash = $null - <# - TODO implement more hashing types - `extract` Should be able to extract from origin page source - `sourceforge` Default `extract` method for sf.net - `metalink` Default `extract` method for metalink - `json` Find hash from JSONPath - `rdf` Find hash from a RDF Xml file - `download` Last resort, download the real file and hash it - #> $hashmode = $config.mode $basename = url_remote_filename($url) diff --git a/lib/buckets.ps1 b/lib/buckets.ps1 index 54462e6e79..1a7d02f230 100644 --- a/lib/buckets.ps1 +++ b/lib/buckets.ps1 @@ -2,30 +2,42 @@ $bucketsdir = "$scoopdir\buckets" -<# -.DESCRIPTION - Return full path for bucket with given name. - Main bucket will be returned as default. -.PARAMETER name - Name of bucket -#> -function bucketdir($name) { - $bucket = relpath '..\bucket' # main bucket +function Find-BucketDirectory { + <# + .DESCRIPTION + Return full path for bucket with given name. + Main bucket will be returned as default. + .PARAMETER Name + Name of bucket. + .PARAMETER Root + Root folder of bucket repository will be returned instead of 'bucket' subdirectory (if exists). + #> + param( + [string] $Name = 'main', + [switch] $Root + ) - if ($name) { - $bucket = "$bucketsdir\$name" - } - if (Test-Path "$bucket\bucket") { + # Handle info passing empty string as bucket ($install.bucket) + if(($null -eq $Name) -or ($Name -eq '')) { $Name = 'main' } + $bucket = "$bucketsdir\$Name" + + if ((Test-Path "$bucket\bucket") -and !$Root) { $bucket = "$bucket\bucket" } return $bucket } +function bucketdir($name) { + Show-DeprecatedWarning $MyInvocation 'Find-BucketDirectory' + + return Find-BucketDirectory $name +} + function known_bucket_repos { - $dir = versiondir 'scoop' 'current' - $json = "$dir\buckets.json" - Get-Content $json -raw | convertfrom-json -ea stop + $json = "$PSScriptRoot\..\buckets.json" + + return Get-Content $json -raw | convertfrom-json -ea stop } function known_bucket_repo($name) { @@ -47,9 +59,7 @@ function Get-LocalBucket { List all local buckets. #> - if (Test-Path $bucketsdir) { - return (Get-ChildItem $bucketsdir).Name - } + return (Get-ChildItem $bucketsdir).Name } function buckets { @@ -65,8 +75,7 @@ function find_manifest($app, $bucket) { return $null } - $buckets = @($null) + @(Get-LocalBucket) # null for main bucket - foreach($bucket in $buckets) { + foreach($bucket in Get-LocalBucket) { $manifest = manifest $app $bucket if($manifest) { return $manifest, $bucket } } @@ -84,7 +93,7 @@ function add_bucket($name, $repo) { abort "Git is required for buckets. Run 'scoop install git'." } - $dir = bucketdir $name + $dir = Find-BucketDirectory $name -Root if (test-path $dir) { warn "The '$name' bucket already exists. Use 'scoop bucket rm $name' to remove it." exit 0 @@ -105,7 +114,7 @@ function add_bucket($name, $repo) { function rm_bucket($name) { if (!$name) { " missing"; $usage_rm; exit 1 } - $dir = "$bucketsdir\$name" + $dir = Find-BucketDirectory $name -Root if (!(test-path $dir)) { abort "'$name' bucket not found." } @@ -116,10 +125,9 @@ function rm_bucket($name) { function new_issue_msg($app, $bucket, $title, $body) { $app, $manifest, $bucket, $url = Find-Manifest $app $bucket $url = known_bucket_repo $bucket - $bucket_path = "$bucketsdir\$bucket" if($manifest -and ($null -eq $url) -and ($null -eq $bucket)) { - $url = 'https://github.com/lukesampson/scoop' + $url = 'https://github.com/scoopinstaller/scoop-main' } elseif (Test-path $bucket_path) { Push-Location $bucket_path $remote = git_config --get remote.origin.url diff --git a/lib/diagnostic.ps1 b/lib/diagnostic.ps1 index 676d0b871e..0d70881fc7 100644 --- a/lib/diagnostic.ps1 +++ b/lib/diagnostic.ps1 @@ -3,7 +3,7 @@ Diagnostic tests. Return $true if the test passed, otherwise $false. Use 'warn' to highlight the issue, and follow up with the recommended actions to rectify. #> - +. "$PSScriptRoot\buckets.ps1" function check_windows_defender($global) { $defender = get-service -name WinDefend -errorAction SilentlyContinue @@ -27,3 +27,14 @@ function check_windows_defender($global) { } return $true } + +function check_main_bucket { + if ((Get-LocalBucket) -notcontains 'main'){ + warn 'Main bucket is not added.' + Write-Host " run 'scoop bucket add main'" + + return $false + } + + return $true +} diff --git a/lib/git.ps1 b/lib/git.ps1 index 5d3ff06eb9..efa706f1f7 100644 --- a/lib/git.ps1 +++ b/lib/git.ps1 @@ -15,6 +15,14 @@ function git_ls_remote { git_proxy_cmd ls-remote $args } +function git_checkout { + git_proxy_cmd checkout $args +} + +function git_branch { + git_proxy_cmd branch $args +} + function git_pull { git_proxy_cmd pull $args } diff --git a/lib/manifest.ps1 b/lib/manifest.ps1 index da3b5c9b80..4e68b4a799 100644 --- a/lib/manifest.ps1 +++ b/lib/manifest.ps1 @@ -2,7 +2,7 @@ . "$psscriptroot/autoupdate.ps1" function manifest_path($app, $bucket) { - fullpath "$(bucketdir $bucket)\$(sanitary_path $app).json" + fullpath "$(Find-BucketDirectory $bucket)\$(sanitary_path $app).json" } function parse_json($path) { diff --git a/libexec/scoop-checkup.ps1 b/libexec/scoop-checkup.ps1 index 84f6780ea3..c03a0ccba2 100644 --- a/libexec/scoop-checkup.ps1 +++ b/libexec/scoop-checkup.ps1 @@ -10,6 +10,7 @@ $issues = 0 $issues += !(check_windows_defender $false) $issues += !(check_windows_defender $true) +$issues += !(check_main_bucket) $globaldir = New-Object System.IO.DriveInfo($globaldir) if($globaldir.DriveFormat -ne 'NTFS') { diff --git a/libexec/scoop-install.ps1 b/libexec/scoop-install.ps1 index 2b768a55fc..fc283dcc72 100644 --- a/libexec/scoop-install.ps1 +++ b/libexec/scoop-install.ps1 @@ -4,13 +4,11 @@ # scoop install git # # To install an app from a manifest at a URL: -# scoop install https://raw.githubusercontent.com/lukesampson/scoop/master/bucket/runat.json +# scoop install https://raw.githubusercontent.com/scoopinstaller/scoop-main/master/bucket/runat.json # # To install an app from a manifest on your computer # scoop install \path\to\app.json # -# When installing from your computer, you can leave the .json extension off if you like. -# # Options: # -g, --global Install the app globally # -i, --independent Don't install dependencies automatically @@ -34,14 +32,14 @@ reset_aliases function is_installed($app, $global) { - if($app.EndsWith('.json')) { + if ($app.EndsWith('.json')) { $app = [System.IO.Path]::GetFileNameWithoutExtension($app) } - if(installed $app $global) { - function gf($g) { if($g) { ' --global' } } + if (installed $app $global) { + function gf($g) { if ($g) { ' --global' } } $version = @(versions $app $global)[-1] - if(!(install_info $app $version $global)) { + if (!(install_info $app $version $global)) { error "It looks like a previous installation of $app failed.`nRun 'scoop uninstall $app$(gf $global)' before retrying the install." } warn "'$app' ($version) is already installed.`nUse 'scoop update $app$(gf $global)' to install a new version." @@ -51,7 +49,7 @@ function is_installed($app, $global) { } $opt, $apps, $err = getopt $args 'gfiksa:' 'global', 'force', 'independent', 'no-cache', 'skip', 'arch=' -if($err) { "scoop install: $err"; exit 1 } +if ($err) { "scoop install: $err"; exit 1 } $global = $opt.g -or $opt.global $check_hash = !($opt.s -or $opt.skip) @@ -64,19 +62,19 @@ try { abort "ERROR: $_" } -if(!$apps) { error ' missing'; my_usage; exit 1 } +if (!$apps) { error ' missing'; my_usage; exit 1 } -if($global -and !(is_admin)) { +if ($global -and !(is_admin)) { abort 'ERROR: you need admin rights to install global apps' } -if(is_scoop_outdated) { +if (is_scoop_outdated) { scoop update } -if($apps.length -eq 1) { +if ($apps.length -eq 1) { $app, $null, $null = parse_app $apps - if(is_installed $app $global) { + if (is_installed $app $global) { return } } @@ -108,21 +106,21 @@ $apps = @(($specific_versions_paths + $difference) | Where-Object { $_ } | Sort- # differentiate after dependencies are added $explicit_apps = $apps -if(!$independent) { +if (!$independent) { $apps = install_order $apps $architecture # adds dependencies } ensure_none_failed $apps $global $apps, $skip = prune_installed $apps $global -$skip | Where-Object { $explicit_apps -contains $_} | ForEach-Object { +$skip | Where-Object { $explicit_apps -contains $_ } | ForEach-Object { $app, $null, $null = parse_app $_ $version = @(versions $app $global)[-1] warn "'$app' ($version) is already installed. Skipping." } -$suggested = @{}; -if(aria2_enabled) { +$suggested = @{ }; +if (aria2_enabled) { warn "Scoop uses 'aria2c' for multi-connection downloads." warn "Should it cause issues, run 'scoop config aria2-enabled false' to disable it." } diff --git a/libexec/scoop-list.ps1 b/libexec/scoop-list.ps1 index 31ee3ca491..10ff736f85 100644 --- a/libexec/scoop-list.ps1 +++ b/libexec/scoop-list.ps1 @@ -31,7 +31,7 @@ if($apps) { if (!$install_info) { Write-Host ' *failed*' -ForegroundColor DarkRed -NoNewline } - if ($install_info.bucket) { + if ($install_info.bucket -and ($install_info.bucket -ne 'main')) { write-host -f Yellow " [$($install_info.bucket)]" -NoNewline } elseif ($install_info.url) { write-host -f Yellow " [$($install_info.url)]" -NoNewline diff --git a/libexec/scoop-search.ps1 b/libexec/scoop-search.ps1 index f03be63c0c..5ec6a8a014 100644 --- a/libexec/scoop-search.ps1 +++ b/libexec/scoop-search.ps1 @@ -26,7 +26,7 @@ function bin_match($manifest, $query) { } function search_bucket($bucket, $query) { - $apps = apps_in_bucket (bucketdir $bucket) | ForEach-Object { + $apps = apps_in_bucket (Find-BucketDirectory $bucket) | ForEach-Object { @{ name = $_ } } @@ -80,7 +80,7 @@ function search_remotes($query) { $buckets = known_bucket_repos $names = $buckets | get-member -m noteproperty | Select-Object -exp name - $results = $names | Where-Object { !(test-path $(bucketdir $_)) } | ForEach-Object { + $results = $names | Where-Object { !(test-path $(Find-BucketDirectory $_)) } | ForEach-Object { @{"bucket" = $_; "results" = (search_remote $_ $query)} } | Where-Object { $_.results } @@ -97,14 +97,13 @@ function search_remotes($query) { } } -@($null) + @(Get-LocalBucket) | ForEach-Object { +Get-LocalBucket | ForEach-Object { $res = search_bucket $_ $query $local_results = $local_results -or $res if($res) { $name = "$_" - if(!$_) { $name = "main" } - "'$name' bucket:" + Write-Host "'$name' bucket:" $res | ForEach-Object { $item = " $($_.name) ($($_.version))" if($_.bin) { $item += " --> includes '$($_.bin)'" } diff --git a/libexec/scoop-update.ps1 b/libexec/scoop-update.ps1 index 4efc437ebb..c3b79e14c4 100644 --- a/libexec/scoop-update.ps1 +++ b/libexec/scoop-update.ps1 @@ -97,12 +97,24 @@ function update_scoop() { } } + if ((Get-LocalBucket) -notcontains 'main') { + add_bucket 'main' + } + ensure_scoop_in_path shim "$currentdir\bin\scoop.ps1" $false Get-LocalBucket | ForEach-Object { write-host "Updating '$_' bucket..." - Push-Location (bucketdir $_) + + $loc = Find-BucketDirectory $_ -Root + # Make sure main bucket, which was downloaded as zip, will be properly "converted" into git + if (($_ -eq 'main') -and !(Test-Path "$loc\.git")) { + rm_bucket 'main' + add_bucket 'main' + } + + Push-Location $loc git_pull -q if($show_update_log) { git_log --no-decorate --date=local --since="`"$last_update`"" --format="`"tformat: * %C(yellow)%h%Creset %<|(72,trunc)%s %C(cyan)%cr%Creset`"" HEAD @@ -122,6 +134,9 @@ function update($app, $global, $quiet = $false, $independent, $suggested, $use_c # re-use architecture, bucket and url from first install $architecture = ensure_architecture $install.architecture $bucket = $install.bucket + if ($null -eq $bucket) { + $bucket = 'main' + } $url = $install.url if(!$independent) {