Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: jonforums/buildlets
base: 06a74e2879
...
head fork: jonforums/buildlets
compare: cf76cec7e7
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 26 additions and 43 deletions.
  1. +19 −41 build_zlib.ps1
  2. +7 −2 buildlet_utils.ps1
View
60 build_zlib.ps1
@@ -2,11 +2,10 @@
# Author: Jon Maken
# License: 3-clause BSD
-# Revision: 2013-03-20 22:44:30 -0600
+# Revision: 2013-03-21 23:19:02 -0600
#
# TODO:
# - extract generics into a downloadable utils helper module
-# - add proper try-catch-finally error handling
# - add x86/x64 dynamic package naming
param(
@@ -24,7 +23,6 @@ param(
[string] $DEVKIT = 'C:/Devkit'
)
-$root = Split-Path -parent $script:MyInvocation.MyCommand.Path
$libname = 'zlib'
$source = "${libname}-${version}.tar.gz"
$source_dir = "${libname}-${version}"
@@ -32,48 +30,34 @@ $repo_root = 'http://zlib.net/'
$archive = "${repo_root}${source}"
$hash_uri = "https://raw.github.com/jonforums/buildlets/master/hashery/${libname}.md5"
-function Write-Status($msg, $leader='--->', $color='Yellow') {
- Write-Host "$leader $msg" -foregroundcolor $color
+# download and source the buildlet library
+if (-not (Test-Path "$PWD\buildlet_utils.ps1")) {
+ Write-Host '---> fetching buildlet library' -foregroundcolor yellow
+ try {
+ $fetcher = New-Object System.Net.WebClient
+ $fetcher.DownloadFile('https://raw.github.com/jonforums/buildlets/master/buildlet_utils.ps1',
+ "$PWD\buildlet_utils.ps1")
+ }
+ catch {
+ throw '[ERROR] unable to fetch required buildlet library'
+ }
}
+. "$PWD\buildlet_utils.ps1"
# download source archive
-if(-not (Test-Path $source)) {
- Import-Module BitsTransfer
- Write-Status "downloading $archive"
- Start-BitsTransfer $archive "$PWD\$source"
-}
+Fetch-Archive
# download hash data and validate source archive
-Write-Status "validating $source"
-$client = New-Object System.Net.WebClient
-$hash = ConvertFrom-StringData $client.DownloadString($hash_uri)
-
-try {
- $hasher = New-Object System.Security.Cryptography.MD5Cng
- $fs = New-Object System.IO.FileStream "$PWD\$source", 'Open', 'Read'
- $test_hash = [BitConverter]::ToString($hasher.ComputeHash($fs)).Replace('-','').ToLower()
-} finally {
- $fs.Close()
-}
-
-if ($test_hash -ne $hash[$version].ToLower()) {
- Write-Status "$source validation failed, exiting" '[ERROR]' 'Red'
- break
-}
-
+Validate-Archive
# extract
-Write-Status "extracting $source"
-$tar_file = "$($source.Substring(0, $source.LastIndexOf('-')))*.tar"
-(& "$7ZA" "x" $source) -and (& "$7ZA" "x" $tar_file) -and (rm $tar_file) | Out-Null
-
+Extract-Archive
# patch, configure, build, archive
Push-Location "${source_dir}"
# activate toolchain
- Write-Status "activating toolchain"
- . "$DEVKIT/devkitvars.ps1" | Out-Null
+ Activate-Toolchain
# configure
Write-Status "configuring ${source_dir}"
@@ -91,15 +75,9 @@ Push-Location "${source_dir}"
sh -c "make install -f win32/Makefile.gcc $(${install_opts} -join ' ')" | Out-Null
# archive
- Push-Location "$install_dir"
- Write-Status "creating binary archive for ${source_dir}"
- $bin_archive = "${source_dir}-x86-windows-bin.7z"
- & "$7ZA" "a" "-mx=9" "-r" $bin_archive "*" | Out-Null
- Pop-Location
+ Archive-Build
Pop-Location
# hoist binary archive and cleanup
-Write-Status "cleaning up"
-mv "$install_dir/$bin_archive" "$PWD" -force
-rm "${source_dir}" -recurse -force
+Clean-Build
View
9 buildlet_utils.ps1
@@ -2,7 +2,7 @@
# Author: Jon Maken
# License: 3-clause BSD
-# Revision: 2013-03-21 22:18:46 -0600
+# Revision: 2013-03-21 22:49:38 -0600
function Write-Status($msg, $leader='--->', $color='Yellow') {
Write-Host "$leader $msg" -foregroundcolor $color
@@ -22,7 +22,12 @@ function Validate-Archive() {
$fetcher = New-Object System.Net.WebClient
$hash = ConvertFrom-StringData $fetcher.DownloadString($hash_uri)
- $hasher = New-Object System.Security.Cryptography.SHA1Cng
+ switch ($hash_uri.SubString($hash_uri.LastIndexOf('.')+1)) {
+ 'md5' { $hasher = New-Object System.Security.Cryptography.MD5Cng; break }
+ 'sha1' { $hasher = New-Object System.Security.Cryptography.SHA1Cng; break }
+ default { throw }
+ }
+
$fs = New-Object System.IO.FileStream "$PWD\$source", 'Open', 'Read'
$test_hash = [BitConverter]::ToString($hasher.ComputeHash($fs)).Replace('-','').ToLower()
}

No commit comments for this range

Something went wrong with that request. Please try again.