[systemd-commits] 6 commits - Makefile.am TODO configure.ac man/systemd.time.xml man/systemd.timer.xml man/systemd.unit.xml src/core src/login src/shared src/systemctl src/test

Lennart Poettering lennart at kemper.freedesktop.org
Fri Nov 23 15:25:13 PST 2012


 Makefile.am               |   10 -
 TODO                      |    2 
 configure.ac              |    9 -
 man/systemd.time.xml      |  291 ++++++++++++++++++++++++++++++++++++++++++++++
 man/systemd.timer.xml     |   26 +++-
 man/systemd.unit.xml      |    3 
 src/core/locale-setup.c   |    2 
 src/core/service.c        |    8 -
 src/login/loginctl.c      |    4 
 src/shared/time-util.c    |   42 ++++++
 src/shared/time-util.h    |    2 
 src/systemctl/systemctl.c |    2 
 src/test/test-date.c      |   69 ++++------
 13 files changed, 398 insertions(+), 72 deletions(-)

New commits:
commit d85f4d4ebf088bdc6e4f7bf65b355e93e8c83498
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sat Nov 24 00:24:30 2012 +0100

    update TODO

diff --git a/TODO b/TODO
index 9c84162..a9f76de 100644
--- a/TODO
+++ b/TODO
@@ -19,6 +19,8 @@ F18:
 
 Features:
 
+* reschedule calendar timer events when the time jumps
+
 * kill insserv code
 
 * In parse_timestamp() allow specifying a week day, and if it doesn't match the date, generate a parse failure

commit 7a529f63e60dfdccc23d61808c20ba40d9901e47
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sat Nov 24 00:24:14 2012 +0100

    man: document calendar timers

diff --git a/Makefile.am b/Makefile.am
index 5d772be..6321840 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -477,6 +477,7 @@ MANPAGES = \
 	man/systemd.kill.5 \
 	man/systemd.special.7 \
 	man/systemd.journal-fields.7 \
+	man/systemd.time.7 \
 	man/kernel-command-line.7 \
 	man/daemon.7 \
 	man/bootup.7 \
@@ -746,7 +747,8 @@ XML_DIRECTIVE_FILES = \
 	man/systemd.kill.xml \
 	man/systemd.device.xml \
 	man/systemd.conf.xml \
-	man/systemd.journal-fields.xml
+	man/systemd.journal-fields.xml \
+	man/systemd.time.xml
 
 man/systemd.directives.xml: make-directive-index.py $(XML_DIRECTIVE_FILES)
 	$(AM_V_at)$(MKDIR_P) $(dir $@)
