Browse files

Update minised buildlet to use buildlet library

  • Loading branch information...
1 parent cf76cec commit dad4df4b6807eb040760e9d6758c82104125e755 @jonforums committed Mar 21, 2013
Showing with 19 additions and 41 deletions.
  1. +19 −41 build_minised.ps1
View
60 build_minised.ps1
@@ -2,11 +2,10 @@
# Author: Jon Maken
# License: 3-clause BSD
-# Revision: 2013-03-20 21:17:27 -0600
+# Revision: 2013-03-21 23:43:25 -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,56 +23,41 @@ param(
[string] $DEVKIT = 'C:/Devkit'
)
-$root = Split-Path -parent $script:MyInvocation.MyCommand.Path
$libname = 'minised'
$source = "${libname}-${version}.tar.gz"
$source_dir = "${libname}-${version}"
$repo_root = "http://dl.exactcode.de/oss/${libname}/"
$archive = "${repo_root}${source}"
$hash_uri = "https://raw.github.com/jonforums/buildlets/master/hashery/${libname}.sha1"
-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.SHA1Cng
- $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}"
@@ -89,15 +73,9 @@ Push-Location "${source_dir}"
cp minised.exe, README, LICENSE -destination "$install_dir" | 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

0 comments on commit dad4df4

Please sign in to comment.