feat(install): msi installer format compiled from the WiX source
VoidBuildSystem CI / 3A · Linux test (debug) (push) Canceled after 0s
VoidBuildSystem CI / 3A · Linux test (relwithdebinfo) (push) Canceled after 0s
VoidBuildSystem CI / 3A · Linux test (sanitizers) (push) Canceled after 0s
VoidBuildSystem CI / 3B · Windows Wine test (debug) (push) Canceled after 0s
VoidBuildSystem CI / 3B · Windows Wine test (relwithdebinfo) (push) Canceled after 0s
VoidBuildSystem CI / 4A2 · VBS installers (linux target) (push) Canceled after 0s
VoidBuildSystem CI / 4A2 · VBS installers (windows target) (push) Canceled after 0s
VoidBuildSystem CI / 5 · Release (push) Canceled after 0s
VoidBuildSystem CI / 1 · Requirements (push) Successful in 3s
VoidBuildSystem CI / 2A · Linux build (debug) (push) Successful in 4m32s
VoidBuildSystem CI / 2A · Linux build (sanitizers) (push) Successful in 4m57s
VoidBuildSystem CI / 2A · Linux build (relwithdebinfo) (push) Successful in 4m44s
VoidBuildSystem CI / 2B · Windows Wine build (debug) (push) Successful in 1m45s
VoidBuildSystem CI / 2B · Windows Wine build (relwithdebinfo) (push) Successful in 3m11s
VoidBuildSystem CI / 3A · Linux test (debug) (push) Canceled after 0s
VoidBuildSystem CI / 3A · Linux test (relwithdebinfo) (push) Canceled after 0s
VoidBuildSystem CI / 3A · Linux test (sanitizers) (push) Canceled after 0s
VoidBuildSystem CI / 3B · Windows Wine test (debug) (push) Canceled after 0s
VoidBuildSystem CI / 3B · Windows Wine test (relwithdebinfo) (push) Canceled after 0s
VoidBuildSystem CI / 4A2 · VBS installers (linux target) (push) Canceled after 0s
VoidBuildSystem CI / 4A2 · VBS installers (windows target) (push) Canceled after 0s
VoidBuildSystem CI / 5 · Release (push) Canceled after 0s
VoidBuildSystem CI / 1 · Requirements (push) Successful in 3s
VoidBuildSystem CI / 2A · Linux build (debug) (push) Successful in 4m32s
VoidBuildSystem CI / 2A · Linux build (sanitizers) (push) Successful in 4m57s
VoidBuildSystem CI / 2A · Linux build (relwithdebinfo) (push) Successful in 4m44s
VoidBuildSystem CI / 2B · Windows Wine build (debug) (push) Successful in 1m45s
VoidBuildSystem CI / 2B · Windows Wine build (relwithdebinfo) (push) Successful in 3m11s
'vbs install --archive-format msi' renders the WiX v3 source with absolute file sources and compiles it with wixl (msitools) or the WiX toolset (candle/light) when available, failing explicitly otherwise. The .wxs intermediate is removed afterwards. Verified locally: wixl produces a valid MSI (OLE compound file, File table with the installed binaries and correct summary information), and the install suite passes with msitools on PATH. CI adds msi to the installer sets when the tooling exists.
This commit is contained in:
1 parent
6b9074241f
commit
ff562acc1a
4 files changed
+129
-12
No files matched your search
+12
-2
@@ -317,7 +317,12 @@ jobs:
|
|||||||
echo "retrying vbs install (${fmt}) in '${build_dir}'..." >&2
|
echo "retrying vbs install (${fmt}) in '${build_dir}'..." >&2
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
for fmt in tar sh zip deb rpm wix dmg nuget; do
|
for fmt in tar sh zip deb rpm wix msi dmg nuget; do
|
||||||
|
if [ "${fmt}" = "msi" ] && ! command -v wixl >/dev/null 2>&1 &&
|
||||||
|
! command -v candle >/dev/null 2>&1; then
|
||||||
|
echo "skipping msi: wixl or the WiX toolset is not installed"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
case "${fmt}" in
|
case "${fmt}" in
|
||||||
tar) ext=tar ;;
|
tar) ext=tar ;;
|
||||||
wix) ext=wxs ;;
|
wix) ext=wxs ;;
|
||||||
@@ -388,7 +393,12 @@ jobs:
|
|||||||
prefix="$(mktemp -d)"
|
prefix="$(mktemp -d)"
|
||||||
mkdir -p "${out}"
|
mkdir -p "${out}"
|
||||||
build_dir="build/selfhost-windows-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT:-1}"
|
build_dir="build/selfhost-windows-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT:-1}"
|
||||||
for fmt in tar zip nuget wix; do
|
for fmt in tar zip nuget wix msi; do
|
||||||
|
if [ "${fmt}" = "msi" ] && ! command -v wixl >/dev/null 2>&1 &&
|
||||||
|
! command -v candle >/dev/null 2>&1; then
|
||||||
|
echo "skipping msi: wixl or the WiX toolset is not installed"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
case "${fmt}" in
|
case "${fmt}" in
|
||||||
tar) ext=tar ;;
|
tar) ext=tar ;;
|
||||||
wix) ext=wxs ;;
|
wix) ext=wxs ;;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <Void/Build/Package/Archive.hpp>
|
#include <Void/Build/Package/Archive.hpp>
|
||||||
#include <Void/Build/Platform/FileOps.hpp>
|
#include <Void/Build/Platform/FileOps.hpp>
|
||||||
|
#include <Void/Build/Platform/ProcessSupervisor.hpp>
|
||||||
#include <Void/Build/Provenance/Signing.hpp>
|
#include <Void/Build/Provenance/Signing.hpp>
|
||||||
#include <Void/Build/Util/Json.hpp>
|
#include <Void/Build/Util/Json.hpp>
|
||||||
#include <Void/Build/Util/Sha256.hpp>
|
#include <Void/Build/Util/Sha256.hpp>
|
||||||
@@ -13,6 +14,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <chrono>
|
||||||
#include <format>
|
#include <format>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <set>
|
#include <set>
|
||||||
@@ -451,10 +453,9 @@ std::string wix_xml_escape(std::string_view text) {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
// WiX v3 source (the CPack WIX model): consumed by candle/light on Windows to produce an MSI.
|
std::string render_wix_source(const InstallOptions &options,
|
||||||
Void::Result::Result<void, Void::Result::Error>
|
const std::vector<Package::ArchiveEntrySpec> &entries,
|
||||||
write_wix_source(const std::filesystem::path &output, const InstallOptions &options,
|
const std::filesystem::path &source_root) {
|
||||||
const std::vector<Package::ArchiveEntrySpec> &entries) {
|
|
||||||
const std::string product_guid = wix_guid_from("product:" + options.package_name);
|
const std::string product_guid = wix_guid_from("product:" + options.package_name);
|
||||||
const std::string upgrade_guid = wix_guid_from("upgrade:" + options.package_name);
|
const std::string upgrade_guid = wix_guid_from("upgrade:" + options.package_name);
|
||||||
const std::string manufacturer =
|
const std::string manufacturer =
|
||||||
@@ -467,6 +468,9 @@ write_wix_source(const std::filesystem::path &output, const InstallOptions &opti
|
|||||||
const auto rel = std::filesystem::path{entry.archive_path};
|
const auto rel = std::filesystem::path{entry.archive_path};
|
||||||
files_by_dir[rel.parent_path().generic_string()].push_back(rel.filename().string());
|
files_by_dir[rel.parent_path().generic_string()].push_back(rel.filename().string());
|
||||||
}
|
}
|
||||||
|
const auto source_of = [&source_root](const std::string &rel) {
|
||||||
|
return source_root.empty() ? rel : (source_root / rel).generic_string();
|
||||||
|
};
|
||||||
|
|
||||||
std::string xml =
|
std::string xml =
|
||||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||||
@@ -498,7 +502,7 @@ write_wix_source(const std::filesystem::path &output, const InstallOptions &opti
|
|||||||
xml += " <Component Id=\"" + wix_id("c_", rel) +
|
xml += " <Component Id=\"" + wix_id("c_", rel) +
|
||||||
"\" Guid=\"*\">\n"
|
"\" Guid=\"*\">\n"
|
||||||
" <File Id=\"" +
|
" <File Id=\"" +
|
||||||
wix_id("f_", rel) + "\" Source=\"" + wix_xml_escape(rel) +
|
wix_id("f_", rel) + "\" Source=\"" + wix_xml_escape(source_of(rel)) +
|
||||||
"\" KeyPath=\"yes\"/>\n"
|
"\" KeyPath=\"yes\"/>\n"
|
||||||
" </Component>\n";
|
" </Component>\n";
|
||||||
}
|
}
|
||||||
@@ -521,10 +525,85 @@ write_wix_source(const std::filesystem::path &output, const InstallOptions &opti
|
|||||||
xml += " </ComponentGroup>\n"
|
xml += " </ComponentGroup>\n"
|
||||||
" </Fragment>\n"
|
" </Fragment>\n"
|
||||||
"</Wix>\n";
|
"</Wix>\n";
|
||||||
|
return xml;
|
||||||
return Platform::atomic_write_file(output, xml, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WiX v3 source (the CPack WIX model): consumed by candle/light on Windows to produce an MSI.
|
||||||
|
Void::Result::Result<void, Void::Result::Error>
|
||||||
|
write_wix_source(const std::filesystem::path &output, const InstallOptions &options,
|
||||||
|
const std::vector<Package::ArchiveEntrySpec> &entries) {
|
||||||
|
return Platform::atomic_write_file(output, render_wix_source(options, entries, {}), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compiles the WiX source into an MSI with wixl (msitools) or the WiX toolset.
|
||||||
|
Void::Result::Result<void, Void::Result::Error>
|
||||||
|
write_msi_package(const std::filesystem::path &output, const InstallOptions &options,
|
||||||
|
const std::vector<Package::ArchiveEntrySpec> &entries,
|
||||||
|
const std::filesystem::path &source_root) {
|
||||||
|
const auto wxs = output.parent_path() / (output.stem().string() + ".wxs");
|
||||||
|
if (auto written =
|
||||||
|
Platform::atomic_write_file(wxs, render_wix_source(options, entries, source_root),
|
||||||
|
false);
|
||||||
|
!written) {
|
||||||
|
return written;
|
||||||
|
}
|
||||||
|
std::error_code ec;
|
||||||
|
const auto cleanup = Void::Scope::on_exit([&] { std::filesystem::remove(wxs, ec); });
|
||||||
|
|
||||||
|
const auto run_tool = [](const std::filesystem::path &tool,
|
||||||
|
const std::vector<std::string> &arguments,
|
||||||
|
std::string_view what) -> Void::Result::Result<void, Void::Result::Error> {
|
||||||
|
Platform::ProcessRequest req;
|
||||||
|
req.executable = tool;
|
||||||
|
req.arguments = arguments;
|
||||||
|
req.timeout = std::chrono::minutes{10};
|
||||||
|
auto res = Platform::run_supervised(req);
|
||||||
|
if (!res) {
|
||||||
|
return std::unexpected{res.error()};
|
||||||
|
}
|
||||||
|
if (!res->succeeded()) {
|
||||||
|
return std::unexpected{make_error(
|
||||||
|
Void::System::SystemErrorCode::io_error,
|
||||||
|
std::format("{} failed (exit {}): {}{}", what, res->exit_code,
|
||||||
|
res->stdout_data, res->stderr_data))};
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
};
|
||||||
|
|
||||||
|
if (const auto wixl = Platform::resolve_executable("wixl"); wixl) {
|
||||||
|
if (auto r = run_tool(*wixl, {"-o", output.string(), wxs.string()}, "wixl"); !r) {
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
} else if (const auto candle = Platform::resolve_executable("candle"); candle) {
|
||||||
|
const auto light = Platform::resolve_executable("light");
|
||||||
|
if (!light) {
|
||||||
|
return std::unexpected{make_error(
|
||||||
|
Void::System::SystemErrorCode::not_found,
|
||||||
|
"msi packaging requires wixl or the WiX toolset (candle and light)")};
|
||||||
|
}
|
||||||
|
const auto wixobj = output.parent_path() / (output.stem().string() + ".wixobj");
|
||||||
|
if (auto r = run_tool(*candle, {"-o", wixobj.string(), wxs.string()}, "candle"); !r) {
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
auto linked = run_tool(*light, {"-o", output.string(), wixobj.string()}, "light");
|
||||||
|
std::filesystem::remove(wixobj, ec);
|
||||||
|
if (!linked) {
|
||||||
|
return linked;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return std::unexpected{make_error(
|
||||||
|
Void::System::SystemErrorCode::not_found,
|
||||||
|
"msi packaging requires wixl or the WiX toolset (candle and light)")};
|
||||||
|
}
|
||||||
|
if (!std::filesystem::exists(output, ec)) {
|
||||||
|
return std::unexpected{make_error(
|
||||||
|
Void::System::SystemErrorCode::io_error,
|
||||||
|
std::format("msi packaging produced no '{}'", output.string()))};
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ── UDIF (DMG) trailer ─────────────────────────────────────────────────────────────────────
|
// ── UDIF (DMG) trailer ─────────────────────────────────────────────────────────────────────
|
||||||
// A DMG is a data fork (the disk image payload) followed by a 512-byte "koly" trailer. This
|
// A DMG is a data fork (the disk image payload) followed by a 512-byte "koly" trailer. This
|
||||||
// writer produces a valid UDIF container whose payload is the deterministic tar of the package;
|
// writer produces a valid UDIF container whose payload is the deterministic tar of the package;
|
||||||
@@ -1205,6 +1284,12 @@ install_project(const Graph::ProjectDescription &description, const Graph::Build
|
|||||||
!packed) {
|
!packed) {
|
||||||
return std::unexpected{packed.error()};
|
return std::unexpected{packed.error()};
|
||||||
}
|
}
|
||||||
|
} else if (options.archive_format == "msi") {
|
||||||
|
if (auto packed = write_msi_package(*options.archive_path, options, archive_entries,
|
||||||
|
prefix_abs);
|
||||||
|
!packed) {
|
||||||
|
return std::unexpected{packed.error()};
|
||||||
|
}
|
||||||
} else if (options.archive_format == "dmg") {
|
} else if (options.archive_format == "dmg") {
|
||||||
const auto payload = stage_root / "installer-payload.tar";
|
const auto payload = stage_root / "installer-payload.tar";
|
||||||
auto archived =
|
auto archived =
|
||||||
|
|||||||
+4
-3
@@ -2639,9 +2639,10 @@ int execute_install_command(const InstallCmdOptions &opts) {
|
|||||||
if (opts.archive_format_arg != "tar" && opts.archive_format_arg != "sh" &&
|
if (opts.archive_format_arg != "tar" && opts.archive_format_arg != "sh" &&
|
||||||
opts.archive_format_arg != "zip" && opts.archive_format_arg != "deb" &&
|
opts.archive_format_arg != "zip" && opts.archive_format_arg != "deb" &&
|
||||||
opts.archive_format_arg != "rpm" && opts.archive_format_arg != "wix" &&
|
opts.archive_format_arg != "rpm" && opts.archive_format_arg != "wix" &&
|
||||||
opts.archive_format_arg != "dmg" && opts.archive_format_arg != "nuget") {
|
opts.archive_format_arg != "msi" && opts.archive_format_arg != "dmg" &&
|
||||||
|
opts.archive_format_arg != "nuget") {
|
||||||
std::cerr << "vbs install: unsupported --archive-format '" << opts.archive_format_arg
|
std::cerr << "vbs install: unsupported --archive-format '" << opts.archive_format_arg
|
||||||
<< "' (expected tar, sh, zip, deb, rpm, wix, dmg or nuget)\n";
|
<< "' (expected tar, sh, zip, deb, rpm, wix, msi, dmg or nuget)\n";
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
if (opts.archive_arg && !opts.archive_arg->empty()) {
|
if (opts.archive_arg && !opts.archive_arg->empty()) {
|
||||||
@@ -3966,7 +3967,7 @@ int main(int argc, char **argv) {
|
|||||||
.option("--archive", "", "Write a deterministic installer archive of the prefix",
|
.option("--archive", "", "Write a deterministic installer archive of the prefix",
|
||||||
install_opts.archive_arg)
|
install_opts.archive_arg)
|
||||||
.option_default("--archive-format", "",
|
.option_default("--archive-format", "",
|
||||||
"Installer archive format: tar (default), sh, zip, deb, rpm, wix, dmg or nuget",
|
"Installer archive format: tar (default), sh, zip, deb, rpm, wix, msi, dmg or nuget",
|
||||||
install_opts.archive_format_arg, "tar")
|
install_opts.archive_format_arg, "tar")
|
||||||
.option("--signing-key", "",
|
.option("--signing-key", "",
|
||||||
"Ed25519 seed file; signs the archive and writes .sha256/.sig/.pub",
|
"Ed25519 seed file; signs the archive and writes .sha256/.sig/.pub",
|
||||||
|
|||||||
@@ -1100,6 +1100,27 @@ void build(Void::Build::Project &p) {
|
|||||||
Void::Testing::expect(wix_text->find("ComponentGroup Id=\"ProductComponents\"") !=
|
Void::Testing::expect(wix_text->find("ComponentGroup Id=\"ProductComponents\"") !=
|
||||||
std::string::npos);
|
std::string::npos);
|
||||||
|
|
||||||
|
// MSI compiled from the WiX source, when wixl or the WiX toolset is available.
|
||||||
|
if (Platform::resolve_executable("wixl").has_value() ||
|
||||||
|
Platform::resolve_executable("candle").has_value()) {
|
||||||
|
const auto msi_archive = tmp / "cli_hi.msi";
|
||||||
|
auto msi_req = inst_req;
|
||||||
|
for (auto &arg : msi_req.arguments) {
|
||||||
|
if (arg == installer_archive.string()) {
|
||||||
|
arg = msi_archive.string();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
msi_req.arguments.push_back("--archive-format");
|
||||||
|
msi_req.arguments.push_back("msi");
|
||||||
|
auto msi_res = Platform::run_supervised(msi_req);
|
||||||
|
Void::Testing::expect(msi_res.has_value() && msi_res->succeeded());
|
||||||
|
auto msi_bytes = Void::FileSystem::read_file(msi_archive);
|
||||||
|
Void::Testing::require(msi_bytes.has_value() && msi_bytes->size() > 8);
|
||||||
|
// OLE compound file magic (the MSI container).
|
||||||
|
Void::Testing::expect(msi_bytes->substr(0, 8) ==
|
||||||
|
std::string("\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1", 8));
|
||||||
|
}
|
||||||
|
|
||||||
// UDIF (DMG-style) container: tar payload followed by a 512-byte koly trailer.
|
// UDIF (DMG-style) container: tar payload followed by a 512-byte koly trailer.
|
||||||
const auto dmg_archive = tmp / "cli_hi.dmg";
|
const auto dmg_archive = tmp / "cli_hi.dmg";
|
||||||
auto dmg_req = inst_req;
|
auto dmg_req = inst_req;
|
||||||
|
|||||||
Reference in new issue
Block a user