From 540128daca90f06f50b12fee8371a7a67c15fd18 Mon Sep 17 00:00:00 2001 From: Weijia Wang <9713184+wegank@users.noreply.github.com> Date: Sun, 24 Sep 2023 23:37:50 +0200 Subject: powershell: 7.3.4 -> 7.3.7 --- pkgs/shells/powershell/default.nix | 172 +++++++++++++++++++++++------------- pkgs/shells/powershell/getHashes.sh | 33 ------- 2 files changed, 111 insertions(+), 94 deletions(-) delete mode 100755 pkgs/shells/powershell/getHashes.sh (limited to 'pkgs/shells') diff --git a/pkgs/shells/powershell/default.nix b/pkgs/shells/powershell/default.nix index 2f7bc15c1b3c..0366dac5b944 100644 --- a/pkgs/shells/powershell/default.nix +++ b/pkgs/shells/powershell/default.nix @@ -1,89 +1,139 @@ -{ stdenv, lib, autoPatchelfHook, fetchurl, libunwind, libuuid, icu, curl -, darwin, makeWrapper, less, openssl, pam, lttng-ust }: - -let archString = if stdenv.isAarch64 then "arm64" - else if stdenv.isx86_64 then "x64" - else throw "unsupported platform"; - platformString = if stdenv.isDarwin then "osx" - else if stdenv.isLinux then "linux" - else throw "unsupported platform"; - platformHash = { - x86_64-darwin = "sha256-FX3OyVzwU+Ms2tgjpZ4dPdjeJx2H5541dQZAjhI3n1U="; - aarch64-darwin = "sha256-Dg7FRF5inRnzP6tjDhIgHTJ1J2EQXnegqimZPK574WQ="; - x86_64-linux = "sha256-6F1VROE6kk+LLEpdwtQ6vkbkZjP4no0TjTnAqurLmXY="; - aarch64-linux = "sha256-NO4E2TOUIYyUFJmi3zKJzOyP0/rTPTZgJZcebVNkSfk="; - }.${stdenv.hostPlatform.system} or (throw "unsupported platform"); - platformLdLibraryPath = if stdenv.isDarwin then "DYLD_FALLBACK_LIBRARY_PATH" - else if stdenv.isLinux then "LD_LIBRARY_PATH" - else throw "unsupported platform"; - libraries = [ libunwind libuuid icu curl openssl ] ++ - (if stdenv.isLinux then [ pam lttng-ust ] else [ darwin.Libsystem ]); +{ lib +, stdenv +, fetchurl +, less +, makeWrapper +, autoPatchelfHook +, curl +, icu +, libuuid +, libunwind +, openssl +, darwin +, lttng-ust +, pam +, testers +, powershell +, writeShellScript +, common-updater-scripts +, gnused +, jq +}: + +let + ext = stdenv.hostPlatform.extensions.sharedLibrary; + platformLdLibraryPath = { + darwin = "DYLD_FALLBACK_LIBRARY_PATH"; + linux = "LD_LIBRARY_PATH"; + }.${stdenv.hostPlatform.parsed.kernel.name} or (throw "unsupported platform"); in stdenv.mkDerivation rec { pname = "powershell"; - version = "7.3.4"; + version = "7.3.7"; - src = fetchurl { - url = "https://github.com/PowerShell/PowerShell/releases/download/v${version}/powershell-${version}-${platformString}-${archString}.tar.gz"; - hash = platformHash; - }; + src = passthru.sources.${stdenv.hostPlatform.system} + or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); sourceRoot = "."; strictDeps = true; - buildInputs = [ less ] ++ libraries; - nativeBuildInputs = [ makeWrapper ] - ++ lib.optional stdenv.isLinux autoPatchelfHook; - installPhase = - let - ext = stdenv.hostPlatform.extensions.sharedLibrary; - in '' - pslibs=$out/share/powershell - mkdir -p $pslibs + nativeBuildInputs = [ + less + makeWrapper + ] ++ lib.optionals stdenv.isLinux [ + autoPatchelfHook + ]; + + buildInputs = [ + curl + icu + libuuid + libunwind + openssl + ] ++ lib.optionals stdenv.isDarwin [ + darwin.Libsystem + ] ++ lib.optionals stdenv.isLinux [ + lttng-ust + pam + ]; - cp -r * $pslibs + installPhase = '' + runHook preInstall - # At least the 7.1.4-osx package does not have the executable bit set. - chmod a+x $pslibs/pwsh + mkdir -p $out/{bin,share/powershell} + cp -R * $out/share/powershell + chmod +x $out/share/powershell/pwsh + makeWrapper $out/share/powershell/pwsh $out/bin/pwsh \ + --prefix ${platformLdLibraryPath} : "${lib.makeLibraryPath buildInputs}" \ + --set TERM xterm \ + --set POWERSHELL_TELEMETRY_OPTOUT 1 \ + --set DOTNET_CLI_TELEMETRY_OPTOUT 1 '' + lib.optionalString (stdenv.isLinux && stdenv.isx86_64) '' - patchelf --replace-needed libcrypto${ext}.1.0.0 libcrypto${ext} $pslibs/libmi.so - patchelf --replace-needed libssl${ext}.1.0.0 libssl${ext} $pslibs/libmi.so - '' + lib.optionalString stdenv.isLinux '' - patchelf --replace-needed liblttng-ust${ext}.0 liblttng-ust${ext}.1 $pslibs/libcoreclrtraceptprovider.so - '' + '' + patchelf --replace-needed libcrypto${ext}.1.0.0 libcrypto${ext} $out/share/powershell/libmi.so + patchelf --replace-needed libssl${ext}.1.0.0 libssl${ext} $out/share/powershell/libmi.so - mkdir -p $out/bin + '' + lib.optionalString stdenv.isLinux '' + patchelf --replace-needed liblttng-ust${ext}.0 liblttng-ust${ext}.1 $out/share/powershell/libcoreclrtraceptprovider.so - makeWrapper $pslibs/pwsh $out/bin/pwsh \ - --prefix ${platformLdLibraryPath} : "${lib.makeLibraryPath libraries}" \ - --set TERM xterm --set POWERSHELL_TELEMETRY_OPTOUT 1 --set DOTNET_CLI_TELEMETRY_OPTOUT 1 + '' + '' + runHook postInstall ''; dontStrip = true; - doInstallCheck = true; - installCheckPhase = '' - # May need a writable home, seen on Darwin. - HOME=$TMP $out/bin/pwsh --help > /dev/null - ''; + passthru = { + shellPath = "/bin/pwsh"; + sources = { + aarch64-darwin = fetchurl { + url = "https://github.com/PowerShell/PowerShell/releases/download/v${version}/powershell-${version}-osx-arm64.tar.gz"; + hash = "sha256-KSBsYw369fURSmoD/YyZm9CLEIbhDR12mRp1xLCJ4Wc="; + }; + aarch64-linux = fetchurl { + url = "https://github.com/PowerShell/PowerShell/releases/download/v${version}/powershell-${version}-linux-arm64.tar.gz"; + hash = "sha256-GaAu3nD0xRqqE0Lm7Z5Da6YUQGiCFc5xHuJYDLKySGc="; + }; + x86_64-darwin = fetchurl { + url = "https://github.com/PowerShell/PowerShell/releases/download/v${version}/powershell-${version}-osx-x64.tar.gz"; + hash = "sha256-+6cy4PLpt3ZR7ui3H9rAg3C39kVryPtqE5HKzMpBa24="; + }; + x86_64-linux = fetchurl { + url = "https://github.com/PowerShell/PowerShell/releases/download/v${version}/powershell-${version}-linux-x64.tar.gz"; + hash = "sha256-GKsAH+A89/M1fxvw4C4yb7+ITcfD6Y4Oicb1K8AswwI="; + }; + }; + tests.version = testers.testVersion { + package = powershell; + command = "HOME=$(mktemp -d) pwsh --version"; + }; + updateScript = writeShellScript "update-powershell" '' + set -o errexit + export PATH="${lib.makeBinPath [ common-updater-scripts curl gnused jq ]}" + NEW_VERSION=$(curl -s https://api.github.com/repos/PowerShell/PowerShell/releases/latest | jq .tag_name --raw-output | sed -e 's/v//') + + if [[ "${version}" = "$NEW_VERSION" ]]; then + echo "The new version same as the old version." + exit 0 + fi + + for platform in ${lib.escapeShellArgs meta.platforms}; do + update-source-version "powershell" "0" "${lib.fakeHash}" --source-key="sources.$platform" + update-source-version "powershell" "$NEW_VERSION" --source-key="sources.$platform" + done + ''; + }; meta = with lib; { description = "Powerful cross-platform (Windows, Linux, and macOS) shell and scripting language based on .NET"; - homepage = "https://github.com/PowerShell/PowerShell"; + homepage = "https://microsoft.com/PowerShell"; + license = licenses.mit; + mainProgram = "pwsh"; + maintainers = with maintainers; [ wegank ]; + platforms = builtins.attrNames passthru.sources; sourceProvenance = with sourceTypes; [ binaryBytecode binaryNativeCode ]; - maintainers = with maintainers; [ yrashk srgom p3psi ]; - mainProgram = "pwsh"; - platforms = [ "x86_64-darwin" "x86_64-linux" "aarch64-linux" "aarch64-darwin" ]; - license = with licenses; [ mit ]; }; - - passthru = { - shellPath = "/bin/pwsh"; - }; - } diff --git a/pkgs/shells/powershell/getHashes.sh b/pkgs/shells/powershell/getHashes.sh deleted file mode 100755 index 785ab264ebcc..000000000000 --- a/pkgs/shells/powershell/getHashes.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env nix-shell -#!nix-shell -i bash -p bash wget coreutils nix -version=$1 - -if [[ -z $version ]] -then - echo "Pass the version to get hashes for as an argument" - exit 1 -fi - -allOutput="" - -dlDest=$(mktemp) - -trap 'rm $dlDest' EXIT - -for plat in osx linux; do - for arch in x64 arm64; do - - URL="https://github.com/PowerShell/PowerShell/releases/download/v$version/powershell-$version-$plat-$arch.tar.gz" - wget $URL -O $dlDest >&2 - - hash=$(nix hash file $dlDest) - - allOutput+=" -variant: $plat $arch -hash: $hash -" - - done -done - -echo "$allOutput" -- cgit 1.4.1