Skip to content

Commit

Permalink
ascli-actions-pkgmgr.c: "Fix" build on Windows
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fanc999-1 committed Nov 27, 2023
1 parent d7e56f4 commit 926cdb9
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tools/ascli-actions-pkgmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@

#include <config.h>
#include <glib/gi18n-lib.h>

#ifndef G_OS_WIN32
#include <unistd.h>
#endif

#include <errno.h>

#include "ascli-utils.h"
Expand All @@ -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";
Expand All @@ -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
}

/**
Expand All @@ -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."));
Expand All @@ -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
Expand Down

0 comments on commit 926cdb9

Please sign in to comment.