Skip to content

Commit

Permalink
Copy from package_manager
Browse files Browse the repository at this point in the history
  • Loading branch information
jayvdb committed Jun 9, 2019
1 parent c50ebe9 commit 33dddca
Show file tree
Hide file tree
Showing 10 changed files with 868 additions and 66 deletions.
22 changes: 22 additions & 0 deletions .ci/AppVeyor.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
. .ci/FudgeGenerateFake.ps1
. .ci/PrepareAVVM.ps1

function Set-Python-Arch
{
# run_with_env.cmd needs PYTHON_ARCH set to 64 for x64
if ($env:Platform -eq 'x64')
{
Set-ItemProperty -path 'HKCU:\Environment' -name 'PYTHON_ARCH' -value '64'
}
}

function Fix-AppVeyor
{
Set-Python-Arch

$config = Get-FudgefileContent .ci/Fudgefile.appveyor

PackFakeNupkgs $config.packages

Setup-Products $config.packages
}
61 changes: 61 additions & 0 deletions .ci/FudgeGenerateFake.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
Set-StrictMode -Version latest

function GenerateFakeNuspec
{
param (
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]
$name,

[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]
$version
)

$template = Get-Content .ci\nuspecs\template.nuspec.in

$content = $template -replace '{name}', $name
$content = $content -replace '{version}', $version

$nuspec = ('.ci\nuspecs\' + $name + '.nuspec')

Set-Content $nuspec $content

Write-Output "Created $nuspec"
}

function GenerateFakeNuspecs
{
param (
[array]
$Packages
)

foreach ($pkg in $Packages)
{
GenerateFakeNuspec $pkg.name $pkg.version
}
}

function PackFakeNupkgs
{
param (
[array]
$Packages
)

GenerateFakeNuspecs $Packages

foreach ($pkg in $Packages)
{
$filename = ($pkg.name + '.nuspec')
choco pack ".ci\nuspecs\$filename" > $null
}
mv *.nupkg .ci\nuspecs\

# fudge pack -FudgefilePath .ci/Fudgefile.appveyor

Write-Output 'Packed!'
}
182 changes: 182 additions & 0 deletions .ci/FudgePostInstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
. $env:ChocolateyInstall\helpers\functions\Write-FunctionCallLogMessage.ps1
. $env:ChocolateyInstall\helpers\functions\Get-EnvironmentVariable.ps1
. $env:ChocolateyInstall\helpers\functions\Get-EnvironmentVariableNames.ps1
. $env:ChocolateyInstall\helpers\functions\Start-ChocolateyProcessAsAdmin.ps1
. $env:ChocolateyInstall\helpers\functions\Set-EnvironmentVariable.ps1
. $env:ChocolateyInstall\helpers\functions\Set-PowerShellExitCode.ps1
. $env:ChocolateyInstall\helpers\functions\Update-SessionEnvironment.ps1
. $env:ChocolateyInstall\helpers\functions\Write-FunctionCallLogMessage.ps1
. $env:ChocolateyInstall\helpers\functions\Install-ChocolateyPath.ps1

Set-StrictMode -Version latest


function Get-PHP-Root
{
$list = Get-ChildItem -Directory 'C:\tools\' | Out-String
Write-Verbose $list

Get-ChildItem -Directory 'C:\tools\' -filter 'php*' | % {
$PHP_ROOT = $_.FullName

Write-Host 'Setting PHP_ROOT='$PHP_ROOT

Set-ItemProperty -path 'HKCU:\Environment' -name 'PHP_ROOT' -value $PHP_ROOT
}
if ($PHP_ROOT) {
return $PHP_ROOT
}
throw ('php not found in ' + $list)
}

function Create-PHP-Ini
{
param (
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]
$PHP_ROOT
)

$PHP_INI = ($PHP_ROOT + '\php.ini')

Write-Host 'Creating '$PHP_INI

cp ($PHP_INI + '-production') $PHP_INI
sed -i 's/;date.timezone =.*/date.timezone=UTC/' $PHP_INI

$list = Get-ChildItem -Recurse $PHP_ROOT | Out-String
Write-Verbose ('php dir ' + $list)

Write-Host 'Enabling PHP openssl ...'

$openssl_dll = ''

