cmder/scripts/pack.ps1

77 lines
2.1 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
#>
[CmdletBinding(SupportsShouldProcess=$true)]
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
# 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
$targets = @{
"cmder.7z" = "-t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on -myx=7 -mqs=on";
"cmder.zip" = "-mm=Deflate -mfb=128 -mpass=3";
2022-10-18 19:28:16 +08:00
"cmder_mini.zip" = "-xr!`"vendor\git-for-windows`"";
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..."
$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