Unverified Commit f92f7ba7 authored by Samruddhi Khandale's avatar Samruddhi Khandale Committed by GitHub

[common-utils]: Bug fix: Install zsh on an image previously built with "installZsh:false" (#649)

* [common-utils]: Bug fix: Installs zsh on an image built with installZsh:false

* version bump

* nit: fix merge conflicts

* Version bump
parent 97eea5de
{ {
"id": "common-utils", "id": "common-utils",
"version": "2.1.2", "version": "2.1.3",
"name": "Common Utilities", "name": "Common Utilities",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/common-utils", "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.", "description": "Installs a set of common command line utilities, Oh My Zsh!, and sets up a non-root user.",
......
...@@ -28,7 +28,10 @@ install_debian_packages() { ...@@ -28,7 +28,10 @@ install_debian_packages() {
# Ensure apt is in non-interactive to avoid prompts # Ensure apt is in non-interactive to avoid prompts
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
local package_list="apt-utils \ local package_list=""
if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then
package_list="${package_list} \
apt-utils \
openssh-client \ openssh-client \
gnupg2 \ gnupg2 \
dirmngr \ dirmngr \
...@@ -70,6 +73,34 @@ install_debian_packages() { ...@@ -70,6 +73,34 @@ install_debian_packages() {
manpages-dev \ manpages-dev \
init-system-helpers" init-system-helpers"
# Include libssl1.1 if available
if [[ ! -z $(apt-cache --names-only search ^libssl1.1$) ]]; then
package_list="${package_list} libssl1.1"
fi
# Include libssl3 if available
if [[ ! -z $(apt-cache --names-only search ^libssl3$) ]]; then
package_list="${package_list} libssl3"
fi
# Include appropriate version of libssl1.0.x if available
local libssl_package=$(dpkg-query -f '${db:Status-Abbrev}\t${binary:Package}\n' -W 'libssl1\.0\.?' 2>&1 || echo '')
if [ "$(echo "$libssl_package" | grep -o 'libssl1\.0\.[0-9]:' | uniq | sort | wc -l)" -eq 0 ]; then
if [[ ! -z $(apt-cache --names-only search ^libssl1.0.2$) ]]; then
# Debian 9
package_list="${package_list} libssl1.0.2"
elif [[ ! -z $(apt-cache --names-only search ^libssl1.0.0$) ]]; then
# Ubuntu 18.04
package_list="${package_list} libssl1.0.0"
fi
fi
# Include git if not already installed (may be more recent than distro version)
if ! type git > /dev/null 2>&1; then
package_list="${package_list} git"
fi
fi
# Needed for adding manpages-posix and manpages-posix-dev which are non-free packages in Debian # Needed for adding manpages-posix and manpages-posix-dev which are non-free packages in Debian
if [ "${ADD_NON_FREE_PACKAGES}" = "true" ]; then if [ "${ADD_NON_FREE_PACKAGES}" = "true" ]; then
# Bring in variables from /etc/os-release like VERSION_CODENAME # Bring in variables from /etc/os-release like VERSION_CODENAME
...@@ -88,33 +119,6 @@ install_debian_packages() { ...@@ -88,33 +119,6 @@ install_debian_packages() {
package_list="${package_list} manpages-posix manpages-posix-dev" package_list="${package_list} manpages-posix manpages-posix-dev"
fi fi
# Include libssl1.1 if available
if [[ ! -z $(apt-cache --names-only search ^libssl1.1$) ]]; then
package_list="${package_list} libssl1.1"
fi
# Include libssl3 if available
if [[ ! -z $(apt-cache --names-only search ^libssl3$) ]]; then
package_list="${package_list} libssl3"
fi
# Include appropriate version of libssl1.0.x if available
local libssl_package=$(dpkg-query -f '${db:Status-Abbrev}\t${binary:Package}\n' -W 'libssl1\.0\.?' 2>&1 || echo '')
if [ "$(echo "$libssl_package" | grep -o 'libssl1\.0\.[0-9]:' | uniq | sort | wc -l)" -eq 0 ]; then
if [[ ! -z $(apt-cache --names-only search ^libssl1.0.2$) ]]; then
# Debian 9
package_list="${package_list} libssl1.0.2"
elif [[ ! -z $(apt-cache --names-only search ^libssl1.0.0$) ]]; then
# Ubuntu 18.04
package_list="${package_list} libssl1.0.0"
fi
fi
# Include git if not already installed (may be more recent than distro version)
if ! type git > /dev/null 2>&1; then
package_list="${package_list} git"
fi
# Install the list of packages # Install the list of packages
echo "Packages to verify are installed: ${package_list}" echo "Packages to verify are installed: ${package_list}"
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
...@@ -139,6 +143,8 @@ install_debian_packages() { ...@@ -139,6 +143,8 @@ install_debian_packages() {
LOCALE_ALREADY_SET="true" LOCALE_ALREADY_SET="true"
fi fi
PACKAGES_ALREADY_INSTALLED="true"
# Clean up # Clean up
apt-get -y clean apt-get -y clean
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
...@@ -146,59 +152,69 @@ install_debian_packages() { ...@@ -146,59 +152,69 @@ install_debian_packages() {
# RedHat / RockyLinux / CentOS / Fedora packages # RedHat / RockyLinux / CentOS / Fedora packages
install_redhat_packages() { install_redhat_packages() {
local package_list="\ local package_list=""
gawk \ local remove_epel="false"
openssh-clients \
gnupg2 \
iproute \
procps \
lsof \
net-tools \
psmisc \
wget \
ca-certificates \
rsync \
unzip \
zip \
nano \
vim-minimal \
less \
jq \
openssl-libs \
krb5-libs \
libicu \
zlib \
sudo \
sed \
grep \
which \
man-db \
strace"
local install_cmd=dnf local install_cmd=dnf
if ! type dnf > /dev/null 2>&1; then if ! type dnf > /dev/null 2>&1; then
install_cmd=yum install_cmd=yum
fi fi
if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then
package_list="${package_list} \
gawk \
openssh-clients \
gnupg2 \
iproute \
procps \
lsof \
net-tools \
psmisc \
wget \
ca-certificates \
rsync \
unzip \
zip \
nano \
vim-minimal \
less \
jq \
openssl-libs \
krb5-libs \
libicu \
zlib \
sudo \
sed \
grep \
which \
man-db \
strace"
# rockylinux:9 installs 'curl-minimal' which clashes with 'curl' # rockylinux:9 installs 'curl-minimal' which clashes with 'curl'
# Install 'curl' for every OS except this rockylinux:9 # Install 'curl' for every OS except this rockylinux:9
if [[ "${ID}" = "rocky" ]] && [[ "${VERSION}" != *"9."* ]]; then if [[ "${ID}" = "rocky" ]] && [[ "${VERSION}" != *"9."* ]]; then
package_list="${package_list} curl" package_list="${package_list} curl"
fi fi
# Install OpenSSL 1.0 compat if needed # Install OpenSSL 1.0 compat if needed
if ${install_cmd} -q list compat-openssl10 >/dev/null 2>&1; then if ${install_cmd} -q list compat-openssl10 >/dev/null 2>&1; then
package_list="${package_list} compat-openssl10" package_list="${package_list} compat-openssl10"
fi fi
# Install lsb_release if available # Install lsb_release if available
if ${install_cmd} -q list redhat-lsb-core >/dev/null 2>&1; then if ${install_cmd} -q list redhat-lsb-core >/dev/null 2>&1; then
package_list="${package_list} redhat-lsb-core" package_list="${package_list} redhat-lsb-core"
fi fi
# Install git if not already installed (may be more recent than distro version) # Install git if not already installed (may be more recent than distro version)
if ! type git > /dev/null 2>&1; then if ! type git > /dev/null 2>&1; then
package_list="${package_list} git" package_list="${package_list} git"
fi
# Install EPEL repository if needed (required to install 'jq' for CentOS)
if ! ${install_cmd} -q list jq >/dev/null 2>&1; then
${install_cmd} -y install epel-release
remove_epel="true"
fi
fi fi
# Install zsh if needed # Install zsh if needed
...@@ -206,13 +222,6 @@ install_redhat_packages() { ...@@ -206,13 +222,6 @@ install_redhat_packages() {
package_list="${package_list} zsh" package_list="${package_list} zsh"
fi fi
# Install EPEL repository if needed (required to install 'jq' for CentOS)
local remove_epel="false"
if ! ${install_cmd} -q list jq >/dev/null 2>&1; then
${install_cmd} -y install epel-release
remove_epel="true"
fi
${install_cmd} -y install ${package_list} ${install_cmd} -y install ${package_list}
# Get to latest versions of all packages # Get to latest versions of all packages
...@@ -223,63 +232,70 @@ install_redhat_packages() { ...@@ -223,63 +232,70 @@ install_redhat_packages() {
if [[ "${remove_epel}" = "true" ]]; then if [[ "${remove_epel}" = "true" ]]; then
${install_cmd} -y remove epel-release ${install_cmd} -y remove epel-release
fi fi
PACKAGES_ALREADY_INSTALLED="true"
} }
# Alpine Linux packages # Alpine Linux packages
install_alpine_packages() { install_alpine_packages() {
apk update apk update
apk add --no-cache \
openssh-client \
gnupg \
procps \
lsof \
htop \
net-tools \
psmisc \
curl \
wget \
rsync \
ca-certificates \
unzip \
zip \
nano \
vim \
less \
jq \
libgcc \
libstdc++ \
krb5-libs \
libintl \
libssl1.1 \
lttng-ust \
tzdata \
userspace-rcu \
zlib \
sudo \
coreutils \
sed \
grep \
which \
ncdu \
shadow \
strace
# Install man pages - package name varies between 3.12 and earlier versions if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then
if apk info man > /dev/null 2>&1; then apk add --no-cache \
apk add --no-cache man man-pages openssh-client \
else gnupg \
apk add --no-cache mandoc man-pages procps \
fi lsof \
htop \
net-tools \
psmisc \
curl \
wget \
rsync \
ca-certificates \
unzip \
zip \
nano \
vim \
less \
jq \
libgcc \
libstdc++ \
krb5-libs \
libintl \
libssl1.1 \
lttng-ust \
tzdata \
userspace-rcu \
zlib \
sudo \
coreutils \
sed \
grep \
which \
ncdu \
shadow \
strace
# Install man pages - package name varies between 3.12 and earlier versions
if apk info man > /dev/null 2>&1; then
apk add --no-cache man man-pages
else
apk add --no-cache mandoc man-pages
fi
# Install git if not already installed (may be more recent than distro version) # Install git if not already installed (may be more recent than distro version)
if ! type git > /dev/null 2>&1; then if ! type git > /dev/null 2>&1; then
apk add --no-cache git apk add --no-cache git
fi
fi fi
# Install zsh if needed # Install zsh if needed
if [ "${INSTALL_ZSH}" = "true" ] && ! type zsh > /dev/null 2>&1; then if [ "${INSTALL_ZSH}" = "true" ] && ! type zsh > /dev/null 2>&1; then
apk add --no-cache zsh apk add --no-cache zsh
fi fi
PACKAGES_ALREADY_INSTALLED="true"
} }
# ****************** # ******************
...@@ -318,20 +334,17 @@ else ...@@ -318,20 +334,17 @@ else
fi fi
# Install packages for appropriate OS # Install packages for appropriate OS
if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then case "${ADJUSTED_ID}" in
case "${ADJUSTED_ID}" in "debian")
"debian") install_debian_packages
install_debian_packages ;;
;; "rhel")
"rhel") install_redhat_packages
install_redhat_packages ;;
;; "alpine")
"alpine") install_alpine_packages
install_alpine_packages ;;
;; esac
esac
PACKAGES_ALREADY_INSTALLED="true"
fi
# If in automatic mode, determine if a user already exists, if not use vscode # If in automatic mode, determine if a user already exists, if not use vscode
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment