Skip to content

Commit 6f5532c

Browse files
committed
🚧 instlib: skip DM services if not exist yet
we run enable_services both for base install, and for desktop install; when running base install DM services are not available yet as it's not part of the base install to have DM at all.
1 parent 3726603 commit 6f5532c

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

‎installer-lib/src/packages.cpp‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ using cachyos::installer::InstallContext;
3434
auto apply_services(const std::vector<gucc::profile::ServiceEntry>& services, std::string_view mountpoint) noexcept -> bool {
3535
for (const auto& entry : services) {
3636
if (!gucc::services::systemd_unit_exists(entry.name, mountpoint)) {
37+
// A service targeted for Disable is already effectively disabled
38+
// if its unit doesn't exist, then not an error condition
39+
if (entry.action == gucc::profile::ServiceAction::Disable) {
40+
spdlog::debug("service '{}' not present, skip disable", entry.name);
41+
continue;
42+
}
3743
if (entry.is_urgent) {
3844
spdlog::error("required service '{}': unit not found", entry.name);
3945
} else {
@@ -271,9 +277,19 @@ auto enable_services(const InstallContext& ctx) noexcept
271277
// Display manager detection (desktop mode only)
272278
if (!ctx.server_mode) {
273279
const std::vector<std::string_view> dm_services{"plasmalogin", "lightdm", "sddm", "gdm", "lxdm", "ly", "cosmic-greeter"};
274-
const auto is_enabled = std::ranges::any_of(dm_services, [=](auto&& service) { return enable_service_if_exists(service, mountpoint); });
275-
if (!is_enabled) {
276-
spdlog::error("Failed to enable any of the DM services");
280+
// Only attempt DM enablement if at least one DM unit exists on target.
281+
const auto has_any_dm = std::ranges::any_of(dm_services, [=](auto&& service) {
282+
return gucc::services::systemd_unit_exists(service, mountpoint);
283+
});
284+
const auto is_enabled = std::ranges::any_of(dm_services, [=](auto&& service) {
285+
return enable_service_if_exists(service, mountpoint);
286+
});
287+
if (has_any_dm) {
288+
if (!is_enabled) {
289+
spdlog::error("Failed to enable any of the DM services");
290+
}
291+
} else {
292+
spdlog::debug("No display manager units found on target yet. Skipping DM enablement..");
277293
}
278294

279295
if (gucc::services::systemd_unit_exists("lightdm"sv, mountpoint)) {

0 commit comments

Comments
 (0)