From 00fb6b8dcc6eb06d97d31d864efc1a95fecfe4e7 Mon Sep 17 00:00:00 2001 From: sirokujira Date: Wed, 26 Dec 2018 09:57:54 +0900 Subject: [PATCH] modified pkg-config download setting.(powershell use upper version 5.) --- pkg-config/Install-GTKPlus.ps1 | 87 ++++++++++++++++++---------- pkg-config/InstallWindowsGTKPlus.bat | 6 +- 2 files changed, 63 insertions(+), 30 deletions(-) diff --git a/pkg-config/Install-GTKPlus.ps1 b/pkg-config/Install-GTKPlus.ps1 index 6854c4513..6fa94522c 100644 --- a/pkg-config/Install-GTKPlus.ps1 +++ b/pkg-config/Install-GTKPlus.ps1 @@ -1,19 +1,12 @@ <# .SYNOPSIS -Retrieves and extracts the GTK lirary from the "http://win32builder.gnome.org/" page. +Retrieves and extracts the GTK lirary from the "http://ftp.gnome.org/" page. .EXAMPLE Get-GTKPlus #> -# 3.0? -# Import-Module "PS-Zip.psm1" -Force -# Import-Module "E:\python-pcl\pkg-config\PS-Zip.psm1" - -# current officially supported version -$gtkVersion = "3.10.4" -$gtkDate = "20131202" - -# FUll versioned pack file name to download +# pkg-config downloads +# https://stackoverflow.com/questions/1710922/how-to-install-pkg-config-in-windows/25605631 # determine 32 or 64bit OS? # https://social.technet.microsoft.com/Forums/office/en-US/5dfeb3ab-6265-40cd-a4ac-05428b9db5c3/determine-32-or-64bit-os?forum=winserverpowershell @@ -23,26 +16,38 @@ if ([System.IntPtr]::Size -eq 4) # 32 bit logic here # Write "32-bit OS" $os_bit = "win32" - $zipFilePath = "pkg-config_0.23-3_win32.zip" + $glibversion = "2.28" + $zipFilePath1 = "pkg-config_0.26-1_win32.zip" + $zipFilePath2 = "glib_2.28.8-1_win32.zip" + $zipFilePath3 = "gettext-runtime_0.18.1.1-2_win32.zip" } else { # 64 bit logic here # Write "64-bit OS" $os_bit = "win64" - $zipFilePath = "pkg-config_0.23-2_win64.zip" + $glibversion = "2.26" + $zipFilePath1 = "pkg-config_0.23-2_win64.zip" + $zipFilePath2 = "glib_2.26.1-1_win64.zip" + $zipFilePath3 = "gettext-runtime_0.18.1.1-2_win64.zip" } # $zipFilePath = "gtk+-bundle_$gtkVersion-" + "$gtkDate" + "_$os_bit.zip" # base URL to download the pack file from +# 404 # $SourceURLBase = "http://win32builder.gnome.org/$zipFilePath" -$SourceURLBase = "http://ftp.gnome.org/pub/gnome/binaries/$os_bit/dependencies/$zipFilePath" +$SourceURLBase1 = "http://ftp.gnome.org/pub/gnome/binaries/$os_bit/dependencies/$zipFilePath1" +$SourceURLBase2 = "http://ftp.gnome.org/pub/gnome/binaries/$os_bit/glib/$glibversion/$zipFilePath2" +$SourceURLBase3 = "http://ftp.gnome.org/pub/gnome/binaries/$os_bit/dependencies/$zipFilePath3" # download the pack and extract the files into the curent directory # How to get the current directory of the cmdlet being executed # http://stackoverflow.com/questions/8343767/how-to-get-the-current-directory-of-the-cmdlet-being-executed $dstPath = (Get-Item -Path ".\" -Verbose).FullName -$dstFile = $zipFilePath +# $dstFile = $zipFilePath +$dstFile1 = $zipFilePath1 +$dstFile2 = $zipFilePath2 +$dstFile3 = $zipFilePath3 # Version Check # PowerShell Version 2.0 @@ -50,21 +55,45 @@ $dstFile = $zipFilePath # $PSVersionTable # Download gtk -# Write $SourceURLBase -# PowerShell Version 3.0 -Invoke-WebRequest -UseBasicParsing -Uri $packSourceURLBase | Expand-Stream -Destination $dstPath -# 2.0(Windows 10 Error [not use NetFramework 2.0]) -# $cli = New-Object System.Net.WebClient -# $cli.DownloadFile($SourceURLBase, (Join-Path $dstPath $dstFile)) - -# Extract zip File -# 3.0 -New-ZipExtract -source $zipFilePath -destination $dstPath -force -verbose -# 2.0 -# $shell = New-Object -ComObject shell.application -# $zip = $shell.NameSpace((Join-Path $dstPath $dstFile)) -# $dest = $shell.NameSpace((Split-Path (Join-Path $dstPath $dstFile) -Parent)) -# $dest.CopyHere($zip.Items()) +switch($PSVersionTable.PSVersion.Major) +{ + 2 + { + # 2.0(Windows 10 Error [not use .NetFramework 2.0/3.5]) + # use .Net Framework setting(JP) + # https://qiita.com/miyamiya/items/95745587ced2c02a1966 + $cli = New-Object System.Net.WebClient + $cli.DownloadFile($SourceURLBase1, (Join-Path $dstPath $dstFile1)) + $cli.DownloadFile($SourceURLBase2, (Join-Path $dstPath $dstFile2)) + $cli.DownloadFile($SourceURLBase3, (Join-Path $dstPath $dstFile3)) + $shell = New-Object -ComObject shell.application + $zip1 = $shell.NameSpace((Join-Path $dstPath $dstFile1)) + $dest1 = $shell.NameSpace((Split-Path (Join-Path $dstPath $dstFile1) -Parent)) + $dest1.CopyHere($zip1.Items()) + $zip2 = $shell.NameSpace((Join-Path $dstPath $dstFile2)) + $dest2 = $shell.NameSpace((Split-Path (Join-Path $dstPath $dstFile2) -Parent)) + $dest2.CopyHere($zip2.Items()) + $zip3 = $shell.NameSpace((Join-Path $dstPath $dstFile3)) + $dest3 = $shell.NameSpace((Split-Path (Join-Path $dstPath $dstFile3) -Parent)) + $dest3.CopyHere($zip3.Items()) + } + default + { + # PowerShell Version 3.0- + Invoke-WebRequest -Uri $SourceURLBase1 -OutFile (Join-Path $dstPath $dstFile1) + Invoke-WebRequest -Uri $SourceURLBase2 -OutFile (Join-Path $dstPath $dstFile2) + Invoke-WebRequest -Uri $SourceURLBase3 -OutFile (Join-Path $dstPath $dstFile3) + # Extract zip File + # 3.0- + # New-ZipExtract -source $zipFilePath1 -destination $dstPath -force -verbose + # New-ZipExtract -source $zipFilePath2 -destination $dstPath -force -verbose + # New-ZipExtract -source $zipFilePath3 -destination $dstPath -force -verbose + # 5.0- + Expand-Archive -Force -Path $zipFilePath1 -DestinationPath $dstPath + Expand-Archive -Force -Path $zipFilePath2 -DestinationPath $dstPath + Expand-Archive -Force -Path $zipFilePath3 -DestinationPath $dstPath + } +} # Copy binary Copy-Item $dstPath/bin/* $dstPath diff --git a/pkg-config/InstallWindowsGTKPlus.bat b/pkg-config/InstallWindowsGTKPlus.bat index 211523810..405228076 100644 --- a/pkg-config/InstallWindowsGTKPlus.bat +++ b/pkg-config/InstallWindowsGTKPlus.bat @@ -23,7 +23,11 @@ if "%ELEVATED%" neq "yes" ( :admins REM Install GTK+ - powershell -NoProfile -ExecutionPolicy Unrestricted .\Install-GTKPlus.ps1 + REM powershell -NoProfile -ExecutionPolicy Unrestricted .\Install-GTKPlus.ps1 + REM powershell -v 2 -NoProfile -ExecutionPolicy Unrestricted .\Install-GTKPlus.ps1 + REM powershell -v 3 -NoProfile -ExecutionPolicy Unrestricted .\Install-GTKPlus.ps1 + REM default use upper ver 5(use zip archive package) + powershell -v 5 -NoProfile -ExecutionPolicy Unrestricted .\Install-GTKPlus.ps1 goto exit1