Skip to content

Commit

Permalink
feature: Prepare extraction of main bucket (ScoopInstaller#3060)
Browse files Browse the repository at this point in the history
- Add preparing changes for extracting the main bucket to https://github.com/scoopinstaller/scoop-main
- Download main bucket on installation
- Add check_main_bucket function
- Add main bucket to buckets.json
- Add docker-compose.yml with default debugging image
- Remove old TODOs
- Refactor bucketdir -> Find-BucketDirectory
- Remove redundant .vscode settings
  • Loading branch information
Ash258 authored and Richard Kuhnt committed Apr 24, 2019
1 parent fa6ccc9 commit 56d54d1
Show file tree
Hide file tree
Showing 22 changed files with 182 additions and 107 deletions.
8 changes: 0 additions & 8 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 10 additions & 5 deletions bin/auto-pr.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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: <user>/<repo>:<branch>'
}
$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,
Expand Down
8 changes: 5 additions & 3 deletions bin/checkhashes.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,24 @@
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!"
} else {
$true
}
})]
[String] $Dir = "$PSScriptRoot\..\bucket",
[Alias('Path')]
[String] $Dir,
[Switch] $Update,
[Switch] $ForceUpdate,
[Switch] $SkipCorrect,
Expand Down
4 changes: 3 additions & 1 deletion bin/checkurls.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@
#>
param(
[String] $App = '*',
[Parameter(Mandatory = $true)]
[ValidateScript( {
if (!(Test-Path $_ -Type Container)) {
throw "$_ is not a directory!"
} else {
$true
}
})]
[String] $Dir = "$PSScriptRoot\\..\bucket",
[Alias('Path')]
[String] $Dir,
[Int] $Timeout = 5,
[Switch] $SkipValid
)
Expand Down
31 changes: 17 additions & 14 deletions bin/checkver.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 7 additions & 4 deletions bin/describe.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down
6 changes: 4 additions & 2 deletions bin/formatjson.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
26 changes: 20 additions & 6 deletions bin/install.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# requires -v 3
#Requires -Version 3

# remote install:
# iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
Expand Down Expand Up @@ -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
11 changes: 10 additions & 1 deletion bin/missing-checkver.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
2 changes: 1 addition & 1 deletion bin/scoop.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions buckets.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
11 changes: 0 additions & 11 deletions lib/autoupdate.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<#
TODO
- add a github release autoupdate type
- tests (single arch, without hashes etc.)
- clean up
#>
. "$psscriptroot\..\lib\json.ps1"
Expand Down Expand Up @@ -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)

Expand Down
Loading

0 comments on commit 56d54d1

Please sign in to comment.