fix
All checks were successful
sgraves/cpp-build-system_msys2/pipeline/head This commit looks good
sgraves/cpp-build-system_mac/pipeline/head This commit looks good
sgraves/cpp-build-system/pipeline/head This commit looks good

This commit is contained in:
2025-12-14 19:53:07 -06:00
parent e54538ec47
commit 6b8c787688

View File

@@ -311,11 +311,24 @@ auto use_getpwuid(uid_t uid, passwd_callback_t callback) -> result {
#if defined(PROJECT_ENABLE_PUGIXML) #if defined(PROJECT_ENABLE_PUGIXML)
auto generate_launchd_plist(const plist_cfg &cfg, bool overwrite_existing) auto generate_launchd_plist(const plist_cfg &cfg, bool overwrite_existing)
-> bool { -> bool {
FIFTHGRID_USES_FUNCTION_NAME();
auto file = utils::path::combine(cfg.plist_path, {cfg.label + ".plist"}); auto file = utils::path::combine(cfg.plist_path, {cfg.label + ".plist"});
if (utils::file::file{file}.exists() && not overwrite_existing) { if (utils::file::file{file}.exists() && not overwrite_existing) {
return true; return true;
} }
auto parent_directory = utils::path::get_parent_path(file);
if (not utils::file::directory{parent_directory}.create_directory()) {
utils::error::handle_error(function_name,
utils::error::create_error_message({
"failed to create plist parent directory",
parent_directory,
std::to_string(errno),
}));
return false;
}
pugi::xml_document doc; pugi::xml_document doc;
auto decl = doc.append_child(pugi::node_declaration); auto decl = doc.append_child(pugi::node_declaration);
decl.append_attribute("version") = "1.0"; decl.append_attribute("version") = "1.0";
@@ -370,26 +383,24 @@ auto generate_launchd_plist(const plist_cfg &cfg, bool overwrite_existing)
#if defined(PROJECT_ENABLE_SPDLOG) || defined(PROJECT_ENABLE_FMT) #if defined(PROJECT_ENABLE_SPDLOG) || defined(PROJECT_ENABLE_FMT)
auto launchctl_command(std::string_view label, launchctl_type type) -> int { auto launchctl_command(std::string_view label, launchctl_type type) -> int {
auto launch_agents_dir = utils::path::combine("~", {
"Library",
"LaunchAgents",
});
switch (type) { switch (type) {
case launchctl_type::bootout: case launchctl_type::bootout:
return system( return system(
fmt::format("launchctl bootout gui/{} '{}' 1>/dev/null 2>&1", getuid(), fmt::format("launchctl bootout gui/{} '{}' 1>/dev/null 2>&1", getuid(),
utils::path::combine("~", utils::path::combine(launch_agents_dir,
{ {fmt::format("{}.plist", label)}))
"/Library/LaunchAgents",
fmt::format("{}.plist", label),
}))
.c_str()); .c_str());
case launchctl_type::bootstrap: case launchctl_type::bootstrap:
return system( return system(
fmt::format("launchctl bootstrap gui/{} '{}' 1>/dev/null 2>&1", fmt::format("launchctl bootstrap gui/{} '{}' 1>/dev/null 2>&1",
getuid(), getuid(),
utils::path::combine("~", utils::path::combine(launch_agents_dir,
{ {fmt::format("{}.plist", label)}))
"/Library/LaunchAgents",
fmt::format("{}.plist", label),
}))
.c_str()); .c_str());
case launchctl_type::kickstart: case launchctl_type::kickstart: