diff --git a/.github/workflows/commit_test.yml b/.github/workflows/commit_test.yml index f1cc13c..e04759f 100644 --- a/.github/workflows/commit_test.yml +++ b/.github/workflows/commit_test.yml @@ -19,19 +19,24 @@ jobs: severity: error ubuntu_test: - name: Ubuntu 24.04 - runs-on: ubuntu-24.04 + name: Ubuntu 26.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - - name: Run Setup + - name: Run Setup and Verify PAServer in Ubuntu 26.04 run: | - chmod +x ./scripts/SetupLinux4Delphi.sh - sudo ./scripts/SetupLinux4Delphi.sh 13.0 - - name: Verify PAServer - run: | - /usr/local/bin/pa13.0.sh & - sleep 10 - pgrep paserver + docker run --rm --privileged \ + -e DEBIAN_FRONTEND=noninteractive \ + -v "$PWD:/workspace" \ + ubuntu:26.04 \ + bash -c " + set -e + chmod +x /workspace/scripts/SetupLinux4Delphi.sh + /workspace/scripts/SetupLinux4Delphi.sh 13.1 + /usr/local/bin/pa13.1.sh & + sleep 15 + pgrep paserver + " rhel_test: name: RHEL 10 @@ -43,9 +48,9 @@ jobs: - name: Run Setup run: | chmod +x ./scripts/SetupLinux4Delphi.sh - ./scripts/SetupLinux4Delphi.sh 13.0 + ./scripts/SetupLinux4Delphi.sh 13.1 - name: Verify PAServer run: | - /usr/local/bin/pa13.0.sh & + /usr/local/bin/pa13.1.sh & sleep 15 - pgrep paserver \ No newline at end of file + pgrep paserver diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..3973f3e --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,52 @@ +# Repository Guidelines + +## Project Structure & Module Organization + +This repository centers on one maintained Bash installer: `scripts/SetupLinux4Delphi.sh`. It installs PAServer and Linux dependencies for Delphi development across supported distributions. The `legacy/` directory contains superseded historical scripts and should be used only for reference. Images and README assets live in `images/`. GitHub Actions configuration is in `.github/workflows/commit_test.yml`. Local helper files such as `test-local.ps1` may exist, but production changes should stay focused on the maintained script and documentation. + +## Build, Test, and Development Commands + +- `shellcheck scripts/SetupLinux4Delphi.sh` checks the main script; CI treats ShellCheck findings at error severity. +- `bash -n scripts/SetupLinux4Delphi.sh` performs a fast Bash syntax check. +- `shfmt -d scripts/SetupLinux4Delphi.sh` previews formatting differences without rewriting the file. +- `powershell -ExecutionPolicy Bypass -File .\test-local.ps1` runs local validation when available. + +GitHub Actions also runs live install tests for Ubuntu 26.04 and RHEL 10. Push to a `test**` branch to exercise CI before sending changes to `main`. + +## Coding Style & Naming Conventions + +Keep the main script POSIX-aware where practical, but preserve existing Bash conventions. Use uppercase variable names for installer state such as `COMPILER`, `PRODUCT`, `RELEASE`, and `PASERVER_URL`. Keep version alias handling in the `case "$PARAM"` block and maintain clear package-manager branches for `apt`, `dnf`, `yum`, and `pacman`. Prefer small, readable conditionals over dense one-liners because this script is intended to be reviewed before running with `sudo`. + +## Testing Guidelines + +Run ShellCheck and `bash -n` before committing script changes. When adding Delphi releases or package-manager behavior, update help text and CI version references in the same change. For risky install logic, test in WSL, a VM, or a container rather than on a production host. + +## Commit & Pull Request Guidelines + +Recent commits use short, direct, mostly lowercase subjects, for example `add 13.1 support for issue #5`. Keep commits scoped to one behavior or documentation update. Pull requests should describe the affected distro or Delphi version, list local checks run, link related issues, and include relevant CI results. Add screenshots only for README or asset changes. + +## Agent-Specific Instructions + +Do not modify `legacy/` unless the task explicitly targets historical scripts. Avoid reverting local user changes. When changing supported versions, verify the PAServer URL from the Embarcadero DocWiki rather than inferring it from nearby entries. + +## Script Architecture + +`scripts/SetupLinux4Delphi.sh` has three main phases: + +1. Argument parsing: `PARAM` defaults to the latest supported compiler version. The argument loop handles `--help` and optional package-manager overrides. +2. Version resolution: `case "$PARAM"` maps accepted aliases to `COMPILER`, `PRODUCT`, `RELEASE`, and `PASERVER_URL`; `ARCHIVE` is derived from the URL basename. +3. Distro detection and install: the script reads `/etc/os-release`, selects `apt`, `dnf`, `yum`, or `pacman`, installs packages, downloads PAServer, extracts it, and writes `/usr/local/bin/pa$PRODUCT.sh`. + +## Adding Delphi Versions + +When adding a point release, add the specific version case before the broader compiler-version case. Update the canonical compiler alias to point at the latest point release, adjust the default `PARAM` if it is the newest release overall, and update both help-text blocks. Also update `.github/workflows/commit_test.yml` when CI should test the new version. + +The compiler version, such as `37.0` or `23.0`, is the canonical alias and should map to the latest point release for that compiler. Specific product versions, such as `13.0` or `12.2`, should keep exact entries. + +## PAServer URLs + +PAServer download URLs are not fully predictable. Use the Embarcadero DocWiki page for the authoritative current URL: + +`https://docwiki.embarcadero.com/RADStudio/en/Installing_the_Platform_Assistant_on_Linux` + +For older releases, compare existing `case` entries before making a change. diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..f6aa6c0 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,3 @@ +# CLAUDE.md + +@AGENTS.md diff --git a/README.md b/README.md index 1579cb5..1c49286 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Linux4Delphi Setup [![ShellCheck](https://img.shields.io/github/actions/workflow/status/jimmckeeth/linux4delphi/commit_test.yml?job=ShellCheck&label=ShellCheck&logo=shell)](https://github.com/jimmckeeth/linux4delphi/actions/workflows/commit_test.yml) -[![Ubuntu 24.04 with Delphi 13](https://img.shields.io/github/actions/workflow/status/jimmckeeth/linux4delphi/commit_test.yml?job=ubuntu_test&label=Ubuntu%2024.04%20with%20Delphi%2013&logo=ubuntu)](https://github.com/jimmckeeth/linux4delphi/actions/workflows/commit_test.yml) +[![Ubuntu 26.04 with Delphi 13](https://img.shields.io/github/actions/workflow/status/jimmckeeth/linux4delphi/commit_test.yml?job=ubuntu_test&label=Ubuntu%2026.04%20with%20Delphi%2013&logo=ubuntu)](https://github.com/jimmckeeth/linux4delphi/actions/workflows/commit_test.yml) [![RHEL 10 with Delphi 13](https://img.shields.io/github/actions/workflow/status/jimmckeeth/linux4delphi/commit_test.yml?job=rhel_test&label=RHEL%2010%20with%20Delphi%2013&logo=redhat&logoColor=red)](https://github.com/jimmckeeth/linux4delphi/actions/workflows/commit_test.yml) **Update**: This project was formerly known as *Delphi-on-Linux-Setup*, but it has been renamed to *Linux4Delphi* to better reflect the scope of the project. Update your bookmarks and references accordingly. -Scripts and resources to simplify the setup and development with Delphi on Linux. It should work with all x86 64-bit Linux distros that Delphi suports in WSL, Virtual Machines, or running on hardware native. +Scripts and resources to simplify the setup and development with Delphi on Linux. It should work with all x86 64-bit Linux distros that Delphi supports in WSL, Virtual Machines, or running on hardware native. Supporting Delphi 10.2 *Tokyo* (19.0) through Delphi 13 *Florence* (37.0), from one script. The installation location changed now, so it isn't user specific. @@ -28,7 +28,7 @@ If you don't have curl you can use wget instead (Debian usually excludes curl by wget -qO - https://tinyurl.com/SetupLinux4Delphi | sudo bash ``` -⚠️*Warning*: Is is recommended to [locally review the script](scripts/SetupLinux4Delphi.sh) before running it in a *production* envorment. +⚠️*Warning*: It is recommended to [locally review the script](scripts/SetupLinux4Delphi.sh) before running it in a *production* environment. ✅*Update*: To improve performance, especially if testing in a containerized environment, calls to `apt`, `yum`, & `dnf` use `--no-install-recommends` or `--setopt=install_weak_deps=False` respectively, which prevents the installation of *recommended packages*, that are not essential for the core functionality. It also makes the script less likely to change unrelated packages you might need. @@ -40,7 +40,8 @@ Usage: `sudo SetupLinux4Delphi.sh [version] [pkgmgr]` Where [version] is one of the following: -* Florence 13.0 = `Florence`, `37.0`, `13.0` or *blank* +* Florence 13.1 = `Florence`, `37.0`, `13.1` or *blank* +* Florence 13.0 = `13.0` * Athens 12.3 = `Athens`, `23.0`, `12.3`, or `12` * Athens 12.2 = `12.2` * Athens 12.1 = `12.1` @@ -78,10 +79,11 @@ I tested Delphi 13 Florence against the following distros with this script: * Ubuntu 20.04 * Ubuntu 22.04 * Ubuntu 24.04 + * Ubuntu 26.04 * Kali Linux Rolling 2.6.3.0 * Debian 13 (trixie) * Pengwin (WSL) -* Fedora bassed +* Fedora based * Fedora Linux 42 * Fedora Remix for WSL * Rocky Linux 9.6 (Blue Onyx) @@ -102,17 +104,17 @@ The old version of the script installed it based on the compiler version number, It defaults to a **blank password**. You should *probably* change that. -The instalation locations are as follows: +The installation locations are as follows: * `INSTALL_DIR="/opt/PAServer/$PRODUCT"` * `SCRIPT_PATH="/usr/local/bin/pa$PRODUCT.sh"` -* `SCRATCH_DIR="/var/tmp/paserver-$PRODUCT"` +* `SCRATCH_DIR="$REAL_HOME/.PAServer/$PRODUCT-scratch"` -Where `$PRODUCT` is 13.0, 12.2, etc. So you launch the *Florence* PAServer with `pa13.0.sh`. +Where `$PRODUCT` is 13.1, 13.0, 12.2, etc. So you launch the latest *Florence* PAServer with `pa13.1.sh`. ## More information -The installation of packages is based on the [DocWiki](https://docwiki.embarcadero.com/RADStudio/en/Linux_Application_Development), but with a few changes to address neuances of different distros & installs. If the script doesn't work on your distro of choice then see if the original DocWiki instructions do, and if that still doesn't work, then you distro or installation might not be supported. +The installation of packages is based on the [DocWiki](https://docwiki.embarcadero.com/RADStudio/en/Linux_Application_Development), but with a few changes to address nuances of different distros & installs. If the script doesn't work on your distro of choice then see if the original DocWiki instructions do, and if that still doesn't work, then your distro or installation might not be supported. DocWiki Links: @@ -148,4 +150,5 @@ Start Ubuntu from the start menu, or from the terminal by typing `ubuntu` ### Then run the following script ```bash -curl -fsSL https://tinyurl.com/SetupLinux4Delphi | sudo bash``` +curl -fsSL https://tinyurl.com/SetupLinux4Delphi | sudo bash +``` diff --git a/scripts/SetupLinux4Delphi.sh b/scripts/SetupLinux4Delphi.sh index e590f1c..070ee3d 100644 --- a/scripts/SetupLinux4Delphi.sh +++ b/scripts/SetupLinux4Delphi.sh @@ -80,49 +80,25 @@ while [[ $# -gt 0 ]]; do done case "$PARAM" in - "help"|"--help"|"h"|"--h"|"-h") - echo "Usage: sudo SetupUbuntu4Delphi.sh [version]" - echo "" - echo "Where [version] is one of the following:" - echo " 37.0, 13.1 = Florence 13.1 [DEFAULT]" - echo " 13.0 = Florence 13.0" - echo " 23.0, 12.3, 12 = Athens 12.3" - echo " 12.2 = Athens 12.2" - echo " 12.1 = Athens 12.1" - echo " 12.0 = Athens 12.0" - echo " 22.0, 11.3, 11 = Alexandria 11.3" - echo " 11.2 = Alexandria 11.2" - echo " 11.1 = Alexandria 11.1" - echo " 11.0 = Alexandria 11.0" - echo " 21.0, 10.4.1 = Sydney 10.4.1" - echo " 10.4.0 = Sydney 10.4.0" - echo " 20.0, 10.3, 10.3.3 = Rio 10.3.3" - echo " 10.3.2 = Rio 10.3.2" - echo " 10.3.1 = Rio 10.3.1" - echo " 10.3.0 = Rio 10.3.0" - echo " 19.0, 10.2, 10.2.3 = Tokyo 10.2.3" - echo " 10.2 = Tokyo 10.2.0" - exit 0 - ;; # Florence "37.0"|"13.1"|"florence") COMPILER="37.0" PRODUCT="13.1" RELEASE="Florence" - PASERVER_URL="http://altd.embarcadero.com/releases/studio/37.0/131/LinuxPAServer37.0.tar.gz" + PASERVER_URL="https://altd.embarcadero.com/releases/studio/37.0/131/LinuxPAServer37.0.tar.gz" ;; "13.0") COMPILER="37.0" PRODUCT="13.0" RELEASE="Florence" - PASERVER_URL="http://altd.embarcadero.com/releases/studio/37.0/130/LinuxPAServer37.0.tar.gz" + PASERVER_URL="https://altd.embarcadero.com/releases/studio/37.0/130/LinuxPAServer37.0.tar.gz" ;; # Athens "23.0"|"12.3"|"12"|"athens") COMPILER="23.0" RELEASE="Athens" PRODUCT="12.3" - PASERVER_URL="http://altd.embarcadero.com/releases/studio/23.0/123/LinuxPAServer23.0.tar.gz" + PASERVER_URL="https://altd.embarcadero.com/releases/studio/23.0/123/LinuxPAServer23.0.tar.gz" ;; "12.2") COMPILER="23.0" @@ -140,14 +116,14 @@ case "$PARAM" in COMPILER="23.0" PRODUCT="12.0" RELEASE="Athens" - PASERVER_URL="http://altd.embarcadero.com/releases/studio/23.0/120/LinuxPAServer23.0.tar.gz" + PASERVER_URL="https://altd.embarcadero.com/releases/studio/23.0/120/LinuxPAServer23.0.tar.gz" ;; # Alexandria "22.0"|"11"|"11.3"|"alexandria") COMPILER="22.0" PRODUCT="11.3" RELEASE="Alexandria" - PASERVER_URL="http://altd.embarcadero.com/releases/studio/22.0/113/LinuxPAServer22.0.tar.gz" + PASERVER_URL="https://altd.embarcadero.com/releases/studio/22.0/113/LinuxPAServer22.0.tar.gz" ;; "11.0") COMPILER="22.0" @@ -178,45 +154,45 @@ case "$PARAM" in COMPILER="21.0" PRODUCT="10.4.0" RELEASE="Sydney" - PASERVER_URL="http://altd.embarcadero.com/releases/studio/21.0/PAServer/LinuxPAServer21.0.tar.gz" + PASERVER_URL="https://altd.embarcadero.com/releases/studio/21.0/PAServer/LinuxPAServer21.0.tar.gz" ;; # Rio "10.3"|"rio"|"10.3.3") COMPILER="20.0" PRODUCT="10.3.3" RELEASE="Rio" - PASERVER_URL="http://altd.embarcadero.com/releases/studio/20.0/PAServer/Release3/LinuxPAServer20.0.tar.gz" + PASERVER_URL="https://altd.embarcadero.com/releases/studio/20.0/PAServer/Release3/LinuxPAServer20.0.tar.gz" ;; "10.3.2") COMPILER="20.0" PRODUCT="10.3.2" RELEASE="Rio" - PASERVER_URL="http://altd.embarcadero.com/releases/studio/20.0/PAServer/Release2/LinuxPAServer20.0.tar.gz" + PASERVER_URL="https://altd.embarcadero.com/releases/studio/20.0/PAServer/Release2/LinuxPAServer20.0.tar.gz" ;; "10.3.1") COMPILER="20.0" PRODUCT="10.3.1" RELEASE="Rio" - PASERVER_URL="http://altd.embarcadero.com/releases/studio/20.0/PAServer/Release1/LinuxPAServer20.0.tar.gz" + PASERVER_URL="https://altd.embarcadero.com/releases/studio/20.0/PAServer/Release1/LinuxPAServer20.0.tar.gz" ;; "10.3.0") COMPILER="20.0" PRODUCT="10.3.0" RELEASE="Rio" - PASERVER_URL="http://altd.embarcadero.com/releases/studio/20.0/PAServer/LinuxPAServer20.0.tar.gz" + PASERVER_URL="https://altd.embarcadero.com/releases/studio/20.0/PAServer/LinuxPAServer20.0.tar.gz" ;; # Tokyo "10.2") COMPILER="19.0" PRODUCT="10.2.0" RELEASE="Tokyo" - PASERVER_URL="http://altd.embarcadero.com/releases/studio/19.0/PAServer/LinuxPAServer19.0.tar.gz" + PASERVER_URL="https://altd.embarcadero.com/releases/studio/19.0/PAServer/LinuxPAServer19.0.tar.gz" ;; "tokyo"|"10.2.3") COMPILER="19.0" PRODUCT="10.2.3" RELEASE="Tokyo" - PASERVER_URL="http://altd.embarcadero.com/releases/studio/19.0/PAServer/Release3/LinuxPAServer19.0.tar.gz" + PASERVER_URL="https://altd.embarcadero.com/releases/studio/19.0/PAServer/Release3/LinuxPAServer19.0.tar.gz" ;; esac @@ -336,7 +312,10 @@ if [[ "$PKG" == "apt" ]]; then apt purge openssh-server -y fi # Removed libosmesa-dev from strict requirements - apt install joe wget p7zip-full curl build-essential zlib1g-dev libcurl4-gnutls-dev python3 libpython3-dev libgtk-3-dev $NCURSES_PKG xorg libgl1-mesa-dev libgtk-3-bin libc6-dev -y --no-install-recommends + if ! apt install joe wget p7zip-full curl build-essential zlib1g-dev libcurl4-gnutls-dev python3 libpython3-dev libgtk-3-dev $NCURSES_PKG xorg libgl1-mesa-dev libgtk-3-bin libc6-dev -y --no-install-recommends; then + echo "Required package installation failed. Aborting." + exit 1 + fi # Optional installation of OSMesa (handles missing package errors gracefully) echo "Attempting to install optional libosmesa-dev..." if apt install libosmesa-dev -y --no-install-recommends 2>/dev/null; then @@ -355,6 +334,7 @@ elif [[ "$PKG" == "pacman" ]]; then if command -v steamos-readonly &> /dev/null; then echo "Temporarily disabling SteamOS read-only filesystem..." steamos-readonly disable + trap 'if [ -f /etc/pacman.conf.bak ]; then mv /etc/pacman.conf.bak /etc/pacman.conf; fi; steamos-readonly enable' EXIT fi echo "Initializing pacman keyring and updating packages..." @@ -396,6 +376,7 @@ else fi echo "Setting up directories for PAServer" +# Clear contents but keep the directory; mkdir -p always follows to recreate it if rm somehow removed it rm -rf "${INSTALL_DIR:?}"/* if ! mkdir -p "$INSTALL_DIR"; then echo "Failed to create installation directory. Aborting." @@ -460,14 +441,6 @@ if [ ! -f "$SCRIPT_PATH" ]; then exit 1 fi -if [[ "$ID" == "steamos" ]]; then - # Re-enable SteamOS read-only filesystem - if command -v steamos-readonly &> /dev/null; then - echo "Re-enabling SteamOS read-only filesystem..." - steamos-readonly enable - fi -fi - if [[ -n "$osmesa" ]]; then echo "$osmesa" fi diff --git a/test-local.ps1 b/test-local.ps1 new file mode 100644 index 0000000..cf84c34 --- /dev/null +++ b/test-local.ps1 @@ -0,0 +1,232 @@ +#!/usr/bin/env pwsh +# test-local.ps1 - Run lint and install tests locally +# +# Requires: Docker Desktop for ShellCheck and install tests +# WSL for the fast bash -n syntax check +# +# Usage: +# .\test-local.ps1 # ShellCheck + syntax check only (fast) +# .\test-local.ps1 -Ubuntu # + Ubuntu 26.04 install test +# .\test-local.ps1 -RHEL # + RHEL 10 install test +# .\test-local.ps1 -All # + both install tests +# .\test-local.ps1 -Version 13.0 # Override PAServer version (default: 13.1) + +param( + [switch]$Ubuntu, + [switch]$RHEL, + [switch]$All, + [string]$Version = "13.1" # Match CI default +) + +$Root = $PSScriptRoot +$Failures = 0 +$Skipped = 0 + +function Write-Header([string]$Text) { + Write-Host "" + Write-Host ("=" * 66) -ForegroundColor Cyan + Write-Host " $Text" -ForegroundColor Cyan + Write-Host ("=" * 66) -ForegroundColor Cyan +} + +function Invoke-Check([string]$Label, [scriptblock]$Body) { + Write-Host " Running: $Label ..." -ForegroundColor DarkGray + & $Body + if ($LASTEXITCODE -ne 0) { + Write-Host " FAIL: $Label" -ForegroundColor Red + $script:Failures++ + } else { + Write-Host " PASS: $Label" -ForegroundColor Green + } +} + +function Write-Skip([string]$Text) { + Write-Host " SKIP: $Text" -ForegroundColor Yellow + $script:Skipped++ +} + +function Set-CheckExitCode([bool]$Passed) { + if ($Passed) { + $global:LASTEXITCODE = 0 + } else { + $global:LASTEXITCODE = 1 + } +} + +function Test-DockerDaemon { + docker info 2>&1 | Out-Null + return $LASTEXITCODE -eq 0 +} + +function Get-DockerDesktopPath { + $Candidates = @( + "$env:ProgramFiles\Docker\Docker\Docker Desktop.exe", + "${env:ProgramFiles(x86)}\Docker\Docker\Docker Desktop.exe", + "$env:LOCALAPPDATA\Docker\Docker Desktop.exe" + ) + + foreach ($Candidate in $Candidates) { + if ($Candidate -and (Test-Path -LiteralPath $Candidate)) { + return $Candidate + } + } + + return $null +} + +function Start-DockerIfNeeded { + if (Test-DockerDaemon) { + return $true + } + + Write-Host " Docker is installed but the daemon is not running; attempting to start Docker Desktop..." -ForegroundColor Yellow + + if ($IsWindows -or $env:OS -eq "Windows_NT") { + $DockerDesktop = Get-DockerDesktopPath + if (-not $DockerDesktop) { + Write-Host " Docker CLI found, but Docker Desktop executable was not found." -ForegroundColor Red + return $false + } + + Start-Process -FilePath $DockerDesktop -WindowStyle Hidden + } else { + Write-Host " Automatic Docker startup is only implemented for Docker Desktop on Windows." -ForegroundColor Red + return $false + } + + for ($Attempt = 1; $Attempt -le 60; $Attempt++) { + Start-Sleep -Seconds 2 + if (Test-DockerDaemon) { + return $true + } + Write-Host "." -NoNewline -ForegroundColor DarkGray + } + + Write-Host "" + Write-Host " Docker did not become ready within 120 seconds." -ForegroundColor Red + return $false +} + +# Pre-flight +$DockerOk = $false + +Write-Header "Docker availability" + +Invoke-Check "docker installed and daemon ready" { + $DockerAvailable = $null -ne (Get-Command docker -ErrorAction SilentlyContinue) + if (-not $DockerAvailable) { + Write-Host " Docker is not installed or is not on PATH." -ForegroundColor Red + Set-CheckExitCode $false + return + } + + $script:DockerOk = Start-DockerIfNeeded + Set-CheckExitCode $script:DockerOk +} + +$WslAvailable = $null -ne (Get-Command wsl -ErrorAction SilentlyContinue) + +# 1. bash -n syntax check (via WSL, no Docker needed) +Write-Header "Syntax check (bash -n)" + +if ($WslAvailable) { + Invoke-Check "bash -n via WSL" { + $WslPath = (wsl wslpath ($Root -replace "\\", "/")) + "/scripts/SetupLinux4Delphi.sh" + wsl bash -n $WslPath + } +} else { + Write-Skip "WSL not found - skipping bash -n check" +} + +# 2. HTTP URL check (pure PowerShell, no Docker needed) +Write-Header "HTTP URL check" + +Invoke-Check "no plain http:// URLs in script" { + $Found = Select-String -Path "$Root\scripts\SetupLinux4Delphi.sh" -Pattern "http://" -SimpleMatch + if ($Found) { + Write-Host "" + $Found | ForEach-Object { Write-Host " $_" -ForegroundColor Yellow } + cmd /c exit 1 + } else { + cmd /c exit 0 + } +} + +# 3. ShellCheck (via Docker) +Write-Header "ShellCheck" + +if ($DockerOk) { + Invoke-Check "shellcheck --severity=error" { + docker run --rm ` + -v "${Root}:/workspace" ` + koalaman/shellcheck:stable ` + --severity=error ` + /workspace/scripts/SetupLinux4Delphi.sh + } +} else { + Write-Skip "Docker not running - skipping ShellCheck" +} + +# 4. Ubuntu 26.04 install test (optional, slow) +if ($Ubuntu -or $All) { + Write-Header "Ubuntu 26.04 install test [version: $Version] (~5-10 min)" + + if ($DockerOk) { + Invoke-Check "Ubuntu 26.04: install + paserver starts" { + $BashCommand = @( + "set -e", + "chmod +x /workspace/scripts/SetupLinux4Delphi.sh", + "/workspace/scripts/SetupLinux4Delphi.sh $Version", + ("/usr/local/bin/pa$($Version).sh " + [char]38), + "sleep 15", + "pgrep paserver" + ) -join "`n" + docker run --rm --privileged ` + -e DEBIAN_FRONTEND=noninteractive ` + -v "${Root}:/workspace" ` + ubuntu:26.04 ` + bash -c $BashCommand + } + } else { + Write-Skip "Docker not running" + } +} + +# 5. RHEL 10 (UBI) install test (optional, slow) +if ($RHEL -or $All) { + Write-Header "RHEL 10 (UBI) install test [version: $Version] (~5-10 min)" + + if ($DockerOk) { + Invoke-Check "RHEL 10: install + paserver starts" { + $BashCommand = @( + "set -e", + "chmod +x /workspace/scripts/SetupLinux4Delphi.sh", + "/workspace/scripts/SetupLinux4Delphi.sh $Version", + ("/usr/local/bin/pa$($Version).sh " + [char]38), + "sleep 15", + "pgrep paserver" + ) -join "`n" + docker run --rm --privileged ` + -v "${Root}:/workspace" ` + redhat/ubi10:latest ` + bash -c $BashCommand + } + } else { + Write-Skip "Docker not running" + } +} + +# Summary +Write-Host "" +Write-Host ("=" * 66) -ForegroundColor Cyan +if ($Failures -eq 0 -and $Skipped -eq 0) { + Write-Host " All checks passed." -ForegroundColor Green +} elseif ($Failures -eq 0) { + Write-Host " No checks failed; $Skipped check(s) skipped." -ForegroundColor Yellow +} else { + Write-Host " $Failures check(s) failed." -ForegroundColor Red +} +Write-Host ("=" * 66) -ForegroundColor Cyan +Write-Host "" + +exit $Failures