US-16 Detect Debian-family dependencies instead of fixed OS versions
This commit is contained in:
1 parent
7dc4ee60f0
commit
23a824dd81
5 files changed
+73
-23
No files matched your search
@@ -24,7 +24,7 @@ must not already exist. Copy `healthapp-release` to the test computer.
|
|||||||
Open a terminal inside the copied release directory. Replace `192.168.1.20` with
|
Open a terminal inside the copied release directory. Replace `192.168.1.20` with
|
||||||
the test computer's reachable IP address or DNS name.
|
the test computer's reachable IP address or DNS name.
|
||||||
|
|
||||||
**Ubuntu 24.04 or 26.04 / Debian 12 or 13** (also the macOS command):
|
**Debian/Ubuntu-based Linux with systemd** (also the macOS command):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo bash install.sh --services all --host 192.168.1.20
|
sudo bash install.sh --services all --host 192.168.1.20
|
||||||
|
|||||||
+12
-6
@@ -35,12 +35,18 @@ files contain no generated secrets. Build output must be a new directory.
|
|||||||
|
|
||||||
## Normal Ubuntu/Debian installation
|
## Normal Ubuntu/Debian installation
|
||||||
|
|
||||||
Automatic Linux package provisioning currently supports Ubuntu 24.04/26.04 and Debian 12/13,
|
Automatic Linux provisioning accepts Debian/Ubuntu ancestry (`ID` or `ID_LIKE`),
|
||||||
with a running systemd manager and administrative access. This is the implemented
|
with apt, a running systemd manager and administrative access. It checks actual package
|
||||||
Linux adapter's supported set, not a restriction in the application binaries. Other
|
availability rather than a fixed distribution/version list. Internet access to configured
|
||||||
Linux distributions need corresponding package-manager integration before the installer
|
package feeds is needed when dependencies are absent. Existing .NET 10 ASP.NET Core
|
||||||
can claim native dependency provisioning there. Internet access to the signed OS/.NET
|
runtime and PostgreSQL installations are reused where available.
|
||||||
package feeds is needed when dependencies are absent.
|
|
||||||
|
The installer prefers configured distribution feeds. On Debian itself, if the runtime
|
||||||
|
package is absent, it attempts Microsoft's repository for that Debian VERSION_ID.
|
||||||
|
Derivatives use their own configured feeds; their version numbers are never passed to
|
||||||
|
an upstream repository. If no compatible runtime source or PostgreSQL package is
|
||||||
|
available, installation stops with a specific dependency error. Debian ancestry alone
|
||||||
|
does not guarantee .NET/CPU compatibility; startup and topology verification still apply.
|
||||||
|
|
||||||
From the release directory:
|
From the release directory:
|
||||||
|
|
||||||
|
|||||||
@@ -1,32 +1,49 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Source from install.sh. Package commands use the supported distribution's signed feeds.
|
# Source from install.sh. Package commands use the supported distribution's signed feeds.
|
||||||
|
package_available() {
|
||||||
|
local policy
|
||||||
|
policy=$(LC_ALL=C apt-cache policy "$1") || return 1
|
||||||
|
[[ "$policy" =~ Candidate:[[:space:]]+([^[:space:]]+) && "${BASH_REMATCH[1]}" != '(none)' ]]
|
||||||
|
}
|
||||||
|
|
||||||
ensure_dependencies() {
|
ensure_dependencies() {
|
||||||
local distribution=$1 version=$2 runtime=$3 persistence=$4
|
local distribution=$1 version=$2 runtime=$3 persistence=$4 ancestry=${5:-}
|
||||||
case "$distribution:$version" in ubuntu:24.04|ubuntu:26.04|debian:12|debian:13) ;; *) fail 'Automatic provisioning supports Ubuntu 24.04/26.04 and Debian 12/13.';; esac
|
case " $distribution $ancestry " in
|
||||||
|
*" debian "*|*" ubuntu "*) ;;
|
||||||
|
*) fail 'Automatic Linux provisioning requires a Debian/Ubuntu-based distribution (ID or ID_LIKE).';;
|
||||||
|
esac
|
||||||
|
command -v apt-get >/dev/null && command -v apt-cache >/dev/null || fail 'Debian/Ubuntu provisioning requires apt-get and apt-cache.'
|
||||||
|
step='refresh dependency package availability'
|
||||||
|
apt-get update || fail 'Could not refresh package feeds; check network access and configured repositories.'
|
||||||
step='install base dependencies'
|
step='install base dependencies'
|
||||||
if ! command -v curl >/dev/null || ! command -v update-ca-certificates >/dev/null; then
|
if ! command -v curl >/dev/null || ! command -v update-ca-certificates >/dev/null; then
|
||||||
apt-get update
|
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates curl
|
DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates curl
|
||||||
fi
|
fi
|
||||||
if [[ ! -x "$runtime" ]] || ! "$runtime" --list-runtimes | grep -q 'Microsoft.AspNetCore.App 10\.'; then
|
if [[ ! -x "$runtime" ]] || ! "$runtime" --list-runtimes | grep -q 'Microsoft.AspNetCore.App 10\.'; then
|
||||||
step='install .NET 10 ASP.NET Core runtime'
|
step='install .NET 10 ASP.NET Core runtime'
|
||||||
apt-get update
|
if ! package_available aspnetcore-runtime-10.0 && [[ "$distribution" == debian ]]; then
|
||||||
if [[ "$distribution" == debian ]]; then
|
[[ "$version" =~ ^[0-9]+$ ]] || fail 'Cannot identify a compatible Microsoft Debian package repository from VERSION_ID.'
|
||||||
local package_dir
|
local package_dir
|
||||||
package_dir=$(mktemp -d)
|
package_dir=$(mktemp -d)
|
||||||
curl --fail --silent --show-error "https://packages.microsoft.com/config/debian/$version/packages-microsoft-prod.deb" -o "$package_dir/microsoft.deb"
|
if ! curl --fail --silent --show-error --location "https://packages.microsoft.com/config/debian/$version/packages-microsoft-prod.deb" -o "$package_dir/microsoft.deb"; then
|
||||||
|
rm -f -- "$package_dir/microsoft.deb"
|
||||||
|
rmdir -- "$package_dir"
|
||||||
|
fail "No accessible Microsoft Debian $version repository; aspnetcore-runtime-10.0 is unavailable in configured feeds."
|
||||||
|
fi
|
||||||
dpkg -i "$package_dir/microsoft.deb"
|
dpkg -i "$package_dir/microsoft.deb"
|
||||||
rm -f -- "$package_dir/microsoft.deb"
|
rm -f -- "$package_dir/microsoft.deb"
|
||||||
rmdir -- "$package_dir"
|
rmdir -- "$package_dir"
|
||||||
apt-get update
|
apt-get update
|
||||||
fi
|
fi
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get install -y aspnetcore-runtime-10.0
|
package_available aspnetcore-runtime-10.0 || fail "Required package aspnetcore-runtime-10.0 is unavailable for $distribution $version in configured feeds; no compatible runtime repository could be identified automatically."
|
||||||
|
DEBIAN_FRONTEND=noninteractive apt-get install -y aspnetcore-runtime-10.0 || fail 'Failed to install aspnetcore-runtime-10.0 from configured feeds.'
|
||||||
fi
|
fi
|
||||||
[[ -x "$runtime" ]] && "$runtime" --list-runtimes | grep -q 'Microsoft.AspNetCore.App 10\.' || fail 'The .NET 10 ASP.NET Core runtime could not be provisioned.'
|
[[ -x "$runtime" ]] && "$runtime" --list-runtimes | grep -q 'Microsoft.AspNetCore.App 10\.' || fail 'The .NET 10 ASP.NET Core runtime could not be provisioned.'
|
||||||
if [[ "$persistence" == true ]]; then
|
if [[ "$persistence" == true ]]; then
|
||||||
step='provision PostgreSQL server'
|
step='provision PostgreSQL server'
|
||||||
if ! command -v pg_isready >/dev/null || ! pg_isready -q -h localhost -p 5432; then
|
if ! command -v pg_isready >/dev/null || ! pg_isready -q -h localhost -p 5432; then
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get install -y postgresql
|
package_available postgresql || fail "Required package postgresql is unavailable for $distribution $version in configured feeds."
|
||||||
|
DEBIAN_FRONTEND=noninteractive apt-get install -y postgresql || fail 'Failed to install PostgreSQL from configured feeds.'
|
||||||
systemctl enable --now postgresql
|
systemctl enable --now postgresql
|
||||||
fi
|
fi
|
||||||
local ready=false attempt
|
local ready=false attempt
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ for service in "${selected_services[@]}"; do case "$service" in patient-profile|
|
|||||||
if [[ "$target_root" == / && "$prepare_only" == false ]]; then
|
if [[ "$target_root" == / && "$prepare_only" == false ]]; then
|
||||||
[[ $EUID -eq 0 && -d /run/systemd/system ]] || fail 'Live installation requires root and a running systemd manager.'
|
[[ $EUID -eq 0 && -d /run/systemd/system ]] || fail 'Live installation requires root and a running systemd manager.'
|
||||||
source /etc/os-release
|
source /etc/os-release
|
||||||
ensure_dependencies "$ID" "$VERSION_ID" "$dotnet_path" "$persistence"
|
ensure_dependencies "$ID" "${VERSION_ID:-}" "$dotnet_path" "$persistence" "${ID_LIKE:-}"
|
||||||
else
|
else
|
||||||
[[ -x "$dotnet_path" ]] || fail 'Offline preparation needs an available .NET 10 runtime.'
|
[[ -x "$dotnet_path" ]] || fail 'Offline preparation needs an available .NET 10 runtime.'
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -14,8 +14,18 @@ public sealed class BootstrapTests
|
|||||||
[InlineData("ubuntu", "26.04", true, true, true)]
|
[InlineData("ubuntu", "26.04", true, true, true)]
|
||||||
[InlineData("debian", "12", true, false, false)]
|
[InlineData("debian", "12", true, false, false)]
|
||||||
[InlineData("debian", "13", false, true, false)]
|
[InlineData("debian", "13", false, true, false)]
|
||||||
|
[InlineData("linuxmint", "22", false, true, false, "ubuntu debian")]
|
||||||
|
[InlineData("pop", "future", false, false, false, "ubuntu")]
|
||||||
|
[InlineData("ubuntu", "future", false, false, false)]
|
||||||
|
[InlineData("debian", "13", false, false, false, "", false)]
|
||||||
|
[InlineData("linuxmint", "22", false, false, false, "ubuntu debian", false, true, true, "aspnetcore-runtime-10.0 is unavailable")]
|
||||||
|
[InlineData("debian", "99", false, false, false, "", false, true, false, "No accessible Microsoft Debian 99 repository")]
|
||||||
|
[InlineData("ubuntu", "26.04", true, true, false, "", true, false, true, "Required package postgresql is unavailable")]
|
||||||
|
[InlineData("fedora", "44", true, false, false, "", true, true, true, "requires a Debian/Ubuntu-based distribution")]
|
||||||
public async Task Package_provisioning_detects_runtime_and_postgresql_and_installs_only_needed_dependencies(
|
public async Task Package_provisioning_detects_runtime_and_postgresql_and_installs_only_needed_dependencies(
|
||||||
string distribution, string version, bool runtimeAvailable, bool databaseRequired, bool databaseAvailable)
|
string distribution, string version, bool runtimeAvailable, bool databaseRequired, bool databaseAvailable,
|
||||||
|
string ancestry = "", bool runtimePackage = true, bool postgresPackage = true,
|
||||||
|
bool repositoryAvailable = true, string expectedError = "")
|
||||||
{
|
{
|
||||||
var directory = Path.Combine(Path.GetTempPath(), "healthapp-bootstrap-" + Guid.NewGuid().ToString("N"));
|
var directory = Path.Combine(Path.GetTempPath(), "healthapp-bootstrap-" + Guid.NewGuid().ToString("N"));
|
||||||
Directory.CreateDirectory(directory);
|
Directory.CreateDirectory(directory);
|
||||||
@@ -27,16 +37,21 @@ public sealed class BootstrapTests
|
|||||||
var script = Path.Combine(directory, "test.sh");
|
var script = Path.Combine(directory, "test.sh");
|
||||||
await File.WriteAllTextAsync(script, """
|
await File.WriteAllTextAsync(script, """
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
fail() { exit 1; }
|
fail() { printf '%s\n' "$*" >&2; exit 1; }
|
||||||
runtime() { if [[ "$RUNTIME_PRESENT" == true || -f "$RUNTIME_INSTALLED" ]]; then printf '%s\n' 'Microsoft.AspNetCore.App 10.0.12 [runtime]'; else return 1; fi; }
|
runtime() { if [[ "$RUNTIME_PRESENT" == true || -f "$RUNTIME_INSTALLED" ]]; then printf '%s\n' 'Microsoft.AspNetCore.App 10.0.12 [runtime]'; else return 1; fi; }
|
||||||
apt-get() { printf '%s\n' "apt-get $*" >> "$COMMAND_LOG"; if [[ "$*" == *aspnetcore-runtime-10.0* ]]; then touch "$RUNTIME_INSTALLED"; fi; }
|
apt-get() { printf '%s\n' "apt-get $*" >> "$COMMAND_LOG"; if [[ "$*" == *aspnetcore-runtime-10.0* ]]; then touch "$RUNTIME_INSTALLED"; fi; }
|
||||||
curl() { printf '%s\n' "curl $*" >> "$COMMAND_LOG"; }
|
apt-cache() {
|
||||||
|
if [[ "$2" == aspnetcore-runtime-10.0 && ( "$RUNTIME_PACKAGE" == true || -f "$REPOSITORY_ADDED" ) || "$2" == postgresql && "$POSTGRES_PACKAGE" == true ]]; then
|
||||||
|
printf '%s\n' ' Candidate: 10.0.1';
|
||||||
|
else printf '%s\n' ' Candidate: (none)'; fi
|
||||||
|
}
|
||||||
|
curl() { [[ "$REPOSITORY_AVAILABLE" == true ]] || return 22; printf '%s\n' "curl $*" >> "$COMMAND_LOG"; }
|
||||||
update-ca-certificates() { :; }
|
update-ca-certificates() { :; }
|
||||||
dpkg() { printf '%s\n' "dpkg $*" >> "$COMMAND_LOG"; }
|
dpkg() { printf '%s\n' "dpkg $*" >> "$COMMAND_LOG"; touch "$REPOSITORY_ADDED"; }
|
||||||
pg_isready() { [[ -f "$DATABASE_READY" ]]; }
|
pg_isready() { [[ -f "$DATABASE_READY" ]]; }
|
||||||
systemctl() { printf '%s\n' "systemctl $*" >> "$COMMAND_LOG"; touch "$DATABASE_READY"; }
|
systemctl() { printf '%s\n' "systemctl $*" >> "$COMMAND_LOG"; touch "$DATABASE_READY"; }
|
||||||
source "$BOOTSTRAP"
|
source "$BOOTSTRAP"
|
||||||
ensure_dependencies "$DISTRO" "$VERSION" /bin/true "$DATABASE_REQUIRED"
|
ensure_dependencies "$DISTRO" "$VERSION" /bin/true "$DATABASE_REQUIRED" "$ANCESTRY"
|
||||||
""");
|
""");
|
||||||
// Runtime is an executable stub; installed packages switch its simulated inventory.
|
// Runtime is an executable stub; installed packages switch its simulated inventory.
|
||||||
var runtime = Path.Combine(directory, "dotnet");
|
var runtime = Path.Combine(directory, "dotnet");
|
||||||
@@ -49,16 +64,28 @@ public sealed class BootstrapTests
|
|||||||
["COMMAND_LOG"] = log, ["RUNTIME_INSTALLED"] = installed,
|
["COMMAND_LOG"] = log, ["RUNTIME_INSTALLED"] = installed,
|
||||||
["RUNTIME_PRESENT"] = runtimeAvailable ? "true" : "false", ["RUNTIME_EXECUTABLE"] = runtime,
|
["RUNTIME_PRESENT"] = runtimeAvailable ? "true" : "false", ["RUNTIME_EXECUTABLE"] = runtime,
|
||||||
["DATABASE_READY"] = Path.Combine(directory, "pg-ready"), ["DATABASE_REQUIRED"] = databaseRequired ? "true" : "false",
|
["DATABASE_READY"] = Path.Combine(directory, "pg-ready"), ["DATABASE_REQUIRED"] = databaseRequired ? "true" : "false",
|
||||||
|
["ANCESTRY"] = ancestry, ["RUNTIME_PACKAGE"] = runtimePackage ? "true" : "false",
|
||||||
|
["POSTGRES_PACKAGE"] = postgresPackage ? "true" : "false", ["REPOSITORY_AVAILABLE"] = repositoryAvailable ? "true" : "false",
|
||||||
|
["REPOSITORY_ADDED"] = Path.Combine(directory, "repository-added"),
|
||||||
["BOOTSTRAP"] = Path.Combine(DeploymentFixture.Repository, "deploy/installer/bootstrap.sh"), ["DISTRO"] = distribution, ["VERSION"] = version
|
["BOOTSTRAP"] = Path.Combine(DeploymentFixture.Repository, "deploy/installer/bootstrap.sh"), ["DISTRO"] = distribution, ["VERSION"] = version
|
||||||
};
|
};
|
||||||
if (databaseAvailable) await File.WriteAllTextAsync(environment["DATABASE_READY"], "ready");
|
if (databaseAvailable) await File.WriteAllTextAsync(environment["DATABASE_READY"], "ready");
|
||||||
var result = await DeploymentFixture.Run("bash", [script], environment);
|
var result = await DeploymentFixture.Run("bash", [script], environment);
|
||||||
Assert.Equal(0, result.Code);
|
if (expectedError.Length > 0)
|
||||||
|
{
|
||||||
|
Assert.NotEqual(0, result.Code);
|
||||||
|
Assert.Contains(expectedError, result.Output);
|
||||||
|
var failedCommands = await File.ReadAllTextAsync(log);
|
||||||
|
Assert.DoesNotContain("install -y aspnetcore-runtime-10.0", failedCommands);
|
||||||
|
Assert.DoesNotContain("install -y postgresql", failedCommands);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Assert.True(result.Code == 0, result.Output);
|
||||||
var commands = await File.ReadAllTextAsync(log);
|
var commands = await File.ReadAllTextAsync(log);
|
||||||
Assert.Equal(!runtimeAvailable, commands.Contains("install -y aspnetcore-runtime-10.0"));
|
Assert.Equal(!runtimeAvailable, commands.Contains("install -y aspnetcore-runtime-10.0"));
|
||||||
Assert.Equal(databaseRequired && !databaseAvailable, commands.Contains("install -y postgresql"));
|
Assert.Equal(databaseRequired && !databaseAvailable, commands.Contains("install -y postgresql"));
|
||||||
Assert.Equal(databaseRequired && !databaseAvailable, commands.Contains("systemctl enable --now postgresql"));
|
Assert.Equal(databaseRequired && !databaseAvailable, commands.Contains("systemctl enable --now postgresql"));
|
||||||
Assert.Equal(!runtimeAvailable && distribution == "debian", commands.Contains("packages.microsoft.com/config/debian/" + version));
|
Assert.Equal(!runtimeAvailable && !runtimePackage && distribution == "debian", commands.Contains("packages.microsoft.com/config/debian/" + version));
|
||||||
}
|
}
|
||||||
finally { Directory.Delete(directory, true); }
|
finally { Directory.Delete(directory, true); }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user