Skip to content

Commit

Permalink
Merge branch 'devcontainers:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
tsuga authored Jan 11, 2025
2 parents 96a0145 + 978aa3f commit e946f6e
Show file tree
Hide file tree
Showing 37 changed files with 407 additions and 139 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/test-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ jobs:
"mcr.microsoft.com/devcontainers/base:debian",
"mcr.microsoft.com/devcontainers/base:noble"
]
exclude:
- features: oryx
baseImage: ubuntu:jammy
- features: oryx
baseImage: mcr.microsoft.com/devcontainers/base:ubuntu
steps:
- uses: actions/checkout@v4

Expand Down
2 changes: 1 addition & 1 deletion src/common-utils/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "common-utils",
"version": "2.5.1",
"version": "2.5.2",
"name": "Common Utilities",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/common-utils",
"description": "Installs a set of common command line utilities, Oh My Zsh!, and sets up a non-root user.",
Expand Down
4 changes: 3 additions & 1 deletion src/common-utils/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,9 @@ if [ "${INSTALL_ZSH}" = "true" ]; then

# Add devcontainer .zshrc template
if [ "$INSTALL_OH_MY_ZSH_CONFIG" = "true" ]; then
echo -e "$(cat "${template_path}")\nDISABLE_AUTO_UPDATE=true\nDISABLE_UPDATE_PROMPT=true" > ${user_rc_file}
if ! [ -f "${template_path}" ] || ! grep -qF "$(head -n 1 "${template_path}")" "${user_rc_file}"; then
echo -e "$(cat "${template_path}")\nDISABLE_AUTO_UPDATE=true\nDISABLE_UPDATE_PROMPT=true" > ${user_rc_file}
fi
sed -i -e 's/ZSH_THEME=.*/ZSH_THEME="devcontainers"/g' ${user_rc_file}
fi

Expand Down
2 changes: 1 addition & 1 deletion src/dotnet/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "dotnet",
"version": "2.1.3",
"version": "2.2.0",
"name": "Dotnet CLI",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/dotnet",
"description": "This Feature installs the latest .NET SDK, which includes the .NET CLI and the shared runtime. Options are provided to choose a different version or additional versions.",
Expand Down
6 changes: 3 additions & 3 deletions src/dotnet/scripts/dotnet-helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ fetch_latest_version_in_channel() {
local channel="$1"
local runtime="$2"
if [ "$runtime" = "dotnet" ]; then
wget -qO- "https://dotnetcli.azureedge.net/dotnet/Runtime/$channel/latest.version"
wget -qO- "https://builds.dotnet.microsoft.com/dotnet/Runtime/$channel/latest.version"
elif [ "$runtime" = "aspnetcore" ]; then
wget -qO- "https://dotnetcli.azureedge.net/dotnet/aspnetcore/Runtime/$channel/latest.version"
wget -qO- "https://builds.dotnet.microsoft.com/dotnet/aspnetcore/Runtime/$channel/latest.version"
else
wget -qO- "https://dotnetcli.azureedge.net/dotnet/Sdk/$channel/latest.version"
wget -qO- "https://builds.dotnet.microsoft.com/dotnet/Sdk/$channel/latest.version"
fi
}

