Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 798972

Summary: app-shells/pwsh: New ebuild (source-based version of app-shells/pwsh-bin)
Product: Gentoo Linux Reporter: Zac Medico <zmedico>
Component: New packagesAssignee: Default Assignee for New Packages <maintainer-wanted>
Status: CONFIRMED ---    
Severity: normal CC: kingjon3377, lssndrbarbieri, lucas.yamanishi, sam
Priority: Normal Keywords: PullRequest
Version: unspecified   
Hardware: All   
OS: All   
See Also: https://github.com/gentoo/gentoo/pull/21451
https://bugs.gentoo.org/show_bug.cgi?id=798975
Whiteboard:
Package list:
Runtime testing required: ---

Description Zac Medico gentoo-dev 2021-06-28 03:44:00 UTC
I've got a working ebuild except that it currently requires RESTRICT+=" network-sandbox":

> # Copyright 2021 Gentoo Authors
> # Distributed under the terms of the GNU General Public License v2
> 
> EAPI="7"
> 
> MY_PN=PowerShell
> DESCRIPTION="PowerShell Core is a cross-platformautomation and configuration tool/framework"
> HOMEPAGE="https://powershell.org/"
> KEYWORDS="~amd64"
> LICENSE="MIT"
> SRC_URI="https://github.com/PowerShell/PowerShell/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz"
> SLOT="0"
> RESTRICT+=" network-sandbox"
> # TODO: Can we test if some flags were respected?
> # Similar issue for Rust: https://bugs.gentoo.org/796887
> QA_FLAGS_IGNORED=".*"
> QA_PRESTRIPPED=".*"
> RDEPEND="
> 	app-crypt/mit-krb5:=
> 	dev-util/lttng-ust:=
> 	dev-libs/openssl:=
> 	sys-libs/pam:=
> 	sys-libs/zlib:=
> "
> DEPEND="
> 	${RDEPEND}
> "
> BDEPEND="
> 	|| ( app-shells/pwsh-bin app-shells/pwsh )
> 	virtual/dotnet-sdk
> "
> S=${WORKDIR}/${MY_PN}-${PV}
> 
> fake-git-describe() {
> 	echo "v${PV}-0-ge22c2cf6f9653e10a2a37371d11ac4f18c3fd681"
> }
> 
> src_prepare() {
> 	local dotnet_version
> 	dotnet_version=$(cd "${T}" && dotnet --version) || die
> 	sed -e 's/\([^#]\)\(Install-Dotnet @DotnetArguments\)/\1#\2/' -i ./build.psm1 || die
> 	#sed -e 's/\([^#]\)\(Restore-PSPackage -Options\)/\1#\2/' -i ./build.psm1 || die
> 	sed -e 's|"version": .*|"version": "'${dotnet_version}'"|' -i ./global.json || die
> 	#sed -e "s|<Exec Command='git describe[^']*'|<Exec Command='echo $(fake-git-describe)'|" -i PowerShell.Common.props || die
> 	default
> }
> 
> src_compile() {
> 	# Use a git wrapper to log any undesirable git calls.
> 	mkdir "${T}/bin" || die
> 	cat <<-EOF >"${T}/bin/git"
> 	#!/bin/bash
> 	if [[ \$1 != describe ]]; then
> 		echo " * QA Notice: git \${*}" >&2
> 	fi
> 	echo "$(fake-git-describe)"
> 	EOF
> 	chmod +x "${T}/bin/git" || die
> 
> 	(
> 		export PATH=${T}/bin:${PATH}
> 
> 		einfo Start-PSBootstrap
> 		pwsh - < <(
> 			printf -- 'Import-Module ./build.psm1 -ArgumentList $true\nStart-PSBootstrap\n'
> 		) || die "Start-PSBootstrap failed"
> 
> 		einfo Start-PSBuild
> 		pwsh - < <(
> 			printf -- 'Import-Module ./build.psm1 -ArgumentList $true\nStart-PSBuild -ReleaseTag v%s\n' "${PV}"
> 		) || die "Start-PSBuild failed"
> 
> 	) || die
> }
> 
> src_test() {
> 	local failures=0 pwsh_exe=./src/powershell-unix/bin/Debug/net5.0/linux-x64/publish/pwsh
> 
> 	ebegin "--version"
> 	[[ $("${pwsh_exe}" --version) == "${MY_PN} ${PV}" ]]
> 	eend "$?" "fail" || (( failures += 1 ))
> 
> 	ebegin "hello world"
> 	[[ $("${pwsh_exe}" -NonInteractive -c "Write-Host 'hello world'") == "hello world" ]]
> 	eend "$?" "fail" || (( failures += 1 ))
> 
> 	if (( failures > 0 )); then
> 		die "${failures} tests failed"
> 	fi
> }
> 
> src_install() {
> 	local dest=var/lib/pwsh symlink
> 	dodir "${dest%/*}"
> 
> 	mv "${S}/src/powershell-unix/bin/Debug/net5.0/linux-x64/publish" "${ED}/${dest}" || die
> 	fperms 0755 "/${dest}/pwsh"
> 
> 	dosym "../../${dest}/pwsh" "/usr/bin/pwsh"
> }