cmder/scripts/pack.ps1

106 lines
4.3 KiB
PowerShell
Raw Normal View History

2014-04-10 18:41:19 +08:00
<#
.Synopsis
Pack Cmder
2014-04-10 18:41:19 +08:00
.DESCRIPTION
Use this script to pack cmder into release archives
You will need to make this script executable by setting your Powershell Execution Policy to Remote signed
Then unblock the script for execution with UnblockFile .\pack.ps1
.EXAMPLE
.\pack.ps1
Creates default archives for cmder
.EXAMPLE
.\pack.ps1 -verbose
2014-04-10 18:41:19 +08:00
Creates default archives for cmder with plenty of information
.NOTES
AUTHORS
Samuel Vasko, Jack Bennett, Martin Kemp
2014-04-10 18:41:19 +08:00
Part of the Cmder project.
.LINK
https://github.com/cmderdev/cmder - Project Home
2014-04-10 18:41:19 +08:00
#>
2022-11-04 23:17:16 +08:00
[CmdletBinding(SupportsShouldProcess = $true)]
2014-04-10 18:41:19 +08:00
Param(
# CmdletBinding will give us;
# -verbose switch to turn on logging and
# -whatif switch to not actually make changes
# Path to the vendor configuration source file
[string]$cmderRoot = "$PSScriptRoot\..",
2014-04-10 18:41:19 +08:00
2023-11-23 22:07:32 +08:00
# Using this option will pack artifacts for a specific included terminal emulator [none, all, conemu-maximus5, or windows-terminal]
2023-11-23 20:10:59 +08:00
[string]$terminal = 'all',
2014-04-10 18:41:19 +08:00
# Vendor folder locaton
[string]$saveTo = "$PSScriptRoot\..\build"
2014-04-10 18:41:19 +08:00
)
2022-10-15 03:37:45 +08:00
$cmderRoot = Resolve-Path $cmderRoot
2014-04-10 18:41:19 +08:00
. "$PSScriptRoot\utils.ps1"
$ErrorActionPreference = "Stop"
2014-08-27 06:52:49 +08:00
Ensure-Executable "7z"
2014-04-10 18:41:19 +08:00
2023-11-23 22:07:32 +08:00
if ($terminal -eq "none") {
$targets = @{
2023-11-25 00:35:24 +08:00
"cmder_win.7z" = "-t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on -myx=7 -mqs=on -xr!`"vendor\conemu-maximus5`" -xr!`"vendor\windows-terminal`"";
"cmder_win.zip" = "-mm=Deflate -mfb=128 -mpass=3 -xr!`"vendor\conemu-maximus5`" -xr!`"vendor\windows-terminal`"";
"cmder_win.mini.zip" = "-xr!`"vendor\git-for-windows`" -xr!`"vendor\conemu-maximus5`" -xr!`"vendor\windows-terminal`"";
2023-11-23 22:07:32 +08:00
}
} elseif ($terminal -eq "windows-terminal") {
$targets = @{
2023-09-26 03:59:10 +08:00
"cmder_wt.7z" = "-t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on -myx=7 -mqs=on -xr!`"vendor\conemu-maximus5`"";
"cmder_wt.zip" = "-mm=Deflate -mfb=128 -mpass=3 -xr!`"vendor\conemu-maximus5`"";
"cmder_wt_mini.zip" = "-xr!`"vendor\git-for-windows`" -xr!`"vendor\conemu-maximus5`"";
}
2023-11-23 20:10:59 +08:00
} elseif ($terminal -eq "windows-terminal") {
2023-09-26 04:09:47 +08:00
$targets = @{
"cmder.7z" = "-t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on -myx=7 -mqs=on -xr!`"vendor\windows-terminal`"";
"cmder.zip" = "-mm=Deflate -mfb=128 -mpass=3 -xr!`"vendor\windows-terminal`"";
"cmder_mini.zip" = "-xr!`"vendor\git-for-windows`" -xr!`"vendor\windows-terminal`"";
}
} else {
$targets = @{
2023-11-25 00:35:24 +08:00
"cmder_win.7z" = "-t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on -myx=7 -mqs=on -xr!`"vendor\conemu-maximus5`" -xr!`"vendor\windows-terminal`"";
"cmder_win.zip" = "-mm=Deflate -mfb=128 -mpass=3 -xr!`"vendor\conemu-maximus5`" -xr!`"vendor\windows-terminal`"";
2023-11-25 01:04:03 +08:00
"cmder_win_mini.zip" = "-xr!`"vendor\git-for-windows`" -xr!`"vendor\conemu-maximus5`" -xr!`"vendor\windows-terminal`"";
2023-09-26 04:09:47 +08:00
"cmder_wt.7z" = "-t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on -myx=7 -mqs=on -xr!`"vendor\conemu-maximus5`"";
"cmder_wt.zip" = "-mm=Deflate -mfb=128 -mpass=3 -xr!`"vendor\conemu-maximus5`"";
"cmder_wt_mini.zip" = "-xr!`"vendor\git-for-windows`" -xr!`"vendor\conemu-maximus5`"";
2023-09-26 03:59:10 +08:00
"cmder.7z" = "-t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on -myx=7 -mqs=on -xr!`"vendor\windows-terminal`"";
"cmder.zip" = "-mm=Deflate -mfb=128 -mpass=3 -xr!`"vendor\windows-terminal`"";
"cmder_mini.zip" = "-xr!`"vendor\git-for-windows`" -xr!`"vendor\windows-terminal`"";
}
2014-04-10 18:41:19 +08:00
}
Push-Location -Path $cmderRoot
2022-10-15 06:14:21 +08:00
Delete-Existing "$cmderRoot\Version*"
Delete-Existing "$cmderRoot\build\*"
2014-04-10 19:11:41 +08:00
2022-10-16 20:43:26 +08:00
if (-not (Test-Path -PathType container $saveTo)) {
(New-Item -ItemType Directory -Path $saveTo) | Out-Null
}
$saveTo = Resolve-Path $saveTo
2018-03-31 02:53:44 +08:00
$version = Get-VersionStr
2014-04-10 20:42:20 +08:00
(New-Item -ItemType file "$cmderRoot\Version $version") | Out-Null
2014-04-10 18:41:19 +08:00
if ($PSCmdlet.MyInvocation.BoundParameters["Verbose"].IsPresent) {
Write-Verbose "Packing Cmder $version in $saveTo..."
2022-11-04 23:17:16 +08:00
$excluded = (Get-Content -Path "$cmderRoot\packignore") -Split [System.Environment]::NewLine | Where-Object { $_ }
2022-10-15 04:57:27 +08:00
Get-ChildItem $cmderRoot -Force -Exclude $excluded
}
2014-04-10 18:41:19 +08:00
foreach ($t in $targets.GetEnumerator()) {
Create-Archive "$cmderRoot" "$saveTo\$($t.Name)" $t.Value
2017-04-07 12:57:16 +08:00
$hash = (Digest-Hash "$saveTo\$($t.Name)")
2017-04-07 13:45:28 +08:00
Add-Content -path "$saveTo\hashes.txt" -value ($t.Name + ' ' + $hash)
}
Pop-Location