Skip to content

Commit 78cb999

Browse files
committed
Add Chocolatey package code
1 parent 26a35cc commit 78cb999

File tree

6 files changed

+145
-0
lines changed

6 files changed

+145
-0
lines changed

pkgs/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<h1 align=center>Configuration for Chocolatey</h1>
2+
3+
Official support for Chocolatey started by the release of Scala 3.6.0
4+
5+
> [!IMPORTANT]
6+
> This folder contains the templates to generate the configuration for Chocolatey.
7+
> The `scala.nuspec` and `chocolateyInstall.ps1` files needs to be rewritten by changing the following placeholders:
8+
> - @LAUNCHER_VERSION@ : Placeholder for the current scala version to deploy
9+
> - @LAUNCHER_URL@ : Placeholder for the URL to the windows zip released on GitHub
10+
11+
## Important information
12+
13+
- How to create a *Chocolatey* package: https://docs.chocolatey.org/en-us/create/create-packages/
14+
- Guidelines to follow for the package icon: https://docs.chocolatey.org/en-us/create/create-packages/#package-icon-guidelines
15+
- `.nuspec` format specification: https://learn.microsoft.com/en-gb/nuget/reference/nuspec

pkgs/chocolatey/README.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<h1 align=center>Configuration for Chocolatey</h1>
2+
3+
Official support for Chocolatey started by the release of Scala 3.6.0
4+
5+
> [!IMPORTANT]
6+
> This folder contains the templates to generate the configuration for Chocolatey.
7+
> The `scala.nuspec` and `chocolateyInstall.ps1` files needs to be rewritten by changing the following placeholders:
8+
> - @LAUNCHER_VERSION@ : Placeholder for the current scala version to deploy
9+
> - @LAUNCHER_URL@ : Placeholder for the URL to the windows zip released on GitHub
10+
> - @LAUNCHER_SHA256@ : Placeholder for the SHA256 of the msi file released on GitHub

pkgs/chocolatey/icon.svg

+30
Loading

pkgs/chocolatey/scala.nuspec

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
3+
<metadata>
4+
<id>scala</id>
5+
<version>@LAUNCHER_VERSION@</version>
6+
<title>Scala</title>
7+
<authors>scala</authors>
8+
<owners>scala</owners>
9+
<tags>scala</tags>
10+
<summary>Scala</summary>
11+
<description>Official release of the Scala Programming Language on Chocolatey.</description>
12+
<packageSourceUrl>https://github.com/scala/scala3/tree/main/pkgs/chocolatey</packageSourceUrl>
13+
<projectSourceUrl>https://github.com/scala/scala3</projectSourceUrl>
14+
<projectUrl>https://scala-lang.org/</projectUrl>
15+
<bugTrackerUrl>https://github.com/scala/scala3/issues</bugTrackerUrl>
16+
<copyright>© 2002-2024, LAMP/EPFL</copyright>
17+
<iconUrl>https://cdn.jsdelivr.net/gh/scala/scala3@version/pkgs/chocolatey/icon.svg</iconUrl>
18+
<licenseUrl>https://github.com/scala/scala3/blob/main/LICENSE</licenseUrl>
19+
<requireLicenseAcceptance>true</requireLicenseAcceptance>
20+
<releaseNotes>https://github.com/scala/scala3/releases</releaseNotes>
21+
</metadata>
22+
<files>
23+
<file src="tools\**" target="tools" />
24+
</files>
25+
</package>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
$ErrorActionPreference = 'Stop';
2+
3+
$unzipLocation = Split-Path -Parent $MyInvocation.MyCommand.Definition # Get the root of chocolatey folder
4+
$unzipLocation = Join-Path $unzipLocation "$($env:chocolateyPackageName)" # Append the package's name
5+
$unzipLocation = Join-Path $unzipLocation "$($env:chocolateyPackageVersion)" # Append the package's version
6+
7+
# Configure the installation arguments
8+
$packageArgs = @{
9+
packageName = 'scala'
10+
Url64 = '@LAUNCHER_URL@'
11+
UnzipLocation = $unzipLocation
12+
}
13+
14+
## In case we are running in the CI, add the authorisation header to fetch the zip
15+
## See: https://docs.github.com/en/rest/actions/artifacts?apiVersion=2022-11-28#download-an-artifact
16+
if ($env:DOTTY_CI_INSTALLATION) {
17+
Write-Host "Installing the Chocolatey package in Scala 3's CI"
18+
$packageArgs += @{
19+
Options = @{
20+
Headers = @{
21+
Accept = 'application/vnd.github+json'
22+
Authorization = "Bearer $env:DOTTY_CI_INSTALLATION"
23+
}
24+
}
25+
}
26+
}
27+
28+
Install-ChocolateyZipPackage @packageArgs
29+
30+
# Find the path to the bin directory to create the shims
31+
if($env:DOTTY_CI_INSTALLATION) {
32+
$scalaBinPath = Join-Path $unzipLocation 'bin' # Update this path if the structure inside the ZIP changes
33+
} else {
34+
$extractedDir = Get-ChildItem -Path $unzipLocation | Where-Object { $_.PSIsContainer } | Select-Object -First 1
35+
$scalaBinPath = Join-Path $unzipLocation $extractedDir | Join-Path -ChildPath 'bin'
36+
}
37+
38+
# Iterate through the .bat files in the bin directory and create shims
39+
Write-Host "Creating shims for .bat file from $scalaBinPath"
40+
Get-ChildItem -Path $scalaBinPath -Filter '*.bat' | ForEach-Object {
41+
$file = $_.FullName
42+
Write-Host "Creating shim for $file..."
43+
Install-BinFile -Name $_.BaseName -Path $file
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
$ErrorActionPreference = 'Stop';
2+
3+
$unzipLocation = Split-Path -Parent $MyInvocation.MyCommand.Definition # Get the root of chocolatey folder
4+
$unzipLocation = Join-Path $unzipLocation "$($env:chocolateyPackageName)" # Append the package's name
5+
$unzipLocation = Join-Path $unzipLocation "$($env:chocolateyPackageVersion)" # Append the package's version
6+
7+
# Find the path to the bin directory to create the shims
8+
if($env:DOTTY_CI_INSTALLATION) {
9+
$scalaBinPath = Join-Path $unzipLocation 'bin' # Update this path if the structure inside the ZIP changes
10+
} else {
11+
$extractedDir = Get-ChildItem -Path $unzipLocation | Where-Object { $_.PSIsContainer } | Select-Object -First 1
12+
$scalaBinPath = Join-Path $unzipLocation $extractedDir | Join-Path -ChildPath 'bin'
13+
}
14+
15+
# Iterate through the .bat files in the bin directory and remove shims
16+
Write-Host "Removing shims for .bat file from $scalaBinPath"
17+
Get-ChildItem -Path $scalaBinPath -Filter '*.bat' | ForEach-Object {
18+
$file = $_.FullName
19+
Write-Host "Removing shim for $file..."
20+
Uninstall-BinFile -Name $_.BaseName -Path $file
21+
}

0 commit comments

Comments
 (0)