From 176cfe931ed48c9df14cbee4e06168e5cdc58198 Mon Sep 17 00:00:00 2001 From: Andre Riesco Date: Mon, 18 Mar 2024 12:11:18 -0300 Subject: [PATCH] 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 | 16 ++-- .../install-dotnet-sdk-6.sh | 0 .../install-dotnet-sdk-7.sh | 0 .../install-dotnet-sdk-8.sh | 0 scripts/projectUpdater.ps1 | 14 +-- 17 files changed, 77 insertions(+), 109 deletions(-) delete mode 100644 dotnetConsole/.conf/install-deps-scripts/install-dotnet-sdk-8.sh rename scripts/{install-deps-scripts => installDepsScripts}/install-dotnet-sdk-6.sh (100%) rename scripts/{install-deps-scripts => installDepsScripts}/install-dotnet-sdk-7.sh (100%) rename scripts/{install-deps-scripts => installDepsScripts}/install-dotnet-sdk-8.sh (100%) diff --git a/aspnetBlazor/.conf/deps.json b/aspnetBlazor/.conf/deps.json index 1cfa12a80..0d6aac629 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/install-dotnet-sdk-8.sh" ] } diff --git a/dotnetAvalonia/.conf/deps.json b/dotnetAvalonia/.conf/deps.json index c12f75be9..3050180e2 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/install-dotnet-sdk-7.sh", + ".conf/installDepsScripts/install-dotnet-sdk-8.sh" ] } diff --git a/dotnetAvaloniaFrameBuffer/.conf/deps.json b/dotnetAvaloniaFrameBuffer/.conf/deps.json index d71faacfe..3f706a335 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/install-dotnet-sdk-7.sh", + ".conf/installDepsScripts/install-dotnet-sdk-8.sh" ] } diff --git a/dotnetConsole/.conf/deps.json b/dotnetConsole/.conf/deps.json index 1cfa12a80..0d6aac629 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/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 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..0d6aac629 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/install-dotnet-sdk-8.sh" ] } diff --git a/dotnetUno/.conf/deps.json b/dotnetUno/.conf/deps.json index ceb034fe7..4368ccb8f 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/install-dotnet-sdk-6.sh" ] } diff --git a/dotnetUno5/.conf/deps.json b/dotnetUno5/.conf/deps.json index f065bbcf7..3aa2a2443 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/install-dotnet-sdk-8.sh" ] } diff --git a/dotnetUno5FrameBuffer/.conf/deps.json b/dotnetUno5FrameBuffer/.conf/deps.json index f065bbcf7..3aa2a2443 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/install-dotnet-sdk-8.sh" ] } diff --git a/dotnetUnoFrameBuffer/.conf/deps.json b/dotnetUnoFrameBuffer/.conf/deps.json index 944531227..6da020150 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/install-dotnet-sdk-6.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..e46c38185 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. 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/install-dotnet-sdk-6.sh similarity index 100% rename from scripts/install-deps-scripts/install-dotnet-sdk-6.sh rename to scripts/installDepsScripts/install-dotnet-sdk-6.sh diff --git a/scripts/install-deps-scripts/install-dotnet-sdk-7.sh b/scripts/installDepsScripts/install-dotnet-sdk-7.sh similarity index 100% rename from scripts/install-deps-scripts/install-dotnet-sdk-7.sh rename to scripts/installDepsScripts/install-dotnet-sdk-7.sh diff --git a/scripts/install-deps-scripts/install-dotnet-sdk-8.sh b/scripts/installDepsScripts/install-dotnet-sdk-8.sh similarity index 100% rename from scripts/install-deps-scripts/install-dotnet-sdk-8.sh rename to scripts/installDepsScripts/install-dotnet-sdk-8.sh diff --git a/scripts/projectUpdater.ps1 b/scripts/projectUpdater.ps1 index 60e676ff2..c622603de 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. 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