summaryrefslogtreecommitdiff
path: root/testing/powershell/APKBUILD
blob: d357c827a0fbb809655b78f9c1b17c64cead0ece (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Maintainer: Antoine Martin (ayakael) <dev@ayakael.net>
# Contributor: Antoine Martin (ayakael) <dev@ayakael.net>

pkgname=powershell
pkgver=7.2.5
pkgrel=1
pkgdesc="A cross-platform automation and configuration tool/framework"
arch="x86_64" # arm / arm64 seem to require crosscompilation
url="https://github.com/PowerShell/PowerShell"
license="MIT"
makedepends="
	cmake
	dotnet6-sdk
	git
	icu-dev
	lttng-ust-dev
	openssl-dev>3
	zlib-dev
	"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/PowerShell/PowerShell/archive/refs/tags/v$pkgver.tar.gz
	disable-test-mode.patch
	Microsoft.PowerShell.SDK.csproj.TypeCatalog.targets
	"
builddir="$srcdir"/PowerShell-$pkgver
options="!check" # fail on builders

case $CARCH in
	x86_64) _dotnet_arch=x64;;
	aarch64) _dotnet_arch=arm64;;
	armv7|armhf) _dotnet_arch=arm;;
esac

prepare() {
	default_prepare
	# build expects to be in git directory
	git init
	git add *
	git commit -m 'Initial'
	git tag -a "v$pkgver" -m "Initial"
	rm "global.json"
}

build() {
	## Restore
	dotnet restore src/powershell-unix
	dotnet restore src/ResGen
	dotnet restore src/TypeCatalogGen

	## Setup the build target to gather dependency information
	cp "$srcdir/Microsoft.PowerShell.SDK.csproj.TypeCatalog.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 --arch $_dotnet_arch
}

check() {
	cd "$builddir"/test/xUnit
	dotnet test -c Release
}

package() {
	# directory creation
	install -dm 755 \
		"$pkgdir"/usr/lib/$pkgname \
		"$pkgdir"/usr/bin

	# libary copy
	cp -ar "$builddir"/src/powershell-unix/bin/Linux/net6.0/linux-musl-$_dotnet_arch/* "$pkgdir"/usr/lib/$pkgname/

	# clean-up non musl files
	rm "$pkgdir"/usr/lib/$pkgname/libSystem.IO.Ports.Native.so

	# binary link
	ln -s "/usr/lib/$pkgname/pwsh" "$pkgdir"/usr/bin/pwsh
}
sha512sums="
c40a059e12e1c37a9d21f72b30f7006a31db46943003776723450335fbe4864153eb427ed7b644dce3936113a0c0095569767d38172f4dc1e8a1da8b9f90e1ac  powershell-7.2.5.tar.gz
14f1d5be6c390a216012a5ef48886ed398804443731836bb4dc1eb5af26f733144a2d627e5ea109a39fb02a9557003064e14dffb150c1e4752dc8b95f8d4325a  disable-test-mode.patch
e9c4aeebd4fead1542b2c48c70134efcdb6c573273d8d05b1f8a2ece070e26899876b30264749992beac3044059716ca8c07b3bf970a419e525057c422f843c6  Microsoft.PowerShell.SDK.csproj.TypeCatalog.targets
"