Get-ChildItem $PHP_ROOT -Recurse -filter '*openssl*.dll' | % {
$openssl_dll = $_.FullName
Write-Host ' found '$openssl_dll
}
if (! $openssl_dll) {
Write-Host ' not found'
throw ('openssl not found in ' + $list)
}

sed -i 's/;extension=openssl/extension=openssl/' $PHP_INI

$dir = Split-Path -Path $openssl_dll
Write-Host 'Setting extension directory: '$dir

(Get-Content $PHP_INI) | % {
$_ -replace ';extension_dir *=.*', ('extension_dir="' + $dir + '"')
} | Set-Content $PHP_INI

grep '^extension' $PHP_INI
}

function Install-PEAR
{
param (
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]
$PHP_ROOT
)

$PHP = ($PHP_ROOT + '\php.exe')

Write-Host 'Installing PEAR'

$pear_install_url = 'http://pear.php.net/install-pear-nozlib.phar'
$phar = $env:TMP + '\install-pear.phar'

curl -o $phar $pear_install_url

$opts = ('-b ' + $PHP_ROOT + ' -d ' + $PHP_ROOT + ' -p ' + $PHP)

Invoke-Expression ($PHP + ' ' + $phar + ' ' + $opts)
}

function Update-PEAR
{
param (
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]
$PHP_ROOT
)

$PHP = ($PHP_ROOT + '\php.exe')

Write-Host 'Updating PEAR channel pear.php.net'

$pearcmd = ($PHP_ROOT + '\pearcmd.php')

$pear_update_cmd = ($PHP + ' ' + $pearcmd + ' channel-update pear.php.net')

Invoke-Expression $pear_update_cmd
}

function Add-R-to-PATH
{
$list = Get-ChildItem -Directory 'C:\Program Files\R' | Out-String
Write-Verbose $list

Get-ChildItem -Directory 'C:\Program Files\R' | % {
$R_ROOT = $_.FullName

# $R_ROOT = $R_ROOT -replace 'C:\\Program Files', '%ProgramFiles%'

Write-Host 'Setting R_ROOT='$R_ROOT

Set-ItemProperty -path 'HKCU:\Environment' -name 'R_ROOT' -value $R_ROOT

$R_BIN = ($R_ROOT + '\bin')

Install-ChocolateyPath -PathToInstall $R_BIN
}
if ($R_ROOT) {
return $R_ROOT
}
throw ('R not found in ' + $list)
}

function Update-Cabal
{
cabal update
}

function PPM-Install-cpanm
{
ppm install App-cpanminus
}

function Install-GoMetaLinter
{
go.exe get -u gopkg.in/alecthomas/gometalinter.v2
}

function Install-GoPM
{
go.exe get -u github.com/gpmgo/gopm
go.exe install github.com/gpmgo/gopm
}

function Fixes
{
$PHP_ROOT = Get-PHP-Root

Create-PHP-Ini $PHP_ROOT
Install-PEAR $PHP_ROOT
Update-PEAR $PHP_ROOT

Add-R-to-PATH

Update-Cabal

PPM-Install-cpanm

Install-GoMetaLinter
Install-GoPM

return $LastExitCode
}
24 changes: 24 additions & 0 deletions .ci/Fudgefile.appveyor
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"scripts": {
"pre": {
"install": ". .ci/AppVeyor.ps1; Fix-AppVeyor"
}
},
"source": ".ci/nuspecs",
"packages": [
{ "name": "python", "version": "3.6.8" },
{ "name": "nodejs", "version": "11.13.0" },
{ "name": "ruby", "version": "2.6.1.1" },
{ "name": "golang", "version": "1.9.7" },
{ "name": "StrawberryPerl", "version": "5.28.0.1" },
{ "name": "miniconda3", "version": "4.5.12" }
],
"pack": {
"python": ".ci/nuspecs/python.nuspec",
"nodejs": ".ci/nuspecs/nodejs.nuspec",
"ruby": ".ci/nuspecs/ruby.nuspec",
"golang": ".ci/nuspecs/golang.nuspec",
"StrawberryPerl": ".ci/nuspecs/StrawberryPerl.nuspec",
"miniconda3": ".ci/nuspecs/miniconda3.nuspec"
}
}
Loading

0 comments on commit 33dddca

Please sign in to comment.