aboutsummaryrefslogtreecommitdiffstats
path: root/community/powershell/APKBUILD
blob: 973e9ef45636e715f708e83bc0edf74ff5d5c4d6 (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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# Maintainer: Antoine Martin (ayakael) <dev@ayakael.net>
# Contributor: Antoine Martin (ayakael) <dev@ayakael.net>
pkgname=powershell
pkgver=7.3.3
_gittag=v$pkgver
pkgrel=1
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-$_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

# 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
"