From c50b85ec4741d6335cb6a50bf66c7acdaf9529dc Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Thu, 23 Feb 2023 23:59:25 -0500 Subject: [PATCH] user/powershell: new aport --- user/powershell/APKBUILD | 115 ++++++++++++++++++ user/powershell/dependency-gatherer.targets | 9 ++ user/powershell/fix-filesystem-test.patch | 40 ++++++ user/powershell/update-sdk-test-ppc64le.patch | 13 ++ 4 files changed, 177 insertions(+) create mode 100644 user/powershell/APKBUILD create mode 100644 user/powershell/dependency-gatherer.targets create mode 100644 user/powershell/fix-filesystem-test.patch create mode 100644 user/powershell/update-sdk-test-ppc64le.patch diff --git a/user/powershell/APKBUILD b/user/powershell/APKBUILD new file mode 100644 index 0000000..da86894 --- /dev/null +++ b/user/powershell/APKBUILD @@ -0,0 +1,115 @@ +# Maintainer: Antoine Martin (ayakael) +# Contributor: Antoine Martin (ayakael) +pkgname=powershell +pkgver=7.3.3 +pkgrel=0 +pkgdesc="A cross-platform automation and configuration tool/framework" +arch="all !x86 !armhf !riscv64" # blocked by dotnet runtime +url="https://github.com/PowerShell/PowerShell" +license="MIT" +depends=" + dotnet7-runtime + libpsl-native + " +makedepends=" + dotnet7-sdk + git + " +source=" + $pkgname-$pkgver.tar.gz::https://github.com/PowerShell/PowerShell/archive/refs/tags/v$pkgver.tar.gz + dependency-gatherer.targets + fix-filesystem-test.patch + update-sdk-test-ppc64le.patch + " +builddir="$srcdir"/PowerShell-$pkgver + +# 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" +} + +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 publish --configuration Linux "src/powershell-unix/" \ + --output bin \ + --no-self-contained \ + --runtime "$(dotnet --info | awk '$1=="RID:"{print $2}')" \ + -p:PublishReadyToRun=$_use_crossgen2 +} + +check() { + msg "Checking $pkgname" + cd "$builddir"/test/xUnit + dotnet test \ + -c Release \ + --runtime "$(dotnet --info | awk '$1=="RID:"{print $2}')" \ + -p:PublishReadyToRun=$_use_crossgen2 +} + +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-7.3.3.tar.gz +e9c4aeebd4fead1542b2c48c70134efcdb6c573273d8d05b1f8a2ece070e26899876b30264749992beac3044059716ca8c07b3bf970a419e525057c422f843c6 dependency-gatherer.targets +0e7550d8b702eeb9ebbd42100b32cbf7a0be676c5922cd6ee03ecdd3ba11d20d42a468f73ee428c6c92c8b7b18f9b022591a368191c2a358034ba4d7e78d2b84 fix-filesystem-test.patch +82615aaf4139fad21dd152271433239e5c60b340e00b3d996a384ec4610fa423f386a4e612da6a8f6f4876446da67f3c8b9f8445e7049ab6859a15781d01281e update-sdk-test-ppc64le.patch +" diff --git a/user/powershell/dependency-gatherer.targets b/user/powershell/dependency-gatherer.targets new file mode 100644 index 0000000..85ece3e --- /dev/null +++ b/user/powershell/dependency-gatherer.targets @@ -0,0 +1,9 @@ + + + + <_RefAssemblyPath Include="%(_ReferencesFromRAR.HintPath)%3B" Condition=" '%(_ReferencesFromRAR.NuGetPackageId)' != 'Microsoft.Management.Infrastructure' "/> + + + + diff --git a/user/powershell/fix-filesystem-test.patch b/user/powershell/fix-filesystem-test.patch new file mode 100644 index 0000000..640d942 --- /dev/null +++ b/user/powershell/fix-filesystem-test.patch @@ -0,0 +1,40 @@ +From 04b0c8b1274918015c91f609cd63fdda6099ab95 Mon Sep 17 00:00:00 2001 +Patch-Source: https://github.com/PowerShell/PowerShell/issues/17889 +From: Antoine Martin +Date: Tue, 26 Jul 2022 20:34:30 -0400 +Subject: [PATCH 1/1] Neutralize PSTests.Parallel.FileSystemProviderTests.TestMode + +PSTests.Parallel.FileSystemProviderTests.TestMode prints error: +[xUnit.net 00:00:06.26] PSTests.Parallel.FileSystemProviderTests.TestMode [FAIL] + Failed PSTests.Parallel.FileSystemProviderTests.TestMode [5 ms] + Error Message: + Assert.Equal() Failure + ↓ (pos 0) +Expected: ----- +Actual: l---- + ↑ (pos 0) + Stack Trace: + at PSTests.Parallel.FileSystemProviderTests.TestMode() in /home/user/projects/powershell/testing/powershell/src/PowerShell-7.2.5/test/xUnit/csharp/test_FileSystemProvider.cs:line 123 + +This patch fixes this failed test by pointing the to-be-tested file to +/bin/busybox rather than /bin/echo, as the latter is a symbolic link + +--- + test/xUnit/csharp/test_FileSystemProvider.cs | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/test/xUnit/csharp/test_FileSystemProvider.cs b/test/xUnit/csharp/test_FileSystemProvider.cs +index 85ab0b2ee..160862146 100644 +--- a/test/xUnit/csharp/test_FileSystemProvider.cs ++++ b/test/xUnit/csharp/test_FileSystemProvider.cs +@@ -109,7 +109,7 @@ namespace PSTests.Parallel + { + directoryObject = new DirectoryInfo(@"/"); + fileObject = new FileInfo(@"/etc/hosts"); +- executableObject = new FileInfo(@"/bin/echo"); ++ executableObject = new FileInfo(@"/bin/busybox"); + } + else + { +-- +2.36.2 diff --git a/user/powershell/update-sdk-test-ppc64le.patch b/user/powershell/update-sdk-test-ppc64le.patch new file mode 100644 index 0000000..de81350 --- /dev/null +++ b/user/powershell/update-sdk-test-ppc64le.patch @@ -0,0 +1,13 @@ +diff --git a/test/xUnit/xUnit.tests.csproj.orig b/test/xUnit/xUnit.tests.csproj +index 797f1bd..6f78ed9 100644 +--- a/test/xUnit/xUnit.tests.csproj.orig ++++ b/test/xUnit/xUnit.tests.csproj +@@ -27,7 +27,7 @@ + + + +- ++ + + +