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

fix: Adopt new installer #1

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
35 changes: 33 additions & 2 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ $org = 'shovelinstaller'
$image = "$org/shovel"
$scoopImage = "$org/scoop"

# --tag "${image}:nanoserver" `
# --tag "${image}:nanoserver-latest" `
# --tag "${image}:nanoserver-2004" `
docker build `
--build-arg 'IMAGE=powershell' `
--build-arg 'VERSION=nanoserver-2004' `
--build-arg 'POWERSHELL=pwsh.exe' `
--build-arg 'SKIP_ROBOCOPY=true' `
--file .\windows\Dockerfile `
--no-cache `
.

exit 0

## windows
### latest, windows, windows-latest, 20H2, windows-20H2
docker build `
Expand All @@ -20,13 +34,15 @@ docker build `
--no-cache `
.

exit 0

### 2009, windows-2009
docker build `
--tag "${image}:2009" `
--tag "${image}:windows-2009" `
--build-arg 'VERSION=2009' `
--no-cache `
--file .\windows\Dockerfile `
--no-cache `
.

### 2004, windows-2004
Expand All @@ -38,7 +54,8 @@ docker build `
--no-cache `
.

##servercore
## servercore
### windowsservercore, windowsservercore-latest, windowsservercore-2004
docker build `
--tag "${image}:windowsservercore" `
--tag "${image}:windowsservercore-latest" `
Expand All @@ -50,6 +67,7 @@ docker build `
--no-cache `
.

### windowsservercore-1909
docker build `
--tag "${image}:windowsservercore-1909" `
--build-arg 'IMAGE=powershell' `
Expand All @@ -59,6 +77,19 @@ docker build `
--no-cache `
.

### nanoserver, nanoserver-latest, nanoserver-2004
docker build `
--tag "${image}:nanoserver" `
--tag "${image}:nanoserver-latest" `
--tag "${image}:nanoserver-2004" `
--build-arg 'IMAGE=powershell' `
--build-arg 'VERSION=nanoserver-2004' `
--build-arg 'POWERSHELL=pwsh.exe' `
--build-arg 'SKIP_ROBOCOPY=1' `
--file .\windows\Dockerfile `
--no-cache `
.

## just scoop windows latest for some verification runs
docker build `
--tag "${scoopImage}:latest" `
Expand Down
8 changes: 6 additions & 2 deletions windows/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ LABEL org.label-schema.maintainer="Jakub 'Ash258' Čábera <cabera.jakub@gmail.c
org.label-schema.description='Shovel docker image' \
org.label-schema.url='https://github.com/Ash258/Scoop-Core'

USER ContainerAdministrator

ARG SCOOP_REPO='https://github.com/Ash258/Scoop-Core.git'
ARG SCOOP_BRANCH='main'
ARG POWERSHELL='powershell.exe'
ARG SKIP_ROBOCOPY='false'

ENV SCOOP='C:\SCOOP'
ENV SCOOP='C:\Shovel'
ENV SCOOP_GLOBAL='C:\ProgramData\Shovel'

COPY '.cache/*' 'C:/SCOOP/cache/'
COPY '.cache/*' 'C:/Shovel/cache/'
COPY 'windows/install.ps1' 'C:/'

RUN %POWERSHELL% -NoLogo -NonInteractive -Command "Set-ExecutionPolicy Bypass; & 'C:\install.ps1'; exit $LASTEXITCODE"
Expand Down
54 changes: 37 additions & 17 deletions windows/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,45 @@ Write-Host 'Starting installation' -ForegroundColor 'Green'
Set-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -Value 1

# Shovel installation
Write-Host 'Downloading installer' -ForegroundColor 'Green'

Invoke-WebRequest 'https://raw.githubusercontent.com/ScoopInstaller/Install/master/install.ps1' -OutFile "$env:TMP\install.ps1" -UseBasicParsing
& "$env:TMP\install.ps1" -RunAsAdmin
Get-ChildItem "${env:SCOOP}\shims" -Filter 'scoop.*' | Copy-Item -Destination { Join-Path $_.Directory.FullName (($_.BaseName -replace 'scoop', 'shovel') + $_.Extension) }

# Remove trash config options
shovel config rm 'rootPath'
$cc = "${env:SCOOP}\cache"
if (Test-Path -LiteralPath "${cc}\install.ps1" -PathType 'Leaf') {
Write-Host 'Using cached installer' -ForegroundColor 'Green'
Copy-Item "${cc}\install.ps1" "${env:TMP}\install.ps1"
} else {
Write-Host 'Downloading installer' -ForegroundColor 'Green'
Invoke-WebRequest 'https://raw.githubusercontent.com/shovel-org/Install/NEW/install.ps1' -OutFile "${env:TMP}\install.ps1" -UseBasicParsing
}

$installParams = @{
'ScoopDir' = $env:SCOOP
'ScoopGlobalDir' = $env:SCOOP_GLOBAL
'ScoopBranch' = 'robocopyConfig'
'SkipRobocopy' = ($env:SKIP_ROBOCOPY -ne 'false')
'InstallerCacheDir' = $cc
'RunAsAdmin' = $true
}
& "$env:TMP\install.ps1" @installParams

# Install dependencies and new powershell
Write-Host 'Installing crucial applications' -ForegroundColor 'Green'
shovel install --global 'lessmsi'
shovel config 'MSIEXTRACT_USE_LESSMSI' $true
shovel install --global '7zip' 'mingit' 'gsudo' 'innounp' 'dark' 'pwsh' 'zstd'
shovel config 'SCOOP_REPO' ${env:SCOOP_REPO}
shovel update
shovel config 'SCOOP_BRANCH' ${env:SCOOP_BRANCH}

shovel bucket add Base 'https://github.com/shovel-org/Base.git'
$pkgs = @('7zip', 'mingit', 'gsudo', 'innounp', 'dark', 'pwsh', 'zstd')
if ($env:POWERSHELL_DISTRIBUTION_CHANNEL -notlike '*nanoserver*') {
shovel install --global 'lessmsi'
} else {
$pkgs[0] = 'https://raw.githubusercontent.com/shovel-org/Base/7zip/bucket/7zip.json'
$pkgs = $pkgs -notlike 'pwsh'

# Nanoserver hacks
Write-Host 'Downloading alternative shim'
$shim = "${env:SCOOP}\apps\scoop\current\supporting\shimexe\bin\shim.exe"
Invoke-WebRequest -Uri 'https://raw.githubusercontent.com/ScoopInstaller/Scoop/5ad8c76dd7fd534ff7ed6e8e67d66e793293eab0/supporting/shims/rshim/shim.exe' -OutFile $shim -UseBasicParsing
New-Item "${env:SCOOP_GLOBAL}\shims" -ItemType 'Directory' -Force
Copy-Item $shim "${env:SCOOP_GLOBAL}\shims\powershell.exe"
Set-Content "${env:SCOOP_GLOBAL}\shims\powershell.shim" @'
path = pwsh.exe
'@
}
shovel install --global @pkgs

# Updates/migrations
shovel update
Expand All @@ -34,6 +54,6 @@ shovel status
# Cleanup
Write-Host 'Performing cleanup' -ForegroundColor 'Green'
shovel cache rm '*'
Remove-Item "$env:SCOOP\cache\*", "$env:TMP\*", "$env:TEMP\*" -ErrorAction 'SilentlyContinue' -Force -Recurse
Remove-Item "${env:SCOOP}\cache\*", "${env:TMP}\*", "${env:TEMP}\*" -ErrorAction 'SilentlyContinue' -Force -Recurse

exit 0