From 4393b58dced4a0674f341dd573d9b18daa305fc1 Mon Sep 17 00:00:00 2001 From: Mikhail Timofeev <48208649+miketimofeev@users.noreply.github.com> Date: Wed, 25 May 2022 20:25:12 +0400 Subject: [PATCH] Get back container tools on Ubuntu 18&20 (#5611) --- .../SoftwareReport.Generator.ps1 | 10 +++------ .../SoftwareReport/SoftwareReport.Tools.psm1 | 12 +++++++++++ images/linux/scripts/installers/containers.sh | 21 ++++++++++++++++++- images/linux/scripts/tests/Tools.Tests.ps1 | 2 +- images/linux/ubuntu1804.json | 1 + images/linux/ubuntu2004.json | 1 + 6 files changed, 38 insertions(+), 9 deletions(-) diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 index dc0f9a8f1..4671f90bd 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 @@ -120,6 +120,9 @@ $toolsList = @( (Get-DockerComposeV2Version), (Get-DockerBuildxVersion), (Get-DockerAmazonECRCredHelperVersion), + (Get-BuildahVersion), + (Get-PodManVersion), + (Get-SkopeoVersion), (Get-GitVersion), (Get-GitLFSVersion), (Get-GitFTPVersion), @@ -155,13 +158,6 @@ if ((Test-IsUbuntu18) -or (Test-IsUbuntu20)) { (Get-HHVMVersion) ) } -if (Test-IsUbuntu22) { - $toolsList += @( - (Get-BuildahVersion), - (Get-PodManVersion), - (Get-SkopeoVersion) - ) -} if ((Test-IsUbuntu20) -or (Test-IsUbuntu22)) { $toolsList += (Get-FastlaneVersion) diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 index 383c113a8..ca119f67b 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 @@ -42,16 +42,28 @@ function Get-CodeQLBundleVersion { function Get-PodManVersion { $podmanVersion = podman --version | Take-OutputPart -Part 2 + if ((Test-IsUbuntu18) -or (Test-IsUbuntu20)) { + $aptSourceRepo = Get-AptSourceRepository -PackageName "containers" + return "Podman $podmanVersion (apt source repository: $aptSourceRepo)" + } return "Podman $podmanVersion" } function Get-BuildahVersion { $buildahVersion = buildah --version | Take-OutputPart -Part 2 + if ((Test-IsUbuntu18) -or (Test-IsUbuntu20)) { + $aptSourceRepo = Get-AptSourceRepository -PackageName "containers" + return "Buildah $buildahVersion (apt source repository: $aptSourceRepo)" + } return "Buildah $buildahVersion" } function Get-SkopeoVersion { $skopeoVersion = skopeo --version | Take-OutputPart -Part 2 + if ((Test-IsUbuntu18) -or (Test-IsUbuntu20)) { + $aptSourceRepo = Get-AptSourceRepository -PackageName "containers" + return "Skopeo $skopeoVersion (apt source repository: $aptSourceRepo)" + } return "Skopeo $skopeoVersion" } diff --git a/images/linux/scripts/installers/containers.sh b/images/linux/scripts/installers/containers.sh index ebd42cabf..00595b319 100644 --- a/images/linux/scripts/installers/containers.sh +++ b/images/linux/scripts/installers/containers.sh @@ -4,11 +4,30 @@ ## Desc: Installs container tools: podman, buildah and skopeo onto the image ################################################################################ +source $HELPER_SCRIPTS/os.sh + install_packages=(podman buildah skopeo) +# Packages is available in the official Ubuntu upstream starting from Ubuntu 21 +if isUbuntu18 || isUbuntu20; then + REPO_URL="https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable" + source /etc/os-release + sh -c "echo 'deb ${REPO_URL}/x${NAME}_${VERSION_ID}/ /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list" + wget -qnv https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/x${NAME}_${VERSION_ID}/Release.key -O Release.key + apt-key add Release.key +fi + # Install podman, buildah, scopeo container's tools -apt-get -qq -y install ${install_packages[@]} +apt-get update +apt-get -y install ${install_packages[@]} mkdir -p /etc/containers echo -e "[registries.search]\nregistries = ['docker.io', 'quay.io']" | tee /etc/containers/registries.conf +if isUbuntu18 || isUbuntu20; then + # Remove source repo + rm /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list + # Document source repo + echo "containers $REPO_URL" >> $HELPER_SCRIPTS/apt-sources.txt +fi + invoke_tests "Tools" "Containers" diff --git a/images/linux/scripts/tests/Tools.Tests.ps1 b/images/linux/scripts/tests/Tools.Tests.ps1 index 582da0ea6..16a7e57cf 100644 --- a/images/linux/scripts/tests/Tools.Tests.ps1 +++ b/images/linux/scripts/tests/Tools.Tests.ps1 @@ -338,7 +338,7 @@ Describe "GraalVM" -Skip:(Test-IsUbuntu18) { } } -Describe "Containers" -Skip:(-not (Test-IsUbuntu22)) { +Describe "Containers" { $testCases = @("podman", "buildah", "skopeo") | ForEach-Object { @{ContainerCommand = $_} } It "" -TestCases $testCases { diff --git a/images/linux/ubuntu1804.json b/images/linux/ubuntu1804.json index 8b8a0a166..bdd5847ab 100644 --- a/images/linux/ubuntu1804.json +++ b/images/linux/ubuntu1804.json @@ -199,6 +199,7 @@ "{{template_dir}}/scripts/installers/swift.sh", "{{template_dir}}/scripts/installers/cmake.sh", "{{template_dir}}/scripts/installers/codeql-bundle.sh", + "{{template_dir}}/scripts/installers/containers.sh", "{{template_dir}}/scripts/installers/dotnetcore-sdk.sh", "{{template_dir}}/scripts/installers/erlang.sh", "{{template_dir}}/scripts/installers/firefox.sh", diff --git a/images/linux/ubuntu2004.json b/images/linux/ubuntu2004.json index 1b1b1d708..ee9fb00f7 100644 --- a/images/linux/ubuntu2004.json +++ b/images/linux/ubuntu2004.json @@ -200,6 +200,7 @@ "{{template_dir}}/scripts/installers/swift.sh", "{{template_dir}}/scripts/installers/cmake.sh", "{{template_dir}}/scripts/installers/codeql-bundle.sh", + "{{template_dir}}/scripts/installers/containers.sh", "{{template_dir}}/scripts/installers/dotnetcore-sdk.sh", "{{template_dir}}/scripts/installers/erlang.sh", "{{template_dir}}/scripts/installers/firefox.sh",