-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Getting the build script to a working state #157
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,103 @@ | ||
<# | ||
Samuel Vasko | ||
Part of Cmder project | ||
This script builds dependencies from current vendor/sources.json | ||
file and unpacks them. | ||
#> | ||
.Synopsis | ||
Build Cmder | ||
.DESCRIPTION | ||
Use this script to build your own edition of Cmder | ||
|
||
# Configs | ||
$sourcesPath = "..\vendor\sources.json" | ||
$saveTo = "..\vendor\" | ||
# ------- | ||
This script builds dependencies from current vendor/sources.json file and unpacks them. | ||
|
||
# Check for requirements | ||
Ensure-Exists $sourcesPath | ||
Ensure-Executable "7z" | ||
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 .\build.ps1 | ||
.EXAMPLE | ||
.\build.ps1 | ||
|
||
$sources = Get-Content $sourcesPath | ConvertTo-Json | ||
Executes the default build for cmder, this is equivalent to the "minimum" style package in the releases | ||
.EXAMPLE | ||
.\build -verbose | ||
|
||
foreach ($s in $sources) { | ||
$ext = $s.url.Split('.')[-1] | ||
Delete-Existing $saveTo + $($s.name) | ||
Delete-Existing $saveTo + $($s.name) + "." + $ext | ||
|
||
Write-Host "-- Downloading $($s.name) --" | ||
New-Object System.Net.WebClient | ||
$wc.DownloadFile($s.url, "..\vendor\" + $s.name + "." + $ext) | ||
Invoke-Item "7z x " + $s.name + "." + $ex | ||
if ($LastExitCode != 0) { | ||
Write-Error "Failied to extract " + $s.name; | ||
exit 1 | ||
} | ||
} | ||
Execute the build and see what's going on. | ||
.EXAMPLE | ||
.\build.ps1 -SourcesPath '~/custom/vendors.json' | ||
|
||
Write-Host "All good and done!" | ||
Build cmder with your own packages. See vendor/sources.json for the syntax you need to copy. | ||
.NOTES | ||
AUTHORS | ||
Samuel Vasko, Jack Bennett | ||
Part of the Cmder project. | ||
.LINK | ||
https://github.com/bliker/cmder - Project Home | ||
#> | ||
[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]$sourcesPath = "..\vendor\sources.json" | ||
|
||
, # Vendor folder locaton | ||
[string]$saveTo = "..\vendor\" | ||
) | ||
|
||
function Ensure-Exists ($item) { | ||
if (!Test-Path $item) { | ||
Write-Error "Missing required $($item) file" | ||
if (-not (Test-Path $item)) { | ||
Write-Error "Missing required $item file" | ||
exit 1 | ||
} | ||
} | ||
function Ensure-Executable ($command) { | ||
try { Get-Command $command -ErrorAction Stop > $null} | ||
catch{ | ||
Write-Error "Missing $command! Ensure it is installed and on in the PATH" | ||
exit 1 | ||
} | ||
} | ||
function Delete-Existing ($name) { | ||
Write-Verbose "Change directory to $($name.path)" | ||
Push-Location -Path $name.path | ||
|
||
function Delete-Existing ($item) { | ||
if (Test-Path $item) { Remove-Item $item } | ||
Write-Verbose "Remove $($name.name)" | ||
Remove-Item -Recurse -force $name.name -ErrorAction SilentlyContinue | ||
|
||
Pop-Location | ||
} | ||
|
||
function Ensure-Executable ($command) { | ||
if (!Get-Command $command) { | ||
Write-Error "Missing $($command)! Ensure it is installed and on in the PATH" | ||
exit 1 | ||
function Expand-Download{ | ||
[CmdletBinding()] | ||
Param( | ||
[psobject]$name | ||
) | ||
Push-Location -Path $name.path | ||
Write-Verbose "Extract $($name.package)" | ||
|
||
# As if 7-zip doesn't have a silent output option. Append > `&null to the end to silence it. | ||
# Also silences the error output | ||
Invoke-Expression "7z x -y -o$($name.name) $($name.package)" | ||
|
||
Write-Verbose "Delete downloaded archive: $($name.package)" | ||
Remove-Item $name.package | ||
|
||
Pop-Location | ||
} | ||
|
||
# Check for requirements | ||
Ensure-Exists $sourcesPath | ||
Ensure-Executable "7z" | ||
|
||
$sources = Get-Content $sourcesPath | Out-String | Convertfrom-Json | ||
|
||
foreach ($s in $sources) { | ||
$s | Add-Member -MemberType NoteProperty -Name 'path' -Value $saveTo | ||
if( -not $s.package){ | ||
$filename = $s.name + '.' + $s.url.Split('.')[-1] | ||
$s | Add-Member -MemberType NoteProperty -Name 'package' -Value $filename | ||
} | ||
} | ||
Write-Verbose "URL $($s.url) has package $($s.package)" | ||
|
||
Delete-Existing $s | ||
Invoke-WebRequest -Uri $s.url -OutFile "H:\src\cmder\vendor\$($s.package)" | ||
Expand-download $s -ErrorAction SilentlyContinue | ||
} | ||
|
||
Write-Host "All good and done!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we somehow avoid this? The link I used was nice, but as you changed it I guess b/c it does not allow hot linking.
Could we possibly just name the download the archive, name it
conemu-maximus5.zip
(or justconemu-maximus5
). I am pretty sure 7z only cares about archive metadata/headers. That way we can avoid caring about the extension and filename and this field will be unnecessary.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah without hotlinking it's fairly useless.
You can name that package key whatever you want if you set it, otherwise the script pulls the
name
and url extension together sets that as the package, and carries on.