[gnome-software/wip/hughsie/plugin-fedora-liveusb] Add a plugin to disable updates when running on a Fedora LiveUSB image
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/hughsie/plugin-fedora-liveusb] Add a plugin to disable updates when running on a Fedora LiveUSB image
- Date: Mon, 31 Oct 2016 10:13:39 +0000 (UTC)
commit cb946dcae33eb66a38f80c9040af1f62a217c207
Author: Richard Hughes <richard hughsie com>
Date: Mon Oct 31 09:08:58 2016 +0000
Add a plugin to disable updates when running on a Fedora LiveUSB image
contrib/gnome-software.spec.in | 1 +
src/plugins/Makefile.am | 6 ++++
src/plugins/gs-plugin-fedora-liveusb.c | 45 ++++++++++++++++++++++++++++++++
3 files changed, 52 insertions(+), 0 deletions(-)
---
diff --git a/contrib/gnome-software.spec.in b/contrib/gnome-software.spec.in
index f60586b..ae08821 100644
--- a/contrib/gnome-software.spec.in
+++ b/contrib/gnome-software.spec.in
@@ -158,6 +158,7 @@ glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || :
%{_libdir}/gs-plugins-%{gs_plugin_version}/libgs_plugin_external-appstream.so
%{_libdir}/gs-plugins-%{gs_plugin_version}/libgs_plugin_fedora-distro-upgrades.so
%{_libdir}/gs-plugins-%{gs_plugin_version}/libgs_plugin_fedora-tagger-usage.so
+%{_libdir}/gs-plugins-%{gs_plugin_version}/libgs_plugin_fedora-liveusb.so
%{_libdir}/gs-plugins-%{gs_plugin_version}/libgs_plugin_flatpak-system.so
%{_libdir}/gs-plugins-%{gs_plugin_version}/libgs_plugin_flatpak-user.so
%{_libdir}/gs-plugins-%{gs_plugin_version}/libgs_plugin_fwupd.so
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index de0782e..9c7241a 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -42,6 +42,7 @@ plugin_LTLIBRARIES = \
libgs_plugin_hardcoded-popular.la \
libgs_plugin_hardcoded-featured.la \
libgs_plugin_fedora-distro-upgrades.la \
+ libgs_plugin_fedora-liveusb.la \
libgs_plugin_provenance.la \
libgs_plugin_provenance-license.la \
libgs_plugin_repos.la \
@@ -161,6 +162,11 @@ libgs_plugin_fedora_distro_upgrades_la_LIBADD = $(GS_PLUGIN_LIBS) $(JSON_GLIB_LI
libgs_plugin_fedora_distro_upgrades_la_LDFLAGS = -module -avoid-version
libgs_plugin_fedora_distro_upgrades_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(JSON_GLIB_CFLAGS) $(WARN_CFLAGS)
+libgs_plugin_fedora_liveusb_la_SOURCES = gs-plugin-fedora-liveusb.c
+libgs_plugin_fedora_liveusb_la_LIBADD = $(GS_PLUGIN_LIBS) $(JSON_GLIB_LIBS) $(SOUP_LIBS)
+libgs_plugin_fedora_liveusb_la_LDFLAGS = -module -avoid-version
+libgs_plugin_fedora_liveusb_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(JSON_GLIB_CFLAGS) $(WARN_CFLAGS)
+
if HAVE_GUDEV
libgs_plugin_modalias_la_SOURCES = gs-plugin-modalias.c
libgs_plugin_modalias_la_LIBADD = $(GS_PLUGIN_LIBS) $(GUDEV_LIBS)
diff --git a/src/plugins/gs-plugin-fedora-liveusb.c b/src/plugins/gs-plugin-fedora-liveusb.c
new file mode 100644
index 0000000..f9d04bd
--- /dev/null
+++ b/src/plugins/gs-plugin-fedora-liveusb.c
@@ -0,0 +1,45 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2016 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <config.h>
+
+#include <gnome-software.h>
+
+void
+gs_plugin_initialize (GsPlugin *plugin)
+{
+ if (!gs_plugin_check_distro_id (plugin, "fedora"))
+ gs_plugin_set_enabled (plugin, FALSE);
+}
+
+gboolean
+gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
+{
+ g_autofree gchar *data = NULL;
+ if (!g_file_get_contents ("/proc/cmdline", &data, NULL, error)) {
+ g_prefix_error (error, "failed to get kernel command line: ");
+ return FALSE;
+ }
+ g_debug ("kernel command line: %s", data);
+ if (g_strstr_len (data, -1, "root=live") != NULL)
+ gs_plugin_set_allow_updates (plugin, FALSE);
+ return TRUE;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]