Fixing a few issues found while testing the scripts on Windows

This commit is contained in:
ulvii 2017-07-06 17:19:21 -07:00
parent 6639098446
commit af3ea7023b
2 changed files with 24 additions and 34 deletions

View file

@ -467,7 +467,7 @@ def get_php_arch():
Returns
x86 or x64
"""
p = subprocess.Popen( "php -r 'echo PHP_INT_SIZE;'", stdout=subprocess.PIPE, shell = True )
p = subprocess.Popen( "php -r \"echo PHP_INT_SIZE;\"", stdout=subprocess.PIPE, shell = True )
out, err = p.communicate()
if out.decode('ascii') == "8":
return "x64"
@ -482,7 +482,7 @@ def get_php_version():
Returns:
php version
"""
p = subprocess.Popen( "php -r 'echo phpversion();'", stdout=subprocess.PIPE, shell = True )
p = subprocess.Popen( "php -r \"echo phpversion();\"", stdout=subprocess.PIPE, shell = True )
out, err = p.communicate()
return out.decode('ascii')
@ -495,7 +495,7 @@ def get_php_thread():
nts or ts
"""
if os.name == 'nt':
command = "php -i | findstr 'Thread'"
command = "php -i | findstr \"Thread\""
else:
command = "php -i | grep 'Thread'"
p = subprocess.Popen( command, stdout=subprocess.PIPE, shell = True )
@ -514,7 +514,6 @@ def get_driver_version( driver_name ):
The version of the given driver
"""
command = "php -r \"echo phpversion('{0}');\""
print(command.format( driver_name ))
p = subprocess.Popen( command.format( driver_name ), stdout=subprocess.PIPE, shell = True )
out, err = p.communicate()
return out.decode('ascii')
@ -527,7 +526,7 @@ def get_msodbcsql_version( test_db ):
Returns:
MSODBCSQL version
"""
command = "php -r \"echo sqlsrv_client_info( sqlsrv_connect( '{0}', array( 'UID'=>'{1}', 'PWD'=>'{2}')))['DriverName'];\""
command = "php -r \"echo sqlsrv_client_info( sqlsrv_connect( '{0}', array( 'UID'=>'{1}', 'PWD'=>'{2}')))['DriverVer'];\""
p = subprocess.Popen( command.format( test_db.server_name, test_db.username, test_db.password ), stdout=subprocess.PIPE, shell = True )
out, err = p.communicate()
return out.decode('ascii')
@ -790,4 +789,4 @@ if __name__ == '__main__':
"""
exit()

View file

