From bca40434e5f9a8e3e0c46b0a8d9d619ad7f07af5 Mon Sep 17 00:00:00 2001 From: Kaniska244 Date: Sat, 7 Dec 2024 15:39:49 +0000 Subject: [PATCH 1/6] For PR# 1144 checks --- src/git/devcontainer-feature.json | 9 +++++++-- src/git/install.sh | 6 ++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/git/devcontainer-feature.json b/src/git/devcontainer-feature.json index 87fb2ab3f..61125f2d1 100644 --- a/src/git/devcontainer-feature.json +++ b/src/git/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "git", - "version": "1.3.2", + "version": "1.3.3", "name": "Git (from source)", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/git", "description": "Install an up-to-date version of Git, built from source as needed. Useful for when you want the latest and greatest features. Auto-detects latest stable version and installs needed dependencies.", @@ -19,7 +19,12 @@ "type": "boolean", "default": true, "description": "Install from PPA if available (only supported for Ubuntu distributions)" - } + }, + "installSubtree": { + "type": "boolean", + "default": true, + "description": "Install git/contrib/subtree" + } }, "installsAfter": [ "ghcr.io/devcontainers/features/common-utils" diff --git a/src/git/install.sh b/src/git/install.sh index 976eb348d..211806249 100755 --- a/src/git/install.sh +++ b/src/git/install.sh @@ -9,6 +9,7 @@ GIT_VERSION=${VERSION} # 'system' checks the base image first, else installs 'latest' USE_PPA_IF_AVAILABLE=${PPA} +INSTALL_SUBTREE="${INSTALLSUBTREE:-"true"}" GIT_CORE_PPA_ARCHIVE_GPG_KEY=E1DD270288B4E6030699E45FA1715D88E1DF1F24 @@ -309,6 +310,11 @@ if [ "${ADJUSTED_ID}" = "alpine" ]; then git_options+=("NO_GETTEXT=YesPlease") fi make -s "${git_options[@]}" all && make -s "${git_options[@]}" install 2>&1 +if [[ $INSTALL_SUBTREE = "true" ]]; then + cd contrib/subtree/ + make && make install && make install-doc && cp git-subtree ../.. 2>&1 + cd ../../ +fi rm -rf /tmp/git-${GIT_VERSION} clean_up echo "Done!" From 24d0122c8d5721e74a955ebfde2a817109cd88aa Mon Sep 17 00:00:00 2001 From: Kaniska244 Date: Mon, 16 Dec 2024 13:41:11 +0000 Subject: [PATCH 2/6] Changes done for git subtree installation for git feature which is related to features repo issue #1143 --- src/git/install.sh | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/git/install.sh b/src/git/install.sh index 211806249..e0be28c8e 100755 --- a/src/git/install.sh +++ b/src/git/install.sh @@ -7,6 +7,8 @@ # Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/git-from-src.md # Maintainer: The VS Code and Codespaces Teams +set -ex + GIT_VERSION=${VERSION} # 'system' checks the base image first, else installs 'latest' USE_PPA_IF_AVAILABLE=${PPA} INSTALL_SUBTREE="${INSTALLSUBTREE:-"true"}" @@ -209,7 +211,12 @@ export DEBIAN_FRONTEND=noninteractive if [ ${GIT_VERSION} = "os-provided" ] || [ ${GIT_VERSION} = "system" ]; then if type git > /dev/null 2>&1; then echo "Detected existing system install: $(git version)" - # Clean up + if [[ $INSTALL_SUBTREE = "true" ]]; then + cd /usr/share/ + git clone https://github.com/git/git.git + cd git/contrib/subtree + make && make install && make install-doc && cp git-subtree ../.. 2>&1 + fi clean_up exit 0 fi @@ -225,6 +232,28 @@ if [ ${GIT_VERSION} = "os-provided" ] || [ ${GIT_VERSION} = "system" ]; then check_packages ca-certificates fi check_packages git + if [[ $INSTALL_SUBTREE = "true" ]]; then + if ! type make > /dev/null 2>&1; then + check_packages make + fi + if ! type asciidoc > /dev/null 2>&1; then + check_packages asciidoc + fi + if ! type xmlto > /dev/null 2>&1; then + check_packages xmlto + fi + if ! type getopt > /dev/null 2>&1; then + check_packages getopt + fi + cd /usr/share/ + git clone https://github.com/git/git.git + cd git/contrib/subtree + make && make install && make install-doc && cp git-subtree ../.. 2>&1 + export PATH=$PATH:/usr/share/git + # Persist the PATH change by adding it to .bashrc + echo 'export PATH=$PATH:/usr/share/git' >> ~/.bashrc + echo $PATH + fi # Clean up clean_up exit 0 From 0e75385c3770777b9651a93295b6624f46d29983 Mon Sep 17 00:00:00 2001 From: Kaniska244 Date: Mon, 16 Dec 2024 13:59:15 +0000 Subject: [PATCH 3/6] Removing CBL Mariner base image related test cases as git feature and git subtree don't get installed in these containers due to lack of support of commands such as awk, curl and getopt --- test/git/scenarios.json | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/test/git/scenarios.json b/test/git/scenarios.json index 0f5d522b3..35aee050f 100644 --- a/test/git/scenarios.json +++ b/test/git/scenarios.json @@ -116,15 +116,6 @@ } } }, - "install_git_from_src_mariner": { - "image": "mcr.microsoft.com/cbl-mariner/base/core:2.0", - "features": { - "git": { - "version": "latest", - "ppa": "false" - } - } - }, "install_git_from_system_alpine": { "image": "mcr.microsoft.com/devcontainers/base:alpine", "features": { @@ -187,14 +178,5 @@ "ppa": "true" } } - }, - "install_git_from_system_mariner": { - "image": "mcr.microsoft.com/cbl-mariner/base/core:2.0", - "features": { - "git": { - "version": "system", - "ppa": "true" - } - } } } From eb6ad3b6533d52e3f963a8272d287d8575ef2399 Mon Sep 17 00:00:00 2001 From: Kaniska244 Date: Thu, 19 Dec 2024 14:46:01 +0000 Subject: [PATCH 4/6] Changed the installation part for git subtree --- src/git/install.sh | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/src/git/install.sh b/src/git/install.sh index e0be28c8e..f9696da87 100755 --- a/src/git/install.sh +++ b/src/git/install.sh @@ -7,8 +7,6 @@ # Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/git-from-src.md # Maintainer: The VS Code and Codespaces Teams -set -ex - GIT_VERSION=${VERSION} # 'system' checks the base image first, else installs 'latest' USE_PPA_IF_AVAILABLE=${PPA} INSTALL_SUBTREE="${INSTALLSUBTREE:-"true"}" @@ -212,8 +210,26 @@ if [ ${GIT_VERSION} = "os-provided" ] || [ ${GIT_VERSION} = "system" ]; then if type git > /dev/null 2>&1; then echo "Detected existing system install: $(git version)" if [[ $INSTALL_SUBTREE = "true" ]]; then + + if ! type make > /dev/null 2>&1; then + check_packages make + fi + if ! type asciidoc > /dev/null 2>&1; then + check_packages asciidoc + fi + if ! type xmlto > /dev/null 2>&1; then + check_packages xmlto + fi + if ! type tar > /dev/null 2>&1; then + check_packages tar + fi + if ! type curl > /dev/null 2>&1; then + check_packages curl + fi cd /usr/share/ - git clone https://github.com/git/git.git + curl -sL https://github.com/git/git/tarball/master -o git-repo.tar.gz + mkdir git + tar -xzvf git-repo.tar.gz -C git --strip-components=1 cd git/contrib/subtree make && make install && make install-doc && cp git-subtree ../.. 2>&1 fi @@ -242,17 +258,26 @@ if [ ${GIT_VERSION} = "os-provided" ] || [ ${GIT_VERSION} = "system" ]; then if ! type xmlto > /dev/null 2>&1; then check_packages xmlto fi - if ! type getopt > /dev/null 2>&1; then - check_packages getopt - fi + if ! type tar > /dev/null 2>&1; then + check_packages tar + fi + if ! type curl > /dev/null 2>&1; then + check_packages curl + fi + if ! type cmp > /dev/null 2>&1; then + check_packages diffutils + fi cd /usr/share/ - git clone https://github.com/git/git.git + curl -sL https://github.com/git/git/tarball/master -o git-repo.tar.gz + mkdir git + tar -xzvf git-repo.tar.gz -C git --strip-components=1 cd git/contrib/subtree - make && make install && make install-doc && cp git-subtree ../.. 2>&1 + make && make install && make install-doc 2>&1 + cp git-subtree ../.. export PATH=$PATH:/usr/share/git # Persist the PATH change by adding it to .bashrc echo 'export PATH=$PATH:/usr/share/git' >> ~/.bashrc - echo $PATH + echo $PATH fi # Clean up clean_up From 6fe711164286e1e1b588cf76d8da67061898880a Mon Sep 17 00:00:00 2001 From: Kaniska Date: Tue, 7 Jan 2025 23:12:31 +0530 Subject: [PATCH 5/6] Corrected subtree installation part and removed temp files --- src/git/install.sh | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/src/git/install.sh b/src/git/install.sh index f9696da87..c4572dceb 100755 --- a/src/git/install.sh +++ b/src/git/install.sh @@ -30,7 +30,7 @@ elif [[ "${ID}" = "rhel" || "${ID}" = "fedora" || "${ID}" = "mariner" || "${ID_L VERSION_CODENAME="${ID}${VERSION_ID}" else echo "Linux distro ${ID} not supported." - exit 1 + exit 0 fi if [ "${ADJUSTED_ID}" = "rhel" ] && [ "${VERSION_CODENAME-}" = "centos7" ]; then @@ -226,12 +226,14 @@ if [ ${GIT_VERSION} = "os-provided" ] || [ ${GIT_VERSION} = "system" ]; then if ! type curl > /dev/null 2>&1; then check_packages curl fi - cd /usr/share/ - curl -sL https://github.com/git/git/tarball/master -o git-repo.tar.gz - mkdir git - tar -xzvf git-repo.tar.gz -C git --strip-components=1 - cd git/contrib/subtree + cd /tmp/ + GIT_VERSION=$(git --version | awk '{print $3}') + curl -sL https://github.com/git/git/archive/v${GIT_VERSION}.tar.gz | tar -xzC /tmp 2>&1 + cd /tmp/git-${GIT_VERSION} + cd contrib/subtree make && make install && make install-doc && cp git-subtree ../.. 2>&1 + cd ../../ + rm -rf /tmp/git-${GIT_VERSION} fi clean_up exit 0 @@ -267,17 +269,21 @@ if [ ${GIT_VERSION} = "os-provided" ] || [ ${GIT_VERSION} = "system" ]; then if ! type cmp > /dev/null 2>&1; then check_packages diffutils fi - cd /usr/share/ - curl -sL https://github.com/git/git/tarball/master -o git-repo.tar.gz - mkdir git - tar -xzvf git-repo.tar.gz -C git --strip-components=1 - cd git/contrib/subtree - make && make install && make install-doc 2>&1 - cp git-subtree ../.. - export PATH=$PATH:/usr/share/git - # Persist the PATH change by adding it to .bashrc - echo 'export PATH=$PATH:/usr/share/git' >> ~/.bashrc - echo $PATH + cd /tmp/ + GIT_VERSION=$(git --version | awk '{print $3}') + curl -sL https://github.com/git/git/archive/v${GIT_VERSION}.tar.gz | tar -xzC /tmp 2>&1 + cd /tmp/git-${GIT_VERSION} + cd contrib/subtree + make && make install && make install-doc && cp git-subtree ../.. 2>&1 + cd ../../ + #For some base images such as alma, rocky, fedora git subtree feature doesn’t work + # even after successful subtree installation. This happens particularly when the git + # version provided by default is an old one. Adding the installation path specifically + # for them. + if [ -f "/usr/local/libexec/git-core/git-subtree" ]; then + echo 'export PATH=$PATH:/usr/local/libexec/git-core' >> ~/.bashrc + fi + rm -rf /tmp/git-${GIT_VERSION} fi # Clean up clean_up @@ -371,4 +377,5 @@ if [[ $INSTALL_SUBTREE = "true" ]]; then fi rm -rf /tmp/git-${GIT_VERSION} clean_up +exit 0 echo "Done!" From 66c10b72e839e1ac013a8408eb631490e37059fc Mon Sep 17 00:00:00 2001 From: Kaniska Date: Tue, 7 Jan 2025 23:17:23 +0530 Subject: [PATCH 6/6] Small correction, removing debug statement --- src/git/install.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/git/install.sh b/src/git/install.sh index c4572dceb..c965f5503 100755 --- a/src/git/install.sh +++ b/src/git/install.sh @@ -30,7 +30,7 @@ elif [[ "${ID}" = "rhel" || "${ID}" = "fedora" || "${ID}" = "mariner" || "${ID_L VERSION_CODENAME="${ID}${VERSION_ID}" else echo "Linux distro ${ID} not supported." - exit 0 + exit 1 fi if [ "${ADJUSTED_ID}" = "rhel" ] && [ "${VERSION_CODENAME-}" = "centos7" ]; then @@ -377,5 +377,4 @@ if [[ $INSTALL_SUBTREE = "true" ]]; then fi rm -rf /tmp/git-${GIT_VERSION} clean_up -exit 0 echo "Done!"