diff --git a/man/systemd.time.xml b/man/systemd.time.xml
new file mode 100644
index 0000000..8e44e3d
--- /dev/null
+++ b/man/systemd.time.xml
@@ -0,0 +1,291 @@
+<?xml version='1.0'?> <!--*-nxml-*-->
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
+        "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
+
+<!--
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
+  (at your option) any later version.
+
+  systemd 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
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+-->
+
+<refentry id="systemd.time">
+
+        <refentryinfo>
+                <title>systemd.time</title>
+                <productname>systemd</productname>
+
+                <authorgroup>
+                        <author>
+                                <contrib>Developer</contrib>
+                                <firstname>Lennart</firstname>
+                                <surname>Poettering</surname>
+                                <email>lennart at poettering.net</email>
+                        </author>
+                </authorgroup>
+        </refentryinfo>
+
+        <refmeta>
+                <refentrytitle>systemd.time</refentrytitle>
+                <manvolnum>7</manvolnum>
+        </refmeta>
+
+        <refnamediv>
+                <refname>systemd.time</refname>
+                <refpurpose>Time and date specifications</refpurpose>
+        </refnamediv>
+
+        <refsect1>
+                <title>Description</title>
+
+                <para>In systemd timestamps, timespans, and calendar
+                events are displayed and may be specified in closely
+                related syntaxes.</para>
+        </refsect1>
+
+        <refsect1>
+                <title>Displaying Timespans</title>
+
+                <para>Timespans refer to time durations. On display
+                systemd will present timespans as a space separated
+                series of time values each suffixed by a time
+                unit.</para>
+
+                <programlisting>2h 30min</programlisting>
+
+                <para>All specified time values are meant to be added
+                up. The above hence refers to 150 minutes.</para>
+        </refsect1>
+
+        <refsect1>
+                <title>Parsing Timespans</title>
+
+                <para>When parsing systemd will accept the same
+                timespan syntax. Separating spaces may be omitted. The
+                following time units are understood:</para>
+
+                <itemizedlist>
+                        <listitem><para>usec, us</para></listitem>
+                        <listitem><para>msec, ms</para></listitem>
+                        <listitem><para>seconds, second, sec, s</para></listitem>
+                        <listitem><para>minutes, minute, min, m</para></listitem>
+                        <listitem><para>hours, hour, hr, h</para></listitem>
+                        <listitem><para>days, day, d</para></listitem>
+                        <listitem><para>weeks, week, w</para></listitem>
+                        <listitem><para>months, month</para></listitem>
+                        <listitem><para>years, year, y</para></listitem>
+                </itemizedlist>
+
+                <para>If no time unit is specified, generally seconds
+                are assumed, but some exceptions exist and are marked
+                as such. In a few cases <literal>ns</literal>,
+                <literal>nsec</literal> is accepted too, where the
+                granularity of the timespan allows for this.</para>
+
+                <para>Examples for valid timespan specifications:</para>
+
+                <programlisting>2 h
+2hours
+48hr
+1y 12month
+55s500ms
+300ms20s 5day</programlisting>
+        </refsect1>
+
+        <refsect1>
+                <title>Displaying Timestamps</title>
+
+                <para>Timestamps refer to specific, unique points in
+                time. On display systemd will format these in the
+                local timezone as follows:</para>
+
+                <programlisting>Fri 2012-11-23 23:02:15 CET</programlisting>
+
+                <para>The week day is printed according to the locale
+                choice of the user.</para>
+        </refsect1>
+
+        <refsect1>
+                <title>Parsing Timestamps</title>
+
+                <para>When parsing systemd will accept a similar
+                timestamp syntax, but excluding any timezone
+                specification (this limitation might be removed
+                eventually). The week day specification is optional,
+                but when the week day is specified it must either be
+                in the abbreviated (<literal>Wed</literal>) or
+                non-abbreviated (<literal>Wednesday</literal>) english
+                language form (case doesn't matter), and is not
+                subject to the locale choice of the user. Either the
+                date, or the time part may be omitted, in which case
+                the current date or 00:00:00, resp., is assumed. The
+                seconds component of the time may also be omitted, in
+                which case ":00" is assumed. Year numbers may be
+                specified in full or may be abbreviated (omitting the
+                century).</para>
+
+                <para>A timestamp is considered invalid if a week day
+                is specified and the date does not actually match the
+                specified day of the week.</para>
+
+                <para>When parsing systemd will also accept a few
+                special placeholders instead of timestamps:
+                <literal>now</literal> may be used to refer to the
+                current time (or of the invocation of the command
+                that is currently executed). <literal>today</literal>,
+                <literal>yesterday</literal>,
+                <literal>tomorrow</literal> refer to 00:00:00 of the
+                current day, the day before or the next day,
+                respectively.</para>
+
+                <para>When parsing systemd will also accept relative
+                time specifications. A timespan (see above) that is
+                prefixed with <literal>+</literal> is evaluated to the
+                current time plus the specified
+                timespan. Correspondingly a timespan that is prefix
+                with <literal>-</literal> is evaluated to the current
+                time minus the specified timespan. Instead of
+                prefixing the timespan with <literal>-</literal> it
+                may also be suffixed with a space and the word
+                <literal>ago</literal>.</para>
+
+                <para>Examples for valid timestamps and their
+                normalized form (assuming the current time was
+                2012-11-23 18:15:22):</para>
+
+                <programlisting>Fri 2012-11-23 11:12:13 → Fri 2012-11-23 11:12:13
+    2012-11-23 11:12:13 → Fri 2012-11-23 11:12:13
+             2012-11-23 → Fri 2012-11-23 00:00:00
+               12-11-23 → Fri 2012-11-23 00:00:00
+               11:12:13 → Fri 2012-11-23 11:12:13
+                  11:12 → Fri 2012-11-23 11:12:00
+                    now → Fri 2012-11-23 18:15:22
+                  today → Fri 2012-11-23 00:00:00
+              yesterday → Fri 2012-11-22 00:00:00
+               tomorrow → Fri 2012-11-24 00:00:00
+               +3h30min → Fri 2012-11-23 21:45:22
+                    -5s → Fri 2012-11-23 18:15:17
+              11min ago → Fri 2012-11-23 18:04:22</programlisting>
+
+                <para>Note that timestamps printed by systemd will not
+                be parsed correctly by systemd, as the timezone
+                specification is not accepted, and printing timestamps
+                is subject to locale settings for the week day while
+                parsing only accepts english week day names.</para>
+
+                <para>In some cases systemd will display a relative
+                timestamp (relative to the current time, or the time
+                of invocation of the command) instead or in addition
+                to an absolute timestamp as described above. A
+                relative timestamp is formatted as follows:</para>
+
+                <para>2 months 5 days ago</para>
+
+                <para>Note that any relative timestamp will also parse
+                correctly where a timestamp is expected. (see above)</para>
+        </refsect1>
+
+        <refsect1>
+                <title>Calendar Events</title>
+
+                <para>Calendar events may be used to refer to one or
+                more points in time in a single expression. They form
+                a superset of the absolute timestamps explained above:</para>
+
+                <programlisting>Thu,Fri 2012-*-1,5 11:12:13</programlisting>
+
+                <para>The above refers to 11:12:13 of the first or
+                fifth day of any month of the year 2012, given that it
+                is a thursday or friday.</para>
+
+                <para>The weekday specification is optional. If
+                specified it should consist of one or more english
+                language week day names, either in the abbreviated
+                (Wed) or non-abbreviated (Wednesday) form (case does
+                not matter), separated by colons. Specifying two week
+                days separated by "-" refers to a range of continuous
+                week days. "," and "-" may be combined freely.</para>
+
+                <para>In the date and time specifications any
+                component may be specified as "*" in which case any
+                value will match. Alternatively, each component can be
+                specified as list of values separated by
+                colons. Values may also be suffixed with "/" and a
+                repetition value, which indicates that the value and
+                all values plus multiples of the repetition value are
+                matched.</para>
+
+                <para>Either time or date specification may be
+                omitted, in which case the current day and 00:00:00 is
+                implied, respectively. If the second component is not
+                specified ":00" is assumed.</para>
+
+                <para>Timezone names may not be specified.</para>
+
+                <para>The special expressions
+                <literal>hourly</literal>, <literal>daily</literal>,
+                <literal>monthly</literal> and <literal>weekly</literal>
+                may be used as calendar events which refer to
+                <literal>*-*-* *:00:00</literal>, <literal>*-*-*
+                00:00:00</literal>, <literal>*-*-01 00:00:00</literal> and
+                <literal>Mon *-*-* 00:00:00</literal>,
+                respectively.</para>
+
+                <para>Examples for valid timestamps and their
+                normalized form:</para>
+
+<programlisting>   Sat,Thu,Mon-Wed,Sat-Sun → Mon-Thu,Sat,Sun *-*-* 00:00:00
+     Mon,Sun 12-*-* 2,1:23 → Mon,Sun 2012-*-* 01,02:23:00
+                   Wed *-1 → Wed *-*-01 00:00:00
+           Wed-Wed,Wed *-1 → Wed *-*-01 00:00:00
+                Wed, 17:48 → Wed *-*-* 17:48:00
+Wed-Sat,Tue 12-10-15 1:2:3 → Tue-Sat 2012-10-15 01:02:03
+               *-*-7 0:0:0 → *-*-07 00:00:00
+                     10-15 → *-10-15 00:00:00
+       monday *-12-* 17:00 → Mon *-12-* 17:00:00
+ Mon,Fri *-*-3,1,2 *:30:45 → Mon,Fri *-*-01,02,03 *:30:45
+      12,14,13,12:20,10,30 → *-*-* 12,13,14:10,20,30:00
+ mon,fri *-1/2-1,3 *:30:45 → Mon,Fri *-01/2-01,03 *:30:45
+            03-05 08:05:40 → *-03-05 08:05:40
+                  08:05:40 → *-*-* 08:05:40
+                     05:40 → *-*-* 05:40:00
+    Sat,Sun 12-05 08:05:40 → Sat,Sun *-12-05 08:05:40
+          Sat,Sun 08:05:40 → Sat,Sun *-*-* 08:05:40
+          2003-03-05 05:40 → 2003-03-05 05:40:00
+                2003-03-05 → 2003-03-05 00:00:00
+                     03-05 → *-03-05 00:00:00
+                    hourly → *-*-* *:00:00
+                     daily → *-*-* 00:00:00
+                   monthly → *-*-01 00:00:00
+                    weekly → Mon *-*-* 00:00:00
+                     *:2/3 → *-*-* *:02/3:00</programlisting>
+
+                  <para>Calendar events are used by timer units, see
+                  <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>5</manvolnum></citerefentry>
+                  for details.</para>
+
+        </refsect1>
+
+        <refsect1>
+                  <title>See Also</title>
+                  <para>
+                          <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
+                          <citerefentry><refentrytitle>journalctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
+                          <citerefentry><refentrytitle>systemd.timer</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
+                          <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
+                  </para>
+        </refsect1>
+
+</refentry>
diff --git a/man/systemd.timer.xml b/man/systemd.timer.xml
index 6fc26a5..5cc543e 100644
--- a/man/systemd.timer.xml
+++ b/man/systemd.timer.xml
@@ -105,7 +105,7 @@
                                 <term><varname>OnUnitActiveSec=</varname></term>
                                 <term><varname>OnUnitInactiveSec=</varname></term>
 
-                                <listitem><para>Defines timers
+                                <listitem><para>Defines monotonic timers
                                 relative to different starting points:
                                 <varname>OnActiveSec=</varname> defines a
                                 timer relative to the moment the timer
@@ -139,8 +139,8 @@
                                 seconds. Example: "OnBootSec=50" means
                                 50s after boot-up. The argument may
                                 also include time units. Example:
-                                "OnBootSec=5h 30min" means 5 hours and 30
-                                minutes after boot-up. For details
+                                "OnBootSec=5h 30min" means 5 hours and
+                                30 minutes after boot-up. For details
                                 about the syntax of time spans see
                                 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
 
@@ -152,14 +152,27 @@
                                 elapse and the configured unit is
                                 started. This is not the case for
                                 timers defined in the other
-                                directives.</para></listitem>
+                                directives.</para>
 
                                 <para>These are monotonic timers,
                                 independent of wall-clock time and timezones. If the
                                 computer is temporarily suspended, the
-                                monotonic clock stops too.</para>
+                                monotonic clock stops too.</para></listitem>
 
                         </varlistentry>
+
+                        <varlistentry>
+                                <term><varname>OnCalendar=</varname></term>
+
+                                <listitem><para>Defines realtime
+                                (i.e. wallclock) timers via calendar
+                                event expressions. See
+                                <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>
+                                for more information on the syntax of
+                                calendar event
+                                expressions.</para></listitem>
+                        </varlistentry>
+
                         <varlistentry>
                                 <term><varname>Unit=</varname></term>
 
@@ -185,7 +198,8 @@
                           <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
                           <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
                           <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
-                          <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
+                          <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
+                          <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>
                   </para>
         </refsect1>
 
diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml
index c20efe5..35644d3 100644
--- a/man/systemd.unit.xml
+++ b/man/systemd.unit.xml
@@ -111,7 +111,7 @@
                 the values are added up. Example: "50" refers to 50
                 seconds; "2min 200ms" refers to 2 minutes plus 200
                 milliseconds, i.e. 120200ms. The following time units
-                are understood: s, min, h, d, w, ms, us.</para>
+                are understood: s, min, h, d, w, ms, us. For details see <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para>
 
                 <para>Empty lines and lines starting with # or ; are
                 ignored. This may be used for commenting. Lines ending
@@ -1077,6 +1077,7 @@
                         <citerefentry><refentrytitle>systemd.path</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
                         <citerefentry><refentrytitle>systemd.timer</refentrytitle><manvolnum>5</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>
                 </para>
         </refsect1>

commit 0979f2855c81d144d4c7d814678a5b5b2d34155b
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Nov 23 22:55:38 2012 +0100

    build-sys: drop TARGET_UBUNTU
    
    TARGET_UBUNTU is effectively the same as TARGET_DEBIAN. Given the Ubuntu
    is unlikely to use systemd anytime soon there's no point in keeping this
    separate.

diff --git a/Makefile.am b/Makefile.am
index 25f8231..5d772be 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4111,12 +4111,6 @@ if TARGET_MANDRIVA
 		$(LN_S) rescue.service single.service )
 endif
 