@ -9,18 +9,6 @@ Param(
[string]$ARCH
)
function Get-UrlStatusCode([string] $Url)
{
try
{
(Invoke-WebRequest -Uri $Url -UseBasicParsing -DisableKeepAlive).StatusCode
}
catch [Net.WebException]
{
[int]$_.Exception.Response.StatusCode
}
}
IF($ARCH -ne "x64" -And $ARCH -ne "x86"){
Write-Host "ARCH must either x64 or x86"
Break
@ -37,38 +25,39 @@ $tempFolder=Join-Path $startingDir "temp"
Remove-Item temp -Recurse -Force -ErrorAction Ignore
New-Item -ItemType directory -Path temp
(New-Object System.Net.WebClient).DownloadFile('http://windows.php.net/downloads/releases/sha1sum.txt',"$tempFolder\sha1sum.txt")
(New-Object System.Net.WebClient).DownloadFile("http://windows.php.net/downloads/releases/sha1sum.txt","$tempFolder\sha1sum.txt")
$PHP70_LATEST_VERSION=type $tempFolder\sha1sum.txt | where { $_ -match "php-(7.0\.\d+)-src" } | foreach { $matches[1] }
$PHP71_LATEST_VERSION=type $tempFolder\sha1sum.txt | where { $_ -match "php-(7.1\.\d+)-src" } | foreach { $matches[1] }
#check if PHP_VERSION source exisits
$statusCode = Get-UrlStatusCode "http://windows.php.net/downloads/releases/php-$PHP_VERSION-src.zip"
#If provided php version source does not exists, default the version to latest php 71 source
IF($statusCode -eq 404){$PHP_VERSION=$PHP71_LATEST_VERSION}
$PHP_VERSION_MINOR=$PHP_VERSION.split(".")[1]
Write-Host "Installing chocolatey..."
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
Write-Host "Installing Git..."
choco install git
Write-Host "Downloading Python3..."
(New-Object System.Net.WebClient).DownloadFile('https://www.python.org/ftp/python/3.6.0/python-3.6.0-amd64.exe', "$tempFolder\python.exe")
choco install -y git
Write-Host "Installing Python3..."
.\temp\python.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0 | Out-Null
choco install -y python3
RefreshEnv
Write-Host "Installing pyodbc..."
pip3 install pyodbc | Out-Null
Write-Host "Downloading MSODBCSQL..."
#This needs to be manually updated when there is a new release
(New-object System.Net.WebClient).DownloadFile('https://download.microsoft.com/download/D/5/E/D5EEF288-A277-45C8-855B-8E2CB7E25B96/x64/msodbcsql.msi', "$tempFolder\msodbcsql.msi")
Write-Host "Installing MSODBCSQL..."
msiexec /quiet /passive /qn /i $tempFolder\msodbcsql.msi IACCEPTMSODBCSQLLICENSETERMS=YES | Out-Null
Write-Host "Downloading 7-Zip..."
(New-object System.Net.WebClient).DownloadFile("http://www.7-zip.org/a/7z1604-x64.exe", "$tempFolder\7z1604-x64.exe")
Write-Host "Installing 7-Zip..."
.\temp\7z1604-x64.exe /S | Out-Null
set-alias sz "$env:ProgramFiles\7-Zip\7z.exe"
choco install -y 7zip.install
Write-Host "Downloading PHP-SDK..."
(New-Object System.Net.WebClient).DownloadFile('http://windows.php.net/downloads/php-sdk/php-sdk-binary-tools-20110915.zip', "$tempFolder\binary_tools.zip")
Write-Host "Downloading PHP-$PHP_VERSION source..."
IF($PHP_VERSION -eq $PHP70_LATEST_VERSION -Or $PHP_VERSION -eq $PHP71_LATEST_VERSION){
(New-Object System.Net.WebClient).DownloadFile("http://windows.php.net/downloads/releases/php-$PHP_VERSION-src.zip", "$tempFolder\php-$PHP_VERSION-src.zip")
}
ELSE{
(New-Object System.Net.WebClient).DownloadFile("http://windows.php.net/downloads/releases/archives/php-$PHP_VERSION-src.zip", "$tempFolder\php-$PHP_VERSION-src.zip")
}
Write-Host "Downloading Dependencies..."
(New-Object System.Net.WebClient).DownloadFile("http://windows.php.net/downloads/php-sdk/deps-7.$PHP_VERSION_MINOR-vc14-$ARCH.7z", "$tempFolder\deps-7.$PHP_VERSION_MINOR-vc14-$ARCH.7z")
@ -81,8 +70,7 @@ bin\phpsdk_buildtree.bat phpdev
New-Item -ItemType directory -Path .\phpdev\vc14
Copy-Item .\phpdev\vc9\* phpdev\vc14\ -recurse
[System.IO.Compression.ZipFile]::ExtractToDirectory("$tempFolder\php-$PHP_VERSION-src.zip", "C:\php-sdk\phpdev\vc14\$ARCH\")
set-alias sz "$env:ProgramFiles\7-Zip\7z.exe"
sz x $tempFolder\deps-7.$PHP_VERSION_MINOR-vc14-$ARCH.7z -oC:\php-sdk\phpdev\vc14\$ARCH\
7z.exe x $tempFolder\deps-7.$PHP_VERSION_MINOR-vc14-$ARCH.7z -oC:\php-sdk\phpdev\vc14\$ARCH\
bin\phpsdk_setvars.bat
@ -103,6 +91,8 @@ if ($PHP_THREAD -ceq "nts") {
& $startingDir\compile_php.bat $ARCH $CONFIG_OPTIONS
Copy-Item php.ini-production php.ini
Add-Content php.ini "extension=C:\php\ext\php_sqlsrv.dll"
Add-Content php.ini "extension=C:\php\ext\php_pdo_sqlsrv.dll"
@ -112,7 +102,8 @@ Copy-Item C:\php-sdk\phpdev\vc14\$ARCH\deps\bin\ssleay32.dll C:\Windows -force
Copy-Item C:\php-sdk\phpdev\vc14\$ARCH\deps\bin\libeay32.dll C:\Windows -force
cd $startingDir
set-alias php "C:\php\php.exe"
$env:Path += ";C:\php\"
RefreshEnv
wget https://getcomposer.org/installer -O composer-setup.php
php composer-setup.php
php composer.phar install