From acf15757da6d0883f2b6547e3382bab23bce3fbd Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Fri, 20 Oct 2023 10:31:46 +0800 Subject: [PATCH] ascli-actions-pkgmgr.c: "Fix" build on Windows Like previous commits, avoid including unistd.h on Windows, and just bail out trying to run package managers or flatpak as they are more or less concepts that are foreign to Windows, at least for now. --- tools/ascli-actions-pkgmgr.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tools/ascli-actions-pkgmgr.c b/tools/ascli-actions-pkgmgr.c index a6807b292..7d5a5fc22 100644 --- a/tools/ascli-actions-pkgmgr.c +++ b/tools/ascli-actions-pkgmgr.c @@ -22,7 +22,11 @@ #include #include + +#ifndef G_OS_WIN32 #include +#endif + #include #include "ascli-utils.h" @@ -41,6 +45,12 @@ exec_pm_action (const gchar *action, gchar **pkgnames) const gchar *exe = NULL; g_auto(GStrv) cmd = NULL; +#ifdef G_OS_WIN32 + g_printerr ("%s\n", + _("No supported package managers are available on Windows.")); + return ASCLI_EXIT_CODE_FAILED; +#else + #ifdef HAVE_APT_SUPPORT if (g_file_test ("/usr/bin/apt", G_FILE_TEST_EXISTS)) exe = "/usr/bin/apt"; @@ -66,6 +76,7 @@ exec_pm_action (const gchar *action, gchar **pkgnames) if (ret != 0) ascli_print_stderr (_("Unable to spawn package manager: %s"), g_strerror (errno)); return ret; +#endif } /** @@ -80,6 +91,12 @@ exec_flatpak_action (const gchar *action, const gchar *bundle_id) const gchar *exe = NULL; g_auto(GStrv) cmd = NULL; +#ifdef G_OS_WIN32 + g_printerr ("%s\n", + _("Flatpak is unavailable on Windows.")); + return ASCLI_EXIT_CODE_FAILED; +#else + exe = "/usr/bin/flatpak"; if (!g_file_test (exe, G_FILE_TEST_EXISTS)) { g_printerr ("%s\n", _("Flatpak was not found! Please install it to continue.")); @@ -95,6 +112,7 @@ exec_flatpak_action (const gchar *action, const gchar *bundle_id) if (ret != 0) ascli_print_stderr (_("Unable to spawn Flatpak process: %s"), g_strerror (errno)); return ret; +#endif } static int