Release: fix portable runtime and updater
This commit is contained in:
1 parent
659e4467e0
commit
978930f4d2
5 files changed
+45
-6
No files matched your search
@@ -32,6 +32,9 @@ namespace Echoion::Standalone
|
||||
const std::filesystem::path& installRoot,
|
||||
const std::filesystem::path& executableDirectory);
|
||||
|
||||
[[nodiscard]] std::optional<std::filesystem::path>
|
||||
bundledCertificateBundle(const std::filesystem::path& installRoot);
|
||||
|
||||
[[nodiscard]] std::expected<std::filesystem::path, std::string>
|
||||
resolveAvatarCacheDirectory(
|
||||
const std::filesystem::path& configuredDirectory,
|
||||
|
||||
+17
-1
@@ -120,7 +120,10 @@ namespace Echoion::Standalone
|
||||
if (std::filesystem::is_regular_file(
|
||||
packagedDirectory / "web" / "index.html", error) &&
|
||||
!error) {
|
||||
return packagedDirectory;
|
||||
// Installed config paths are rooted at the release prefix (for
|
||||
// example ./share/echoion/web), so the working directory must be
|
||||
// the installation root rather than share/echoion itself.
|
||||
return installRoot;
|
||||
}
|
||||
|
||||
error.clear();
|
||||
@@ -132,6 +135,19 @@ namespace Echoion::Standalone
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<std::filesystem::path>
|
||||
bundledCertificateBundle(const std::filesystem::path& installRoot)
|
||||
{
|
||||
const auto bundle =
|
||||
installRoot / "share" / "echoion" / "certs" / "ca-certificates.crt";
|
||||
std::error_code error;
|
||||
if (!std::filesystem::is_regular_file(bundle, error) || error ||
|
||||
std::filesystem::file_size(bundle, error) == 0 || error) {
|
||||
return std::nullopt;
|
||||
}
|
||||
return bundle.lexically_normal();
|
||||
}
|
||||
|
||||
std::expected<std::filesystem::path, std::string>
|
||||
resolveAvatarCacheDirectory(
|
||||
const std::filesystem::path& configuredDirectory,
|
||||
|
||||
@@ -558,6 +558,16 @@ int main(int argc, char** argv)
|
||||
std::cerr << "Cannot export ECHOION_HOME\n";
|
||||
return 2;
|
||||
}
|
||||
if (!environmentPath("SSL_CERT_FILE")) {
|
||||
if (const auto certificateBundle =
|
||||
Echoion::Standalone::bundledCertificateBundle(installRoot)) {
|
||||
const auto bundleString = certificateBundle->string();
|
||||
if (::setenv("SSL_CERT_FILE", bundleString.c_str(), 0) != 0) {
|
||||
std::cerr << "Cannot export bundled TLS certificate store\n";
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const std::string_view requiredValue : {"--config", "--state-dir"}) {
|
||||
if (hasArgument(argc, argv, requiredValue) &&
|
||||
!optionalArgumentPath(argc, argv, requiredValue)) {
|
||||
|
||||
@@ -101,11 +101,19 @@ int main()
|
||||
const auto packagedIndex =
|
||||
installRoot / "share" / "echoion" / "web" / "index.html";
|
||||
check(writeFile(packagedIndex), "failed to create packaged web fixture");
|
||||
check(
|
||||
Echoion::Standalone::runtimeWorkingDirectory(installRoot,
|
||||
executableDirectory) ==
|
||||
installRoot / "share" / "echoion",
|
||||
"packaged web root did not select share/echoion as working directory");
|
||||
check(Echoion::Standalone::runtimeWorkingDirectory(
|
||||
installRoot, executableDirectory) == installRoot,
|
||||
"packaged web root did not select the installation root as working "
|
||||
"directory");
|
||||
const auto bundledCertificates =
|
||||
installRoot / "share" / "echoion" / "certs" / "ca-certificates.crt";
|
||||
check(!Echoion::Standalone::bundledCertificateBundle(installRoot),
|
||||
"missing bundled certificate store was accepted");
|
||||
check(writeFile(bundledCertificates),
|
||||
"failed to create bundled certificate store fixture");
|
||||
check(Echoion::Standalone::bundledCertificateBundle(installRoot) ==
|
||||
bundledCertificates,
|
||||
"bundled certificate store was not resolved from the install root");
|
||||
std::filesystem::remove_all(installRoot / "share");
|
||||
const auto developmentIndex = executableDirectory / "web" / "index.html";
|
||||
check(writeFile(developmentIndex),
|
||||
|
||||
@@ -14,6 +14,7 @@ mkdir -p -- \
|
||||
"$bundle/bin" \
|
||||
"$bundle/lib" \
|
||||
"$bundle/service" \
|
||||
"$bundle/share/echoion/certs" \
|
||||
"$bundle/share/echoion/tools" \
|
||||
"$bundle/share/echoion/web"
|
||||
printf '#!/bin/sh\necho "echoiond must not run during release staging" >&2\nexit 97\n' \
|
||||
@@ -27,6 +28,7 @@ install -m 0644 -- \
|
||||
"$service_templates/echoion-updater.timer.in" \
|
||||
"$bundle/service/"
|
||||
printf '{"webRoot":"./web"}\n' > "$bundle/share/echoion/config.example.json"
|
||||
printf 'test trust bundle\n' > "$bundle/share/echoion/certs/ca-certificates.crt"
|
||||
install -m 0755 -- "$manifest_validator" \
|
||||
"$bundle/share/echoion/tools/validate-release-manifest.py"
|
||||
printf '<!doctype html>\n' > "$bundle/share/echoion/web/index.html"
|
||||
|
||||
Reference in new issue
Block a user