From bf33df0018797dbca104960d8f88d79593ba0cef Mon Sep 17 00:00:00 2001 From: Andre Riesco Date: Thu, 14 Mar 2024 11:05:27 -0300 Subject: [PATCH 1/5] cpp: Correction on the .gitignore file Signed-off-by: Andre Riesco --- cConsole/.gitignore | 5 ++--- cmakeConsole/.gitignore | 6 +----- cppConsole/.gitignore | 5 ++--- cppQML/.gitignore | 6 ++++-- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/cConsole/.gitignore b/cConsole/.gitignore index b2ffb9414..a184adf95 100644 --- a/cConsole/.gitignore +++ b/cConsole/.gitignore @@ -72,9 +72,8 @@ dkms.conf # Compiled Static libraries *.lai -/bin -/obj -/debug +#Build directories +build-* # End of https://www.gitignore.io/api/c,c++,cmake diff --git a/cmakeConsole/.gitignore b/cmakeConsole/.gitignore index 953ef2898..a3b9b74c6 100644 --- a/cmakeConsole/.gitignore +++ b/cmakeConsole/.gitignore @@ -72,17 +72,13 @@ dkms.conf # Compiled Static libraries *.lai -/bin -/obj -/debug - # End of https://www.gitignore.io/api/c,c++,cmake credentials.zip *.lock.yml #Build directories -/build-* +build-* .conf/.depok .conf/.docok \ No newline at end of file diff --git a/cppConsole/.gitignore b/cppConsole/.gitignore index b2ffb9414..a184adf95 100644 --- a/cppConsole/.gitignore +++ b/cppConsole/.gitignore @@ -72,9 +72,8 @@ dkms.conf # Compiled Static libraries *.lai -/bin -/obj -/debug +#Build directories +build-* # End of https://www.gitignore.io/api/c,c++,cmake diff --git a/cppQML/.gitignore b/cppQML/.gitignore index c70dc1065..8d7dc1b84 100644 --- a/cppQML/.gitignore +++ b/cppQML/.gitignore @@ -10,12 +10,14 @@ amd64 credentials.zip *.lock.yml +#Build directories build-* -# After committing it once, to stop having modifications every time you do + +# After committing it once, to stop having modifications every time you do # anything on Qt Creator (like dragging the window, literally almost anything), # uncomment the line below # .qt .conf/.depok -.conf/.docok +.conf/.docok \ No newline at end of file From e861d8cf6a23d29b157c7d4e0399dcd54e638aca Mon Sep 17 00:00:00 2001 From: Andre Riesco Date: Thu, 14 Mar 2024 11:11:53 -0300 Subject: [PATCH 2/5] dotnet: Fixes .net 8 names that were with .net 6 names in some places Signed-off-by: Andre Riesco --- README.md | 4 ++-- dotnetAvaloniaFrameBuffer/.doc/README.md | 2 +- dotnetConsole/.doc/README.md | 2 +- dotnetUno/.doc/README.md | 2 +- templates.json | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 0e8aadb35..1d03dd20f 100644 --- a/README.md +++ b/README.md @@ -51,8 +51,8 @@ We encourage you to also contribute templates. The community supported templates | ![](assets/img/electronjs.png?raw=true) | Node.js JavaScript Electron Application | Electron | JavaScript | ![](assets/img/arm32.png?raw=true&id=2) ![](assets/img/arm64.png?raw=true&id=2) | [nodeElectron](./nodeElectron) | ![](https://avatars.githubusercontent.com/u/2633321?v=4) [@microhobby](https://www.github.com/microhobby) | | ![](assets/img/monowinforms.png?raw=true) | Mono 4.7 C# Windows Forms Application | .NET 4.7 | C# | ![](assets/img/arm32.png?raw=true&id=2) ![](assets/img/arm64.png?raw=true&id=2) | [monoCsharpForms](./monoCsharpForms) | ![](https://avatars.githubusercontent.com/u/2633321?v=4) [@microhobby](https://www.github.com/microhobby) | | ![](assets/img/unofbdrm.png?raw=true) | .NET 6 C# Uno Platform Frame Buffer | .NET 6.0 | C# | ![](assets/img/arm32.png?raw=true&id=2) ![](assets/img/arm64.png?raw=true&id=2) | [dotnetUnoFrameBuffer](./dotnetUnoFrameBuffer) | ![](https://avatars.githubusercontent.com/u/2633321?v=4) [@microhobby](https://www.github.com/microhobby) | -| ![](assets/img/avaloniafbdrm.png?raw=true) | .NET 6 C# Avalonia Frame Buffer DRM | .NET 6.0 | C# | ![](assets/img/arm32.png?raw=true&id=2) ![](assets/img/arm64.png?raw=true&id=2) | [dotnetAvaloniaFrameBuffer](./dotnetAvaloniaFrameBuffer) | ![](https://avatars.githubusercontent.com/u/2633321?v=4) [@microhobby](https://www.github.com/microhobby) | -| ![](assets/img/avaloniagtk.png?raw=true) | .NET 6 C# Avalonia GTK MVVM | .NET 6.0 | C# | ![](assets/img/arm32.png?raw=true&id=2) ![](assets/img/arm64.png?raw=true&id=2) | [dotnetAvalonia](./dotnetAvalonia) | ![](https://avatars.githubusercontent.com/u/2633321?v=4) [@microhobby](https://www.github.com/microhobby) | +| ![](assets/img/avaloniafbdrm.png?raw=true) | .NET 8 C# Avalonia Frame Buffer DRM | .NET 8.0 | C# | ![](assets/img/arm32.png?raw=true&id=2) ![](assets/img/arm64.png?raw=true&id=2) | [dotnetAvaloniaFrameBuffer](./dotnetAvaloniaFrameBuffer) | ![](https://avatars.githubusercontent.com/u/2633321?v=4) [@microhobby](https://www.github.com/microhobby) | +| ![](assets/img/avaloniagtk.png?raw=true) | .NET 8 C# Avalonia GTK MVVM | .NET 8.0 | C# | ![](assets/img/arm32.png?raw=true&id=2) ![](assets/img/arm64.png?raw=true&id=2) | [dotnetAvalonia](./dotnetAvalonia) | ![](https://avatars.githubusercontent.com/u/2633321?v=4) [@microhobby](https://www.github.com/microhobby) | | ![](assets/img/gambasform.png?raw=true) | Gambas3 Form Project | Gambas3 | Visual Basic | ![](assets/img/arm32.png?raw=true&id=2) ![](assets/img/arm64.png?raw=true&id=2) | [gambasForms](./gambasForms) | ![](https://avatars.githubusercontent.com/u/2633321?v=4) [@microhobby](https://www.github.com/microhobby) | | ![](assets/img/python3console.png?raw=true) | Python 3 Pyside 2(Qt5) QML | Pyside 2 | Python 3 | ![](assets/img/arm32.png?raw=true&id=2) ![](assets/img/arm64.png?raw=true&id=2) | [python3Pyside2QML](./python3Pyside2QML) | ![](https://avatars.githubusercontent.com/u/83607022?v=4) [@andreriesco](https://www.github.com/andreriesco) | | ![](assets/img/cconsole.png?raw=true) | C Makefile Console Application | libc | C | ![](assets/img/arm32.png?raw=true&id=2) ![](assets/img/arm64.png?raw=true&id=2) ![](assets/img/riscv64.png?raw=true&id=2) ![](assets/img/x8664.png?raw=true&id=2) | [cConsole](./cConsole) | ![](https://avatars.githubusercontent.com/u/19562097?v=4) [@hiagofranco](https://www.github.com/hiagofranco) | diff --git a/dotnetAvaloniaFrameBuffer/.doc/README.md b/dotnetAvaloniaFrameBuffer/.doc/README.md index bd1effd35..6b1d10c9d 100644 --- a/dotnetAvaloniaFrameBuffer/.doc/README.md +++ b/dotnetAvaloniaFrameBuffer/.doc/README.md @@ -1,4 +1,4 @@ -# .NET 6 C# Avalonia Frame Buffer DRM Template Specific Documentation +# .NET 8 C# Avalonia Frame Buffer DRM Template Specific Documentation > ⚠️ **WARNING:** This is just the documentation part specific of this template. **For the complete and general Torizon IDE documentation, check the [developer website documentation](https://developer.toradex.com/torizon/application-development/ide-extension/)** ⚠️ diff --git a/dotnetConsole/.doc/README.md b/dotnetConsole/.doc/README.md index a143ea1f7..fdaf42d17 100644 --- a/dotnetConsole/.doc/README.md +++ b/dotnetConsole/.doc/README.md @@ -1,4 +1,4 @@ -# .NET 6 C# Console Template Specific Documentation +# .NET 8 C# Console Template Specific Documentation > ⚠️ **WARNING:** This is just the documentation part specific of this template. **For the complete and general Torizon IDE documentation, check the [developer website documentation](https://developer.toradex.com/torizon/application-development/ide-extension/)** ⚠️ diff --git a/dotnetUno/.doc/README.md b/dotnetUno/.doc/README.md index 02c2d2a74..cc6e12b8e 100644 --- a/dotnetUno/.doc/README.md +++ b/dotnetUno/.doc/README.md @@ -1,4 +1,4 @@ -# .NET6 C# Uno Platform Skia.GTK Template Specific Documentation +# .NET 6 C# Uno Platform Skia.GTK Template Specific Documentation > ⚠️ **WARNING:** This is just the documentation part specific of this template. **For the complete and general Torizon IDE documentation, check the [developer website documentation](https://developer.toradex.com/torizon/application-development/ide-extension/)** ⚠️ diff --git a/templates.json b/templates.json index 71b5cf0aa..3a457ec9c 100644 --- a/templates.json +++ b/templates.json @@ -83,8 +83,8 @@ { "img": "avaloniafbdrm.png", "folder": "dotnetAvaloniaFrameBuffer", - "description": ".NET 6 C# Avalonia Frame Buffer DRM", - "runtime": ".net 6.0", + "description": ".NET 8 C# Avalonia Frame Buffer DRM", + "runtime": ".net 8.0", "language": "C#", "debugSSHPort": "2224", "multiContainer": true, From e3af56179adf6d2cf4225c55ddbdb48fe3c5a3d8 Mon Sep 17 00:00:00 2001 From: Andre Riesco Date: Thu, 14 Mar 2024 13:26:01 -0300 Subject: [PATCH 3/5] deps: Add the possibility to use scripts in deps.json, for check-deps Add the possibility to use scripts in the deps.json file, that are checked by the check-deps task. Also, add the dotnet-sdk-* and the mono-devel install scripts. Signed-off-by: Andre Riesco --- aspnetBlazor/.conf/deps.json | 6 +- dotnetAvalonia/.conf/deps.json | 6 +- dotnetAvaloniaFrameBuffer/.conf/deps.json | 8 +- dotnetConsole/.conf/deps.json | 6 +- .../install-dotnet-sdk-8.sh | 41 ++++++ dotnetSlint/.conf/deps.json | 6 +- dotnetUno/.conf/deps.json | 4 +- dotnetUno5/.conf/deps.json | 4 +- dotnetUno5FrameBuffer/.conf/deps.json | 4 +- dotnetUnoFrameBuffer/.conf/deps.json | 6 +- monoCsharpForms/.conf/deps.json | 6 +- .../install-mono-devel.sh | 33 +++++ scripts/checkDeps.ps1 | 129 ++++++++++++++---- scripts/createFromTemplate.ps1 | 42 ++++-- .../install-dotnet-sdk-6.sh | 40 ++++++ .../install-dotnet-sdk-7.sh | 39 ++++++ .../install-dotnet-sdk-8.sh | 39 ++++++ scripts/projectUpdater.ps1 | 54 +++++++- 18 files changed, 417 insertions(+), 56 deletions(-) create mode 100644 dotnetConsole/.conf/install-deps-scripts/install-dotnet-sdk-8.sh create mode 100755 monoCsharpForms/.conf/install-deps-scripts/install-mono-devel.sh create mode 100755 scripts/install-deps-scripts/install-dotnet-sdk-6.sh create mode 100755 scripts/install-deps-scripts/install-dotnet-sdk-7.sh create mode 100755 scripts/install-deps-scripts/install-dotnet-sdk-8.sh diff --git a/aspnetBlazor/.conf/deps.json b/aspnetBlazor/.conf/deps.json index d420f1fb6..1cfa12a80 100644 --- a/aspnetBlazor/.conf/deps.json +++ b/aspnetBlazor/.conf/deps.json @@ -1,7 +1,9 @@ { "packages": [ "openssh-client", - "sshpass", - "dotnet-sdk-6.0" + "sshpass" + ], + "installDepsScripts": [ + ".conf/install-deps-scripts/install-dotnet-sdk-8.sh" ] } diff --git a/dotnetAvalonia/.conf/deps.json b/dotnetAvalonia/.conf/deps.json index 98f3831af..c12f75be9 100644 --- a/dotnetAvalonia/.conf/deps.json +++ b/dotnetAvalonia/.conf/deps.json @@ -2,8 +2,10 @@ "packages": [ "openssh-client", "sshpass", - "dotnet-sdk-7.0", - "dotnet-sdk-8.0", "libgtk-3-dev" + ], + "installDepsScripts": [ + ".conf/install-deps-scripts/install-dotnet-sdk-7.sh", + ".conf/install-deps-scripts/install-dotnet-sdk-8.sh" ] } diff --git a/dotnetAvaloniaFrameBuffer/.conf/deps.json b/dotnetAvaloniaFrameBuffer/.conf/deps.json index 307ed17d7..d71faacfe 100644 --- a/dotnetAvaloniaFrameBuffer/.conf/deps.json +++ b/dotnetAvaloniaFrameBuffer/.conf/deps.json @@ -1,8 +1,10 @@ { "packages": [ "openssh-client", - "sshpass", - "dotnet-sdk-8.0", - "dotnet-sdk-7.0" + "sshpass" + ], + "installDepsScripts": [ + ".conf/install-deps-scripts/install-dotnet-sdk-7.sh", + ".conf/install-deps-scripts/install-dotnet-sdk-8.sh" ] } diff --git a/dotnetConsole/.conf/deps.json b/dotnetConsole/.conf/deps.json index 2277ff1b9..1cfa12a80 100644 --- a/dotnetConsole/.conf/deps.json +++ b/dotnetConsole/.conf/deps.json @@ -1,7 +1,9 @@ { "packages": [ "openssh-client", - "sshpass", - "dotnet-sdk-8.0" + "sshpass" + ], + "installDepsScripts": [ + ".conf/install-deps-scripts/install-dotnet-sdk-8.sh" ] } diff --git a/dotnetConsole/.conf/install-deps-scripts/install-dotnet-sdk-8.sh b/dotnetConsole/.conf/install-deps-scripts/install-dotnet-sdk-8.sh new file mode 100644 index 000000000..4ba07b51f --- /dev/null +++ b/dotnetConsole/.conf/install-deps-scripts/install-dotnet-sdk-8.sh @@ -0,0 +1,41 @@ +#!/bin/bash +set -e + +echo "bbbbb" + +# This is a script to install .NET on Ubuntu, based on the official Microsoft recommended method of installation: +# https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu + +package='dotnet-sdk-8.0' + +# Get Ubuntu version +declare repo_version=$(if command -v lsb_release &> /dev/null; then lsb_release -r -s; else grep -oP '(?<=^VERSION_ID=).+' /etc/os-release | tr -d '"'; fi) + +# Get the source URL of the dotnet-sdk package installed +source=$(apt policy $package | awk '/ \*/{getline; print $2}') + + +# Check if the dotnet-sdk installed package comes from the Microsoft source +if [ "$source" != "https://packages.microsoft.com/ubuntu/$repo_version/prod" ]; then + + # Download Microsoft signing key and repository + wget https://packages.microsoft.com/config/ubuntu/$repo_version/packages-microsoft-prod.deb -O packages-microsoft-prod.deb + + # Install Microsoft signing key and repository + sudo dpkg -i packages-microsoft-prod.deb + + # Clean up + rm packages-microsoft-prod.deb + + # Remove the dotnet-sdk installation that doesn't come from the Microsoft source + sudo apt-get remove $package -y + + sudo apt-get autoremove -y + +fi + +# Update packages +sudo apt update -y + +# Install the dotnet-sdk that come from the Microsoft source +sudo apt-get install $package -y diff --git a/dotnetSlint/.conf/deps.json b/dotnetSlint/.conf/deps.json index 2277ff1b9..1cfa12a80 100644 --- a/dotnetSlint/.conf/deps.json +++ b/dotnetSlint/.conf/deps.json @@ -1,7 +1,9 @@ { "packages": [ "openssh-client", - "sshpass", - "dotnet-sdk-8.0" + "sshpass" + ], + "installDepsScripts": [ + ".conf/install-deps-scripts/install-dotnet-sdk-8.sh" ] } diff --git a/dotnetUno/.conf/deps.json b/dotnetUno/.conf/deps.json index 1739d7b0a..ceb034fe7 100644 --- a/dotnetUno/.conf/deps.json +++ b/dotnetUno/.conf/deps.json @@ -2,7 +2,9 @@ "packages": [ "openssh-client", "sshpass", - "dotnet-sdk-6.0", "libgtk-3-dev" + ], + "installDepsScripts": [ + ".conf/install-deps-scripts/install-dotnet-sdk-6.sh" ] } diff --git a/dotnetUno5/.conf/deps.json b/dotnetUno5/.conf/deps.json index b27beacd3..f065bbcf7 100644 --- a/dotnetUno5/.conf/deps.json +++ b/dotnetUno5/.conf/deps.json @@ -2,7 +2,9 @@ "packages": [ "openssh-client", "sshpass", - "dotnet-sdk-8.0", "libgtk-3-dev" + ], + "installDepsScripts": [ + ".conf/install-deps-scripts/install-dotnet-sdk-8.sh" ] } diff --git a/dotnetUno5FrameBuffer/.conf/deps.json b/dotnetUno5FrameBuffer/.conf/deps.json index b27beacd3..f065bbcf7 100644 --- a/dotnetUno5FrameBuffer/.conf/deps.json +++ b/dotnetUno5FrameBuffer/.conf/deps.json @@ -2,7 +2,9 @@ "packages": [ "openssh-client", "sshpass", - "dotnet-sdk-8.0", "libgtk-3-dev" + ], + "installDepsScripts": [ + ".conf/install-deps-scripts/install-dotnet-sdk-8.sh" ] } diff --git a/dotnetUnoFrameBuffer/.conf/deps.json b/dotnetUnoFrameBuffer/.conf/deps.json index d420f1fb6..944531227 100644 --- a/dotnetUnoFrameBuffer/.conf/deps.json +++ b/dotnetUnoFrameBuffer/.conf/deps.json @@ -1,7 +1,9 @@ { "packages": [ "openssh-client", - "sshpass", - "dotnet-sdk-6.0" + "sshpass" + ], + "installDepsScripts": [ + ".conf/install-deps-scripts/install-dotnet-sdk-6.sh" ] } diff --git a/monoCsharpForms/.conf/deps.json b/monoCsharpForms/.conf/deps.json index cae3696a6..10ecae731 100644 --- a/monoCsharpForms/.conf/deps.json +++ b/monoCsharpForms/.conf/deps.json @@ -2,10 +2,10 @@ "packages": [ "openssh-client", "sshpass", - "mono-complete", - "mono-roslyn", - "mono-dbg", "msbuild", "nuget" + ], + "installDepsScripts": [ + ".conf/install-deps-scripts/install-mono-devel.sh" ] } diff --git a/monoCsharpForms/.conf/install-deps-scripts/install-mono-devel.sh b/monoCsharpForms/.conf/install-deps-scripts/install-mono-devel.sh new file mode 100755 index 000000000..a8be83331 --- /dev/null +++ b/monoCsharpForms/.conf/install-deps-scripts/install-mono-devel.sh @@ -0,0 +1,33 @@ +#!/bin/bash +set -e + +# This is a script to install .MOno on Ubuntu, based on the official Mono project recommended method of installation: +# https://www.mono-project.com/download/stable/#download-lin + +package='mono-devel' + + +# Get the source URL of the mono-devel package installed +source=$(apt policy $package | awk '/ \*/{getline; print $2}') + + +# Check if the dotnet-sdk installed package comes from the Microsoft source +if [ "$source" != "https://download.mono-project.com/repo/ubuntu" ]; then + + sudo apt install ca-certificates gnupg -y + + # Get and install mono signing key and repository + sudo gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mono-official-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF -y + + # Remove the mono-devel installation that doesn't come from the Microsoft source + sudo apt-get remove $package -y + + sudo apt-get autoremove -y + +fi + +# Update packages +sudo apt update -y + +# Install the mono-devel that come from the Microsoft source +sudo apt-get install $package -y \ No newline at end of file diff --git a/scripts/checkDeps.ps1 b/scripts/checkDeps.ps1 index a5e55852c..5ca8bdb40 100644 --- a/scripts/checkDeps.ps1 +++ b/scripts/checkDeps.ps1 @@ -23,8 +23,6 @@ if ($Env:GITLAB_CI -eq $true) { $Env:DOCKER_HOST = "tcp://docker:2375" } -# tested on Ubuntu 22.04 -$_packages = Get-Content .conf/deps.json | ConvertFrom-Json # docker and docker-compose are special cases # TODO: check also for podman or other runtime @@ -40,48 +38,129 @@ if ($? -eq $false || [string]::IsNullOrEmpty($_dockerComposeV)) { exit 69 } +# Get the deps at .conf/deps.json file +$_deps = Get-Content .conf/deps.json | ConvertFrom-Json + + # ok docker and docker-compose exist so let's check the packages $_packagesToInstall = New-Object Collections.Generic.List[string] + +# Check if all dependencies are installed Write-Host -ForegroundColor Yellow "Checking dependencies ..." -foreach ($package in $_packages.packages) { +foreach ($package in $_deps.packages) { + dpkg -s $package > /dev/null 2>&1 - + if ($? -eq $false) { $_packagesToInstall.Add($package) - Write-Host -ForegroundColor DarkRed "😵 $package not installed" + Write-Host -ForegroundColor DarkRed "😵 $package debian package dependency not installed" + } else { + Write-Host -ForegroundColor DarkGreen "👍 $package debian package dependency installed" + } +} + +$_scriptsToInstall = New-Object Collections.Generic.List[string] + +# Check if all dependency installation scripts have been executed before for this project on this machine +foreach ($script in $_deps.installDepsScripts) { + # For scripts, check if their name is present at the .conf/.depok file to see if they have been executed before + $scriptInstalled = (Test-Path ./.conf/.depok) -and (Get-Content ./.conf/.depok | Select-String $script -Quiet) + + if ($scriptInstalled -eq $false) { + $_scriptsToInstall.Add($script) + Write-Host -ForegroundColor DarkRed "😵 $script dependency installation script not executed before for this project on this machine" } else { - Write-Host -ForegroundColor DarkGreen "👍 $package installed" + Write-Host -ForegroundColor DarkGreen "👍 $script dependency installation script executed before for this project on this machine" } } -# ask if the user want to install the packages that are not installed -if ($_packagesToInstall.Count -gt 0) { +# Check if there are any packages to be installed or scripts to be executed +if ($_packagesToInstall.Count -eq 0 -and $_scriptsToInstall.Count -eq 0) { + Write-Host -ForegroundColor DarkGreen "✅ All packages already installed and installation script executed before for this project on this machine" + + # we need to ran the check deps only if it's not ran yet + New-Item -Path .conf/ -Name .depok -ItemType File 2>&1 | out-null +} else { + + $_packagesInstalledOk = $true + $_scriptsInstalledOk = $true + + # ask if the user want to install the packages that are not installed + if ($_packagesToInstall.Count -gt 0) { + + $_packagesInstalledOk = $false + $_installConfirm = Read-Host ` - "Do you want to try to install the dependencies? " - - if ($_installConfirm -eq 'y') { - # make sure to update the list first - sudo apt-get update - - foreach ($item in $_packagesToInstall) { - sudo apt-get install -y $item - - if ($? -eq $false) { - Write-Host -ForegroundColor DarkRed "❌ error trying to install package $item" - exit 69 + "Do you want to try to install the missing debian package dependencies? " + + if ($_installConfirm -eq 'y') { + # make sure to update the list first + sudo apt-get update + + $_installedScrips = New-Object Collections.Generic.List[string] + + # Try to install the packages + foreach ($item in $_packagesToInstall) { + sudo apt-get install -y $item + + if ($? -eq $false) { + Write-Host -ForegroundColor DarkRed "❌ error trying to install package $item" + exit 69 + } + } + + Write-Host -ForegroundColor DarkGreen "✅ All packages installed successfully" + + $_packagesInstalledOk = $true + + } + } + # ask if the user want to execute the installation scripts that have not been executed before for this project on this machine + if ($_scriptsToInstall.Count -gt 0) { + + $_scriptsInstalledOk = $false + + $_installConfirm = Read-Host ` + "Do you want to try to install the missing debian package dependencies? " + + if ($_installConfirm -eq 'y') { + + $_installedScrips = New-Object Collections.Generic.List[string] + + # Try to execute the installation scripts + foreach ($item in $_scriptsToInstall) { + if ($item.EndsWith('.sh')) { + chmod +x $item + } + + $_installedScrips.Add($item) + & ./$item 2>&1 + + if ($? -eq $false) { + Write-Host -ForegroundColor DarkRed "❌ error trying to execute the dependency installation script $item" + exit 69 + } + } + + Write-Host -ForegroundColor DarkGreen "✅ All packages dependency installation scripts executed successfully" + + $_scriptsInstalledOk = $true + } } - Write-Host -ForegroundColor DarkGreen "✅ All packages installed successfully" + if ($_packagesInstalledOk -eq $true -and $_scriptsInstalledOk -eq $true) { # all packages installed then dep ok New-Item -Path .conf/ -Name .depok -ItemType File 2>&1 | out-null + + # Add the name of the scripts to the .conf/.depok to know that it has + # already been executed for this project on this machine + foreach ($item in $_installedScrips) { + Add-Content -Path ./.conf/.depok -Value ("$item" + "`n") + } } -} else { - Write-Host -ForegroundColor DarkGreen "✅ All packages already installed" - # we need to ran the check deps only if it's not ran yet - New-Item -Path .conf/ -Name .depok -ItemType File 2>&1 | out-null } diff --git a/scripts/createFromTemplate.ps1 b/scripts/createFromTemplate.ps1 index aab3db6d0..9ca086031 100644 --- a/scripts/createFromTemplate.ps1 +++ b/scripts/createFromTemplate.ps1 @@ -79,7 +79,7 @@ Write-Host "Container Name -> $containerName" # get the metadata $_metadata = Get-Content "$templateFolder/../templates.json" | ConvertFrom-Json -$_templateMetadata = +$_templateMetadata = $_metadata.Templates | Where-Object { $_.folder -eq $template } @@ -113,14 +113,14 @@ Write-Host -ForegroundColor DarkGreen "✅ Folder copy done" # apply the common tasks and inputs if ($_templateMetadata.mergeCommon -ne $False) { Write-Host -ForegroundColor Yellow "Applying common tasks ..." - $commonTasks = - Get-Content "$templateFolder/../assets/tasks/common.json" | + $commonTasks = + Get-Content "$templateFolder/../assets/tasks/common.json" | ConvertFrom-Json - $commonInputs = - Get-Content "$templateFolder/../assets/tasks/inputs.json" | + $commonInputs = + Get-Content "$templateFolder/../assets/tasks/inputs.json" | ConvertFrom-Json - $projTasks = - Get-Content "$location/.vscode/tasks.json" | + $projTasks = + Get-Content "$location/.vscode/tasks.json" | ConvertFrom-Json $projTasks.tasks += $commonTasks.tasks @@ -146,6 +146,32 @@ Copy-Item "$templateFolder/../scripts/torizonIO.ps1" "$location/.conf" Copy-Item "$templateFolder/../scripts/checkCIEnv.ps1" "$location/.conf" Copy-Item "$templateFolder/../scripts/validateDepsRunning.ps1" "$location/.conf" +# Check if there are scripts defined in the .conf/deps.json of the template and, if so, +# copy them to the .conf of the project +$_deps = Get-Content "$templateFolder/.conf/deps.json" | ConvertFrom-Json + +# If there are installation scripts listed on the .conf/deps.json of the template +if (($_deps.installDepsScripts.Count -gt 0)) { + # Create the .conf/install-deps-scripts if it doesn't exist and there are + # installation scripts that have the path .conf/install-deps-scripts + if (-not (Test-Path -Path "$location/.conf/install-deps-scripts" )){ + New-Item -ItemType Directory -Path "$location/.conf/install-deps-scripts" + } + + # If there is no script in the .conf/install-deps-scripts of the template, but there is some script defined in the + # installDepsScripts with the .conf/install-deps-scripts path, then it comes from the scripts/install-deps-scripts + # folder of the vscode-torizon-templates repo. This is useful when there are scripts that are common for many + # templates, like the install-dotnet-sdk-8.sh one for example. + foreach ($script in $_deps.installDepsScripts) { + if ((-not (Test-Path -Path "$location/$script" )) -and + $script -match ".conf/install-deps-scripts") { + # Copy the script from the scripts/install-deps-scripts folder to the .conf/install-deps-scripts folder of the template + $scriptSource = $script.Replace(".conf","scripts") + Copy-Item "$templateFolder/../$scriptSource" "$location/$script" + } + } +} + # copy the github actions if not exists if (-not (Test-Path "$location/.github")) { New-Item "$location/.github" -ItemType Directory @@ -201,7 +227,7 @@ Get-ChildItem -Force -File -Recurse * | ForEach-Object { ForEach-Object { $_ -replace "__home__",$env:HOME } | Set-Content $a - + ( Get-Content $a ) | ForEach-Object { $_ -replace "__templateFolder__", $template diff --git a/scripts/install-deps-scripts/install-dotnet-sdk-6.sh b/scripts/install-deps-scripts/install-dotnet-sdk-6.sh new file mode 100755 index 000000000..dc69ec754 --- /dev/null +++ b/scripts/install-deps-scripts/install-dotnet-sdk-6.sh @@ -0,0 +1,40 @@ +#!/bin/bash +set -e + +# This is a script to install .NET on Ubuntu, based on the official Microsoft recommended method of installation: +# https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu + +package='dotnet-sdk-6.0' + +# Get Ubuntu version +declare repo_version=$(if command -v lsb_release &> /dev/null; then lsb_release -r -s; else grep -oP '(?<=^VERSION_ID=).+' /etc/os-release | tr -d '"'; fi) + +# Get the source URL of the dotnet-sdk package installed +source=$(apt policy $package | awk '/ \*/{getline; print $2}') + + +# Check if the dotnet-sdk installed package comes from the Microsoft source +if [ "$source" != "https://packages.microsoft.com/ubuntu/$repo_version/prod" ]; then + + # Download Microsoft signing key and repository + wget https://packages.microsoft.com/config/ubuntu/$repo_version/packages-microsoft-prod.deb -O packages-microsoft-prod.deb + + # Install Microsoft signing key and repository + sudo dpkg -i packages-microsoft-prod.deb + + # Clean up + rm packages-microsoft-prod.deb + + # Remove the dotnet-sdk installation that doesn't come from the Microsoft source + sudo apt-get remove $package -y + + sudo apt-get autoremove -y + +fi + +# Update packages +sudo apt update -y + + +# Install the dotnet-sdk that come from the Microsoft source +sudo apt-get install $package -y \ No newline at end of file diff --git a/scripts/install-deps-scripts/install-dotnet-sdk-7.sh b/scripts/install-deps-scripts/install-dotnet-sdk-7.sh new file mode 100755 index 000000000..5b5827368 --- /dev/null +++ b/scripts/install-deps-scripts/install-dotnet-sdk-7.sh @@ -0,0 +1,39 @@ +#!/bin/bash +set -e + +# This is a script to install .NET on Ubuntu, based on the official Microsoft recommended method of installation: +# https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu + +package='dotnet-sdk-7.0' + +# Get Ubuntu version +declare repo_version=$(if command -v lsb_release &> /dev/null; then lsb_release -r -s; else grep -oP '(?<=^VERSION_ID=).+' /etc/os-release | tr -d '"'; fi) + +# Get the source URL of the dotnet-sdk package installed +source=$(apt policy $package | awk '/ \*/{getline; print $2}') + + +# Check if the dotnet-sdk installed package comes from the Microsoft source +if [ "$source" != "https://packages.microsoft.com/ubuntu/$repo_version/prod" ]; then + + # Download Microsoft signing key and repository + wget https://packages.microsoft.com/config/ubuntu/$repo_version/packages-microsoft-prod.deb -O packages-microsoft-prod.deb + + # Install Microsoft signing key and repository + sudo dpkg -i packages-microsoft-prod.deb + + # Clean up + rm packages-microsoft-prod.deb + + # Remove the dotnet-sdk installation that doesn't come from the Microsoft source + sudo apt-get remove $package -y + + sudo apt-get autoremove -y + +fi + +# Update packages +sudo apt update -y + +# Install the dotnet-sdk that come from the Microsoft source +sudo apt-get install $package -y \ No newline at end of file diff --git a/scripts/install-deps-scripts/install-dotnet-sdk-8.sh b/scripts/install-deps-scripts/install-dotnet-sdk-8.sh new file mode 100755 index 000000000..5feb714fb --- /dev/null +++ b/scripts/install-deps-scripts/install-dotnet-sdk-8.sh @@ -0,0 +1,39 @@ +#!/bin/bash +set -e + +# This is a script to install .NET on Ubuntu, based on the official Microsoft recommended method of installation: +# https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu + +package='dotnet-sdk-8.0' + +# Get Ubuntu version +declare repo_version=$(if command -v lsb_release &> /dev/null; then lsb_release -r -s; else grep -oP '(?<=^VERSION_ID=).+' /etc/os-release | tr -d '"'; fi) + +# Get the source URL of the dotnet-sdk package installed +source=$(apt policy $package | awk '/ \*/{getline; print $2}') + + +# Check if the dotnet-sdk installed package comes from the Microsoft source +if [ "$source" != "https://packages.microsoft.com/ubuntu/$repo_version/prod" ]; then + + # Download Microsoft signing key and repository + wget https://packages.microsoft.com/config/ubuntu/$repo_version/packages-microsoft-prod.deb -O packages-microsoft-prod.deb + + # Install Microsoft signing key and repository + sudo dpkg -i packages-microsoft-prod.deb + + # Clean up + rm packages-microsoft-prod.deb + + # Remove the dotnet-sdk installation that doesn't come from the Microsoft source + sudo apt-get remove $package -y + + sudo apt-get autoremove -y + +fi + +# Update packages +sudo apt update -y + +# Install the dotnet-sdk that come from the Microsoft source +sudo apt-get install $package -y \ No newline at end of file diff --git a/scripts/projectUpdater.ps1 b/scripts/projectUpdater.ps1 index 85e5f0299..f19c85612 100644 --- a/scripts/projectUpdater.ps1 +++ b/scripts/projectUpdater.ps1 @@ -86,10 +86,6 @@ Copy-Item ` $Env:HOME/.apollox/$templateName/.conf/update.json ` $projectFolder/.conf/update.json -# DEPS.JSON: -Copy-Item ` - $Env:HOME/.apollox/$templateName/.conf/deps.json ` - $projectFolder/.conf/deps.json # PROJECT UPDATER: if ( @@ -217,6 +213,43 @@ if ($templateName -ne "tcb") { Copy-Item $Env:HOME/.apollox/$templateName/.gitignore . + +# DEPS.JSON: +Copy-Item $Env:HOME/.apollox/$templateName/.conf/deps.json . + +# Check if there are scripts defined in the .conf/deps.json of the template and, if so, +# copy them to the .conf of the project +$_deps = Get-Content ./deps.json | ConvertFrom-Json + +# If there are installation scripts listed on the .conf/deps.json of the template +if (($_deps.installDepsScripts.Count -gt 0)) { + # Create the install-deps-scripts dir on the .conf/tmp dir + if (-not (Test-Path -Path ./install-deps-scripts )){ + New-Item -ItemType Directory -Path ./install-deps-scripts + } + # If there is no script in the .conf/install-deps-scripts of the template, but there is some script defined in the + # installDepsScripts with the .conf/install-deps-scripts path, then it comes from the scripts/install-deps-scripts + # folder of the vscode-torizon-templates repo. This is useful when there are scripts that are common for many + # templates, like the install-dotnet-sdk-8.sh one for example. + foreach ($script in $_deps.installDepsScripts) { + + if ((-not (Test-Path -Path $Env:HOME/.apollox/$templateName/$script )) -and + $script -match ".conf/install-deps-scripts") { + # Copy the script from the scripts/install-deps-scripts folder to the .conf/install-deps-scripts folder of the template + $scriptSource = $script.Replace(".conf","scripts") + $scriptDest = $script.Replace(".conf/","") + Copy-Item $Env:HOME/.apollox/$scriptSource ./$scriptDest + } else { + $scriptDest = $script.Replace(".conf/","") + Copy-Item $Env:HOME/.apollox/$templateName/$script ./$scriptDest + } + } +} + + + + + # read the update table: for ($i = 0; $i -lt $updateTable.Count; $i++) { $_source = $updateTable[$i].source @@ -325,6 +358,19 @@ _openMergeWindow ` $projectFolder/.conf/tmp/.gitignore ` $projectFolder/.gitignore +# DEPS.JSON: +_openMergeWindow ` + $projectFolder/.conf/tmp/deps.json ` + $projectFolder/.conf/deps.json + +# Install dependencies scripts +foreach ($script in $_deps.installDepsScripts) { + $scriptSource = $script.Replace(".conf/","") + _openMergeWindow ` + $projectFolder/.conf/tmp/$scriptSource ` + $projectFolder/$script +} + Write-Host -ForegroundColor DarkGreen "✅ common" # ---------------------------------------------------------------------- COMMON From d1b724cbafb0cccfa6f3750628d76c384937a1de Mon Sep 17 00:00:00 2001 From: Andre Riesco Date: Fri, 15 Mar 2024 15:54:11 -0300 Subject: [PATCH 4/5] projectUpdater: Fix update when file on source or dest doesn't exist Fix the update giving error when one file from the source or from the destination doesn't exist. The output now shows a merge window with the one that doesn't exist empty, like in a git diff when one of the files doesn't exist Signed-off-by: Andre Riesco --- scripts/projectUpdater.ps1 | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/scripts/projectUpdater.ps1 b/scripts/projectUpdater.ps1 index f19c85612..60e676ff2 100644 --- a/scripts/projectUpdater.ps1 +++ b/scripts/projectUpdater.ps1 @@ -18,6 +18,7 @@ function _checkArg ($_arg) { } function _checkIfFileContentIsEqual ($_file1, $_file2) { + $file1 = Get-FileHash $_file1 $file2 = Get-FileHash $_file2 @@ -28,16 +29,35 @@ function _checkIfFileContentIsEqual ($_file1, $_file2) { } } -function _openMergeWindow ($_path1, $_path2) { +function _openMergeWindow ($_updatedFile, $_currentFile) { if ($acceptAll -eq $true) { - cp $_path1 $_path2 + # If the source doesn't exist anymore on the .apollox repo of the + # template, remove it from the project being updated + if (-not (Test-Path -Path $_updatedFile )) { + Remove-Item -Path $_currentFile + } else { + Copy-Item $_updatedFile $_currentFile + } return } + # If one of the files doesn't exist create an empty one + if (-not (Test-Path -Path $_updatedFile )) { + New-Item -Path $_updatedFile -ItemType File + } elseif (-not (Test-Path -Path $_currentFile )) { + New-Item -Path $_currentFile -ItemType File + } + if ( - -not (_checkIfFileContentIsEqual $_path1 $_path2) + -not (_checkIfFileContentIsEqual $_updatedFile $_currentFile) ) { - code --wait --diff $_path1 $_path2 + code --wait --diff $_updatedFile $_currentFile + # If after the code diff the file is still empty, that means that + # this file should not be added to the project, so let's remove this + # empty file that we have just created above + if ($null -eq (Get-Content $_currentFile)) { + Remove-Item -Path $_currentFile + } } } From 431ba2c487ab0535f75ac4c8be8407e0791f188e Mon Sep 17 00:00:00 2001 From: Andre Riesco Date: Mon, 18 Mar 2024 12:11:18 -0300 Subject: [PATCH 5/5] deps: Fixes on commits about adding scripts to deps.json Signed-off-by: Andre Riesco --- aspnetBlazor/.conf/deps.json | 2 +- dotnetAvalonia/.conf/deps.json | 4 +- dotnetAvaloniaFrameBuffer/.conf/deps.json | 4 +- dotnetConsole/.conf/deps.json | 2 +- .../install-dotnet-sdk-8.sh | 41 --------- dotnetSlint/.conf/deps.json | 2 +- dotnetUno/.conf/deps.json | 2 +- dotnetUno5/.conf/deps.json | 2 +- dotnetUno5FrameBuffer/.conf/deps.json | 2 +- dotnetUnoFrameBuffer/.conf/deps.json | 2 +- monoCsharpForms/.conf/deps.json | 2 +- scripts/checkDeps.ps1 | 91 ++++++++++--------- scripts/createFromTemplate.ps1 | 18 ++-- .../installDotnetSDK6.sh} | 0 .../installDotnetSDK7.sh} | 0 .../installDotnetSDK8.sh} | 0 scripts/projectUpdater.ps1 | 16 ++-- 17 files changed, 79 insertions(+), 111 deletions(-) delete mode 100644 dotnetConsole/.conf/install-deps-scripts/install-dotnet-sdk-8.sh rename scripts/{install-deps-scripts/install-dotnet-sdk-6.sh => installDepsScripts/installDotnetSDK6.sh} (100%) rename scripts/{install-deps-scripts/install-dotnet-sdk-7.sh => installDepsScripts/installDotnetSDK7.sh} (100%) rename scripts/{install-deps-scripts/install-dotnet-sdk-8.sh => installDepsScripts/installDotnetSDK8.sh} (100%) diff --git a/aspnetBlazor/.conf/deps.json b/aspnetBlazor/.conf/deps.json index 1cfa12a80..8986edbc5 100644 --- a/aspnetBlazor/.conf/deps.json +++ b/aspnetBlazor/.conf/deps.json @@ -4,6 +4,6 @@ "sshpass" ], "installDepsScripts": [ - ".conf/install-deps-scripts/install-dotnet-sdk-8.sh" + ".conf/installDepsScripts/installDotnetSDK8.sh" ] } diff --git a/dotnetAvalonia/.conf/deps.json b/dotnetAvalonia/.conf/deps.json index c12f75be9..2d4c1eedc 100644 --- a/dotnetAvalonia/.conf/deps.json +++ b/dotnetAvalonia/.conf/deps.json @@ -5,7 +5,7 @@ "libgtk-3-dev" ], "installDepsScripts": [ - ".conf/install-deps-scripts/install-dotnet-sdk-7.sh", - ".conf/install-deps-scripts/install-dotnet-sdk-8.sh" + ".conf/installDepsScripts/installDotnetSDK7.sh", + ".conf/installDepsScripts/installDotnetSDK8.sh" ] } diff --git a/dotnetAvaloniaFrameBuffer/.conf/deps.json b/dotnetAvaloniaFrameBuffer/.conf/deps.json index d71faacfe..95514c30c 100644 --- a/dotnetAvaloniaFrameBuffer/.conf/deps.json +++ b/dotnetAvaloniaFrameBuffer/.conf/deps.json @@ -4,7 +4,7 @@ "sshpass" ], "installDepsScripts": [ - ".conf/install-deps-scripts/install-dotnet-sdk-7.sh", - ".conf/install-deps-scripts/install-dotnet-sdk-8.sh" + ".conf/installDepsScripts/installDotnetSDK7.sh", + ".conf/installDepsScripts/installDotnetSDK8.sh" ] } diff --git a/dotnetConsole/.conf/deps.json b/dotnetConsole/.conf/deps.json index 1cfa12a80..8986edbc5 100644 --- a/dotnetConsole/.conf/deps.json +++ b/dotnetConsole/.conf/deps.json @@ -4,6 +4,6 @@ "sshpass" ], "installDepsScripts": [ - ".conf/install-deps-scripts/install-dotnet-sdk-8.sh" + ".conf/installDepsScripts/installDotnetSDK8.sh" ] } diff --git a/dotnetConsole/.conf/install-deps-scripts/install-dotnet-sdk-8.sh b/dotnetConsole/.conf/install-deps-scripts/install-dotnet-sdk-8.sh deleted file mode 100644 index 4ba07b51f..000000000 --- a/dotnetConsole/.conf/install-deps-scripts/install-dotnet-sdk-8.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -set -e - -echo "bbbbb" - -# This is a script to install .NET on Ubuntu, based on the official Microsoft recommended method of installation: -# https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu - -package='dotnet-sdk-8.0' - -# Get Ubuntu version -declare repo_version=$(if command -v lsb_release &> /dev/null; then lsb_release -r -s; else grep -oP '(?<=^VERSION_ID=).+' /etc/os-release | tr -d '"'; fi) - -# Get the source URL of the dotnet-sdk package installed -source=$(apt policy $package | awk '/ \*/{getline; print $2}') - - -# Check if the dotnet-sdk installed package comes from the Microsoft source -if [ "$source" != "https://packages.microsoft.com/ubuntu/$repo_version/prod" ]; then - - # Download Microsoft signing key and repository - wget https://packages.microsoft.com/config/ubuntu/$repo_version/packages-microsoft-prod.deb -O packages-microsoft-prod.deb - - # Install Microsoft signing key and repository - sudo dpkg -i packages-microsoft-prod.deb - - # Clean up - rm packages-microsoft-prod.deb - - # Remove the dotnet-sdk installation that doesn't come from the Microsoft source - sudo apt-get remove $package -y - - sudo apt-get autoremove -y - -fi - -# Update packages -sudo apt update -y - -# Install the dotnet-sdk that come from the Microsoft source -sudo apt-get install $package -y diff --git a/dotnetSlint/.conf/deps.json b/dotnetSlint/.conf/deps.json index 1cfa12a80..8986edbc5 100644 --- a/dotnetSlint/.conf/deps.json +++ b/dotnetSlint/.conf/deps.json @@ -4,6 +4,6 @@ "sshpass" ], "installDepsScripts": [ - ".conf/install-deps-scripts/install-dotnet-sdk-8.sh" + ".conf/installDepsScripts/installDotnetSDK8.sh" ] } diff --git a/dotnetUno/.conf/deps.json b/dotnetUno/.conf/deps.json index ceb034fe7..5e0b3339c 100644 --- a/dotnetUno/.conf/deps.json +++ b/dotnetUno/.conf/deps.json @@ -5,6 +5,6 @@ "libgtk-3-dev" ], "installDepsScripts": [ - ".conf/install-deps-scripts/install-dotnet-sdk-6.sh" + ".conf/installDepsScripts/installDotnetSDK6.sh" ] } diff --git a/dotnetUno5/.conf/deps.json b/dotnetUno5/.conf/deps.json index f065bbcf7..ebafd8560 100644 --- a/dotnetUno5/.conf/deps.json +++ b/dotnetUno5/.conf/deps.json @@ -5,6 +5,6 @@ "libgtk-3-dev" ], "installDepsScripts": [ - ".conf/install-deps-scripts/install-dotnet-sdk-8.sh" + ".conf/installDepsScripts/installDotnetSDK8.sh" ] } diff --git a/dotnetUno5FrameBuffer/.conf/deps.json b/dotnetUno5FrameBuffer/.conf/deps.json index f065bbcf7..ebafd8560 100644 --- a/dotnetUno5FrameBuffer/.conf/deps.json +++ b/dotnetUno5FrameBuffer/.conf/deps.json @@ -5,6 +5,6 @@ "libgtk-3-dev" ], "installDepsScripts": [ - ".conf/install-deps-scripts/install-dotnet-sdk-8.sh" + ".conf/installDepsScripts/installDotnetSDK8.sh" ] } diff --git a/dotnetUnoFrameBuffer/.conf/deps.json b/dotnetUnoFrameBuffer/.conf/deps.json index 944531227..ab62a5a24 100644 --- a/dotnetUnoFrameBuffer/.conf/deps.json +++ b/dotnetUnoFrameBuffer/.conf/deps.json @@ -4,6 +4,6 @@ "sshpass" ], "installDepsScripts": [ - ".conf/install-deps-scripts/install-dotnet-sdk-6.sh" + ".conf/installDepsScripts/installDotnetSDK6.sh" ] } diff --git a/monoCsharpForms/.conf/deps.json b/monoCsharpForms/.conf/deps.json index 10ecae731..20c69283c 100644 --- a/monoCsharpForms/.conf/deps.json +++ b/monoCsharpForms/.conf/deps.json @@ -6,6 +6,6 @@ "nuget" ], "installDepsScripts": [ - ".conf/install-deps-scripts/install-mono-devel.sh" + ".conf/installDepsScripts/install-mono-devel.sh" ] } diff --git a/scripts/checkDeps.ps1 b/scripts/checkDeps.ps1 index 5ca8bdb40..af301faaa 100644 --- a/scripts/checkDeps.ps1 +++ b/scripts/checkDeps.ps1 @@ -70,32 +70,48 @@ foreach ($script in $_deps.installDepsScripts) { if ($scriptInstalled -eq $false) { $_scriptsToInstall.Add($script) - Write-Host -ForegroundColor DarkRed "😵 $script dependency installation script not executed before for this project on this machine" + Write-Host -ForegroundColor DarkRed "😵 $script dependency installation script not executed before for this project" } else { - Write-Host -ForegroundColor DarkGreen "👍 $script dependency installation script executed before for this project on this machine" + Write-Host -ForegroundColor DarkGreen "👍 $script dependency installation script executed before for this project" } } # Check if there are any packages to be installed or scripts to be executed -if ($_packagesToInstall.Count -eq 0 -and $_scriptsToInstall.Count -eq 0) { - Write-Host -ForegroundColor DarkGreen "✅ All packages already installed and installation script executed before for this project on this machine" +if ( + ($_packagesToInstall.Count -eq 0) -and + ($_scriptsToInstall.Count -eq 0) - # we need to ran the check deps only if it's not ran yet - New-Item -Path .conf/ -Name .depok -ItemType File 2>&1 | out-null -} else { +) { + Write-Host -ForegroundColor DarkGreen "✅ All packages already installed and installation scripts executed before for this project" - $_packagesInstalledOk = $true - $_scriptsInstalledOk = $true + # all packages installed and installation scripts executed before create dep ok if it doesn't already exist + if ( -not (Test-Path ./.conf/.depok)){ + New-Item -Path .conf/ -Name .depok -ItemType File 2>&1 | out-null + } +} else { - # ask if the user want to install the packages that are not installed + # Check if there are packages to be installed and/or scripts to be executed if ($_packagesToInstall.Count -gt 0) { + $_packagesInstalledOk = $false + } else { + $_packagesInstalledOk = $true + } + + if ($_scriptsToInstall.Count -gt 0) { + $_scriptsInstalledOk = $false + } else { + $_scriptsInstalledOk = $true + } - $_packagesInstalledOk = $false $_installConfirm = Read-Host ` - "Do you want to try to install the missing debian package dependencies? " + "Try to install the missing debian packages and execute the missing installation scripts? " + + if ($_installConfirm -eq 'y') { + + # ask if the user want to install the packages that are not installed + if ($_packagesToInstall.Count -gt 0) { - if ($_installConfirm -eq 'y') { # make sure to update the list first sudo apt-get update @@ -116,45 +132,38 @@ if ($_packagesToInstall.Count -eq 0 -and $_scriptsToInstall.Count -eq 0) { $_packagesInstalledOk = $true } - } - # ask if the user want to execute the installation scripts that have not been executed before for this project on this machine - if ($_scriptsToInstall.Count -gt 0) { + # ask if the user want to execute the installation scripts that have not been executed before for this project on this machine + if ($_scriptsToInstall.Count -gt 0) { - $_scriptsInstalledOk = $false - - $_installConfirm = Read-Host ` - "Do you want to try to install the missing debian package dependencies? " - - if ($_installConfirm -eq 'y') { - - $_installedScrips = New-Object Collections.Generic.List[string] + $_installedScrips = New-Object Collections.Generic.List[string] - # Try to execute the installation scripts - foreach ($item in $_scriptsToInstall) { - if ($item.EndsWith('.sh')) { - chmod +x $item - } + # Try to execute the installation scripts + foreach ($item in $_scriptsToInstall) { + if ($item.EndsWith('.sh')) { + chmod +x $item + } - $_installedScrips.Add($item) - & ./$item 2>&1 + $_installedScrips.Add($item) + & ./$item 2>&1 - if ($? -eq $false) { - Write-Host -ForegroundColor DarkRed "❌ error trying to execute the dependency installation script $item" - exit 69 - } + if ($? -eq $false) { + Write-Host -ForegroundColor DarkRed "❌ error trying to execute the dependency installation script $item" + exit 69 } + } - Write-Host -ForegroundColor DarkGreen "✅ All packages dependency installation scripts executed successfully" - - $_scriptsInstalledOk = $true + Write-Host -ForegroundColor DarkGreen "✅ All dependency installation scripts executed successfully" - } + $_scriptsInstalledOk = $true } + } if ($_packagesInstalledOk -eq $true -and $_scriptsInstalledOk -eq $true) { - # all packages installed then dep ok - New-Item -Path .conf/ -Name .depok -ItemType File 2>&1 | out-null + # all packages installed and installation scripts executed before create dep ok if it doesn't already exist + if ( -not (Test-Path ./.conf/.depok)){ + New-Item -Path .conf/ -Name .depok -ItemType File 2>&1 | out-null + } # Add the name of the scripts to the .conf/.depok to know that it has # already been executed for this project on this machine diff --git a/scripts/createFromTemplate.ps1 b/scripts/createFromTemplate.ps1 index 9ca086031..8963c6cfb 100644 --- a/scripts/createFromTemplate.ps1 +++ b/scripts/createFromTemplate.ps1 @@ -152,20 +152,20 @@ $_deps = Get-Content "$templateFolder/.conf/deps.json" | ConvertFrom-Json # If there are installation scripts listed on the .conf/deps.json of the template if (($_deps.installDepsScripts.Count -gt 0)) { - # Create the .conf/install-deps-scripts if it doesn't exist and there are - # installation scripts that have the path .conf/install-deps-scripts - if (-not (Test-Path -Path "$location/.conf/install-deps-scripts" )){ - New-Item -ItemType Directory -Path "$location/.conf/install-deps-scripts" + # Create the .conf/installDepsScripts if it doesn't exist and there are + # installation scripts that have the path .conf/installDepsScripts + if (-not (Test-Path -Path "$location/.conf/installDepsScripts" )){ + New-Item -ItemType Directory -Path "$location/.conf/installDepsScripts" } - # If there is no script in the .conf/install-deps-scripts of the template, but there is some script defined in the - # installDepsScripts with the .conf/install-deps-scripts path, then it comes from the scripts/install-deps-scripts + # If there is no script in the .conf/installDepsScripts of the template, but there is some script defined in the + # installDepsScripts with the .conf/installDepsScripts path, then it comes from the scripts/installDepsScripts # folder of the vscode-torizon-templates repo. This is useful when there are scripts that are common for many - # templates, like the install-dotnet-sdk-8.sh one for example. + # templates, like the installDotnetSDK8.sh one for example. foreach ($script in $_deps.installDepsScripts) { if ((-not (Test-Path -Path "$location/$script" )) -and - $script -match ".conf/install-deps-scripts") { - # Copy the script from the scripts/install-deps-scripts folder to the .conf/install-deps-scripts folder of the template + $script -match ".conf/installDepsScripts") { + # Copy the script from the scripts/installDepsScripts folder to the .conf/installDepsScripts folder of the template $scriptSource = $script.Replace(".conf","scripts") Copy-Item "$templateFolder/../$scriptSource" "$location/$script" } diff --git a/scripts/install-deps-scripts/install-dotnet-sdk-6.sh b/scripts/installDepsScripts/installDotnetSDK6.sh similarity index 100% rename from scripts/install-deps-scripts/install-dotnet-sdk-6.sh rename to scripts/installDepsScripts/installDotnetSDK6.sh diff --git a/scripts/install-deps-scripts/install-dotnet-sdk-7.sh b/scripts/installDepsScripts/installDotnetSDK7.sh similarity index 100% rename from scripts/install-deps-scripts/install-dotnet-sdk-7.sh rename to scripts/installDepsScripts/installDotnetSDK7.sh diff --git a/scripts/install-deps-scripts/install-dotnet-sdk-8.sh b/scripts/installDepsScripts/installDotnetSDK8.sh similarity index 100% rename from scripts/install-deps-scripts/install-dotnet-sdk-8.sh rename to scripts/installDepsScripts/installDotnetSDK8.sh diff --git a/scripts/projectUpdater.ps1 b/scripts/projectUpdater.ps1 index 60e676ff2..46223ce85 100644 --- a/scripts/projectUpdater.ps1 +++ b/scripts/projectUpdater.ps1 @@ -243,19 +243,19 @@ $_deps = Get-Content ./deps.json | ConvertFrom-Json # If there are installation scripts listed on the .conf/deps.json of the template if (($_deps.installDepsScripts.Count -gt 0)) { - # Create the install-deps-scripts dir on the .conf/tmp dir - if (-not (Test-Path -Path ./install-deps-scripts )){ - New-Item -ItemType Directory -Path ./install-deps-scripts + # Create the installDepsScripts dir on the .conf/tmp dir + if (-not (Test-Path -Path ./installDepsScripts )){ + New-Item -ItemType Directory -Path ./installDepsScripts } - # If there is no script in the .conf/install-deps-scripts of the template, but there is some script defined in the - # installDepsScripts with the .conf/install-deps-scripts path, then it comes from the scripts/install-deps-scripts + # If there is no script in the .conf/installDepsScripts of the template, but there is some script defined in the + # installDepsScripts with the .conf/installDepsScripts path, then it comes from the scripts/installDepsScripts # folder of the vscode-torizon-templates repo. This is useful when there are scripts that are common for many - # templates, like the install-dotnet-sdk-8.sh one for example. + # templates, like the installDotnetSDK8.sh one for example. foreach ($script in $_deps.installDepsScripts) { if ((-not (Test-Path -Path $Env:HOME/.apollox/$templateName/$script )) -and - $script -match ".conf/install-deps-scripts") { - # Copy the script from the scripts/install-deps-scripts folder to the .conf/install-deps-scripts folder of the template + $script -match ".conf/installDepsScripts") { + # Copy the script from the scripts/installDepsScripts folder to the .conf/installDepsScripts folder of the template $scriptSource = $script.Replace(".conf","scripts") $scriptDest = $script.Replace(".conf/","") Copy-Item $Env:HOME/.apollox/$scriptSource ./$scriptDest