Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 798972 - app-shells/pwsh: New ebuild (source-based version of app-shells/pwsh-bin)
Summary: app-shells/pwsh: New ebuild (source-based version of app-shells/pwsh-bin)
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All All
: Normal normal (vote)
Assignee: Default Assignee for New Packages
URL:
Whiteboard:
Keywords: PullRequest
Depends on:
Blocks:
 
Reported: 2021-06-28 03:44 UTC by Zac Medico
Modified: 2023-09-18 19:43 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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"
> }
Comment 1 Maciej Barć gentoo-dev 2023-09-18 19:43:40 UTC
Already in the ::gentoo tree.