Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(php) Added legacy packages as manual packages #564

Merged
merged 7 commits into from
Feb 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion automatic/php/php.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ For example: `--params '"/ThreadSafe ""/InstallDir:C:\PHP"""'`.
<docsUrl>https://secure.php.net/docs.php</docsUrl>
<projectSourceUrl>http://git.php.net</projectSourceUrl>
<dependencies>
<dependency id="chocolatey" version="0.9.10" />
<dependency id="vcredist2015" version="14.0" />
<dependency id="chocolatey-core.extension" version="1.0.5" />
</dependencies>
Expand Down
3 changes: 3 additions & 0 deletions automatic/php/tools/helpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ function UninstallPackage {
$txtFile = Resolve-Path "$libDirectory\*.txt" | select -first 1
$fileName = ($txtFile -split '\\' | select -last 1).TrimEnd('.txt')
Uninstall-ChocolateyZipPackage -PackageName $packageName -ZipFileName $fileName
if (Test-Path $txtFile) {
Remove-Item -Force -ea 0 $txtFile
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions manual/php-legacy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The php versions located in this folder is just here for convenience.
Just in case there is a need to update old versions of php.
Not a single one of these versions are officially supported by the php dev team anymore.
40 changes: 40 additions & 0 deletions manual/php-legacy/php_5.3.x/php_5.3.x.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. -->
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<metadata>
<id>php</id>
<title>PHP (Hypertext Preprocessor)</title>
<version>0.0</version>
<authors>PHP Authors</authors>
<owners>chocolatey, Rob Reynolds</owners>
<summary>PHP – widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.</summary>
<description>PHP is an HTML-embedded scripting language. Much of its syntax is borrowed from C, Java and Perl with a couple of unique PHP-specific features thrown in. The goal of the language is to allow web developers to write dynamically generated pages quickly.

## Package Parameters
- `/DontAddToPath` - Do not add install directory to path
- `/InstallDir:` - Override the installation directory (needs to be specified both during install and update, until it is remembered by choco)
- `/ThreadSafe` - Install the thread safe version of php that is compatible with Apache.

These parameters can be passed to the installer with the use of --params.
For example: `--params '"/ThreadSafe ""/InstallDir:C:\PHP"""'`.
</description>
<projectUrl>http://www.php.net/</projectUrl>
<packageSourceUrl>https://github.com/chocolatey/chocolatey-coreteampackages/tree/master/manual/php-legacy/php_5.3.x</packageSourceUrl>
<tags>php development programming foss cross-platform admin</tags>
<licenseUrl>http://us.php.net/license/</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<releaseNotes>https://secure.php.net/ChangeLog-5.php#5.3.29</releaseNotes>
<iconUrl>https://cdn.rawgit.com/chocolatey/chocolatey-coreteampackages/4e147ce52b1a2a7ac522ffbce6d176f257de6ac1/icons/php.svg</iconUrl>
<bugTrackerUrl>https://bugs.php.net/</bugTrackerUrl>
<docsUrl>https://secure.php.net/docs.php</docsUrl>
<projectSourceUrl>http://git.php.net</projectSourceUrl>
<dependencies>
<dependency id="vcredist2008" version="9.0" />
<dependency id="chocolatey-core.extension" version="1.0.5" />
</dependencies>
</metadata>
<files>
<file src="tools\**" target="tools" />
<file src="..\..\..\automatic\php\tools\helpers.ps1" target="tools" />
</files>
</package>
55 changes: 55 additions & 0 deletions manual/php-legacy/php_5.3.x/tools/chocolateyInstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import-module "$env:ChocolateyInstall\helpers\chocolateyInstaller.psm1"
$ErrorActionPreference = 'Stop'

$toolsPath = Split-Path $MyInvocation.MyCommand.Definition
. $toolsPath\helpers.ps1

$installLocation = GetInstallLocation "$toolsPath\.."

if ($installLocation) {
Write-Host "Uninstalling previous version of php..."
UninstallPackage -libDirectory "$toolsPath\.." -packageName 'php'
Uninstall-ChocolateyPath $installLocation
}

$pp = Get-PackageParameters

$downloadInfo = GetDownloadInfo -downloadInfoFile "$toolsPath\downloadInfo.csv" -parameters $pp

$packageArgs = @{
packageName = 'php'
url = $downloadInfo.URL32
checksum = $downloadInfo.Checksum32
checksumType = 'sha256'
checksumType64 = 'sha256'
}
$newInstallLocation = $packageArgs.unzipLocation = GetNewInstallLocation $packageArgs.packageName $env:ChocolateyPackageVersion $pp

Install-ChocolateyZipPackage @packageArgs

if (!$pp.DontAddToPath) {
Install-ChocolateyPath $newInstallLocation
}

$php_ini_path = $newInstallLocation + '/php.ini'

if (($installLocation -ne $newInstallLocation) -and (Test-Path "$installLocation\php.ini")) {
Write-Host "Moving old configuration file."
Move-Item "$installLocation\php.ini" "$php_ini_path"

$di = Get-ChildItem $installLocation -ea 0 | Measure-Object
if ($di.Count -eq 0) {
Write-Host "Removing old install location."
Remove-Item -Force -ea 0 $installLocation
}
}

if (!(Test-Path $php_ini_path)) {
Write-Host 'Creating default php.ini'
cp $newInstallLocation/php.ini-production $php_ini_path

Write-Host 'Configuring PHP extensions directory'
(gc $php_ini_path) -replace '; extension_dir = "ext"', 'extension_dir = "ext"' | sc $php_ini_path
}

if (!$pp.ThreadSafe) { Write-Host 'Please make sure you have CGI installed in IIS for local hosting' }
20 changes: 20 additions & 0 deletions manual/php-legacy/php_5.3.x/tools/chocolateyUninstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
$toolsPath = Split-Path $MyInvocation.MyCommand.Definition
. $toolsPath\helpers.ps1

$packageName = 'php'

$installLocation = GetInstallLocation -libDirectory "$toolsPath\.."

if ($installLocation) {
UninstallPackage -libDirectory "$toolsPath\.." -packageName $packageName

$di = Get-ChildItem $installLocation -ea 0 | Measure-Object
if ($di.Count -eq 0) {
Remove-Item -Force -ea 0 $installLocation
}

Uninstall-ChocolateyPath $installLocation

} else {
Write-Warning "$packageName install path was not found. It may already be uninstalled!"
}
2 changes: 2 additions & 0 deletions manual/php-legacy/php_5.3.x/tools/downloadInfo.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
threadsafe|http://windows.php.net//downloads/releases/archives/php-5.3.29-Win32-VC9-x86.zip||c1d7bf791fda6dea29c3eb8ae73188ff3a45970d5ca54ff9e5702971381c19cd|
not-threadsafe|http://windows.php.net//downloads/releases/archives/php-5.3.29-nts-Win32-VC9-x86.zip||d63846ede80daacdb1ca2359c4f8bf1bd2f9831fe1b9599d2e4345ede931b75b|
53 changes: 53 additions & 0 deletions manual/php-legacy/php_5.3.x/update.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import-module au

$releases = 'http://windows.php.net/downloads/releases/archives/'

function global:au_BeforeUpdate {
$Latest.ChecksumTS32 = Get-RemoteChecksum $Latest.URLTS32
$Latest.ChecksumNTS32 = Get-RemoteChecksum $Latest.URLNTS32

$lines = @(
@('threadsafe'; $Latest.URLTS32; '' ; $Latest.ChecksumTS32; '') -join '|'
@('not-threadsafe'; $Latest.URLNTS32; '' ; $Latest.ChecksumNTS32; '') -join '|'
)

[System.IO.File]::WriteAllLines("$PSScriptRoot\tools\downloadInfo.csv", $lines);
}

function global:au_SearchReplace {
@{
".\tools\chocolateyInstall.ps1" = @{
"(?i)(^\s*packageName\s*=\s*)('.*')" = "`$1'$($Latest.PackageName)'"
}

"php_5.3.x.nuspec" = @{
"(\<releaseNotes\>).*?(\</releaseNotes\>)" = "`${1}$($Latest.ReleaseNotes)`$2"
}
}
}

function global:au_GetLatest {
$download_page = Invoke-WebRequest -Uri $releases

$re = 'php-5\.3.+-nts.+\.zip$'
$versionSort = { [version]($_ -split '-' | select -Index 1) }
$url = $download_page.links | ? href -match $re | % href | sort $versionSort -Descending | select -First 1
$urlTS = $url -replace '\-nts',''
$version = $url -split '-' | select -Index 1
$majorVersion = $version -split '\.' | select -first 1
$Result = @{
Version = $version
URLNTS32 = "http://windows.php.net/" + $url
URLTS32 = "http://windows.php.net/" + $urlTS
ReleaseNotes = "https://secure.php.net/ChangeLog-${majorVersion}.php#${version}"
PackageName = 'php'
}

if ($Result.URLNTS32 -eq $Result.TS32) {
throw "The threadsafe and non-threadsafe 32bit url is equal... This is not expected"
}

$Result
}

update -ChecksumFor none
40 changes: 40 additions & 0 deletions manual/php-legacy/php_5.4.x/php_5.4.x.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. -->
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<metadata>
<id>php</id>
<title>PHP (Hypertext Preprocessor)</title>
<version>0.0</version>
<authors>PHP Authors</authors>
<owners>chocolatey, Rob Reynolds</owners>
<summary>PHP – widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.</summary>
<description>PHP is an HTML-embedded scripting language. Much of its syntax is borrowed from C, Java and Perl with a couple of unique PHP-specific features thrown in. The goal of the language is to allow web developers to write dynamically generated pages quickly.

## Package Parameters
- `/DontAddToPath` - Do not add install directory to path
- `/InstallDir:` - Override the installation directory (needs to be specified both during install and update, until it is remembered by choco)
- `/ThreadSafe` - Install the thread safe version of php that is compatible with Apache.

These parameters can be passed to the installer with the use of --params.
For example: `--params '"/ThreadSafe ""/InstallDir:C:\PHP"""'`.
</description>
<projectUrl>http://www.php.net/</projectUrl>
<packageSourceUrl>https://github.com/chocolatey/chocolatey-coreteampackages/tree/master/manual/php-legacy/php_5.4.x</packageSourceUrl>
<tags>php development programming foss cross-platform admin</tags>
<licenseUrl>http://us.php.net/license/</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<releaseNotes>https://secure.php.net/ChangeLog-5.php#5.4.45</releaseNotes>
<iconUrl>https://cdn.rawgit.com/chocolatey/chocolatey-coreteampackages/4e147ce52b1a2a7ac522ffbce6d176f257de6ac1/icons/php.svg</iconUrl>
<bugTrackerUrl>https://bugs.php.net/</bugTrackerUrl>
<docsUrl>https://secure.php.net/docs.php</docsUrl>
<projectSourceUrl>http://git.php.net</projectSourceUrl>
<dependencies>
<dependency id="vcredist2008" version="9.0" />
<dependency id="chocolatey-core.extension" version="1.0.5" />
</dependencies>
</metadata>
<files>
<file src="tools\**" target="tools" />
<file src="..\..\..\automatic\php\tools\helpers.ps1" target="tools" />
</files>
</package>
55 changes: 55 additions & 0 deletions manual/php-legacy/php_5.4.x/tools/chocolateyInstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import-module "$env:ChocolateyInstall\helpers\chocolateyInstaller.psm1"
$ErrorActionPreference = 'Stop'

$toolsPath = Split-Path $MyInvocation.MyCommand.Definition
. $toolsPath\helpers.ps1

$installLocation = GetInstallLocation "$toolsPath\.."

if ($installLocation) {
Write-Host "Uninstalling previous version of php..."
UninstallPackage -libDirectory "$toolsPath\.." -packageName 'php'
Uninstall-ChocolateyPath $installLocation
}

$pp = Get-PackageParameters

$downloadInfo = GetDownloadInfo -downloadInfoFile "$toolsPath\downloadInfo.csv" -parameters $pp

$packageArgs = @{
packageName = 'php'
url = $downloadInfo.URL32
checksum = $downloadInfo.Checksum32
checksumType = 'sha256'
checksumType64 = 'sha256'
}
$newInstallLocation = $packageArgs.unzipLocation = GetNewInstallLocation $packageArgs.packageName $env:ChocolateyPackageVersion $pp

Install-ChocolateyZipPackage @packageArgs

if (!$pp.DontAddToPath) {
Install-ChocolateyPath $newInstallLocation
}

$php_ini_path = $newInstallLocation + '/php.ini'

if (($installLocation -ne $newInstallLocation) -and (Test-Path "$installLocation\php.ini")) {
Write-Host "Moving old configuration file."
Move-Item "$installLocation\php.ini" "$php_ini_path"

$di = Get-ChildItem $installLocation -ea 0 | Measure-Object
if ($di.Count -eq 0) {
Write-Host "Removing old install location."
Remove-Item -Force -ea 0 $installLocation
}
}

if (!(Test-Path $php_ini_path)) {
Write-Host 'Creating default php.ini'
cp $newInstallLocation/php.ini-production $php_ini_path

Write-Host 'Configuring PHP extensions directory'
(gc $php_ini_path) -replace '; extension_dir = "ext"', 'extension_dir = "ext"' | sc $php_ini_path
}

if (!$pp.ThreadSafe) { Write-Host 'Please make sure you have CGI installed in IIS for local hosting' }
20 changes: 20 additions & 0 deletions manual/php-legacy/php_5.4.x/tools/chocolateyUninstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
$toolsPath = Split-Path $MyInvocation.MyCommand.Definition
. $toolsPath\helpers.ps1

$packageName = 'php'

$installLocation = GetInstallLocation -libDirectory "$toolsPath\.."

if ($installLocation) {
UninstallPackage -libDirectory "$toolsPath\.." -packageName $packageName

$di = Get-ChildItem $installLocation -ea 0 | Measure-Object
if ($di.Count -eq 0) {
Remove-Item -Force -ea 0 $installLocation
}

Uninstall-ChocolateyPath $installLocation

} else {
Write-Warning "$packageName install path was not found. It may already be uninstalled!"
}
2 changes: 2 additions & 0 deletions manual/php-legacy/php_5.4.x/tools/downloadInfo.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
threadsafe|http://windows.php.net//downloads/releases/archives/php-5.4.45-Win32-VC9-x86.zip||38cde4bac05e916fb0c0b78a2e5bfeec9b02b4b6fc51c9a02a66e4fc1e1a1d08|
not-threadsafe|http://windows.php.net//downloads/releases/archives/php-5.4.45-nts-Win32-VC9-x86.zip||63da6fd7c73c25eef1baec7099c3de348390671f9b2e61b74a8ab300fa4eab92|
53 changes: 53 additions & 0 deletions manual/php-legacy/php_5.4.x/update.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import-module au

$releases = 'http://windows.php.net/downloads/releases/archives/'

function global:au_BeforeUpdate {
$Latest.ChecksumTS32 = Get-RemoteChecksum $Latest.URLTS32
$Latest.ChecksumNTS32 = Get-RemoteChecksum $Latest.URLNTS32

$lines = @(
@('threadsafe'; $Latest.URLTS32; '' ; $Latest.ChecksumTS32; '') -join '|'
@('not-threadsafe'; $Latest.URLNTS32; '' ; $Latest.ChecksumNTS32; '') -join '|'
)

[System.IO.File]::WriteAllLines("$PSScriptRoot\tools\downloadInfo.csv", $lines);
}

function global:au_SearchReplace {
@{
".\tools\chocolateyInstall.ps1" = @{
"(?i)(^\s*packageName\s*=\s*)('.*')" = "`$1'$($Latest.PackageName)'"
}

"php_5.4.x.nuspec" = @{
"(\<releaseNotes\>).*?(\</releaseNotes\>)" = "`${1}$($Latest.ReleaseNotes)`$2"
}
}
}

function global:au_GetLatest {
$download_page = Invoke-WebRequest -Uri $releases

$re = 'php-5\.4.+-nts.+\.zip$'
$versionSort = { [version]($_ -split '-' | select -Index 1) }
$url = $download_page.links | ? href -match $re | % href | sort $versionSort -Descending | select -First 1
$urlTS = $url -replace '\-nts',''
$version = $url -split '-' | select -Index 1
$majorVersion = $version -split '\.' | select -first 1
$Result = @{
Version = $version
URLNTS32 = "http://windows.php.net/" + $url
URLTS32 = "http://windows.php.net/" + $urlTS
ReleaseNotes = "https://secure.php.net/ChangeLog-${majorVersion}.php#${version}"
PackageName = 'php'
}

if ($Result.URLNTS32 -eq $Result.TS32) {
throw "The threadsafe and non-threadsafe 32bit url is equal... This is not expected"
}

$Result
}

update -ChecksumFor none
Loading