forked from Mirrors/flatpak-builder
Check the flatpak version
Before using --noninteractive, check that we are dealing with a new-enough flatpak to understand that option. Closes: #254 Approved by: alexlarssonauto
parent
d5d6debdce
commit
02c69e65d1
|
@ -252,6 +252,46 @@ do_export (BuilderContext *build_context,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
flatpak_version_check (int major,
|
||||
int minor,
|
||||
int micro)
|
||||
{
|
||||
static int flatpak_major = 0;
|
||||
static int flatpak_minor = 0;
|
||||
static int flatpak_micro = 0;
|
||||
|
||||
if (flatpak_major == 0 &&
|
||||
flatpak_minor == 0 &&
|
||||
flatpak_micro == 0)
|
||||
{
|
||||
const char * argv[] = { "flatpak", "--version", NULL };
|
||||
g_autoptr(GSubprocess) subp = NULL;
|
||||
g_autofree char *out = NULL;
|
||||
|
||||
subp = g_subprocess_newv (argv, G_SUBPROCESS_FLAGS_STDOUT_PIPE, NULL);
|
||||
g_subprocess_communicate_utf8 (subp, NULL, NULL, &out, NULL, NULL);
|
||||
|
||||
if (sscanf (out, "Flatpak %d.%d.%d", &flatpak_major, &flatpak_minor, &flatpak_micro) != 3)
|
||||
g_warning ("Failed to get flatpak version");
|
||||
|
||||
g_debug ("Using Flatpak version %d.%d.%d", flatpak_major, flatpak_minor, flatpak_micro);
|
||||
}
|
||||
|
||||
if (flatpak_major > major)
|
||||
return TRUE;
|
||||
if (flatpak_major < major)
|
||||
return FALSE;
|
||||
if (flatpak_minor > minor)
|
||||
return TRUE;
|
||||
if (flatpak_minor < minor)
|
||||
return FALSE;
|
||||
if (flatpak_micro >= micro)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
do_install (BuilderContext *build_context,
|
||||
const gchar *repodir,
|
||||
|
@ -276,7 +316,8 @@ do_install (BuilderContext *build_context,
|
|||
g_ptr_array_add (args, g_strdup ("--system"));
|
||||
|
||||
g_ptr_array_add (args, g_strdup ("-y"));
|
||||
g_ptr_array_add (args, g_strdup ("--noninteractive"));
|
||||
if (flatpak_version_check (1, 2, 0))
|
||||
g_ptr_array_add (args, g_strdup ("--noninteractive"));
|
||||
g_ptr_array_add (args, g_strdup ("--reinstall"));
|
||||
|
||||
ref = flatpak_build_untyped_ref (id, branch,
|
||||
|
@ -417,7 +458,6 @@ main (int argc,
|
|||
else
|
||||
g_unsetenv ("GIO_USE_VFS");
|
||||
|
||||
|
||||
/* Work around libsoup/glib race condition, as per:
|
||||
https://bugzilla.gnome.org/show_bug.cgi?id=796031 and
|
||||
https://bugzilla.gnome.org/show_bug.cgi?id=674885#c87 */
|
||||
|
|
Loading…
Reference in New Issue