From 58033ad1fd42f006525cb72883727546b4ce29ee Mon Sep 17 00:00:00 2001 From: Ivan Nosar Date: Tue, 4 Feb 2020 17:14:16 +0300 Subject: [PATCH 1/6] Install gcc, gfortran and clang on linux --- images/linux/scripts/installers/clang.sh | 84 ++++++++++++++++----- images/linux/scripts/installers/gcc.sh | 39 +++++++--- images/linux/scripts/installers/gfortran.sh | 39 ++++++++++ images/linux/ubuntu1604.json | 1 + images/linux/ubuntu1804.json | 1 + 5 files changed, 133 insertions(+), 31 deletions(-) create mode 100644 images/linux/scripts/installers/gfortran.sh diff --git a/images/linux/scripts/installers/clang.sh b/images/linux/scripts/installers/clang.sh index b8e5fa40..d4214981 100644 --- a/images/linux/scripts/installers/clang.sh +++ b/images/linux/scripts/installers/clang.sh @@ -1,31 +1,77 @@ #!/bin/bash ################################################################################ -## File: example.sh -## Desc: This is an example script that can be copied to add a new software -## installer to the image +## File: clang.sh +## Desc: Installs Clang compiler (versions: 6, 8 and 9) ################################################################################ # Source the helpers for use with the script source $HELPER_SCRIPTS/document.sh source $HELPER_SCRIPTS/apt.sh -wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - -apt-add-repository "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-6.0 main" -apt-get update -apt-get install -y clang-6.0 lldb-6.0 lld-6.0 +function InstallClang6_0 { + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - + apt-add-repository "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-6.0 main" + apt-get update + apt-get install -y clang-6.0 lldb-6.0 lld-6.0 -update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-6.0 100 -update-alternatives --install /usr/bin/clang clang /usr/bin/clang-6.0 100 + # Run tests to determine that the software installed as expected + echo "Testing to make sure that script performed as expected, and basic scenarios work" + for cmd in clang-6.0 clang++-6.0; do + if ! command -v $cmd; then + echo "$cmd was not installed" + exit 1 + fi + done -# Run tests to determine that the software installed as expected -echo "Testing to make sure that script performed as expected, and basic scenarios work" -for cmd in clang clang++ clang-6.0 clang++-6.0; do - if ! command -v $cmd; then - echo "$cmd was not installed" - exit 1 - fi + # Document what was added to the image + echo "Lastly, documenting what we added to the metadata file" + DocumentInstalledItem "Clang 6.0 ($(clang-6.0 --version | head -n 1 | cut -d ' ' -f 3 | cut -d '-' -f 1))" +} + +function InstallClang { + version=$1 + + echo "Installing clang-$version..." + ./llvm.sh $version + + # Run tests to determine that the software installed as expected + echo "Testing to make sure that script performed as expected, and basic scenarios work" + for cmd in clang-$version clang++-$version; do + if ! command -v $cmd; then + echo "$cmd was not installed" + exit 1 + fi + done + + # Document what was added to the image + echo "Documenting clang-$version..." + DocumentInstalledItem "Clang $version ($(clang-$version --version | head -n 1 | cut -d ' ' -f 3 | cut -d '-' -f 1))" +} + +# Install Clang compiler +apt-get update -y + +# Clang 6.0 is not supported by automatic installation script (`llvm.sh`) +# Thus we have to install it explicitly +InstallClang6_0 + +# Download script for automatic installation +wget https://apt.llvm.org/llvm.sh +chmod +x llvm.sh + +# Install Clang 8 and 9 +versions=( + "8" + "9" +) + +for version in ${versions[*]} +do + InstallClang $version done -# Document what was added to the image -echo "Lastly, documenting what we added to the metadata file" -DocumentInstalledItem "Clang 6.0 ($(clang-6.0 --version | head -n 1 | sed 's/~/\\~/g'))" +rm llvm.sh + +# Make Clang 9 default +update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-9 100 +update-alternatives --install /usr/bin/clang clang /usr/bin/clang-9 100 diff --git a/images/linux/scripts/installers/gcc.sh b/images/linux/scripts/installers/gcc.sh index 328d5c76..2d94d025 100644 --- a/images/linux/scripts/installers/gcc.sh +++ b/images/linux/scripts/installers/gcc.sh @@ -7,19 +7,34 @@ # Source the helpers for use with the script source $HELPER_SCRIPTS/document.sh +function InstallGcc { + version=$1 + + echo "Installing $version..." + apt-get install $version -y + + # Run tests to determine that the software installed as expected + echo "Testing to make sure that script performed as expected, and basic scenarios work" + if ! command -v $version; then + echo "$version was not installed" + exit 1 + fi + + # Document what was added to the image + echo "Documenting $version..." + DocumentInstalledItem "GNU C++ $($version --version | head -n 1 | cut -d ' ' -f 4)" +} + # Install GNU C++ compiler -add-apt-repository ppa:ubuntu-toolchain-r/test -y apt-get update -y -apt-get install g++-7 -y +versions=( + "g++-7" + "g++-8" + "g++-9" +) -# Run tests to determine that the software installed as expected -echo "Testing to make sure that script performed as expected, and basic scenarios work" -if ! command -v g++-7; then - echo "GNU C++ was not installed" - exit 1 -fi - -# Document what was added to the image -echo "Lastly, documenting what we added to the metadata file" -DocumentInstalledItem "GNU C++ $(g++-7 --version | head -n 1 | cut -d ' ' -f 4)" +for version in ${versions[*]} +do + InstallGcc $version +done diff --git a/images/linux/scripts/installers/gfortran.sh b/images/linux/scripts/installers/gfortran.sh new file mode 100644 index 00000000..235f55ea --- /dev/null +++ b/images/linux/scripts/installers/gfortran.sh @@ -0,0 +1,39 @@ +#!/bin/bash +################################################################################ +## File: gfortran.sh +## Desc: Installs GNU Fortran +################################################################################ + +# Source the helpers for use with the script +source $HELPER_SCRIPTS/document.sh + +function InstallFortran { + version=$1 + + echo "Installing $version..." + apt-get install $version -y + + # Run tests to determine that the software installed as expected + echo "Testing to make sure that script performed as expected, and basic scenarios work" + if ! command -v $version; then + echo "$version was not installed" + exit 1 + fi + + # Document what was added to the image + echo "Documenting $version..." + DocumentInstalledItem "GNU Fortran $($version --version | head -n 1 | cut -d ' ' -f 5)" +} + +# Install GNU Fortran compiler +apt-get update -y + +versions=( + "gfortran-8" + "gfortran-9" +) + +for version in ${versions[*]} +do + InstallFortran $version +done diff --git a/images/linux/ubuntu1604.json b/images/linux/ubuntu1604.json index bca6a3ed..815fb264 100644 --- a/images/linux/ubuntu1604.json +++ b/images/linux/ubuntu1604.json @@ -132,6 +132,7 @@ "{{template_dir}}/scripts/installers/erlang.sh", "{{template_dir}}/scripts/installers/firefox.sh", "{{template_dir}}/scripts/installers/gcc.sh", + "{{template_dir}}/scripts/installers/gfortran.sh", "{{template_dir}}/scripts/installers/git.sh", "{{template_dir}}/scripts/installers/1604/go.sh", "{{template_dir}}/scripts/installers/google-chrome.sh", diff --git a/images/linux/ubuntu1804.json b/images/linux/ubuntu1804.json index 5c57731d..745922f6 100644 --- a/images/linux/ubuntu1804.json +++ b/images/linux/ubuntu1804.json @@ -135,6 +135,7 @@ "{{template_dir}}/scripts/installers/erlang.sh", "{{template_dir}}/scripts/installers/firefox.sh", "{{template_dir}}/scripts/installers/gcc.sh", + "{{template_dir}}/scripts/installers/gfortran.sh", "{{template_dir}}/scripts/installers/git.sh", "{{template_dir}}/scripts/installers/1804/go.sh", "{{template_dir}}/scripts/installers/google-chrome.sh", From 4983576a0b8ebabdf3fa240c1c3aafb85cd1a91e Mon Sep 17 00:00:00 2001 From: Ivan Nosar Date: Tue, 4 Feb 2020 18:22:33 +0300 Subject: [PATCH 2/6] Install LLVM on Windows --- images/win/Windows2016-Azure.json | 12 +++++ images/win/Windows2019-Azure.json | 12 +++++ .../win/scripts/Installers/Install-Clang.ps1 | 6 +++ .../win/scripts/Installers/Validate-Clang.ps1 | 46 +++++++++++++++++++ 4 files changed, 76 insertions(+) create mode 100644 images/win/scripts/Installers/Install-Clang.ps1 create mode 100644 images/win/scripts/Installers/Validate-Clang.ps1 diff --git a/images/win/Windows2016-Azure.json b/images/win/Windows2016-Azure.json index 375bab0a..cc15ba49 100644 --- a/images/win/Windows2016-Azure.json +++ b/images/win/Windows2016-Azure.json @@ -456,6 +456,12 @@ "{{ template_dir }}/scripts/Installers/Install-MinGW.ps1" ] }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Install-Clang.ps1" + ] + }, { "type": "powershell", "scripts":[ @@ -715,6 +721,12 @@ "{{ template_dir }}/scripts/Installers/Validate-MinGW.ps1" ] }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Validate-Clang.ps1" + ] + }, { "type": "powershell", "scripts":[ diff --git a/images/win/Windows2019-Azure.json b/images/win/Windows2019-Azure.json index c8acc4b5..24cae0e1 100644 --- a/images/win/Windows2019-Azure.json +++ b/images/win/Windows2019-Azure.json @@ -425,6 +425,12 @@ "{{ template_dir }}/scripts/Installers/Install-MinGW.ps1" ] }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Install-Clang.ps1" + ] + }, { "type": "powershell", "scripts":[ @@ -684,6 +690,12 @@ "{{ template_dir }}/scripts/Installers/Validate-MinGW.ps1" ] }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Validate-Clang.ps1" + ] + }, { "type": "powershell", "scripts":[ diff --git a/images/win/scripts/Installers/Install-Clang.ps1 b/images/win/scripts/Installers/Install-Clang.ps1 new file mode 100644 index 00000000..bd567a97 --- /dev/null +++ b/images/win/scripts/Installers/Install-Clang.ps1 @@ -0,0 +1,6 @@ +################################################################################ +## File: Install-Clang.ps1 +## Desc: Install Clang compiler as a part of LLVM framework for Windows +################################################################################ + +choco install -y llvm diff --git a/images/win/scripts/Installers/Validate-Clang.ps1 b/images/win/scripts/Installers/Validate-Clang.ps1 new file mode 100644 index 00000000..709943fa --- /dev/null +++ b/images/win/scripts/Installers/Validate-Clang.ps1 @@ -0,0 +1,46 @@ +################################################################################ +## File: Validate-Clang.ps1 +## Desc: Validate Clang installation +################################################################################ + +if (Get-Command -Name 'clang') +{ + Write-Host "clang is successfully installed:" + clang --version | Write-Host +} +else +{ + Write-Host "clang is not on PATH" + exit 1 +} + +if (Get-Command -Name 'clang++') +{ + Write-Host "clang++ is successfully installed:" + clang++ --version | Write-Host +} +else +{ + Write-Host "clang++ is not on PATH" + exit 1 +} + +# Adding description of the software to Markdown + +# `clang --version` gives output like: +# clang version 9.0.0 (tags/RELEASE_900/final) +# Target: x86_64-pc-windows-msvc +# Thread model: posix +# InstalledDir: C:\Program Files\LLVM\bin + +$SoftwareName = "Clang" +$(clang --version).Split([System.Environment]::NewLine)[0] -match "\d\.\d\.\d" +$Version = $matches[0] + +$Description = @" +_Version:_ $Version
+_Environment:_ +* PATH: contains location of the LLVM 'bin' directory +"@ + +Add-SoftwareDetailsToMarkdown -SoftwareName $SoftwareName -DescriptionMarkdown $Description From 1e889c1a8f76a0d673ad6ebdfa5c07b72e25c570 Mon Sep 17 00:00:00 2001 From: Ivan Nosar Date: Wed, 5 Feb 2020 14:08:16 +0300 Subject: [PATCH 3/6] Fix ubuntu --- images/linux/scripts/installers/gcc.sh | 1 + images/linux/scripts/installers/gfortran.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/images/linux/scripts/installers/gcc.sh b/images/linux/scripts/installers/gcc.sh index 2d94d025..86575568 100644 --- a/images/linux/scripts/installers/gcc.sh +++ b/images/linux/scripts/installers/gcc.sh @@ -26,6 +26,7 @@ function InstallGcc { } # Install GNU C++ compiler +add-apt-repository ppa:ubuntu-toolchain-r/test -y apt-get update -y versions=( diff --git a/images/linux/scripts/installers/gfortran.sh b/images/linux/scripts/installers/gfortran.sh index 235f55ea..1e392839 100644 --- a/images/linux/scripts/installers/gfortran.sh +++ b/images/linux/scripts/installers/gfortran.sh @@ -26,6 +26,7 @@ function InstallFortran { } # Install GNU Fortran compiler +add-apt-repository ppa:ubuntu-toolchain-r/test -y apt-get update -y versions=( From ff62765cc0c563498608528d74691311bea72e42 Mon Sep 17 00:00:00 2001 From: Ivan Nosar Date: Thu, 6 Feb 2020 11:21:06 +0300 Subject: [PATCH 4/6] Resolve comments --- images/linux/scripts/installers/clang.sh | 35 ++++++------------- .../win/scripts/Installers/Validate-Clang.ps1 | 2 +- 2 files changed, 11 insertions(+), 26 deletions(-) diff --git a/images/linux/scripts/installers/clang.sh b/images/linux/scripts/installers/clang.sh index d4214981..b905b5c0 100644 --- a/images/linux/scripts/installers/clang.sh +++ b/images/linux/scripts/installers/clang.sh @@ -8,31 +8,17 @@ source $HELPER_SCRIPTS/document.sh source $HELPER_SCRIPTS/apt.sh -function InstallClang6_0 { - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - - apt-add-repository "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-6.0 main" - apt-get update - apt-get install -y clang-6.0 lldb-6.0 lld-6.0 - - # Run tests to determine that the software installed as expected - echo "Testing to make sure that script performed as expected, and basic scenarios work" - for cmd in clang-6.0 clang++-6.0; do - if ! command -v $cmd; then - echo "$cmd was not installed" - exit 1 - fi - done - - # Document what was added to the image - echo "Lastly, documenting what we added to the metadata file" - DocumentInstalledItem "Clang 6.0 ($(clang-6.0 --version | head -n 1 | cut -d ' ' -f 3 | cut -d '-' -f 1))" -} - function InstallClang { version=$1 echo "Installing clang-$version..." - ./llvm.sh $version + # Clang 6.0 is not supported by automatic installation script (`llvm.sh`) + # Thus we have to install it explicitly + if [[ $version == 6* ]]; then + apt-get install -y "clang-$version" "lldb-$version" "lld-$version" + else + ./llvm.sh $version + fi # Run tests to determine that the software installed as expected echo "Testing to make sure that script performed as expected, and basic scenarios work" @@ -49,18 +35,17 @@ function InstallClang { } # Install Clang compiler +wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - +apt-add-repository "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-6.0 main" apt-get update -y -# Clang 6.0 is not supported by automatic installation script (`llvm.sh`) -# Thus we have to install it explicitly -InstallClang6_0 - # Download script for automatic installation wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh # Install Clang 8 and 9 versions=( + "6.0" "8" "9" ) diff --git a/images/win/scripts/Installers/Validate-Clang.ps1 b/images/win/scripts/Installers/Validate-Clang.ps1 index 709943fa..b785f3d3 100644 --- a/images/win/scripts/Installers/Validate-Clang.ps1 +++ b/images/win/scripts/Installers/Validate-Clang.ps1 @@ -34,7 +34,7 @@ else # InstalledDir: C:\Program Files\LLVM\bin $SoftwareName = "Clang" -$(clang --version).Split([System.Environment]::NewLine)[0] -match "\d\.\d\.\d" +$(clang --version).Split([System.Environment]::NewLine)[0] -match "\d+\.\d+\.\d+" $Version = $matches[0] $Description = @" From 5bc4c009cd055869d351a300e68433d0b3b87c6f Mon Sep 17 00:00:00 2001 From: Ivan Nosar Date: Thu, 6 Feb 2020 14:33:44 +0300 Subject: [PATCH 5/6] Remove extra comment --- images/linux/scripts/installers/clang.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/images/linux/scripts/installers/clang.sh b/images/linux/scripts/installers/clang.sh index b905b5c0..0a7f2252 100644 --- a/images/linux/scripts/installers/clang.sh +++ b/images/linux/scripts/installers/clang.sh @@ -43,7 +43,6 @@ apt-get update -y wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh -# Install Clang 8 and 9 versions=( "6.0" "8" From 9c06dae2e32a6f9fefa528aa5b764237ca293626 Mon Sep 17 00:00:00 2001 From: Ivan Nosar Date: Mon, 10 Feb 2020 13:58:06 +0300 Subject: [PATCH 6/6] Remove Clang --- images/win/Windows2016-Azure.json | 12 ----- images/win/Windows2019-Azure.json | 12 ----- .../win/scripts/Installers/Install-Clang.ps1 | 6 --- .../win/scripts/Installers/Validate-Clang.ps1 | 46 ------------------- 4 files changed, 76 deletions(-) delete mode 100644 images/win/scripts/Installers/Install-Clang.ps1 delete mode 100644 images/win/scripts/Installers/Validate-Clang.ps1 diff --git a/images/win/Windows2016-Azure.json b/images/win/Windows2016-Azure.json index 1530e486..98d96feb 100644 --- a/images/win/Windows2016-Azure.json +++ b/images/win/Windows2016-Azure.json @@ -462,12 +462,6 @@ "{{ template_dir }}/scripts/Installers/Install-MinGW.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Install-Clang.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -733,12 +727,6 @@ "{{ template_dir }}/scripts/Installers/Validate-MinGW.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-Clang.ps1" - ] - }, { "type": "powershell", "scripts":[ diff --git a/images/win/Windows2019-Azure.json b/images/win/Windows2019-Azure.json index 657f76b7..46792679 100644 --- a/images/win/Windows2019-Azure.json +++ b/images/win/Windows2019-Azure.json @@ -437,12 +437,6 @@ "{{ template_dir }}/scripts/Installers/Install-MinGW.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Install-Clang.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -708,12 +702,6 @@ "{{ template_dir }}/scripts/Installers/Validate-MinGW.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-Clang.ps1" - ] - }, { "type": "powershell", "scripts":[ diff --git a/images/win/scripts/Installers/Install-Clang.ps1 b/images/win/scripts/Installers/Install-Clang.ps1 deleted file mode 100644 index bd567a97..00000000 --- a/images/win/scripts/Installers/Install-Clang.ps1 +++ /dev/null @@ -1,6 +0,0 @@ -################################################################################ -## File: Install-Clang.ps1 -## Desc: Install Clang compiler as a part of LLVM framework for Windows -################################################################################ - -choco install -y llvm diff --git a/images/win/scripts/Installers/Validate-Clang.ps1 b/images/win/scripts/Installers/Validate-Clang.ps1 deleted file mode 100644 index b785f3d3..00000000 --- a/images/win/scripts/Installers/Validate-Clang.ps1 +++ /dev/null @@ -1,46 +0,0 @@ -################################################################################ -## File: Validate-Clang.ps1 -## Desc: Validate Clang installation -################################################################################ - -if (Get-Command -Name 'clang') -{ - Write-Host "clang is successfully installed:" - clang --version | Write-Host -} -else -{ - Write-Host "clang is not on PATH" - exit 1 -} - -if (Get-Command -Name 'clang++') -{ - Write-Host "clang++ is successfully installed:" - clang++ --version | Write-Host -} -else -{ - Write-Host "clang++ is not on PATH" - exit 1 -} - -# Adding description of the software to Markdown - -# `clang --version` gives output like: -# clang version 9.0.0 (tags/RELEASE_900/final) -# Target: x86_64-pc-windows-msvc -# Thread model: posix -# InstalledDir: C:\Program Files\LLVM\bin - -$SoftwareName = "Clang" -$(clang --version).Split([System.Environment]::NewLine)[0] -match "\d+\.\d+\.\d+" -$Version = $matches[0] - -$Description = @" -_Version:_ $Version
-_Environment:_ -* PATH: contains location of the LLVM 'bin' directory -"@ - -Add-SoftwareDetailsToMarkdown -SoftwareName $SoftwareName -DescriptionMarkdown $Description