-if TARGET_DEBIAN_OR_UBUNTU
-	( cd $(DESTDIR)$(systemunitdir) && \
-		rm -f runlevel5.target && \
-		$(LN_S) multi-user.target runlevel5.target )
-endif
-
 if TARGET_SUSE
 	( cd $(DESTDIR)$(systemunitdir) && \
 		rm -f local.service && \
diff --git a/configure.ac b/configure.ac
index 393c7ce..d0003bb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -640,7 +640,7 @@ AM_CONDITIONAL(ENABLE_MANPAGES, [test "x$have_manpages" = "xyes"])
 
 # ------------------------------------------------------------------------------
 
-AC_ARG_WITH(distro, AS_HELP_STRING([--with-distro=DISTRO],[Specify the distribution to target: One of fedora, suse, debian, ubuntu, arch, gentoo, slackware, altlinux, mandriva, mageia, angstrom or other]))
+AC_ARG_WITH(distro, AS_HELP_STRING([--with-distro=DISTRO],[Specify the distribution to target: One of fedora, suse, debian, arch, gentoo, slackware, altlinux, mandriva, mageia, angstrom or other]))
 if test "z$with_distro" = "z"; then
         if test "$cross_compiling" = yes; then
                 AC_MSG_WARN([Target distribution cannot be reliably detected when cross-compiling. You should specify it with --with-distro (see $0 --help for recognized distros)])
@@ -676,11 +676,6 @@ case $with_distro in
                 AC_DEFINE(TARGET_DEBIAN, [], [Target is Debian])
                 M4_DEFINES=-DTARGET_DEBIAN=1
                 ;;
-        ubuntu)
-                SYSTEM_SYSVRCND_PATH=/etc
-                AC_DEFINE(TARGET_UBUNTU, [], [Target is Ubuntu])
-                M4_DEFINES=-DTARGET_UBUNTU=1
-                ;;
         arch)
                 SYSTEM_SYSVINIT_PATH=
                 SYSTEM_SYSVRCND_PATH=
