[gnome-settings-daemon] updates: watch inserted media for post-install media such as used by Fedora and RHEL
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] updates: watch inserted media for post-install media such as used by Fedora and RHEL
- Date: Thu, 17 Feb 2011 10:29:12 +0000 (UTC)
commit 791b2da3c037530f887beba181a6c7fd1893df24
Author: Richard Hughes <richard hughsie com>
Date: Thu Feb 17 10:28:41 2011 +0000
updates: watch inserted media for post-install media such as used by Fedora and RHEL
If such a disk is inserted, a GetUpdates call is issued, which causes
PackageKit to do the right thing, typically issuing an UpdatesChanged
event with the new media repo enabled.
...ttings-daemon.plugins.updates.gschema.xml.in.in | 5 +
plugins/updates/Makefile.am | 1 +
plugins/updates/gsd-updates-common.h | 1 +
plugins/updates/gsd-updates-manager.c | 81 +++++++++++++++++++-
4 files changed, 87 insertions(+), 1 deletions(-)
---
diff --git a/data/org.gnome.settings-daemon.plugins.updates.gschema.xml.in.in b/data/org.gnome.settings-daemon.plugins.updates.gschema.xml.in.in
index 7354472..42b0e54 100644
--- a/data/org.gnome.settings-daemon.plugins.updates.gschema.xml.in.in
+++ b/data/org.gnome.settings-daemon.plugins.updates.gschema.xml.in.in
@@ -105,5 +105,10 @@
<_summary>Devices that should be ignored</_summary>
<_description>Devices that should be ignored, separated by commas. These can include '*' and '?' characters.</_description>
</key>
+ <key name="media-repo-filenames" type="s">
+ <default>'media.repo,.discinfo'</default>
+ <_summary>The filenames on removable media that designate it a software source.</_summary>
+ <_description>When removable media is inserted, it is checked to see if it contains any important filenames in the root directory. If the filename matches, then an updates check is performed. This allows post-install disks to be used to update running systems.</_description>
+ </key>
</schema>
</schemalist>
diff --git a/plugins/updates/Makefile.am b/plugins/updates/Makefile.am
index cc20d57..59f035a 100644
--- a/plugins/updates/Makefile.am
+++ b/plugins/updates/Makefile.am
@@ -2,6 +2,7 @@ plugin_LTLIBRARIES = \
libupdates.la
libupdates_la_SOURCES = \
+ gsd-updates-common.h \
gsd-updates-plugin.h \
gsd-updates-plugin.c \
gsd-updates-refresh.h \
diff --git a/plugins/updates/gsd-updates-common.h b/plugins/updates/gsd-updates-common.h
index 8a576da..6016646 100644
--- a/plugins/updates/gsd-updates-common.h
+++ b/plugins/updates/gsd-updates-common.h
@@ -42,6 +42,7 @@ G_BEGIN_DECLS
#define GSD_SETTINGS_SCHEMA "org.gnome.settings-daemon.plugins.updates"
#define GSD_SETTINGS_SESSION_STARTUP_TIMEOUT "session-startup-timeout"
#define GSD_SETTINGS_UPDATE_BATTERY "update-battery"
+#define GSD_SETTINGS_MEDIA_REPO_FILENAMES "media-repo-filenames"
G_END_DECLS
diff --git a/plugins/updates/gsd-updates-manager.c b/plugins/updates/gsd-updates-manager.c
index 0d1905a..e0bdb7f 100644
--- a/plugins/updates/gsd-updates-manager.c
+++ b/plugins/updates/gsd-updates-manager.c
@@ -53,6 +53,7 @@ struct GsdUpdatesManagerPrivate
guint inhibit_cookie;
GDBusProxy *proxy_session;
guint update_viewer_watcher_id;
+ GVolumeMonitor *volume_monitor;
};
static void gsd_updates_manager_class_init (GsdUpdatesManagerClass *klass);
@@ -717,7 +718,7 @@ out:
}
static void
-due_get_updates_cb (GsdUpdatesRefresh *refresh, GsdUpdatesManager *manager)
+query_updates (GsdUpdatesManager *manager)
{
/* optimize the amount of downloaded data by setting the cache age */
pk_client_set_cache_age (PK_CLIENT(manager->priv->task),
@@ -733,6 +734,12 @@ due_get_updates_cb (GsdUpdatesRefresh *refresh, GsdUpdatesManager *manager)
manager);
}
+static void
+due_get_updates_cb (GsdUpdatesRefresh *refresh, GsdUpdatesManager *manager)
+{
+ query_updates (manager);
+}
+
static gchar *
get_proxy_http (GsdUpdatesManager *manager)
{
@@ -1009,6 +1016,69 @@ update_viewer_appeared_cb (GDBusConnection *connection,
}
}
+static gboolean
+file_exists_in_root (const gchar *root, const gchar *filename)
+{
+ gboolean ret;
+ GFile *source;
+ gchar *source_path;
+
+ source_path = g_build_filename (root, filename, NULL);
+ source = g_file_new_for_path (source_path);
+
+ /* an interesting file exists */
+ ret = g_file_query_exists (source, NULL);
+ g_debug ("checking for %s: %s", source_path, ret ? "yes" : "no");
+ if (!ret)
+ goto out;
+out:
+ g_free (source_path);
+ g_object_unref (source);
+ return ret;
+}
+
+static void
+mount_added_cb (GVolumeMonitor *volume_monitor,
+ GMount *mount,
+ GsdUpdatesManager *manager)
+{
+ gboolean ret = FALSE;
+ gchar **filenames = NULL;
+ gchar *media_repo_filenames;
+ gchar *root_path;
+ GFile *root;
+ guint i;
+
+ /* check if any installed media is an install disk */
+ root = g_mount_get_root (mount);
+ root_path = g_file_get_path (root);
+
+ /* use settings */
+ media_repo_filenames = g_settings_get_string (manager->priv->settings_gsd,
+ GSD_SETTINGS_MEDIA_REPO_FILENAMES);
+ if (media_repo_filenames == NULL) {
+ g_warning ("failed to get media repo filenames");
+ goto out;
+ }
+
+ /* search each possible filename */
+ filenames = g_strsplit (media_repo_filenames, ",", -1);
+ for (i=0; filenames[i] != NULL; i++) {
+ ret = file_exists_in_root (root_path, filenames[i]);
+ if (ret)
+ break;
+ }
+
+ /* do an updates check with the new media */
+ if (ret)
+ query_updates (manager);
+out:
+ g_strfreev (filenames);
+ g_free (media_repo_filenames);
+ g_free (root_path);
+ g_object_unref (root);
+}
+
gboolean
gsd_updates_manager_start (GsdUpdatesManager *manager,
GError **error)
@@ -1079,6 +1149,11 @@ gsd_updates_manager_start (GsdUpdatesManager *manager,
manager,
NULL);
+ /* get a volume monitor so we can watch media */
+ manager->priv->volume_monitor = g_volume_monitor_get ();
+ g_signal_connect (manager->priv->volume_monitor, "mount-added",
+ G_CALLBACK (mount_added_cb), manager);
+
/* coldplug */
reload_proxy_settings (manager);
set_install_root (manager);
@@ -1127,6 +1202,10 @@ gsd_updates_manager_stop (GsdUpdatesManager *manager)
g_object_unref (manager->priv->proxy_session);
manager->priv->proxy_session = NULL;
}
+ if (manager->priv->volume_monitor != NULL) {
+ g_object_unref (manager->priv->volume_monitor);
+ manager->priv->volume_monitor = NULL;
+ }
if (manager->priv->cancellable != NULL) {
g_object_unref (manager->priv->cancellable);
manager->priv->cancellable = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]