Last active
March 27, 2020 16:22
-
-
Save miicha/9940a5df75d1ea0381516752f20f8986 to your computer and use it in GitHub Desktop.
Build SVN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env pwsh | |
<# | |
.SYNOPSIS | |
Build SVN (including dependencies). | |
.PARAMETER BuildRoot | |
Directory where downloaded files and build products will be stored. | |
.PARAMETER Parallel | |
Run make with the given number of parallel worker processes. | |
.PARAMETER Tidy | |
Whether files not strictly required to run the distribution should be removed from the deployment. | |
#> | |
param ( | |
[Parameter(Position = 0, Mandatory = $false)] | |
[String]$BuildRoot = $PSScriptRoot, | |
[Int]$Parallel = 1, | |
[Switch]$libressl = $true, | |
[Switch]$apr = $true, | |
[Switch]$neon = $false, | |
[Switch]$libxml = $true, | |
[Switch]$sqlite = $true, | |
[Switch]$serf = $true, | |
[Switch]$buildHelper = $true, | |
[Switch]$Tidy = $false | |
) | |
$LibreSSLVersion = "3.0.2" | |
$LibreSSLSHA256 = "DF7B172BF79B957DD27EF36DCAA1FB162562C0E8999E194AA8C1A3DF2F15398E" | |
$aprVersion = "1.7.0" | |
$aprUtilVersion = "1.6.1" | |
$aprIconvVersion = "1.2.2" | |
$zlibVersion = "1.2.11" | |
$libxmlVersion = "2.9.7" | |
$neonVersion = "0.31.0" | |
$SQLite3Version = "3300100" | |
$SQLite3SHA256 = "8C5A50DB089BD2A1B08DBC5B00D2027602CA7FF238BA7658FABCA454D4298E60" | |
$SvnVersion = "1.13.0" | |
$SvnSHA512 = "36f390b412bf772bf894efc2aadc247f12ca30ac407e04f664c14411c3519e1bb242d1239f2f44cbcb86eafc7c413efc8eadbfe1d1e75118235a7b7adc6c85b2" | |
$SerfVersion = "1.3.9" | |
$sconsVersion = "3.1.2" | |
# Directories for various files | |
if($buildHelper){ | |
$BuildRoot = New-Item $BuildRoot -ItemType Directory -Force | |
if(Test-Path "$BuildRoot/build") {Remove-Item "$BuildRoot/build" -Recurse -Force} | |
if(Test-Path "$BuildRoot/stage") {Remove-Item "$BuildRoot/stage" -Recurse -Force} | |
$Downloads = New-Item "$BuildRoot/downloads" -ItemType Directory -Force | |
$Build = New-Item "$BuildRoot/build" -ItemType Directory | |
$Stage = New-Item "$BuildRoot/stage" -ItemType Directory | |
echo "prepare environment" | |
# Environment preparation | |
New-Item "$Stage/bin" -ItemType Directory | Out-Null | |
New-Item "$Stage/include" -ItemType Directory | Out-Null | |
New-Item "$Stage/lib" -ItemType Directory | Out-Null | |
New-Item "$Stage/lib64" -ItemType SymbolicLink -Target "lib" | Out-Null | |
New-Item "$Stage/lib/pkgconfig" -ItemType Directory | Out-Null | |
New-Item "$Stage/share" -ItemType Directory | Out-Null | |
New-Item "$Stage/share/man" -ItemType Directory | Out-Null | |
New-Item "$Stage/man" -ItemType SymbolicLink -Target "share/man" | Out-Null | |
New-Item "$Stage/share/doc" -ItemType Directory | Out-Null | |
New-Item "$Stage/doc" -ItemType SymbolicLink -Target "share/doc" | Out-Null | |
New-Item "$Stage/share/info" -ItemType Directory | Out-Null | |
} | |
else{ | |
$Downloads = "$BuildRoot/downloads" | |
$Build = "$BuildRoot/build" | |
$Stage = "$BuildRoot/stage" | |
} | |
# LibreSSL cryptography library | |
if ($libressl -And $buildHelper) { | |
$LibreSSLURL = "https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-$LibreSSLVersion.tar.gz" | |
$LibreSSLArchive = "$Downloads/libressl-$LibreSSLVersion.tar.gz" | |
if (-not (Test-Path $LibreSSLArchive -Type Leaf)) { | |
Write-Host "Downloading $LibreSSLURL" -ForegroundColor Blue | |
Invoke-WebRequest $LibreSSLURL -OutFile $LibreSSLArchive | |
} | |
echo "checking checksum" | |
if ($LibreSSLSHA256 -eq (Get-FileHash $LibreSSLArchive -Algorithm SHA256).Hash) { | |
tar -xzf $LibreSSLArchive -C $Build | |
Set-Location "$Build/libressl-$LibreSSLVersion" | |
} else { | |
Write-Error "Checksum mismatch for $LibreSSLArchive" | |
} | |
Write-Host "Building LibreSSL $LibreSSLVersion" -ForegroundColor Green | |
./configure --prefix="$Stage" | |
make -j"$Parallel" | |
make install | |
} | |
# Apache Portable Runtime | |
if ($apr -And $buildHelper) { | |
$aprURL = "http://mirrors.gigenet.com/apache//apr/apr-$aprVersion.tar.gz" | |
$aprArchive = "$Downloads/apr-$aprVersion.tar.gz" | |
if (-not (Test-Path $aprArchive -Type Leaf)) { | |
Write-Host "Downloading $aprURL" -ForegroundColor Blue | |
Invoke-WebRequest $aprURL -OutFile $aprArchive | |
} | |
echo "unpack apr" | |
tar -xzf $aprArchive -C $Build | |
Set-Location "$Build/apr-$aprVersion" | |
Write-Host "Building apr $aprVersion" -ForegroundColor Green | |
./configure --prefix="$Stage" | |
make -j"$Parallel" | |
make install | |
} | |
# Apache Portable Runtime Util | |
if ($apr -And $buildHelper) { | |
$aprUtilURL = "http://mirrors.gigenet.com/apache//apr/apr-util-$aprUtilVersion.tar.gz" | |
$aprUtilArchive = "$Downloads/apr-util-$aprUtilVersion.tar.gz" | |
if (-not (Test-Path $aprUtilArchive -Type Leaf)) { | |
Write-Host "Downloading $aprUtilURL" -ForegroundColor Blue | |
Invoke-WebRequest $aprUtilURL -OutFile $aprUtilArchive | |
} | |
echo "unpack apr util" | |
tar -xzf $aprUtilArchive -C $Build | |
Set-Location "$Build/apr-util-$aprUtilVersion" | |
Write-Host "Building apr-util $aprUtilVersion" -ForegroundColor Green | |
./configure --with-apr="$Build/apr-$aprVersion" --prefix="$Stage" | |
make -j"$Parallel" | |
make install | |
} | |
# Apache Portable Runtime ICONV | |
if ($apr -And $buildHelper) { | |
$aprIconvURL = "http://mirrors.gigenet.com/apache//apr/apr-iconv-$aprIconvVersion.tar.gz" | |
$aprIconvArchive = "$Downloads/apr-iconv-$aprIconvVersion.tar.gz" | |
if (-not (Test-Path $aprIconvArchive -Type Leaf)) { | |
Write-Host "Downloading $aprIconvURL" -ForegroundColor Blue | |
Invoke-WebRequest $aprIconvURL -OutFile $aprIconvArchive | |
} | |
echo "unpack apr iconv" | |
tar -xzf $aprIconvArchive -C $Build | |
Set-Location "$Build/apr-iconv-$aprIconvVersion" | |
Write-Host "Building apr-iconv $aprIconvVersion" -ForegroundColor Green | |
./configure --with-apr="$Build/apr-$aprVersion" --prefix="$Stage" | |
make -j"$Parallel" | |
make install | |
} | |
# SQLite3 database library | |
if ($sqlite -And $buildHelper) { | |
$SQLite3URL = "https://sqlite.org/2019/sqlite-autoconf-$SQLite3Version.tar.gz" | |
$SQLite3Archive = "$Downloads/sqlite-autoconf-$SQLite3Version.tar.gz" | |
if (-not (Test-Path $SQLite3Archive -Type Leaf)) { | |
Write-Host "Downloading $SQLite3URL" -ForegroundColor Blue | |
Invoke-WebRequest $SQLite3URL -OutFile $SQLite3Archive | |
} | |
echo "checking checksum" | |
if ($SQLite3SHA256 -eq (Get-FileHash $SQLite3Archive -Algorithm SHA256).Hash) { | |
tar -xzf $SQLite3Archive -C $Build | |
Set-Location "$Build/sqlite-autoconf-$SQLite3Version" | |
} else { | |
Write-Error "Checksum mismatch for $SQLite3Archive" | |
} | |
Write-Host "Building SQLite3 $SQLite3Version" -ForegroundColor Green | |
./configure --prefix="$Stage" --disable-static | |
make -j"$Parallel" | |
make install | |
} | |
# ZLib | |
if ($zlib -And $buildHelper) { | |
$zlibURL = "http://zlib.net/zlib-$zlibVersion.tar.gz" | |
$zlibArchive = "$Downloads/zlib-$zlibVersion.tar.gz" | |
if (-not (Test-Path $zlibArchive -Type Leaf)) { | |
Write-Host "Downloading $zlibURL" -ForegroundColor Blue | |
Invoke-WebRequest $zlibURL -OutFile $zlibArchive | |
} | |
echo "unpack zlib" | |
tar -xzf $zlibArchive -C $Build | |
Set-Location "$Build/zlib-$zlibVersion" | |
Write-Host "Building zlib $zlibVersion" -ForegroundColor Green | |
./configure --prefix="$Stage" | |
make -j"$Parallel" | |
make install | |
} | |
# Libxml 2 | |
if ($libxml -And $buildHelper) { | |
$libxmlURL = "ftp://xmlsoft.org/libxml2/libxml2-$libxmlVersion.tar.gz" | |
$libxmlArchive = "$Downloads/libxml2-$libxmlVersion.tar.gz" | |
if (-not (Test-Path $libxmlArchive -Type Leaf)) { | |
Write-Host "Downloading $libxmlURL" -ForegroundColor Blue | |
wget $libxmlURL -O $libxmlArchive | |
} | |
echo "unpack libxml" | |
tar -xzf $libxmlArchive -C $Build | |
Set-Location "$Build/libxml2-$libxmlVersion" | |
Write-Host "Building libxml2 $libxmlVersion" -ForegroundColor Green | |
./configure --prefix="$Stage" | |
make -j"$Parallel" | |
make install | |
} | |
# webdav neon | |
if ($neon -And $buildHelper) { | |
$neonURL = "http://www.webdav.org/neon/neon-$neonVersion.tar.gz" | |
$neonArchive = "$Downloads/neon-$neonVersion.tar.gz" | |
if (-not (Test-Path $neonArchive -Type Leaf)) { | |
Write-Host "Downloading $neonURL" -ForegroundColor Blue | |
Invoke-WebRequest $neonURL -OutFile $neonArchive | |
} | |
echo "unpack neon" | |
tar -xzf $neonArchive -C $Build | |
Set-Location "$Build/neon-$neonVersion" | |
Write-Host "Building neon $neonVersion" -ForegroundColor Green | |
./configure --with-ssl --with-libs="$Stage" --prefix="$Stage" | |
make -j"$Parallel" | |
make install | |
} | |
# Apache Serf library | |
if ($serf -And $buildHelper) { | |
$SerfURL = "https://www.apache.org/dist/serf/serf-$SerfVersion.tar.bz2" | |
$SerfArchive = "$Downloads/serf-$SerfVersion.tar.gz" | |
if (-not (Test-Path $SerfArchive -Type Leaf)) { | |
Write-Host "Downloading $SerfURL" -ForegroundColor Blue | |
Invoke-WebRequest $SerfURL -OutFile $SerfArchive | |
} | |
echo "checking checksum" | |
tar -xjvf $SerfArchive -C $Build | |
Set-Location "$Build/serf-$SerfVersion" | |
wget http://prdownloads.sourceforge.net/scons/scons-local-$sconsVersion.tar.gz | |
tar -xvf ./scons-local-$sconsVersion.tar.gz | |
#sed -i "/Append/s:RPATH=libdir,::" SConstruct | |
#sed -i "/Default/s:lib_static,::" SConstruct | |
#sed -i "/Alias/s:install_static,::" SConstruct | |
#sed -i "/ print/{s/print/print(/; s/$/)/}" SConstruct | |
#sed -i "/get_contents()/s/,/.decode()&/" SConstruct | |
sed -i 's/OPENSSL_VERSION_NUMBER >= 0x10100000L/OPENSSL_VERSION_NUMBER >= 0x10100000L \&\& !defined(LIBRESSL_VERSION_NUMBER)/' buckets/ssl_buckets.c | |
sed -i 's/OPENSSL_VERSION_NUMBER >= 0x10100000L/OPENSSL_VERSION_NUMBER >= 0x10100000L \&\& !defined(LIBRESSL_VERSION_NUMBER)/' test/server/test_sslserver.c | |
Write-Host "Building serf $SerfVersion" -ForegroundColor Green | |
python scons.py APR="$Stage" APU="$Stage" OPENSSL="$Stage" ZLIB="$Stage" PREFIX="$Stage" | |
#python scons.py check | |
python scons.py install | |
} | |
## SVN | |
$svnURL = "http://mirror.dkd.de/apache/subversion/subversion-$SvnVersion.tar.bz2" | |
$svnArchive = "$Downloads/svn.tar.bz2" | |
if (-not (Test-Path $svnArchive -Type Leaf)) { | |
Write-Host "Downloading $svnURL" -ForegroundColor Blue | |
Invoke-WebRequest $svnURL -OutFile $svnArchive | |
} | |
$svnSource = "$Build/subversion-$SvnVersion" | |
$svnBuild = New-Item "$Build/SVNBuild-$SvnVersion" -ItemType Directory -Force | |
echo "checking checksum" | |
if ($SvnSHA512 -eq (Get-FileHash $svnArchive -Algorithm SHA512).Hash) { | |
tar -xjf $svnArchive -C $Build | |
Set-Location $svnBuild | |
} else { | |
Write-Error "Checksum mismatch for $svnArchive" | |
} | |
Write-Host "$svnSource/configure" -ForegroundColor Green | |
& "$svnSource/configure" --without-berkeley-db --without-apxs --without-swig --with-zlib="$Stage" --with-sqlite="$Stage" --with-ssl --without-pic --disable-shared --with-apr="$Build/apr-$aprVersion" --with-apr-util="$Build/apr-util-$aprUtilVersion" --with-lz4=internal --with-utf8proc=internal --with-serf="$Stage" --prefix="$Stage" | |
make | |
make install | |
Set-Location $BuildRoot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment