1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-22 02:35:23 +03:00
aports/community/powershell/APKBUILD
2023-02-27 17:35:14 +00:00

137 lines
4.2 KiB
Text

# Maintainer: Antoine Martin (ayakael) <dev@ayakael.net>
# Contributor: Antoine Martin (ayakael) <dev@ayakael.net>
pkgname=powershell
pkgver=7.3.3
_gittag=v$pkgver
pkgrel=0
pkgdesc="A cross-platform automation and configuration tool/framework"
arch="all !x86 !armhf !riscv64 !ppc64le" # blocked by dotnet runtime, ppc64le too slow for now
url="https://github.com/PowerShell/PowerShell"
license="MIT"
depends="
dotnet7-runtime
libpsl-native
"
makedepends="
dotnet7-sdk
git
"
source="
$pkgname-$_gittag.tar.gz::https://github.com/PowerShell/PowerShell/archive/$_gittag.tar.gz
dependency-gatherer.targets
fix-filesystem-test.patch
update-sdk-test-ppc64le.patch
"
builddir="$srcdir"/PowerShell-${_gittag/v}
# 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
# build on ppc64le tend to hang on roslyn csc processes,
# one during build, another during check. Disable check
# as to expedite build
case $CARCH in
ppc64le) options="!check"
esac
# mono-flavored runtime does not support crossgen2
case $CARCH in
armhf|s390x|ppc64le) _use_crossgen2=false;;
esac
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"
rm "global.json"
mkdir -p "$_logdir"
}
build() {
msg "Building $pkgname"
# change nuget cache
export NUGET_PACKAGES="$srcdir"/nuget_cache
# Restore
dotnet restore src/powershell-unix
dotnet restore src/ResGen
dotnet restore src/TypeCatalogGen
# 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/Microsoft.PowerShell.SDK.csproj \
/t:_GetDependencies \
"/property:DesignTimeBuild=true;_DependencyFile=$PWD/src/TypeCatalogGen/powershell.inc" \
/nologo
# Generate 'powershell.version'
echo "v$pkgver" > powershell.version
# Generate resource binding C# files
cd "$builddir"/src/ResGen
dotnet run
# Generate 'CorePsTypeCatalog.cs'
cd "$builddir"/src/TypeCatalogGen
dotnet run ../System.Management.Automation/CoreCLR/CorePsTypeCatalog.cs powershell.inc
# Build powershell core
cd "$builddir"
dotnet build-server shutdown
dotnet publish --configuration Linux "src/powershell-unix/" \
--output bin \
--no-self-contained \
--runtime "$(dotnet --info | awk '$1=="RID:"{print $2}')" \
-p:PublishReadyToRun=$_use_crossgen2 \
/bl:"$_logdir"/powershell-build.binlog \
/consoleLoggerParameters:ShowTimestamp
}
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"/src/powershell-unix/bin/Linux/*/alpine* "$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="
addd5a25e0979bc207e42768431846062318b25b3350c84c0c3607833df2b3c14616497daa7291e603fbe173462e46b44903de8b2ad095bdec7ead90f18afd16 powershell-v7.3.3.tar.gz
e9c4aeebd4fead1542b2c48c70134efcdb6c573273d8d05b1f8a2ece070e26899876b30264749992beac3044059716ca8c07b3bf970a419e525057c422f843c6 dependency-gatherer.targets
0e7550d8b702eeb9ebbd42100b32cbf7a0be676c5922cd6ee03ecdd3ba11d20d42a468f73ee428c6c92c8b7b18f9b022591a368191c2a358034ba4d7e78d2b84 fix-filesystem-test.patch
82615aaf4139fad21dd152271433239e5c60b340e00b3d996a384ec4610fa423f386a4e612da6a8f6f4876446da67f3c8b9f8445e7049ab6859a15781d01281e update-sdk-test-ppc64le.patch
"