[PATCH 4/5] upstart: add UpstartJob= to service desktop files

Scott James Remnant scott at netsplit.com
Wed Dec 22 07:27:06 PST 2010


Add a field to service desktop files to specify that there is an
equivalent Upstart job for this service; unlike the systemd stuff,
this doesn't need to name that job so it's just a flag.
---
 bus/activation.c   |   20 ++++++++++++++++++++
 bus/desktop-file.h |    1 +
 2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/bus/activation.c b/bus/activation.c
index 7d15910..978fa00 100644
--- a/bus/activation.c
+++ b/bus/activation.c
@@ -74,6 +74,7 @@ typedef struct
   unsigned long mtime;
   BusServiceDirectory *s_dir;
   char *filename;
+  unsigned int upstart_job : 1;
 } BusActivationEntry;
 
 typedef struct BusPendingActivationEntry BusPendingActivationEntry;
@@ -98,6 +99,7 @@ typedef struct
   DBusBabysitter *babysitter;
   DBusTimeout *timeout;
   unsigned int timeout_added : 1;
+  unsigned int upstart_job : 1;
 } BusPendingActivation;
 
 #if 0
@@ -260,6 +262,8 @@ update_desktop_file_entry (BusActivation       *activation,
                            DBusError           *error)
 {
   char *name, *exec, *user, *exec_tmp, *systemd_service;
+  const char *upstart_job_raw;
+  int upstart_job;
   BusActivationEntry *entry;
   DBusStat stat_buf;
   DBusString file_path;
@@ -273,6 +277,8 @@ update_desktop_file_entry (BusActivation       *activation,
   exec_tmp = NULL;
   entry = NULL;
   systemd_service = NULL;
+  upstart_job_raw = NULL;
+  upstart_job = FALSE;
 
   dbus_error_init (&tmp_error);
 
@@ -355,6 +361,16 @@ update_desktop_file_entry (BusActivation       *activation,
         }
     }
 
+  /* upstart job is never required */
+  if (bus_desktop_file_get_raw (desktop_file,
+                                DBUS_SERVICE_SECTION,
+                                DBUS_SERVICE_UPSTART_JOB,
+                                &upstart_job_raw))
+    {
+      if (strchr ("YyTt", upstart_job_raw[0]))
+        upstart_job = TRUE;
+    }
+
   _DBUS_ASSERT_ERROR_IS_CLEAR (&tmp_error);
 
   entry = _dbus_hash_table_lookup_string (s_dir->entries,
@@ -385,6 +401,7 @@ update_desktop_file_entry (BusActivation       *activation,
       entry->exec = exec;
       entry->user = user;
       entry->systemd_service = systemd_service;
+      entry->upstart_job = upstart_job;
       entry->refcount = 1;
 
       entry->s_dir = s_dir;
@@ -428,6 +445,7 @@ update_desktop_file_entry (BusActivation       *activation,
       dbus_free (entry->user);
       dbus_free (entry->systemd_service);
       entry->systemd_service = systemd_service;
+      entry->upstart_job = upstart_job;
       entry->name = name;
       entry->exec = exec;
       entry->user = user;
@@ -1816,6 +1834,8 @@ bus_activation_activate_service (BusActivation  *activation,
             }
         }
 
+      pending_activation->upstart_job = entry->upstart_job;
+
       pending_activation->timeout =
         _dbus_timeout_new (bus_context_get_activation_timeout (activation->context),
                            pending_activation_timed_out,
diff --git a/bus/desktop-file.h b/bus/desktop-file.h
index 58e78e8..d78e24f 100644
--- a/bus/desktop-file.h
+++ b/bus/desktop-file.h
@@ -36,6 +36,7 @@
 #define DBUS_SERVICE_USER     "User"
 #define DBUS_SERVICE_GROUP    "Group"
 #define DBUS_SERVICE_SYSTEMD_SERVICE "SystemdService"
+#define DBUS_SERVICE_UPSTART_JOB "UpstartJob"
 
 typedef struct BusDesktopFile BusDesktopFile;
 
-- 
1.7.1



More information about the dbus mailing list