@@ -765,8 +760,6 @@ AC_ARG_WITH([tty-gid],
 AM_CONDITIONAL(TARGET_FEDORA, test x"$with_distro" = xfedora)
 AM_CONDITIONAL(TARGET_SUSE, test x"$with_distro" = xsuse)
 AM_CONDITIONAL(TARGET_DEBIAN, test x"$with_distro" = xdebian)
-AM_CONDITIONAL(TARGET_UBUNTU, test x"$with_distro" = xubuntu)
-AM_CONDITIONAL(TARGET_DEBIAN_OR_UBUNTU, test x"$with_distro" = xdebian -o x"$with_distro" = xubuntu)
 AM_CONDITIONAL(TARGET_ARCH, test x"$with_distro" = xarch)
 AM_CONDITIONAL(TARGET_GENTOO, test x"$with_distro" = xgentoo)
 AM_CONDITIONAL(TARGET_SLACKWARE, test x"$with_distro" = xslackware)
diff --git a/src/core/locale-setup.c b/src/core/locale-setup.c
index 0a0f95b..8821fc2 100644
--- a/src/core/locale-setup.c
+++ b/src/core/locale-setup.c
@@ -141,7 +141,7 @@ int locale_setup(void) {
                         log_warning("Failed to read /etc/sysconfig/language: %s", strerror(-r));
         }
 
-#elif defined(TARGET_DEBIAN) || defined(TARGET_UBUNTU) || defined(TARGET_ANGSTROM)
+#elif defined(TARGET_DEBIAN) || defined(TARGET_ANGSTROM)
         if (r <= 0) {
                 r = parse_env_file("/etc/default/locale", NEWLINE,
                                    "LANG",              &variables[VARIABLE_LANG],
diff --git a/src/core/service.c b/src/core/service.c
index 25a568f..3d2be96 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -321,7 +321,7 @@ static char *sysv_translate_name(const char *name) {
         if (!(r = new(char, strlen(name) + sizeof(".service"))))
                 return NULL;
 
-#if defined(TARGET_DEBIAN) || defined(TARGET_UBUNTU) || defined(TARGET_ANGSTROM)
+#if defined(TARGET_DEBIAN) || defined(TARGET_ANGSTROM)
         if (endswith(name, ".sh"))
                 /* Drop Debian-style .sh suffix */
                 strcpy(stpcpy(r, name) - 3, ".service");
@@ -368,7 +368,7 @@ static int sysv_translate_facility(const char *name, const char *filename, char
                 "x-display-manager",    SPECIAL_DISPLAY_MANAGER_SERVICE,
                 "null",                 NULL,
 
-#if defined(TARGET_DEBIAN) || defined(TARGET_UBUNTU) || defined(TARGET_ANGSTROM)
+#if defined(TARGET_DEBIAN) || defined(TARGET_ANGSTROM)
                 "mail-transport-agent", SPECIAL_MAIL_TRANSFER_AGENT_TARGET,
 #endif
 
@@ -990,7 +990,7 @@ static int service_load_sysv_name(Service *s, const char *name) {
 
         /* For SysV services we strip the rc.* and *.sh
          * prefixes/suffixes. */
-#if defined(TARGET_DEBIAN) || defined(TARGET_UBUNTU) || defined(TARGET_ANGSTROM)
+#if defined(TARGET_DEBIAN) || defined(TARGET_ANGSTROM)
         if (endswith(name, ".sh.service"))
                 return -ENOENT;
 #endif
@@ -1013,7 +1013,7 @@ static int service_load_sysv_name(Service *s, const char *name) {
 
                 r = service_load_sysv_path(s, path);
 
-#if defined(TARGET_DEBIAN) || defined(TARGET_UBUNTU) || defined(TARGET_ANGSTROM)
+#if defined(TARGET_DEBIAN) || defined(TARGET_ANGSTROM)
                 if (r >= 0 && UNIT(s)->load_state == UNIT_STUB) {
                         /* Try Debian style *.sh source'able init scripts */
                         strcat(path, ".sh");

commit 92134489ab35f6d173cb6fb6f676c1b5d88f5556
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Nov 23 22:52:46 2012 +0100

    time-util: teach parse_timestamp to parse weekdays

diff --git a/src/shared/time-util.c b/src/shared/time-util.c
index 43448e0..13d57ba 100644
--- a/src/shared/time-util.c
+++ b/src/shared/time-util.c
@@ -284,11 +284,32 @@ void dual_timestamp_deserialize(const char *value, dual_timestamp *t) {
 }
 
 int parse_timestamp(const char *t, usec_t *usec) {
+        static const struct {
+                const char *name;
+                const int nr;
+        } day_nr[] = {
+                { "Sunday",    0 },
+                { "Sun",       0 },
+                { "Monday",    1 },
+                { "Mon",       1 },
+                { "Tuesday",   2 },
+                { "Tue",       2 },
+                { "Wednesday", 3 },
+                { "Wed",       3 },
+                { "Thursday",  4 },
+                { "Thu",       4 },
+                { "Friday",    5 },
+                { "Fri",       5 },
+                { "Saturday",  6 },
+                { "Sat",       6 },
+        };
+
         const char *k;
         struct tm tm, copy;
         time_t x;
         usec_t plus = 0, minus = 0, ret;
-        int r;
+        int r, weekday = -1;
+        unsigned i;
 
         /*
          * Allowed syntaxes:
@@ -360,6 +381,21 @@ int parse_timestamp(const char *t, usec_t *usec) {
                 goto finish;
         }
 
+        for (i = 0; i < ELEMENTSOF(day_nr); i++) {
+                size_t skip;
+
+                if (!startswith_no_case(t, day_nr[i].name))
+                        continue;
+
+                skip = strlen(day_nr[i].name);
+                if (t[skip] != ' ')
+                        continue;
+
+                weekday = day_nr[i].nr;
+                t += skip + 1;
+                break;
+        }
+
         copy = tm;
         k = strptime(t, "%y-%m-%d %H:%M:%S", &tm);
         if (k && *k == 0)
@@ -417,6 +453,9 @@ finish:
         if (x == (time_t) -1)
                 return -EINVAL;
 
+        if (weekday >= 0 && tm.tm_wday != weekday)
+                return -EINVAL;
+
         ret = (usec_t) x * USEC_PER_SEC;
 
         ret += plus;
diff --git a/src/test/test-date.c b/src/test/test-date.c
index 7e14d19..40ffc17 100644
--- a/src/test/test-date.c
+++ b/src/test/test-date.c
@@ -19,54 +19,43 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include "util.h"
-
-int main(int argc, char *argv[]) {
-
-        usec_t t;
-        char buf[FORMAT_TIMESTAMP_MAX];
-
-        assert_se(parse_timestamp("17:41", &t) >= 0);
-        log_info("%s", format_timestamp(buf, sizeof(buf), t));
-
-        assert_se(parse_timestamp("18:42:44", &t) >= 0);
-        log_info("%s", format_timestamp(buf, sizeof(buf), t));
-
-        assert_se(parse_timestamp("12-10-02 12:13:14", &t) >= 0);
-        log_info("%s", format_timestamp(buf, sizeof(buf), t));
-
-        assert_se(parse_timestamp("12-10-2 12:13:14", &t) >= 0);
-        log_info("%s", format_timestamp(buf, sizeof(buf), t));
-
-        assert_se(parse_timestamp("12-10-03 12:13", &t) >= 0);
-        log_info("%s", format_timestamp(buf, sizeof(buf), t));
+#include <string.h>
 
-        assert_se(parse_timestamp("2012-12-30 18:42", &t) >= 0);
-        log_info("%s", format_timestamp(buf, sizeof(buf), t));
+#include "util.h"
 
-        assert_se(parse_timestamp("2012-10-02", &t) >= 0);
-        log_info("%s", format_timestamp(buf, sizeof(buf), t));
+static void test_one(const char *p) {
+        usec_t t, q;
+        char buf[FORMAT_TIMESTAMP_MAX], buf_relative[FORMAT_TIMESTAMP_RELATIVE_MAX];
 
-        assert_se(parse_timestamp("now", &t) >= 0);
+        assert_se(parse_timestamp(p, &t) >= 0);
         log_info("%s", format_timestamp(buf, sizeof(buf), t));
 
-        assert_se(parse_timestamp("yesterday", &t) >= 0);
-        log_info("%s", format_timestamp(buf, sizeof(buf), t));
+        /* Chop off timezone */
+        *strrchr(buf, ' ') = 0;
 
-        assert_se(parse_timestamp("today", &t) >= 0);
-        log_info("%s", format_timestamp(buf, sizeof(buf), t));
-
-        assert_se(parse_timestamp("tomorrow", &t) >= 0);
-        log_info("%s", format_timestamp(buf, sizeof(buf), t));
+        assert_se(parse_timestamp(buf, &q) >= 0);
+        assert_se(q == t);
 
-        assert_se(parse_timestamp("+2d", &t) >= 0);
-        log_info("%s", format_timestamp(buf, sizeof(buf), t));
-
-        assert_se(parse_timestamp("+2y 4d", &t) >= 0);
-        log_info("%s", format_timestamp(buf, sizeof(buf), t));
+        log_info("%s", strna(format_timestamp_relative(buf_relative, sizeof(buf_relative), t)));
+        assert_se(parse_timestamp(buf, &q) >= 0);
+}
 
-        assert_se(parse_timestamp("5months ago", &t) >= 0);
-        log_info("%s", format_timestamp(buf, sizeof(buf), t));
+int main(int argc, char *argv[]) {
+        test_one("17:41");
+        test_one("18:42:44");
+        test_one("12-10-02 12:13:14");
+        test_one("12-10-2 12:13:14");
+        test_one("12-10-03 12:13");
+        test_one("2012-12-30 18:42");
+        test_one("2012-10-02");
+        test_one("Tue 2012-10-02");
+        test_one("now");
+        test_one("yesterday");
+        test_one("today");
+        test_one("tomorrow");
+        test_one("+2d");
+        test_one("+2y 4d");
+        test_one("5months ago");
 
         return 0;
 }

commit 6a741b4a2b395fd186d73074bd6986016c501216
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Nov 23 22:52:38 2012 +0100

    path-util: when parsing a timestamp we don't know the timezone

diff --git a/src/shared/time-util.c b/src/shared/time-util.c
index 7f47710..43448e0 100644
--- a/src/shared/time-util.c
+++ b/src/shared/time-util.c
@@ -312,6 +312,7 @@ int parse_timestamp(const char *t, usec_t *usec) {
 
         x = time(NULL);
         assert_se(localtime_r(&x, &tm));
+        tm.tm_isdst = -1;
 
         if (streq(t, "now"))
                 goto finish;

commit 9185c8e6266d607df665d24f525b48b39e20d847
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Nov 23 22:51:55 2012 +0100

    time-util: also rename FORMAT_TIMESTAMP_PRETTY → _MAX

diff --git a/src/login/loginctl.c b/src/login/loginctl.c
index 820fcc0..cfbc5fe 100644
--- a/src/login/loginctl.c
+++ b/src/login/loginctl.c
@@ -323,7 +323,7 @@ typedef struct SeatStatusInfo {
 } SeatStatusInfo;
 
 static void print_session_status_info(SessionStatusInfo *i) {
-        char since1[FORMAT_TIMESTAMP_PRETTY_MAX], *s1;
+        char since1[FORMAT_TIMESTAMP_RELATIVE_MAX], *s1;
         char since2[FORMAT_TIMESTAMP_MAX], *s2;
         assert(i);
 
@@ -418,7 +418,7 @@ static void print_session_status_info(SessionStatusInfo *i) {
 }
 
 static void print_user_status_info(UserStatusInfo *i) {
-        char since1[FORMAT_TIMESTAMP_PRETTY_MAX], *s1;
+        char since1[FORMAT_TIMESTAMP_RELATIVE_MAX], *s1;
         char since2[FORMAT_TIMESTAMP_MAX], *s2;
         assert(i);
 
diff --git a/src/shared/time-util.h b/src/shared/time-util.h
index 1f6952c..4017b57 100644
--- a/src/shared/time-util.h
+++ b/src/shared/time-util.h
@@ -54,7 +54,7 @@ typedef struct dual_timestamp {
 #define NSEC_PER_YEAR (31557600ULL*NSEC_PER_SEC)
 
 #define FORMAT_TIMESTAMP_MAX (6+11+9+4+1)
-#define FORMAT_TIMESTAMP_PRETTY_MAX 256
+#define FORMAT_TIMESTAMP_RELATIVE_MAX 256
 #define FORMAT_TIMESPAN_MAX 64
 
 usec_t now(clockid_t clock);
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index ba4f171..7a19d06 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -2056,7 +2056,7 @@ static void print_status_info(UnitStatusInfo *i) {
         ExecStatusInfo *p;
         const char *on, *off, *ss;
         usec_t timestamp;
-        char since1[FORMAT_TIMESTAMP_PRETTY_MAX], *s1;
+        char since1[FORMAT_TIMESTAMP_RELATIVE_MAX], *s1;
         char since2[FORMAT_TIMESTAMP_MAX], *s2;
         const char *path;
 



More information about the systemd-commits mailing list