Expand Down
123 changes: 107 additions & 16 deletions src/dotnet/scripts/vendor/dotnet-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -423,11 +423,17 @@ get_normalized_architecture_for_specific_sdk_version() {
# args:
# version or channel - $1
is_arm64_supported() {
#any channel or version that starts with the specified versions
case "$1" in
( "1"* | "2"* | "3"* | "4"* | "5"*)
echo false
return 0
# Extract the major version by splitting on the dot
major_version="${1%%.*}"

# Check if the major version is a valid number and less than 6
case "$major_version" in
[0-9]*)
if [ "$major_version" -lt 6 ]; then
echo false
return 0
fi
;;
esac

echo true
Expand Down Expand Up @@ -950,6 +956,37 @@ get_absolute_path() {
return 0
}

# args:
# override - $1 (boolean, true or false)
get_cp_options() {
eval $invocation

local override="$1"
local override_switch=""

if [ "$override" = false ]; then
override_switch="-n"

# create temporary files to check if 'cp -u' is supported
tmp_dir="$(mktemp -d)"
tmp_file="$tmp_dir/testfile"
tmp_file2="$tmp_dir/testfile2"

touch "$tmp_file"

# use -u instead of -n if it's available
if cp -u "$tmp_file" "$tmp_file2" 2>/dev/null; then
override_switch="-u"
fi

# clean up
rm -f "$tmp_file" "$tmp_file2"
rm -rf "$tmp_dir"
fi

echo "$override_switch"
}

# args:
# input_files - stdin
# root_path - $1
Expand All @@ -961,15 +998,7 @@ copy_files_or_dirs_from_list() {
local root_path="$(remove_trailing_slash "$1")"
local out_path="$(remove_trailing_slash "$2")"
local override="$3"
local osname="$(get_current_os_name)"
local override_switch=$(
if [ "$override" = false ]; then
if [ "$osname" = "linux-musl" ]; then
printf -- "-u";
else
printf -- "-n";
fi
fi)
local override_switch="$(get_cp_options "$override")"

cat | uniq | while read -r file_path; do
local path="$(remove_beginning_slash "${file_path#$root_path}")"
Expand Down Expand Up @@ -1243,6 +1272,61 @@ downloadwget() {
return 0
}

extract_stem() {
local url="$1"
# extract the protocol
proto="$(echo $1 | grep :// | sed -e's,^\(.*://\).*,\1,g')"
# remove the protocol
url="${1/$proto/}"
# extract the path (if any) - since we know all of our feeds have a first path segment, we can skip the first one. otherwise we'd use -f2- to get the full path
full_path="$(echo $url | grep / | cut -d/ -f2-)"
path="$(echo $full_path | cut -d/ -f2-)"
echo $path
}

check_url_exists() {
eval $invocation
local url="$1"

local code=""
if machine_has "curl"
then
code=$(curl --head -o /dev/null -w "%{http_code}" -s --fail "$url");
elif machine_has "wget"
then
# get the http response, grab the status code
server_response=$(wget -qO- --method=HEAD --server-response "$url" 2>&1)
code=$(echo "$server_response" | grep "HTTP/" | awk '{print $2}')
fi
if [ $code = "200" ]; then
return 0
else
return 1
fi
}

sanitize_redirect_url() {
eval $invocation

local url_stem
url_stem=$(extract_stem "$1")
say_verbose "Checking configured feeds for the asset at ${yellow:-}$url_stem${normal:-}"

for feed in "${feeds[@]}"
do
local trial_url="$feed/$url_stem"
say_verbose "Checking ${yellow:-}$trial_url${normal:-}"
if check_url_exists "$trial_url"; then
say_verbose "Found a match at ${yellow:-}$trial_url${normal:-}"
echo "$trial_url"
return 0
else
say_verbose "No match at ${yellow:-}$trial_url${normal:-}"
fi
done
return 1
}

get_download_link_from_aka_ms() {
eval $invocation

Expand Down Expand Up @@ -1295,6 +1379,11 @@ get_download_link_from_aka_ms() {
return 1
fi

sanitized_redirect_url=$(sanitize_redirect_url "$aka_ms_download_link")
if [[ -n "$sanitized_redirect_url" ]]; then
aka_ms_download_link="$sanitized_redirect_url"
fi

say_verbose "The redirect location retrieved: '$aka_ms_download_link'."
return 0
else
Expand All @@ -1306,7 +1395,9 @@ get_download_link_from_aka_ms() {
get_feeds_to_use()
{
feeds=(
"https://builds.dotnet.microsoft.com/dotnet"
"https://dotnetcli.azureedge.net/dotnet"
"https://ci.dot.net/public"
"https://dotnetbuilds.azureedge.net/public"
)

Expand Down Expand Up @@ -1735,7 +1826,7 @@ do
zip_path="$1"
;;
-?|--?|-h|--help|-[Hh]elp)
script_name="$(basename "$0")"
script_name="dotnet-install.sh"
echo ".NET Tools Installer"
echo "Usage:"
echo " # Install a .NET SDK of a given Quality from a given Channel"
Expand Down Expand Up @@ -1865,4 +1956,4 @@ fi

say "Note that the script does not resolve dependencies during installation."
say "To check the list of dependencies, go to https://learn.microsoft.com/dotnet/core/install, select your operating system and check the \"Dependencies\" section."
say "Installation finished successfully."
say "Installation finished successfully."
2 changes: 1 addition & 1 deletion src/java/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "java",
"version": "1.6.1",
"version": "1.6.2",
"name": "Java (via SDKMAN!)",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/java",
"description": "Installs Java, SDKMAN! (if not installed), and needed dependencies.",
Expand Down
2 changes: 1 addition & 1 deletion src/java/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ find_version_list() {
fi

if [ "${JDK_DISTRO}" = "ms" ]; then
if [ "${major_version}" = "8" ] || [ "${major_version}" = "18" ] || [ "${major_version}" = "22" ]; then
if [ "${major_version}" = "8" ] || [ "${major_version}" = "18" ] || [ "${major_version}" = "22" ] || [ "${major_version}" = "23" ]; then
JDK_DISTRO="tem"
fi
fi
Expand Down
2 changes: 1 addition & 1 deletion src/node/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "node",
"version": "1.6.0",
"version": "1.6.1",
"name": "Node.js (via nvm), yarn and pnpm",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/node",
"description": "Installs Node.js, nvm, yarn, pnpm, and needed dependencies.",
Expand Down
4 changes: 2 additions & 2 deletions src/node/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ install_yarn() {
# Yum/DNF want to install nodejs dependencies, we'll use NPM to install yarn
su ${USERNAME} -c "umask 0002 && . '${NVM_DIR}/nvm.sh' && nvm use ${_ver} && npm install --global yarn"
fi
else
else
echo "Yarn already installed."
fi
fi
Expand Down Expand Up @@ -309,7 +309,7 @@ curl -so- "https://raw.githubusercontent.com/nvm-sh/nvm/v${NVM_VERSION}/install.
curl -so- "https://raw.githubusercontent.com/nvm-sh/nvm/\${PREV_NVM_VERSION}/install.sh" | bash
NVM_VERSION="\${PREV_NVM_VERSION}"
}
source "${NVM_DIR}/nvm.sh"
[ -s "${NVM_DIR}/nvm.sh" ] && source "${NVM_DIR}/nvm.sh"
if [ "${NODE_VERSION}" != "" ]; then
nvm alias default "${NODE_VERSION}"
fi
Expand Down
2 changes: 1 addition & 1 deletion src/oryx/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "oryx",
"version": "1.3.6",
"version": "1.4.0",
"name": "Oryx",
"description": "Installs the oryx CLI",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/oryx",
Expand Down
29 changes: 15 additions & 14 deletions src/oryx/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -149,27 +149,25 @@ DOTNET_BINARY=""

if dotnet --version > /dev/null ; then
DOTNET_BINARY=$(which dotnet)
RUNTIME_VERSIONS=$(dotnet --list-runtimes | awk '{print $2}' | sort | uniq)
fi

MAJOR_VERSION_ID=$(echo $(dotnet --version) | cut -d . -f 1)
PATCH_VERSION_ID=$(echo $(dotnet --version) | cut -d . -f 3)

PINNED_SDK_VERSION=""
# Oryx needs to be built with .NET 8
if [[ "${DOTNET_BINARY}" = "" ]] || [[ $MAJOR_VERSION_ID != "8" ]] || [[ $MAJOR_VERSION_ID = "8" && ${PATCH_VERSION_ID} -ge "101" ]] ; then
if [[ "${DOTNET_BINARY}" = "" ]] || [[ $MAJOR_VERSION_ID != "8" ]] || [[ $MAJOR_VERSION_ID = "8" && ${PATCH_VERSION_ID} -ne "202" ]] ; then
echo "'dotnet 8' was not detected. Attempting to install .NET 8 to build oryx."

# The oryx build fails with .Net 8.0.201, see https://github.com/devcontainers/images/issues/974
# Pinning it to a working version until the upstream Oryx repo updates the dependency
# install_dotnet_using_apt
PINNED_SDK_VERSION="8.0.101"
PINNED_SDK_VERSION="8.0.202"
install_dotnet_with_script ${PINNED_SDK_VERSION}

if ! dotnet --version > /dev/null ; then
echo "(!) Please install Dotnet before installing Oryx"
exit 1
fi

fi

BUILD_SCRIPT_GENERATOR=/usr/local/buildscriptgen
Expand All @@ -192,8 +190,8 @@ echo "Building solution '$SOLUTION_FILE_NAME'..."
cd $GIT_ORYX
${DOTNET_BINARY} build "$SOLUTION_FILE_NAME" -c Debug

${DOTNET_BINARY} publish -property:ValidateExecutableReferencesMatchSelfContained=false -r linux-x64 -o ${BUILD_SCRIPT_GENERATOR} -c Release $GIT_ORYX/src/BuildScriptGeneratorCli/BuildScriptGeneratorCli.csproj
${DOTNET_BINARY} publish -r linux-x64 -o ${BUILD_SCRIPT_GENERATOR} -c Release $GIT_ORYX/src/BuildServer/BuildServer.csproj
${DOTNET_BINARY} publish -property:ValidateExecutableReferencesMatchSelfContained=false -r linux-x64 -o ${BUILD_SCRIPT_GENERATOR} -c Release $GIT_ORYX/src/BuildScriptGeneratorCli/BuildScriptGeneratorCli.csproj --self-contained true
${DOTNET_BINARY} publish -r linux-x64 -o ${BUILD_SCRIPT_GENERATOR} -c Release $GIT_ORYX/src/BuildServer/BuildServer.csproj --self-contained true

chmod a+x ${BUILD_SCRIPT_GENERATOR}/GenerateBuildScript

Expand Down Expand Up @@ -236,16 +234,19 @@ fi
if [[ "${PINNED_SDK_VERSION}" != "" ]]; then
rm -f ${GIT_ORYX}/global.json
rm -rf /usr/share/dotnet/sdk/$PINNED_SDK_VERSION

# Extract the major, minor version and the first digit of the patch version
MAJOR_MINOR_PATCH1_VERSION=${PINNED_SDK_VERSION%??}
rm -rf /usr/share/dotnet/shared/Microsoft.NETCore.App/$MAJOR_MINOR_PATCH1_VERSION
rm -rf /usr/share/dotnet/shared/Microsoft.AspNetCore.App/$MAJOR_MINOR_PATCH1_VERSION
rm -rf /usr/share/dotnet/templates/$MAJOR_MINOR_PATCH1_VERSION
NEW_RUNTIME_VERSIONS=$(dotnet --list-runtimes | awk '{print $2}' | sort | uniq)
if [ -n "${RUNTIME_VERSIONS:-}" ]; then
SDK_INSTALLED_RUNTIME=$(echo "$NEW_RUNTIME_VERSIONS" | grep -vxFf <(echo "$RUNTIME_VERSIONS"))
else
SDK_INSTALLED_RUNTIME="$NEW_RUNTIME_VERSIONS"
fi
rm -rf /usr/share/dotnet/shared/Microsoft.NETCore.App/$SDK_INSTALLED_RUNTIME
rm -rf /usr/share/dotnet/shared/Microsoft.AspNetCore.App/$SDK_INSTALLED_RUNTIME
rm -rf /usr/share/dotnet/templates/$SDK_INSTALLED_RUNTIME
fi


# Clean up
rm -rf /var/lib/apt/lists/*

echo "Done!"
echo "Done!"
Loading

0 comments on commit e946f6e

Please sign in to comment.