pwsh-7.6.2gentoo
download
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# NOTICE: Before packaging we have to run "ResGen" and "GetDependencies".
# See: https://git.alpinelinux.org/aports/tree/community/powershell/APKBUILD
# The repackaged tarball contains some C# code generated by that subproject.
EAPI=8
DOTNET_PKG_COMPAT="10.0"
NUGET_APIS=(
"https://api.nuget.org/v3-flatcontainer"
"https://www.powershellgallery.com/api/v2"
)
NUGETS="
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
"
# Additional PowerShell Gallery modules.
NUGETV_MICROSOFT_POWERSHELL_ARCHIVE="1.2.5"
NUGETV_MICROSOFT_POWERSHELL_PSRESOURCEGET="1.2.0"
NUGETV_MICROSOFT_POWERSHELL_THREADJOB="2.2.0"
NUGETV_PACKAGEMANAGEMENT="1.4.8.1"
NUGETV_POWERSHELLGET="2.2.5"
NUGETV_PSREADLINE="2.4.5"
NUGETS+="
microsoft.powershell.archive@${NUGETV_MICROSOFT_POWERSHELL_ARCHIVE}
microsoft.powershell.psresourceget@${NUGETV_MICROSOFT_POWERSHELL_PSRESOURCEGET}
microsoft.powershell.threadjob@${NUGETV_MICROSOFT_POWERSHELL_THREADJOB}
packagemanagement@${NUGETV_PACKAGEMANAGEMENT}
powershellget@${NUGETV_POWERSHELLGET}
psreadline@${NUGETV_PSREADLINE}
"
inherit check-reqs desktop dotnet-pkg xdg-utils
DESCRIPTION="Cross-platform automation and configuration tool"
HOMEPAGE="https://microsoft.com/powershell/
https://github.com/PowerShell/PowerShell/"
SRC_URI="
https://dev.gentoo.org/~xgqt/distfiles/repackaged/${P}.repackaged.tar.xz
${NUGET_URIS}
"
LICENSE="MIT"
SLOT="$(ver_cut 1-2)"
KEYWORDS="amd64 arm arm64"
IUSE="gui vanilla"
RDEPEND="
>=dev-libs/libpsl-native-7.4.0:=
dev-libs/openssl-compat:1.0.0
sys-libs/pam:0/0
gui? (
dev-util/desktop-file-utils
x11-misc/shared-mime-info
)
"
DEPEND="
${RDEPEND}
"
IDEPEND="
app-eselect/eselect-pwsh
"
DOTNET_PKG_PROJECTS=(
src/powershell-unix/powershell-unix.csproj
src/Modules/PSGalleryModules.csproj
)
DOTNET_PKG_RESTORE_EXTRA_ARGS=(
-p:"RollForward=Major"
-p:"RuntimeIdentifiers="
-p:"TreatWarningsAsErrors=false"
)
DOTNET_PKG_BUILD_EXTRA_ARGS=(
"${DOTNET_PKG_RESTORE_EXTRA_ARGS[@]}"
)
CHECKREQS_DISK_BUILD="2G"
PATCHES=(
"${FILESDIR}/pwsh-7.3.3-disable-update-check.patch"
)
DOCS=(
CHANGELOG CHANGELOG.md CODE_OF_CONDUCT.md README.md
docs
)
check_requirements_locale() {
if [[ "${MERGE_TYPE}" != binary ]] ; then
if use elibc_glibc ; then
local locales="$(locale -a)"
if has en_US.utf8 ${locales} ; then
LC_ALL="en_US.utf8"
elif has en_US.UTF-8 ${locales} ; then
LC_ALL="en_US.UTF-8"
else
eerror "The locale en_US.utf8 or en_US.UTF-8 is not available."
eerror "Please generate en_US.UTF-8 before building ${CATEGORY}/${P}."
die "Could not switch to the en_US.UTF-8 locale."
fi
else
LC_ALL="en_US.UTF-8"
fi
export LC_ALL
einfo "Successfully switched to the ${LC_ALL} locale."
fi
}
pkg_pretend() {
check-reqs_pkg_pretend
check_requirements_locale
}
pkg_setup() {
check-reqs_pkg_setup
dotnet-pkg_pkg_setup
check_requirements_locale
}
src_prepare() {
if ! use vanilla ; then
PATCHES+=(
"${FILESDIR}/pwsh-7.5.0-disable-telemetry.patch"
)
fi
# This is guarded by "RegexGitVersion" in "PowerShell.Common.props".
local fake_describe="v${PV}-0-g0"
sed -e "s|git describe --abbrev=60 --long|echo ${fake_describe}|g" \
-i ./PowerShell.Common.props || die
echo "v${PV}" > ./powershell.version || die
dotnet-pkg_src_prepare
}
src_compile() {
einfo 'Copying DLL files for the missing "ref" directory'
efsi "${FILESDIR}/pwsh-7.3.3-copy-ref.fsx" "${WORKDIR}/${P}_ref"
dotnet-pkg_src_compile
}
src_test() {
local -a test_args=(
"${DOTNET_PKG_RESTORE_EXTRA_ARGS[@]}"
-p:"RuntimeIdentifier=${DOTNET_PKG_RUNTIME}"
"${S}/test/xUnit/xUnit.tests.csproj"
)
dotnet-pkg-base_restore "${test_args[@]}"
dotnet-pkg-base_test "${test_args[@]}"
}
src_install() {
local dest_root="/usr/share/${PN}-${SLOT}"
# Install additional PowerShell Gallery modules.
local -a psg_modules=(
Microsoft.PowerShell.Archive
Microsoft.PowerShell.PSResourceGet
Microsoft.PowerShell.ThreadJob
PSReadLine
PackageManagement
PowerShellGet
)
local psg_module=""
for psg_module in "${psg_modules[@]}" ; do
insinto "${dest_root}/Modules/${psg_module}"
doins -r "${NUGET_PACKAGES}/${psg_module,,}"/*
done
dotnet-pkg-base_append_launchervar 'DOTNET_ROLL_FORWARD="Major"'
dotnet-pkg-base_append_launchervar 'PSModulePath="${PSModulePath}:${EPREFIX}/usr/share/GentooPowerShell/Modules:"'
dotnet-pkg-base_install "${dest_root}"
dotnet-pkg-base_dolauncher-portable "${dest_root}/pwsh.dll" "pwsh-${SLOT}"
insinto "${dest_root}/ref"
doins "${WORKDIR}/${P}_ref"/*
# Fix runtime config because we roll forward from .NET 9.0 into .NET >-10.0.
sed -i "${ED}/${dest_root}/pwsh.runtimeconfig.json" \
-e "s|.*rollForwardOnNoCandidateFx.*||g" \
|| die "sed failed"
# Replace "libpsl-native.so" provided by "microsoft.powershell.native".
rm "${ED}/${dest_root}/libpsl-native.so" || die
dosym -r "/usr/$(get_libdir)/libpsl-native.so" "${dest_root}/libpsl-native.so"
# On musl remove "libSystem.IO.Ports.Native.so" linked against glibc.
if ! use elibc_glibc ; then
ewarn "libSystem.IO.Ports.Native.so is available only for glibc, removing it"
rm -f "${ED}/${dest_root}/libSystem.IO.Ports.Native.so" || die
fi
if use gui ; then
newicon ./assets/ps_black_128.svg "powershell-${SLOT}.svg"
make_desktop_entry "pwsh-${SLOT} -l" "PowerShell ${SLOT}" \
"powershell-${SLOT}" "ConsoleOnly;System;" "Terminal=true"
fi
einstalldocs
}
pkg_postinst() {
if use gui ; then
xdg_icon_cache_update
xdg_desktop_database_update
fi
eselect pwsh update ifunset
}
pkg_postrm() {
if use gui ; then
xdg_icon_cache_update
xdg_desktop_database_update
fi
eselect pwsh update ifunset
}