aboutsummaryrefslogtreecommitdiffstats
path: root/community/powershell/APKBUILD
diff options
context:
space:
mode:
Diffstat (limited to 'community/powershell/APKBUILD')
-rw-r--r--community/powershell/APKBUILD149
1 files changed, 149 insertions, 0 deletions
diff --git a/community/powershell/APKBUILD b/community/powershell/APKBUILD
new file mode 100644
index 00000000000..69aa07b5c79
--- /dev/null
+++ b/community/powershell/APKBUILD
@@ -0,0 +1,149 @@
+# Contributor: Antoine Martin (ayakael) <dev@ayakael.net>
+# Maintainer: Antoine Martin (ayakael) <dev@ayakael.net>
+pkgname=powershell
+pkgver=7.4.2
+pkgrel=0
+pkgdesc="A cross-platform automation and configuration tool/framework"
+arch="x86_64 aarch64 armv7" # blocked by dotnet runtime
+url="https://github.com/PowerShell/PowerShell"
+license="MIT"
+depends="
+ dotnet8-runtime
+ libpsl-native
+ "
+makedepends="
+ dotnet8-sdk
+ git
+ "
+source="
+ $pkgname-$pkgver.tar.gz::https://github.com/PowerShell/PowerShell/archive/v$pkgver.tar.gz
+ rollback-system-manage-automation-psversioninfo.patch
+ dependency-gatherer.targets
+ fix-filesystem-test.patch
+ "
+builddir="$srcdir/PowerShell-$pkgver"
+# if true, then within pipeline environment, in which case send logs there
+# to be scooped
+if [ -d "$APORTSDIR/logs" ]; then
+ _logdir="$APORTSDIR"/logs
+else
+ _logdir="$srcdir"/logs
+fi
+
+# mono-flavored runtime does not support crossgen2
+case $CARCH in
+ armhf|s390x|ppc64le) _use_crossgen2=false;;
+esac
+
+# change nuget cache
+export NUGET_PACKAGES="$srcdir"/nuget_cache
+
+# secfixes:
+# 7.3.10-r0:
+# - CVE-2023-36013
+
+prepare() {
+ default_prepare
+
+ # build expects to be in git directory
+ git init
+ git config user.name "example"
+ git config user.email "example@example.com"
+ git add ./*
+ git commit -m 'Initial'
+ git tag -a "v$pkgver" -m "Initial"
+ git remote add origin "$url"
+ rm "global.json"
+ mkdir -p "$_logdir"
+
+ # Replicating build.psm1:Start-PSBuild()
+ ## Restore-PSPackage()
+ dotnet restore --locked-mode -p:PublishReadyToRun=$_use_crossgen2 --use-current-runtime src/powershell-unix
+ dotnet restore --locked-mode src/TypeCatalogGen
+ dotnet restore --locked-mode src/ResGen
+ dotnet restore --locked-mode src/Modules
+ dotnet restore --locked-mode src/Microsoft.PowerShell.GlobalTool.Shim
+}
+
+build() {
+ msg "Building $pkgname"
+
+ ## Start-ResGen(): Generate resource binding C# files
+ (
+ cd "$builddir"/src/ResGen
+ dotnet run --no-restore
+ )
+
+ ## Start-TypeGen(): Setup the build target to gather dependency information
+ cp "$srcdir/dependency-gatherer.targets" \
+ "src/Microsoft.PowerShell.SDK/obj/Microsoft.PowerShell.SDK.csproj.TypeCatalog.targets"
+
+ dotnet msbuild \
+ src/Microsoft.PowerShell.SDK \
+ -t:_GetDependencies \
+ -p:DesignTimeBuild=true \
+ -p:_DependencyFile="$builddir"/src/TypeCatalogGen/powershell.inc \
+ -nologo
+
+ dotnet run \
+ --no-restore \
+ --project src/TypeCatalogGen \
+ src/System.Management.Automation/CoreCLR/CorePsTypeCatalog.cs \
+ "$builddir"/src/TypeCatalogGen/powershell.inc
+
+ ## Build powershell core
+ dotnet build-server shutdown
+ dotnet publish --configuration Linux "src/powershell-unix/" \
+ --output lib \
+ --no-self-contained \
+ --no-restore \
+ --framework "net8.0" \
+ --use-current-runtime \
+ -p:PublishReadyToRun=$_use_crossgen2 \
+ /bl:"$_logdir"/powershell-build.binlog \
+ /consoleLoggerParameters:ShowTimestamp
+
+ ## Publish reference assemblies
+ grep 'Microsoft.NETCore.App' "$builddir"/src/TypeCatalogGen/powershell.inc | sed 's/;//' | while read -r assembly; do
+ install -Dm755 -t lib/ref "$assembly"
+ done
+}
+
+check() {
+ msg "Checking $pkgname"
+ cd "$builddir"/test/xUnit
+ dotnet build-server shutdown
+ dotnet test \
+ -c Release \
+ --runtime "$(dotnet --info | awk '$1=="RID:"{print $2}')" \
+ -p:PublishReadyToRun=$_use_crossgen2 \
+ /bl:"$_logdir"/powershell-check.binlog \
+ /consoleLoggerParameters:ShowTimestamp
+}
+
+package() {
+ # directory creation
+ install -dm 755 \
+ "$pkgdir"/usr/lib \
+ "$pkgdir"/usr/bin
+
+ # libary copy
+ cp -ar "$builddir"/lib "$pkgdir"/usr/lib/$pkgname
+
+ # already provided by 'libpsl-native' aport
+ rm -f "$pkgdir"/usr/lib/$pkgname/libpsl-native.so
+
+ # does not build for linux-musl, thus points to libc.so rather than musl
+ # see https://github.com/dotnet/runtime/issues/63187
+ rm -f "$pkgdir"/usr/lib/$pkgname/libSystem.IO.Ports.Native.so
+
+ # binary link
+ ln -s "/usr/lib/$pkgname/pwsh" "$pkgdir"/usr/bin/pwsh
+}
+
+sha512sums="
+b98665e2ffd1b3ebb6c897e361bbfed6477fa3beb54116290275168ad48e31dea30c4ed078359f27f51dab0dda2d925675bade0832670d389e39ae1f4aa01f0b powershell-7.4.2.tar.gz
+bac5ac577fd8e6bb8ba83b5c537269b635619ecde2dfa3b31de754865aab8f4fd004bcb972f08f3218ecbcb7ef33c7fb8489370f7f0aaa0bae2e88e3ec736625 rollback-system-manage-automation-psversioninfo.patch
+5a70efe247cdae8ed5c66702909137e0727cf5e25aca54983891fc17716a56081825f9a6e57c56f8fa8aa5615a159f81c68ca501d42e2ce085c073be633b3025 dependency-gatherer.targets
+0e7550d8b702eeb9ebbd42100b32cbf7a0be676c5922cd6ee03ecdd3ba11d20d42a468f73ee428c6c92c8b7b18f9b022591a368191c2a358034ba4d7e78d2b84 fix-filesystem-test.patch
+"