You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.5KB

  1. # Script that synchronizes zlib.
  2. #
  3. # Version: 20171105
  4. Function DownloadFile($Url, $Destination)
  5. {
  6. $Client = New-Object Net.WebClient
  7. ${Client}.DownloadFile(${Url}, ${Destination})
  8. }
  9. Function ExtractZip($Filename)
  10. {
  11. # AppVeyor does not seem to support extraction using "native ZIP" so we use 7z instead.
  12. $SevenZip = "C:\Program Files\7-Zip\7z.exe"
  13. If (Test-Path ${SevenZip})
  14. {
  15. # PowerShell will raise NativeCommandError if 7z writes to stdout or stderr
  16. # therefore 2>&1 is added and the output is stored in a variable.
  17. # The leading & and single quotes are necessary to compensate for the spaces in the path.
  18. $Output = Invoke-Expression -Command "& '${SevenZip}' -y x ${Filename} 2>&1"
  19. }
  20. else
  21. {
  22. $Shell = New-Object -ComObject Shell.Application
  23. $Archive = ${Shell}.NameSpace(${Filename})
  24. $Directory = ${Shell}.Namespace("${pwd}")
  25. ForEach($FileEntry in ${Archive}.items())
  26. {
  27. ${Directory}.CopyHere(${FileEntry})
  28. }
  29. }
  30. }
  31. $Filename = "${pwd}\zlib1211.zip"
  32. $Url = "http://zlib.net/zlib1211.zip"
  33. $ExtractedPath = "zlib-1.2.11"
  34. $DestinationPath = "..\zlib"
  35. If (Test-Path ${Filename})
  36. {
  37. Remove-Item -Path ${Filename} -Force
  38. }
  39. DownloadFile -Url ${Url} -Destination ${Filename}
  40. If (Test-Path ${ExtractedPath})
  41. {
  42. Remove-Item -Path ${ExtractedPath} -Force -Recurse
  43. }
  44. ExtractZip -Filename ${Filename}
  45. Remove-Item -Path ${Filename} -Force
  46. If (Test-Path ${DestinationPath})
  47. {
  48. Remove-Item -Path ${DestinationPath} -Force -Recurse
  49. }
  50. Move-Item ${ExtractedPath} ${DestinationPath}