update.ps1 851 B

1234567891011121314151617181920212223242526272829
  1. import-module au
  2. $url = 'http://www.sonatype.org/downloads/nexus-latest-bundle.zip'
  3. function global:au_SearchReplace {
  4. @{
  5. 'tools\chocolateyInstall.ps1' = @{
  6. "(^[$]url\s*=\s*)('.*')" = "`$1'$($Latest.URL)'"
  7. "(^[$]checksum\s*=\s*)('.*')" = "`$1'$($Latest.Checksum32)'"
  8. }
  9. }
  10. }
  11. function global:au_GetLatest {
  12. while($true) {
  13. $request = [System.Net.WebRequest]::Create($url)
  14. $request.AllowAutoRedirect=$false
  15. $response=$request.GetResponse()
  16. $location = $response.GetResponseHeader('Location')
  17. if (!$location -or ($location -eq $url)) { break }
  18. $url = $location
  19. }
  20. $version = ($url -split '-|\.' | select -Last 4 -skip 2) -join '.'
  21. $Latest = @{ URL = $url; Version = $version }
  22. return $Latest
  23. }
  24. update -NoCheckUrl -ChecksumFor 32