From b30056c4b3e6dc0184d9e6ff2deeb17d33a61aaa Mon Sep 17 00:00:00 2001 From: Samuel Vasko Date: Mon, 24 Feb 2014 17:33:14 +0100 Subject: [PATCH 01/19] First draft of new build script --- scripts/build.ps1 | 52 +++++++++++++++++++++++++++++++++++++++++++++++ scripts/pack.ps1 | 0 2 files changed, 52 insertions(+) create mode 100644 scripts/build.ps1 create mode 100644 scripts/pack.ps1 diff --git a/scripts/build.ps1 b/scripts/build.ps1 new file mode 100644 index 0000000..b7c8e8a --- /dev/null +++ b/scripts/build.ps1 @@ -0,0 +1,52 @@ +<# + Samuel Vasko + Part of Cmder project + This script builds dependencies from current vendor/sources.json + file and unpacks them. +#> + +# Configs +$sourcesPath = "..\vendor\sources.json" +$saveTo = "..\vendor\" +# ------- + +# Check for requirements +Ensure-Exists $sourcesPath +Ensure-Executable "7z" + +$sources = Get-Content $sourcesPath | ConvertTo-Json + +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 + } +} + +Write-Host "All good and done!" + +function Ensure-Exists ($item) { + if (!Test-Path $item) { + Write-Error "Missing required $($item) file" + exit 1 + } +} + +function Delete-Existing ($item) { + if (Test-Path $item) { Remove-Item $item } +} + +function Ensure-Executable ($command) { + if (!Get-Command $command) { + Write-Error "Missing $($command)! Ensure it is installed and on in the PATH" + exit 1 + } +} \ No newline at end of file diff --git a/scripts/pack.ps1 b/scripts/pack.ps1 new file mode 100644 index 0000000..e69de29 From 83cd726a4169cd2d81b0ed505cbb0c70e0362527 Mon Sep 17 00:00:00 2001 From: Samuel Vasko Date: Mon, 24 Feb 2014 17:55:34 +0100 Subject: [PATCH 02/19] First sources.json draft --- .gitignore | 2 ++ vendor/sources.json | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 vendor/sources.json diff --git a/.gitignore b/.gitignore index 323fe88..8719d1c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ vendor/* !vendor/*.md !vendor/*.bat +!vendor/*.json + config/.history Thumbs.db *.exe diff --git a/vendor/sources.json b/vendor/sources.json new file mode 100644 index 0000000..ad69df5 --- /dev/null +++ b/vendor/sources.json @@ -0,0 +1,17 @@ +[ + { + "name": "msysgit", + "version": "1.9.0-preview", + "url": "https://msysgit.googlecode.com/files/PortableGit-1.9.0-preview20140217.7z" + }, + { + "name": "clink", + "version": "0.4", + "url": "https://github.com/mridgers/clink/releases/download/0.4/clink_0.4.zip" + }, + { + "name": "conemu-maximus5", + "version": "140124", + "url": "http://www.fosshub.com/download/ConEmuPack.140124.7z" + } +] \ No newline at end of file From 3bd0fe517f7ea83a892c03dde9f7907deedb5afe Mon Sep 17 00:00:00 2001 From: Jack Bennett Date: Wed, 26 Feb 2014 16:41:30 +0000 Subject: [PATCH 03/19] Need to use an optional `package` field; incase url's that don't put the file in the url. --- vendor/sources.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vendor/sources.json b/vendor/sources.json index ad69df5..73dd7e0 100644 --- a/vendor/sources.json +++ b/vendor/sources.json @@ -12,6 +12,7 @@ { "name": "conemu-maximus5", "version": "140124", - "url": "http://www.fosshub.com/download/ConEmuPack.140124.7z" + "url": "http://conemu.codeplex.com/downloads/get/782952", + "package": "ConEmuPack.140124.7z" } ] \ No newline at end of file From b4a264b1bc2242d45b940d4d77f8049a4eb9da90 Mon Sep 17 00:00:00 2001 From: Jack Bennett Date: Wed, 26 Feb 2014 16:46:23 +0000 Subject: [PATCH 04/19] This commit amends far more than I would have liked to. working script will; Remove existing folders named in the sources Download the packages listed in sources.json Extracts the above packages deletes the downloaded package --- scripts/build.ps1 | 129 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 90 insertions(+), 39 deletions(-) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index b7c8e8a..72ec6de 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -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. + + 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 + + Executes the default build for cmder, this is equivalent to the "minimum" style package in the releases +.EXAMPLE + .\build -verbose + + Execute the build and see what's going on. +.EXAMPLE + .\build.ps1 -SourcesPath '~/custom/vendors.json' + + 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 (-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 + + Write-Verbose "Remove $($name.name)" + Remove-Item -Recurse -force $name.name -ErrorAction SilentlyContinue + + Pop-Location +} + +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 | ConvertTo-Json +$sources = Get-Content $sourcesPath | Out-String | Convertfrom-Json 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 + $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!" - -function Ensure-Exists ($item) { - if (!Test-Path $item) { - Write-Error "Missing required $($item) file" - exit 1 - } -} - -function Delete-Existing ($item) { - if (Test-Path $item) { Remove-Item $item } -} - -function Ensure-Executable ($command) { - if (!Get-Command $command) { - Write-Error "Missing $($command)! Ensure it is installed and on in the PATH" - exit 1 - } -} \ No newline at end of file From 6a761a88c1a704a9485ebe9e6da2cb7631da1743 Mon Sep 17 00:00:00 2001 From: Samuel Vasko Date: Sun, 2 Mar 2014 22:00:04 +0100 Subject: [PATCH 05/19] Adjusted the build script behavior Removed some absolute path, and refactored the code so it handles the nested folder archives --- scripts/build.ps1 | 56 +++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 72ec6de..abc255c 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -29,10 +29,10 @@ #> [CmdletBinding(SupportsShouldProcess=$true)] Param( - # CmdletBinding will give us; + # 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" @@ -46,6 +46,7 @@ function Ensure-Exists ($item) { exit 1 } } + function Ensure-Executable ($command) { try { Get-Command $command -ErrorAction Stop > $null} catch{ @@ -53,51 +54,54 @@ function Ensure-Executable ($command) { exit 1 } } -function Delete-Existing ($name) { - Write-Verbose "Change directory to $($name.path)" - Push-Location -Path $name.path - Write-Verbose "Remove $($name.name)" - Remove-Item -Recurse -force $name.name -ErrorAction SilentlyContinue - - Pop-Location +function Delete-Existing ($path) { + Write-Verbose "Remove $path" + Remove-Item -Recurse -force $path -ErrorAction SilentlyContinue } function Expand-Download{ [CmdletBinding()] Param( - [psobject]$name + [psobject]$package ) - Push-Location -Path $name.path - Write-Verbose "Extract $($name.package)" + Write-Verbose "Extract $($package.name).tmp" # 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 + Write-Verbose "Delete downloaded archive: $($package.package)" + Remove-Item $package.package } # Check for requirements Ensure-Exists $sourcesPath Ensure-Executable "7z" +Push-Location -Path $saveTo $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)" + Write-Verbose "Getting $($s.name) from URL $($s.url)" + + # We do not care about the extensions/type of archive + $tempArchive = "$($s.name).tmp" + Delete-Existing $tempArchive + Delete-Existing $s.name + + Invoke-WebRequest -Uri $s.url -OutFile $tempArchive + Invoke-Expression "7z x -y -o$($s.name) $tempArchive" + Remove-Item $tempArchive + + # Check for archives that were not extracted correctly + if ((Get-Childitem $s.name).Count -eq 1) { + $child = (Get-Childitem $s.name)[0] + Rename-Item $s.name -NewName "$($s.name)_moving" + Move-Item -Path "$($s.name)_moving\$child" -Destination $s.name + Remove-Item -Recurse "$($s.name)_moving" + } - Delete-Existing $s - Invoke-WebRequest -Uri $s.url -OutFile "H:\src\cmder\vendor\$($s.package)" - Expand-download $s -ErrorAction SilentlyContinue } +Pop-Location Write-Host "All good and done!" From 0314ee5d46b9c8f5cf50af136acb2ff1e010deae Mon Sep 17 00:00:00 2001 From: Samuel Vasko Date: Sun, 2 Mar 2014 22:04:58 +0100 Subject: [PATCH 06/19] Removed unused function --- scripts/build.ps1 | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index abc255c..1d06914 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -60,20 +60,6 @@ function Delete-Existing ($path) { Remove-Item -Recurse -force $path -ErrorAction SilentlyContinue } -function Expand-Download{ - [CmdletBinding()] - Param( - [psobject]$package - ) - Write-Verbose "Extract $($package.name).tmp" - - # As if 7-zip doesn't have a silent output option. Append > `&null to the end to silence it. - # Also silences the error output - - Write-Verbose "Delete downloaded archive: $($package.package)" - Remove-Item $package.package -} - # Check for requirements Ensure-Exists $sourcesPath Ensure-Executable "7z" From f4b6d8f9a88b8ffa67d5a109a062bd0805a9a520 Mon Sep 17 00:00:00 2001 From: Samuel Vasko Date: Wed, 5 Mar 2014 11:22:58 +0100 Subject: [PATCH 07/19] Refactored mail download loop, better error handling --- scripts/build.ps1 | 21 ++++++++++++++------- vendor/sources.json | 3 +-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 1d06914..6a7891d 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -60,6 +60,17 @@ function Delete-Existing ($path) { Remove-Item -Recurse -force $path -ErrorAction SilentlyContinue } +# Check for archives that were not extracted correctly +# when the folder contains another folder +function Flatten-Directory ($name) { + $child = (Get-Childitem $name)[0] + Rename-Item $name -NewName "$($name)_moving" + Move-Item -Path "$($name)_moving\$child" -Destination $name + Remove-Item -Recurse "$($name)_moving" +} + +$ErrorActionPreference = "Stop" + # Check for requirements Ensure-Exists $sourcesPath Ensure-Executable "7z" @@ -68,23 +79,19 @@ Push-Location -Path $saveTo $sources = Get-Content $sourcesPath | Out-String | Convertfrom-Json foreach ($s in $sources) { - Write-Verbose "Getting $($s.name) from URL $($s.url)" + Write-Host "Getting $($s.name) from URL $($s.url)" # We do not care about the extensions/type of archive $tempArchive = "$($s.name).tmp" Delete-Existing $tempArchive Delete-Existing $s.name - Invoke-WebRequest -Uri $s.url -OutFile $tempArchive + Invoke-WebRequest -Uri $s.url -OutFile $tempArchive -ErrorAction Stop Invoke-Expression "7z x -y -o$($s.name) $tempArchive" Remove-Item $tempArchive - # Check for archives that were not extracted correctly if ((Get-Childitem $s.name).Count -eq 1) { - $child = (Get-Childitem $s.name)[0] - Rename-Item $s.name -NewName "$($s.name)_moving" - Move-Item -Path "$($s.name)_moving\$child" -Destination $s.name - Remove-Item -Recurse "$($s.name)_moving" + Flatten-Directory($s.name) } } diff --git a/vendor/sources.json b/vendor/sources.json index 73dd7e0..57aa1e3 100644 --- a/vendor/sources.json +++ b/vendor/sources.json @@ -12,7 +12,6 @@ { "name": "conemu-maximus5", "version": "140124", - "url": "http://conemu.codeplex.com/downloads/get/782952", - "package": "ConEmuPack.140124.7z" + "url": "https://conemu.codeplex.com/downloads/get/782952" } ] \ No newline at end of file From 4c1f96c51daec2f45f8996664b2553e39e41bfda Mon Sep 17 00:00:00 2001 From: Samuel Vasko Date: Sun, 2 Mar 2014 22:00:04 +0100 Subject: [PATCH 08/19] Adjusted the build script behavior Removed some absolute path, and refactored the code so it handles the nested folder archives --- scripts/build.ps1 | 56 +++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 72ec6de..abc255c 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -29,10 +29,10 @@ #> [CmdletBinding(SupportsShouldProcess=$true)] Param( - # CmdletBinding will give us; + # 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" @@ -46,6 +46,7 @@ function Ensure-Exists ($item) { exit 1 } } + function Ensure-Executable ($command) { try { Get-Command $command -ErrorAction Stop > $null} catch{ @@ -53,51 +54,54 @@ function Ensure-Executable ($command) { exit 1 } } -function Delete-Existing ($name) { - Write-Verbose "Change directory to $($name.path)" - Push-Location -Path $name.path - Write-Verbose "Remove $($name.name)" - Remove-Item -Recurse -force $name.name -ErrorAction SilentlyContinue - - Pop-Location +function Delete-Existing ($path) { + Write-Verbose "Remove $path" + Remove-Item -Recurse -force $path -ErrorAction SilentlyContinue } function Expand-Download{ [CmdletBinding()] Param( - [psobject]$name + [psobject]$package ) - Push-Location -Path $name.path - Write-Verbose "Extract $($name.package)" + Write-Verbose "Extract $($package.name).tmp" # 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 + Write-Verbose "Delete downloaded archive: $($package.package)" + Remove-Item $package.package } # Check for requirements Ensure-Exists $sourcesPath Ensure-Executable "7z" +Push-Location -Path $saveTo $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)" + Write-Verbose "Getting $($s.name) from URL $($s.url)" + + # We do not care about the extensions/type of archive + $tempArchive = "$($s.name).tmp" + Delete-Existing $tempArchive + Delete-Existing $s.name + + Invoke-WebRequest -Uri $s.url -OutFile $tempArchive + Invoke-Expression "7z x -y -o$($s.name) $tempArchive" + Remove-Item $tempArchive + + # Check for archives that were not extracted correctly + if ((Get-Childitem $s.name).Count -eq 1) { + $child = (Get-Childitem $s.name)[0] + Rename-Item $s.name -NewName "$($s.name)_moving" + Move-Item -Path "$($s.name)_moving\$child" -Destination $s.name + Remove-Item -Recurse "$($s.name)_moving" + } - Delete-Existing $s - Invoke-WebRequest -Uri $s.url -OutFile "H:\src\cmder\vendor\$($s.package)" - Expand-download $s -ErrorAction SilentlyContinue } +Pop-Location Write-Host "All good and done!" From c661b1f300f059674d679da6e9c0ebcc89d0c3b2 Mon Sep 17 00:00:00 2001 From: Samuel Vasko Date: Sun, 2 Mar 2014 22:04:58 +0100 Subject: [PATCH 09/19] Removed unused function --- scripts/build.ps1 | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index abc255c..1d06914 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -60,20 +60,6 @@ function Delete-Existing ($path) { Remove-Item -Recurse -force $path -ErrorAction SilentlyContinue } -function Expand-Download{ - [CmdletBinding()] - Param( - [psobject]$package - ) - Write-Verbose "Extract $($package.name).tmp" - - # As if 7-zip doesn't have a silent output option. Append > `&null to the end to silence it. - # Also silences the error output - - Write-Verbose "Delete downloaded archive: $($package.package)" - Remove-Item $package.package -} - # Check for requirements Ensure-Exists $sourcesPath Ensure-Executable "7z" From 5243d8bb8d1fb437019754e30934fac7568d41b2 Mon Sep 17 00:00:00 2001 From: Jack Bennett Date: Wed, 5 Mar 2014 13:28:18 +0000 Subject: [PATCH 10/19] In powershell you pretty much never want to use Write-Host, its output can't be redirected along the pipeline. You couldn't pipe this output to a logfile. --- scripts/build.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 6a7891d..863cd18 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -79,7 +79,7 @@ Push-Location -Path $saveTo $sources = Get-Content $sourcesPath | Out-String | Convertfrom-Json foreach ($s in $sources) { - Write-Host "Getting $($s.name) from URL $($s.url)" + Write-Output "Getting $($s.name) from URL $($s.url)" # We do not care about the extensions/type of archive $tempArchive = "$($s.name).tmp" @@ -97,4 +97,4 @@ foreach ($s in $sources) { } Pop-Location -Write-Host "All good and done!" +Write-Output "All good and done!" \ No newline at end of file From b0b8eaef1ea0a6350cc596cd3cbfd44f4b00b7da Mon Sep 17 00:00:00 2001 From: Samuel Vasko Date: Wed, 5 Mar 2014 14:31:01 +0100 Subject: [PATCH 11/19] Error checking for 7z extraction --- scripts/build.ps1 | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 6a7891d..6c8094b 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -48,8 +48,8 @@ function Ensure-Exists ($item) { } function Ensure-Executable ($command) { - try { Get-Command $command -ErrorAction Stop > $null} - catch{ + try { Get-Command $command -ErrorAction Stop > $null } + catch { Write-Error "Missing $command! Ensure it is installed and on in the PATH" exit 1 } @@ -69,6 +69,14 @@ function Flatten-Directory ($name) { Remove-Item -Recurse "$($name)_moving" } +function Extract-Archive ($source, $target) { + Invoke-Expression "7z x -y -o$($target) $source" + if ($lastexitcode -ne 0) { + Write-Error "Extracting of $source failied" + } + Remove-Item $source +} + $ErrorActionPreference = "Stop" # Check for requirements @@ -87,8 +95,7 @@ foreach ($s in $sources) { Delete-Existing $s.name Invoke-WebRequest -Uri $s.url -OutFile $tempArchive -ErrorAction Stop - Invoke-Expression "7z x -y -o$($s.name) $tempArchive" - Remove-Item $tempArchive + Extract-Archive $tempArchive $s.name if ((Get-Childitem $s.name).Count -eq 1) { Flatten-Directory($s.name) From a9bfd2d2a268e8812c1489a47f3ae6c355dafd72 Mon Sep 17 00:00:00 2001 From: Jack Bennett Date: Wed, 5 Mar 2014 14:00:35 +0000 Subject: [PATCH 12/19] Silencing the output from 7z so I can actually see what else the script is doing. Adding some clearer dubugging info for cleaning up folders --- scripts/build.ps1 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 863cd18..465a784 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -56,8 +56,13 @@ function Ensure-Executable ($command) { } function Delete-Existing ($path) { - Write-Verbose "Remove $path" + Write-Verbose "Removing $path in $(get-location)" Remove-Item -Recurse -force $path -ErrorAction SilentlyContinue + if(test-path $path -IsValid){ + Write-Verbose " Removed: $true" + } else { + Write-Verbose " Removed: $false" + } } # Check for archives that were not extracted correctly @@ -87,7 +92,7 @@ foreach ($s in $sources) { Delete-Existing $s.name Invoke-WebRequest -Uri $s.url -OutFile $tempArchive -ErrorAction Stop - Invoke-Expression "7z x -y -o$($s.name) $tempArchive" + Invoke-Expression "7z x -y -o$($s.name) $tempArchive > `$null" Remove-Item $tempArchive if ((Get-Childitem $s.name).Count -eq 1) { From e1c60104ba5c2db3133c47c493d3a0d857f9d932 Mon Sep 17 00:00:00 2001 From: Samuel Vasko Date: Thu, 10 Apr 2014 12:41:19 +0200 Subject: [PATCH 13/19] Updated build and pack Powershell --- scripts/build.ps1 | 52 ++++++++--------------------------------------- scripts/pack.ps1 | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 44 deletions(-) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 6c8094b..a7787bd 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -27,6 +27,7 @@ .LINK https://github.com/bliker/cmder - Project Home #> + [CmdletBinding(SupportsShouldProcess=$true)] Param( # CmdletBinding will give us; @@ -34,58 +35,22 @@ Param( # -whatif switch to not actually make changes # Path to the vendor configuration source file - [string]$sourcesPath = "..\vendor\sources.json" + [string]$sourcesPath = "..\vendor\sources.json", - , # Vendor folder locaton + # Vendor folder locaton [string]$saveTo = "..\vendor\" ) -function Ensure-Exists ($item) { - 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 ($path) { - Write-Verbose "Remove $path" - Remove-Item -Recurse -force $path -ErrorAction SilentlyContinue -} - -# Check for archives that were not extracted correctly -# when the folder contains another folder -function Flatten-Directory ($name) { - $child = (Get-Childitem $name)[0] - Rename-Item $name -NewName "$($name)_moving" - Move-Item -Path "$($name)_moving\$child" -Destination $name - Remove-Item -Recurse "$($name)_moving" -} - -function Extract-Archive ($source, $target) { - Invoke-Expression "7z x -y -o$($target) $source" - if ($lastexitcode -ne 0) { - Write-Error "Extracting of $source failied" - } - Remove-Item $source -} - +. "$PSScriptRoot\utils.ps1" $ErrorActionPreference = "Stop" +Push-Location -Path $saveTo +$sources = Get-Content $sourcesPath | Out-String | Convertfrom-Json + # Check for requirements Ensure-Exists $sourcesPath Ensure-Executable "7z" -Push-Location -Path $saveTo -$sources = Get-Content $sourcesPath | Out-String | Convertfrom-Json - foreach ($s in $sources) { Write-Host "Getting $($s.name) from URL $($s.url)" @@ -100,8 +65,7 @@ foreach ($s in $sources) { if ((Get-Childitem $s.name).Count -eq 1) { Flatten-Directory($s.name) } - } Pop-Location -Write-Host "All good and done!" +Write-Host "All good and done!" \ No newline at end of file diff --git a/scripts/pack.ps1 b/scripts/pack.ps1 index e69de29..2e1bf1a 100644 --- a/scripts/pack.ps1 +++ b/scripts/pack.ps1 @@ -0,0 +1,52 @@ +<# +.Synopsis + Pack cmder +.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 + .\build -verbose + + Creates default archives for cmder with plenty of information +.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]$cmderRoot = "..", + + # Vendor folder locaton + [string]$saveTo = "." +) + +. "$PSScriptRoot\utils.ps1" +$ErrorActionPreference = "Stop" + +$targets = @{ + "cmder.zip" = $null; + "cmder.7z" = $null; + "cmder_mini.zip" = "-x!`"..\vendor\msysgit`""; +} + +$version = Invoke-Expression "git describe --abbrev=0 --tags" +New-Item -ItemType file "$cmderRoot\Version $version" + +foreach ($t in $targets.GetEnumerator()) { + Create-Archive $cmderRoot "$saveTo\$($t.Name)" $t.Value +} \ No newline at end of file From 46bebee94c421d78ba84762b1c8b698d7390e805 Mon Sep 17 00:00:00 2001 From: Samuel Vasko Date: Thu, 10 Apr 2014 12:57:45 +0200 Subject: [PATCH 14/19] More recent package versions --- vendor/sources.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vendor/sources.json b/vendor/sources.json index 57aa1e3..e54c415 100644 --- a/vendor/sources.json +++ b/vendor/sources.json @@ -6,12 +6,12 @@ }, { "name": "clink", - "version": "0.4", - "url": "https://github.com/mridgers/clink/releases/download/0.4/clink_0.4.zip" + "version": "0.4.1", + "url": "https://github.com/mridgers/clink/releases/download/0.4.1/clink_0.4.1.zip" }, { "name": "conemu-maximus5", - "version": "140124", - "url": "https://conemu.codeplex.com/downloads/get/782952" + "version": "140404", + "url": "https://conemu.codeplex.com/downloads/get/823971" } ] \ No newline at end of file From db49c14422506b19aedd3eb34b7c4458ece2792d Mon Sep 17 00:00:00 2001 From: Samuel Vasko Date: Thu, 10 Apr 2014 13:11:25 +0200 Subject: [PATCH 15/19] Fixed paths --- packignore | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/packignore b/packignore index 08205c4..726c5b4 100644 --- a/packignore +++ b/packignore @@ -1,8 +1,9 @@ -cmder\launcher -cmder\icons -cmder\.gitignore -cmder\.gitattributes -cmder\.git -cmder\*.rb -cmder\packignore -cmder\Cmder.bat \ No newline at end of file +launcher +icons +.gitignore +.gitattributes +.git +*.rb +build +packignore +Cmder.bat \ No newline at end of file From b9379b3ae2e567f9423233b69b1da5c167e8d895 Mon Sep 17 00:00:00 2001 From: Samuel Vasko Date: Thu, 10 Apr 2014 13:11:41 +0200 Subject: [PATCH 16/19] Computing hashes --- scripts/pack.ps1 | 8 ++++++-- scripts/utils.ps1 | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/pack.ps1 b/scripts/pack.ps1 index 2e1bf1a..71e2329 100644 --- a/scripts/pack.ps1 +++ b/scripts/pack.ps1 @@ -32,7 +32,7 @@ Param( [string]$cmderRoot = "..", # Vendor folder locaton - [string]$saveTo = "." + [string]$saveTo = "..\build" ) . "$PSScriptRoot\utils.ps1" @@ -41,12 +41,16 @@ $ErrorActionPreference = "Stop" $targets = @{ "cmder.zip" = $null; "cmder.7z" = $null; - "cmder_mini.zip" = "-x!`"..\vendor\msysgit`""; + "cmder_mini.zip" = "-x!`"vendor\msysgit`""; } +Delete-Existing "..\Version*" + $version = Invoke-Expression "git describe --abbrev=0 --tags" New-Item -ItemType file "$cmderRoot\Version $version" foreach ($t in $targets.GetEnumerator()) { Create-Archive $cmderRoot "$saveTo\$($t.Name)" $t.Value + $hash = (Digest-MD5 "$saveTo\$($t.Name)") + Add-Content "$saveTo\hashes.txt" $hash } \ No newline at end of file diff --git a/scripts/utils.ps1 b/scripts/utils.ps1 index a7f016f..36fdcd6 100644 --- a/scripts/utils.ps1 +++ b/scripts/utils.ps1 @@ -42,4 +42,8 @@ function Flatten-Directory ($name) { Rename-Item $name -NewName "$($name)_moving" Move-Item -Path "$($name)_moving\$child" -Destination $name Remove-Item -Recurse "$($name)_moving" +} + +function Digest-MD5 ($path) { + return Invoke-Expression "md5sum $path" } \ No newline at end of file From 8e676b3fc7f19b4ed21917bfa0b3cc56fac0344c Mon Sep 17 00:00:00 2001 From: Samuel Vasko Date: Thu, 10 Apr 2014 13:12:38 +0200 Subject: [PATCH 17/19] Added history files --- packignore | 1 + 1 file changed, 1 insertion(+) diff --git a/packignore b/packignore index 726c5b4..12d1d29 100644 --- a/packignore +++ b/packignore @@ -5,5 +5,6 @@ icons .git *.rb build +config\.history packignore Cmder.bat \ No newline at end of file From d5d8b0944bf9af62b46a1043a82d53efd1a2e10c Mon Sep 17 00:00:00 2001 From: Samuel Vasko Date: Thu, 10 Apr 2014 13:13:20 +0200 Subject: [PATCH 18/19] Removed old ruby scripts --- build.rb | 110 ------------------------------------------------------- pack.rb | 40 -------------------- 2 files changed, 150 deletions(-) delete mode 100644 build.rb delete mode 100644 pack.rb diff --git a/build.rb b/build.rb deleted file mode 100644 index 7665541..0000000 --- a/build.rb +++ /dev/null @@ -1,110 +0,0 @@ -# Samuel Vasko 2013 -# Cmder build script -# Like really a beta -# -# This script downloads dependencies form google code. Each software is extracted -# in a folder with same name as the project on google code. So Conemu becomes -# conemu-maximus5. Correct files are beeing picked by using labels. -# I will move the script for getting files by labels from php to here as soon I feel like it - -require 'fileutils' -require 'open-uri' -require 'uri' - -def get_file project, query - urlToFile = URI.escape('http://samuelvasko.tk/gcode/?project='+project+'&query='+query) - open(urlToFile) do |resp| - urlToFile = URI.escape(resp.read.split(/\r?\n/).first) - end - - extension = urlToFile.split('.').last - filename = project+'.'+extension - - puts "\n ------ Downloading #{project} from #{urlToFile} ------- \n \n" - begin - open(urlToFile, 'rb') do |infile| - open(filename, 'wb') do |outfile| - outfile.write(infile.read) - end - end - rescue IOError => error - puts error - FileUtils.rm(filename) if File.exists?(filename) - exit(1) - end - - system("7z x -o\"#{project}\" #{filename}") - - File.unlink(project+"."+extension); - - # When the folder contains another folder - # that is not what we want - if Dir.glob("#{project}/*").length == 1 - temp_name = "#{project}_temp" - FileUtils.mv(project, temp_name) - FileUtils.mv(Dir.glob("#{temp_name}/*")[0], project) - FileUtils.rm_r(temp_name) - end -end - -def find_on_path exe - path = ENV['PATH'].split(File::PATH_SEPARATOR) - for dir in path - if File.exists?(File.join(dir, exe)) - return true - end - end - - return false -end - -puts ' -______ _ _ _ _ _ -| ___ \ (_) | | (_) | | -| |_/ /_ _ _| | __| |_ _ __ __ _ ___ _ __ ___ __| | ___ _ __ -| ___ \ | | | | |/ _` | | \'_ \ / _` | / __| \'_ ` _ \ / _` |/ _ \ \'__| -| |_/ / |_| | | | (_| | | | | | (_| | | (__| | | | | | (_| | __/ | -\____/ \__,_|_|_|\__,_|_|_| |_|\__, | \___|_| |_| |_|\__,_|\___|_| - __/ | - |___/ -' - -unless find_on_path('7z.exe') - puts '7z.exe not found. Ensure 7-zip is installed and on the PATH.' - exit(1) -end - -build_exe = true -unless find_on_path('msbuild.exe') - puts 'msbuild.exe not found. We need that to build the executable.' - puts 'Do you want to continue? [Y/n]' - build_exe = false - exit(1) unless gets.chomp.downcase == 'y' -end - -puts 'Cleanup' - -if Dir.exists?('vendor') - Dir.glob('vendor/*') { |file| FileUtils.rm_rf(file) if File.directory?(file) } -end - -Dir.chdir('vendor') - -puts 'Getting files' - -get_file('clink', 'label:Type-Archive label:Featured') -get_file('conemu-maximus5', 'label:Type-Archive label:Preview label:Featured') -get_file('msysgit', 'label:Type-Archive label:Featured') - -puts 'Creating executable' - -if build_exe - Dir.chdir('../launcher') - status = system('msbuild /p:Configuration=Release') - unless status - puts 'Looks like the build failied' - exit(1) - end -end - -puts 'Done, bye' diff --git a/pack.rb b/pack.rb deleted file mode 100644 index e93d800..0000000 --- a/pack.rb +++ /dev/null @@ -1,40 +0,0 @@ -# Samuel Vasko 2013 -# Cmder packing script -- Creates zip files for relase - -require "fileutils" - -def create_archive name, exclude - if exclude - exclude = " -x!cmder\\" + exclude - else - exclude = "" - end - system('ls') - puts "Running 7z a -x@cmder\\packignore" + exclude + " " + name + " cmder" - system("7z a -x@cmder\\packignore" + exclude + " " + name + " cmder") -end - -targets = [ - ["cmder.zip"], - ["cmder.7z"], - ["cmder_mini.zip", "vendor\\msysgit"] -] - -unless system("git describe --abbrev=0 --tags") - puts "Failied to get the last tag from git, looks like something is missing" -end - -version = `git describe --abbrev=0 --tags` - -FileUtils.touch('Version ' + version.chomp) -FileUtils.rm('config/.history') if File.exists?('config/.history') - -Dir.chdir('..') - -targets.each do |ar| - create_archive ar[0], ar[1] -end - -Dir.chdir('cmder') - -FileUtils.rm('Version ' + version.chomp) \ No newline at end of file From 46f6f677dc362c0695607be5f28b8b94114fc4bc Mon Sep 17 00:00:00 2001 From: Samuel Vasko Date: Thu, 10 Apr 2014 14:42:20 +0200 Subject: [PATCH 19/19] Silencing the noise --- scripts/build.ps1 | 2 +- scripts/pack.ps1 | 2 +- scripts/utils.ps1 | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 06ee55f..e3119b9 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -68,4 +68,4 @@ foreach ($s in $sources) { } Pop-Location -Write-Verbose "All good and done!" +Write-Verbose "All good and done!" \ No newline at end of file diff --git a/scripts/pack.ps1 b/scripts/pack.ps1 index 71e2329..9d3a32b 100644 --- a/scripts/pack.ps1 +++ b/scripts/pack.ps1 @@ -47,7 +47,7 @@ $targets = @{ Delete-Existing "..\Version*" $version = Invoke-Expression "git describe --abbrev=0 --tags" -New-Item -ItemType file "$cmderRoot\Version $version" +(New-Item -ItemType file "$cmderRoot\Version $version") | Out-Null foreach ($t in $targets.GetEnumerator()) { Create-Archive $cmderRoot "$saveTo\$($t.Name)" $t.Value diff --git a/scripts/utils.ps1 b/scripts/utils.ps1 index 36fdcd6..4717176 100644 --- a/scripts/utils.ps1 +++ b/scripts/utils.ps1 @@ -19,7 +19,7 @@ function Delete-Existing ($path) { } function Extract-Archive ($source, $target) { - Invoke-Expression "7z x -y -o$($target) $source" + Invoke-Expression "7z x -y -o$($target) $source > `$null" if ($lastexitcode -ne 0) { Write-Error "Extracting of $source failied" } @@ -27,7 +27,7 @@ function Extract-Archive ($source, $target) { } function Create-Archive ($source, $target, $params) { - $command = "7z a -x@`"$source\packignore`" $params $target $source" + $command = "7z a -x@`"$source\packignore`" $params $target $source > `$null" Write-Verbose "Running: $command" Invoke-Expression $command if ($lastexitcode -ne 0) {