Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 0 additions & 45 deletions src/usr/local/buildpack/tools/powershell.sh

This file was deleted.

45 changes: 45 additions & 0 deletions src/usr/local/buildpack/tools/v2/powershell.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

function prepare_tool() {
local version_codename

version_codename="$(get_distro)"
case "${version_codename}" in
"bionic") apt_install libc6 libgcc1 libgssapi-krb5-2 libicu60 libssl1.1 libstdc++6 zlib1g;;
"focal") apt_install libc6 libgcc1 libgssapi-krb5-2 libicu66 libssl1.1 libstdc++6 zlib1g;;
"jammy") apt_install libc6 libgcc1 libgssapi-krb5-2 libicu70 libssl3 libstdc++6 zlib1g;;
*)
echo "Tool '${TOOL_NAME}' not supported on: ${version_codename}! Please use ubuntu 'bionic', 'focal' or 'jammy'." >&2
exit 1
;;
esac

create_tool_path > /dev/null
}

function install_tool () {
local file
local versioned_tool_path

if [[ ! -d "$(find_tool_path)" ]]; then
if [[ $(is_root) -ne 0 ]]; then
echo "${TOOL_NAME} not prepared"
exit 1
fi
prepare_tool
fi

versioned_tool_path=$(create_versioned_tool_path)

file=$(get_from_url "https://github.com/PowerShell/PowerShell/releases/download/v${TOOL_VERSION}/powershell-${TOOL_VERSION}-linux-x64.tar.gz")
bsdtar -C "${versioned_tool_path}" -xzf "${file}"
# Happened on v7.3.0
if [[ ! -x "${versioned_tool_path}/pwsh" ]]; then
chmod +x "${versioned_tool_path}/pwsh"
fi
}

function link_tool () {
shell_wrapper pwsh "$(find_versioned_tool_path)"
pwsh -version
}
6 changes: 4 additions & 2 deletions test/powershell/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ FROM ${IMAGE} as base
RUN touch /.dummy

#--------------------------------------
# test: powershell 7.2
# test: powershell 7.2 (non-root)
#--------------------------------------
FROM base as testa

ARG APT_HTTP_PROXY
RUN prepare-tool powershell

USER 1000

# Don't update
RUN install-tool powershell v7.2.8

USER 1000

RUN set -ex; \
pwsh -Version
Expand Down