chiark / gitweb /
core: add %v specifier
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 19 Jul 2013 06:45:27 +0000 (02:45 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 19 Jul 2013 06:45:49 +0000 (02:45 -0400)
TODO
man/systemd.unit.xml
src/core/unit-printf.c
src/shared/install-printf.c
src/shared/specifier.c
src/shared/specifier.h

diff --git a/TODO b/TODO
index 5de106e1225f233661f2e729fda9e9092f07941e..b086b933bb088dc59e5811378b7372c396ec9a95 100644 (file)
--- a/TODO
+++ b/TODO
@@ -60,7 +60,7 @@ Features:
 * given that logind/machined now let PID 1 do all nasty work we can
   probably reduce the capability set they retain substantially.
 
 * given that logind/machined now let PID 1 do all nasty work we can
   probably reduce the capability set they retain substantially.
 
-* btfs raid assembly: some .device jobs stay stuck in the queue
+* btrfs raid assembly: some .device jobs stay stuck in the queue
 
 * Fedora: add an rpmlint check that verifies that all unit files in the RPM are listed in %systemd_post macros.
 
 
 * Fedora: add an rpmlint check that verifies that all unit files in the RPM are listed in %systemd_post macros.
 
@@ -80,8 +80,6 @@ Features:
 
 * journald: optionally, when messages with a high log priority are logged, sync() immediately.
 
 
 * journald: optionally, when messages with a high log priority are logged, sync() immediately.
 
-* introduce %v resolving to the string returned by "uname -r"
-
 * systemctl list-unit-files should list generated files (and probably with a new state "generated" for them, or so)
 
 * do we really need both hasprefix() and startswith()?
 * systemctl list-unit-files should list generated files (and probably with a new state "generated" for them, or so)
 
 * do we really need both hasprefix() and startswith()?
index f45632a0e3599a8bfe5cc7c906ff14d4ee0b8572..65ba54503713715edab2eb370c77603051e71033 100644 (file)
                 </variablelist>
 
                 <para>The following specifiers are interpreted in the
                 </variablelist>
 
                 <para>The following specifiers are interpreted in the
-                Install section: %n, %N, %p, %i, %U, %u, %m, %H, %b.
+                Install section: %n, %N, %p, %i, %U, %u, %m, %H, %b, %v.
                 For their meaning see the next section.
                 </para>
         </refsect1>
                 For their meaning see the next section.
                 </para>
         </refsect1>
                         <entry>Host name</entry>
                         <entry>The hostname of the running system.</entry>
                       </row>
                         <entry>Host name</entry>
                         <entry>The hostname of the running system.</entry>
                       </row>
+                      <row>
+                        <entry><literal>%v</literal></entry>
+                        <entry>Kernel release</entry>
+                        <entry>Identical to <command>uname -r</command> output.</entry>
+                      </row>
                       <row>
                         <entry><literal>%%</literal></entry>
                         <entry>Escaped %</entry>
                       <row>
                         <entry><literal>%%</literal></entry>
                         <entry>Escaped %</entry>
                         <citerefentry><refentrytitle>systemd.snapshot</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
                         <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
                         <citerefentry><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
                         <citerefentry><refentrytitle>systemd.snapshot</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
                         <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
                         <citerefentry><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
-                        <citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry>
+                        <citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
+                        <citerefentry><refentrytitle>uname</refentrytitle><manvolnum>1</manvolnum></citerefentry>
                 </para>
         </refsect1>
 
                 </para>
         </refsect1>
 
index caf51259d2d18a72eefabb5e69cf5a5bfd7bfb41..ffc203dd921163ecdc03dda39f93bee8020de5f6 100644 (file)
@@ -268,6 +268,7 @@ char *unit_full_printf(Unit *u, const char *format) {
          * %m the machine ID of the running system
          * %H the host name of the running system
          * %b the boot ID of the running system
          * %m the machine ID of the running system
          * %H the host name of the running system
          * %b the boot ID of the running system
+         * %v `uname -r` of the running system
          */
 
         const Specifier table[] = {
          */
 
         const Specifier table[] = {
@@ -291,7 +292,8 @@ char *unit_full_printf(Unit *u, const char *format) {
                 { 'm', specifier_machine_id,          NULL },
                 { 'H', specifier_host_name,           NULL },
                 { 'b', specifier_boot_id,             NULL },
                 { 'm', specifier_machine_id,          NULL },
                 { 'H', specifier_host_name,           NULL },
                 { 'b', specifier_boot_id,             NULL },
-                { 0, NULL, NULL }
+                { 'v', specifier_kernel_release,      NULL },
+                {}
         };
 
         assert(format);
         };
 
         assert(format);
index c44459b4e0fbd73fd7db9d6739fd30571f24985a..1157ea989beb2b34169fdff593e2ebb80de93f0f 100644 (file)
@@ -108,6 +108,7 @@ char *install_full_printf(InstallInfo *i, const char *format) {
          * %m the machine ID of the running system
          * %H the host name of the running system
          * %b the boot ID of the running system
          * %m the machine ID of the running system
          * %H the host name of the running system
          * %b the boot ID of the running system
+         * %v `uname -r` of the running system
          */
 
         const Specifier table[] = {
          */
 
         const Specifier table[] = {
@@ -122,7 +123,8 @@ char *install_full_printf(InstallInfo *i, const char *format) {
                 { 'm', specifier_machine_id,          NULL },
                 { 'H', specifier_host_name,           NULL },
                 { 'b', specifier_boot_id,             NULL },
                 { 'm', specifier_machine_id,          NULL },
                 { 'H', specifier_host_name,           NULL },
                 { 'b', specifier_boot_id,             NULL },
-                { 0, NULL, NULL }
+                { 'v', specifier_kernel_release,      NULL },
+                {}
         };
 
         assert(i);
         };
 
         assert(i);
index 7577c91052cd7f57e0a9c6503dc2932843510b86..bb8859fdfd8b6e6480fb81c5fe841f890fc6eab3 100644 (file)
@@ -20,6 +20,7 @@
 ***/
 
 #include <string.h>
 ***/
 
 #include <string.h>
+#include <sys/utsname.h>
 
 #include "macro.h"
 #include "util.h"
 
 #include "macro.h"
 #include "util.h"
@@ -145,3 +146,14 @@ char *specifier_boot_id(char specifier, void *data, void *userdata) {
 char *specifier_host_name(char specifier, void *data, void *userdata) {
         return gethostname_malloc();
 }
 char *specifier_host_name(char specifier, void *data, void *userdata) {
         return gethostname_malloc();
 }
+
+char *specifier_kernel_release(char specifier, void *data, void *userdata) {
+        struct utsname uts;
+        int r;
+
+        r = uname(&uts);
+        if (r < 0)
+                return NULL;
+
+        return strdup(uts.release);
+}
index 0440dcac4897367367ae9fa4c6d8ecad40cb7062..d13e6406b6b3eda68187ba3dfcfa7f62198f0ff5 100644 (file)
@@ -36,3 +36,4 @@ char *specifier_string(char specifier, void *data, void *userdata);
 char *specifier_machine_id(char specifier, void *data, void *userdata);
 char *specifier_boot_id(char specifier, void *data, void *userdata);
 char *specifier_host_name(char specifier, void *data, void *userdata);
 char *specifier_machine_id(char specifier, void *data, void *userdata);
 char *specifier_boot_id(char specifier, void *data, void *userdata);
 char *specifier_host_name(char specifier, void *data, void *userdata);
+char *specifier_kernel_release(char specifier, void *data, void *userdata);