[systemd-commits] 8 commits - Makefile.am configure.ac make-man-index.py src/analyze src/core src/locale

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Fri Jan 4 19:53:38 PST 2013


 Makefile.am                       |   33 ++--
 configure.ac                      |   27 ++-
 make-man-index.py                 |    1 
 src/analyze/systemd-analyze       |  311 --------------------------------------
 src/analyze/systemd-analyze.in    |  310 +++++++++++++++++++++++++++++++++++++
 src/core/service.c                |    4 
 src/locale/generate-kbd-model-map |    2 
 7 files changed, 352 insertions(+), 336 deletions(-)

New commits:
commit d66ee73a3dd7b5433fc0da3125bbdff740de7745
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Fri Jan 4 22:52:32 2013 -0500

    build-sys: fix message about gintrospection
    
    When gobject-introspection-devel was not available, the message
    was missing the yes/no part

diff --git a/configure.ac b/configure.ac
index b8ee626..535b71f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -82,7 +82,9 @@ AS_IF([test "x$enable_gtk_doc" = "xyes" -a "x$XSLTPROC" = x], [
 
 m4_ifdef([GOBJECT_INTROSPECTION_CHECK], [
 GOBJECT_INTROSPECTION_CHECK([1.31.1])
-], [AM_CONDITIONAL([HAVE_INTROSPECTION], [false])])
+], [
+   AM_CONDITIONAL([HAVE_INTROSPECTION], [false])
+   enable_introspection=no])
 
 AC_PATH_TOOL(OBJCOPY, objcopy)
 AC_PATH_TOOL(STRINGS, strings)

commit c4eb236a2c9f07ec236c82f0113139c343a07224
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Sat Dec 22 10:09:24 2012 +0100

    build-sys: invoke scripts with $PYTHON during build
    
    Python binary to be used during compilation can be set with
    ./configure PYTHON=...
    
    The she-bang line is removed, since it is not used anymore.

diff --git a/Makefile.am b/Makefile.am
index e81998d..74a4329 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3307,8 +3307,8 @@ dist_pkgdata_DATA += \
 dist_noinst_SCRIPT = \
 	src/locale/generate-kbd-model-map
 
-update-kbd-model-map:
-	src/locale/generate-kbd-model-map > src/locale/kbd-model-map
+update-kbd-model-map: src/locale/generate-kbd-model-map
+	$PYTHON $< > src/locale/kbd-model-map
 
 localectl_SOURCES = \
 	src/locale/localectl.c
diff --git a/make-man-index.py b/make-man-index.py
index 56f38ce..b40c963 100755
--- a/make-man-index.py
+++ b/make-man-index.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #  -*- Mode: python; indent-tabs-mode: nil -*- */
 #
 #  This file is part of systemd.
diff --git a/src/locale/generate-kbd-model-map b/src/locale/generate-kbd-model-map
index 624c517..b8ffa0f 100755
--- a/src/locale/generate-kbd-model-map
+++ b/src/locale/generate-kbd-model-map
@@ -1,5 +1,3 @@
-#!/usr/bin/python
-
 import sys
 import system_config_keyboard.keyboard_models
 

commit 2f4da3e6c298bc0ae6243cae47aedb01c50fa870
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Sat Dec 22 10:09:23 2012 +0100

    systemd-analyze: use specified binary, add --version
    
    Python binary used in the she-bang line in installed
    scripts can be set with ./configure PYTHON_BINARY=...
    Defaults to the same path as python used during compilation.
    
    Adding --version makes systemd-analyze behave consistently with the
    rest of installed programs.
    
    The lines in ./configure output are reordered to keep all yes/no lines
    separate.  I think that this makes the output clearer.

diff --git a/Makefile.am b/Makefile.am
index c5af8e8..e81998d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3803,6 +3803,8 @@ SED_PROCESS = \
 		-e 's, at VARLOGDIR\@,$(varlogdir),g' \
 		-e 's, at RC_LOCAL_SCRIPT_PATH_START\@,$(RC_LOCAL_SCRIPT_PATH_START),g' \
 		-e 's, at RC_LOCAL_SCRIPT_PATH_STOP\@,$(RC_LOCAL_SCRIPT_PATH_STOP),g' \
+		-e 's, at PYTHON\@,$(PYTHON),g' \
+		-e 's, at PYTHON_BINARY\@,$(PYTHON_BINARY),g' \
 		< $< > $@
 
 units/%: units/%.in Makefile
diff --git a/configure.ac b/configure.ac
index e6dffe6..b8ee626 100644
--- a/configure.ac
+++ b/configure.ac
@@ -102,7 +102,12 @@ AS_IF([test "x$with_python" != "xno"], [
         AM_PATH_PYTHON(,, [:])
         AS_IF([test "$PYTHON" != :], [have_python=yes])
 ])
-AM_CONDITIONAL([HAVE_PYTHON], [test "$have_python" = "yes"])
+AM_CONDITIONAL([HAVE_PYTHON], [test "x$have_python" = "xyes"])
+AS_IF([test "x$PYTHON_BINARY" = "x"],
+      [AS_IF([test "x$have_python" = "xyes"],
+             [PYTHON_BINARY="$PYTHON"],
+             [PYTHON_BINARY=/usr/bin/python])])
+AC_ARG_VAR(PYTHON_BINARY, [Python binary used to launch installed scripts])
 
 AS_IF([test "x$with_python" != "xno"], [
         AC_PATH_PROG(PYTHON_CONFIG, python${PYTHON_VERSION}-config)
@@ -803,9 +808,6 @@ AC_OUTPUT
 AC_MSG_RESULT([
         $PACKAGE_NAME $VERSION
 
-        SysV compatibility:      ${SYSTEM_SYSV_COMPAT}
-        SysV init scripts:       ${SYSTEM_SYSVINIT_PATH}
-        SysV rc?.d directories:  ${SYSTEM_SYSVRCND_PATH}
         libcryptsetup:           ${have_libcryptsetup}
         tcpwrap:                 ${have_tcpwrap}
         PAM:                     ${have_pam}
@@ -831,12 +833,15 @@ AC_MSG_RESULT([
         coredump:                ${have_coredump}
         kmod:                    ${have_kmod}
         blkid:                   ${have_blkid}
-        firmware path:           ${FIRMWARE_PATH}
         gudev:                   ${enable_gudev}
         gintrospection:          ${enable_introspection}
         keymap:                  ${enable_keymap}
         Python:                  ${have_python}
         Python Headers:          ${have_python_devel}
+        man pages:               ${have_manpages}
+        gtk-doc:                 ${enable_gtk_doc}
+        Split /usr:              ${enable_split_usr}
+        SysV compatibility:      ${SYSTEM_SYSV_COMPAT}
 
         prefix:                  ${prefix}
         rootprefix:              ${with_rootprefix}
@@ -846,14 +851,16 @@ AC_MSG_RESULT([
         include_prefix:          ${INCLUDE_PREFIX}
         lib dir:                 ${libdir}
         rootlib dir:             ${with_rootlibdir}
+        SysV init scripts:       ${SYSTEM_SYSVINIT_PATH}
+        SysV rc?.d directories:  ${SYSTEM_SYSVRCND_PATH}
+        Build Python:            ${PYTHON}
+        Installation Python:     ${PYTHON_BINARY}
+        firmware path:           ${FIRMWARE_PATH}
         PAM modules dir:         ${with_pamlibdir}
         D-Bus policy dir:        ${with_dbuspolicydir}
         D-Bus session dir:       ${with_dbussessionservicedir}
         D-Bus system dir:        ${with_dbussystemservicedir}
         D-Bus interfaces dir:    ${with_dbusinterfacedir}
-        Split /usr:              ${enable_split_usr}
-        man pages:               ${have_manpages}
-        gtk-doc:                 ${enable_gtk_doc}
         Extra start script:      ${RC_LOCAL_SCRIPT_PATH_START}
         Extra stop script:       ${RC_LOCAL_SCRIPT_PATH_STOP}
 
diff --git a/src/analyze/systemd-analyze.in b/src/analyze/systemd-analyze.in
index de602be..26a9f7b 100755
--- a/src/analyze/systemd-analyze.in
+++ b/src/analyze/systemd-analyze.in
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!@PYTHON_BINARY@
 
 import sys, os
 import argparse
@@ -282,6 +282,7 @@ def plot():
         surface.finish()
 
 parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter,
+                                 version='systemd-analyze @PACKAGE_VERSION@',
                                  description='Process systemd profiling information',
                                  epilog='''\
 time - print time spent in the kernel before reaching userspace

commit bbed6c0d4b54d9c4e510415770e091d79eee2e8e
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Sat Dec 22 10:09:22 2012 +0100

    systemd-analyze: pipe through SED_PROCESS
    
    To be able to add --version and change python binary.

diff --git a/Makefile.am b/Makefile.am
index 2a67355..c5af8e8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -183,9 +183,6 @@ bin_PROGRAMS = \
 	systemd-detect-virt \
 	systemd-delta
 
-dist_bin_SCRIPTS = \
-	src/analyze/systemd-analyze
-
 rootlibexec_PROGRAMS = \
 	systemd \
 	systemd-cgroups-agent \
@@ -211,6 +208,15 @@ systemgenerator_PROGRAMS = \
 	systemd-fstab-generator \
 	systemd-system-update-generator
 
+dist_bin_SCRIPTS = \
+	src/analyze/systemd-analyze
+
+EXTRA_DIST += \
+	src/analyze/systemd-analyze.in
+
+CLEANFILES += \
+	src/analyze/systemd-analyze
+
 dist_bashcompletion_DATA = \
 	shell-completion/systemd-bash-completion.sh
 
@@ -3824,6 +3830,10 @@ src/%.policy.in: src/%.policy.in.in Makefile
 	$(SED_PROCESS)
 	$(AM_V_GEN)chmod +x $@
 
+src/analyze/systemd-analyze: %: %.in Makefile
+	$(SED_PROCESS)
+	$(AM_V_GEN)chmod +x $@
+
 src/%.c: src/%.gperf
 	$(AM_V_at)$(MKDIR_P) $(dir $@)
 	$(AM_V_GEN)$(GPERF) < $< > $@
diff --git a/src/analyze/systemd-analyze b/src/analyze/systemd-analyze
deleted file mode 100755
index de602be..0000000
--- a/src/analyze/systemd-analyze
+++ /dev/null
@@ -1,309 +0,0 @@
-#!/usr/bin/python
-
-import sys, os
-import argparse
-from gi.repository import Gio
-try:
-        import cairo
-except ImportError:
-        cairo = None
-
-def acquire_time_data():
-        manager = Gio.DBusProxy.new_for_bus_sync(bus, Gio.DBusProxyFlags.NONE,
-                None, 'org.freedesktop.systemd1', '/org/freedesktop/systemd1', 'org.freedesktop.systemd1.Manager', None)
-        units = manager.ListUnits()
-
-        l = []
-
-        for i in units:
-                if i[5] != "":
-                        continue
-
-                properties = Gio.DBusProxy.new_for_bus_sync(bus, Gio.DBusProxyFlags.NONE,
-                        None, 'org.freedesktop.systemd1', i[6], 'org.freedesktop.DBus.Properties', None)
-
-                ixt = properties.Get('(ss)', 'org.freedesktop.systemd1.Unit', 'InactiveExitTimestampMonotonic')
-                aet = properties.Get('(ss)', 'org.freedesktop.systemd1.Unit', 'ActiveEnterTimestampMonotonic')
-                axt = properties.Get('(ss)', 'org.freedesktop.systemd1.Unit', 'ActiveExitTimestampMonotonic')
-                iet = properties.Get('(ss)', 'org.freedesktop.systemd1.Unit', 'InactiveEnterTimestampMonotonic')
-
-                l.append((str(i[0]), ixt, aet, axt, iet))
-
-        return l
-
-def acquire_start_time():
-        properties = Gio.DBusProxy.new_for_bus_sync(bus, Gio.DBusProxyFlags.NONE,
-                None, 'org.freedesktop.systemd1', '/org/freedesktop/systemd1', 'org.freedesktop.DBus.Properties', None)
-
-        # Note that the firmware/loader times are returned as positive
-        # values but are actually considered negative from the point
-        # in time of kernel initialization. Also, the monotonic kernel
-        # time will always be 0 since that's the epoch of the
-        # monotonic clock. Since we want to know whether the kernel
-        # timestamp is set at all we will instead ask for the realtime
-        # clock for this timestamp.
-
-        firmware_time = properties.Get('(ss)', 'org.freedesktop.systemd1.Manager', 'FirmwareTimestampMonotonic')
-        loader_time = properties.Get('(ss)', 'org.freedesktop.systemd1.Manager', 'LoaderTimestampMonotonic')
-        kernel_time = properties.Get('(ss)', 'org.freedesktop.systemd1.Manager', 'KernelTimestamp')
-        initrd_time = properties.Get('(ss)', 'org.freedesktop.systemd1.Manager', 'InitRDTimestampMonotonic')
-        userspace_time = properties.Get('(ss)', 'org.freedesktop.systemd1.Manager', 'UserspaceTimestampMonotonic')
-        finish_time = properties.Get('(ss)', 'org.freedesktop.systemd1.Manager', 'FinishTimestampMonotonic')
-
-        if finish_time == 0:
-                sys.exit("Bootup is not yet finished. Please try again later.")
-
-        assert firmware_time >= loader_time
-        assert initrd_time <= userspace_time
-        assert userspace_time <= finish_time
-
-        return firmware_time, loader_time, kernel_time, initrd_time, userspace_time, finish_time
-
-def draw_box(context, j, k, l, m, r = 0, g = 0, b = 0):
-        context.save()
-        context.set_source_rgb(r, g, b)
-        context.rectangle(j, k, l, m)
-        context.fill()
-        context.restore()
-
-def draw_text(context, x, y, text, size = 12, r = 0, g = 0, b = 0, vcenter = 0.5, hcenter = 0.5):
-        context.save()
-
-        context.set_source_rgb(r, g, b)
-        context.select_font_face("Sans", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
-        context.set_font_size(size)
-
-        if vcenter or hcenter:
-                x_bearing, y_bearing, width, height = context.text_extents(text)[:4]
-
-                if hcenter:
-                        x = x - width*hcenter - x_bearing
-
-                if vcenter:
-                        y = y - height*vcenter - y_bearing
-
-        context.move_to(x, y)
-        context.show_text(text)
-
-        context.restore()
-
-def time():
-
-        firmware_time, loader_time, kernel_time, initrd_time, userspace_time, finish_time = acquire_start_time()
-
-        sys.stdout.write("Startup finished in ")
-
-        if firmware_time > 0:
-                sys.stdout.write("%lums (firmware) + " % ((firmware_time - loader_time) / 1000))
-        if loader_time > 0:
-                sys.stdout.write("%lums (loader) + " % (loader_time / 1000))
-        if initrd_time > 0:
-                sys.stdout.write("%lums (kernel) + %lums (initrd) + " % (initrd_time / 1000, (userspace_time - initrd_time) / 1000))
-        elif kernel_time > 0:
-                sys.stdout.write("%lums (kernel) + " % (userspace_time  / 1000))
-
-        sys.stdout.write("%lums (userspace) " % ((finish_time - userspace_time) / 1000))
-
-        if kernel_time > 0:
-                sys.stdout.write("= %lums\n" % ((firmware_time + finish_time) / 1000))
-        else:
-                sys.stdout.write("= %lums\n" % ((finish_time - userspace_time) / 1000))
-
-def blame():
-
-        data = acquire_time_data()
-        s = sorted(data, key = lambda i: i[2] - i[1], reverse = True)
-
-        for name, ixt, aet, axt, iet in s:
-
-                if ixt <= 0 or aet <= 0:
-                        continue
-
-                if aet <= ixt:
-                        continue
-
-                sys.stdout.write("%6lums %s\n" % ((aet - ixt) / 1000, name))
-
-def plot():
-        if cairo is None:
-                sys.exit("Failed to initilize python-cairo required for 'plot' verb.")
-        firmware_time, loader_time, kernel_time, initrd_time, userspace_time, finish_time = acquire_start_time()
-        data = acquire_time_data()
-        s = sorted(data, key = lambda i: i[1])
-
-        # Account for kernel and initramfs bars if they exist
-        if initrd_time > 0:
-                count = 3
-        else:
-                count = 2
-
-        for name, ixt, aet, axt, iet in s:
-
-                if (ixt >= userspace_time and ixt <= finish_time) or \
-                                (aet >= userspace_time and aet <= finish_time) or \
-                                (axt >= userspace_time and axt <= finish_time):
-                        count += 1
-
-        border = 100
-        bar_height = 20
-        bar_space = bar_height * 0.1
-
-        # 1000px = 10s, 1px = 10ms
-        width = finish_time/10000 + border*2
-        height = count * (bar_height + bar_space) + border * 2
-
-        if width < 1000:
-                width = 1000
-
-        surface = cairo.SVGSurface(sys.stdout, width, height)
-        context = cairo.Context(surface)
-
-        draw_box(context, 0, 0, width, height, 1, 1, 1)
-
-        context.translate(border + 0.5, border + 0.5)
-
-        context.save()
-        context.set_line_width(1)
-        context.set_source_rgb(0.7, 0.7, 0.7)
-
-        for x in range(0, int(finish_time/10000) + 100, 100):
-                context.move_to(x, 0)
-                context.line_to(x, height-border*2)
-
-        context.move_to(0, 0)
-        context.line_to(width-border*2, 0)
-
-        context.move_to(0, height-border*2)
-        context.line_to(width-border*2, height-border*2)
-
-        context.stroke()
-        context.restore()
-
-        osrel = "Linux"
-        if os.path.exists("/etc/os-release"):
-                for line in open("/etc/os-release"):
-                        if line.startswith('PRETTY_NAME='):
-                                osrel = line[12:]
-                                osrel = osrel.strip('\"\n')
-                                break
-
-        banner = "{} {} ({} {}) {}".format(osrel, *(os.uname()[1:5]))
-        draw_text(context, 0, -15, banner, hcenter = 0, vcenter = 1)
-
-        for x in range(0, int(finish_time/10000) + 100, 100):
-                draw_text(context, x, -5, "%lus" % (x/100), vcenter = 0, hcenter = 0)
-
-        y = 0
-
-        # draw boxes for kernel and initramfs boot time
-        if initrd_time > 0:
-                draw_box(context, 0, y, initrd_time/10000, bar_height, 0.7, 0.7, 0.7)
-                draw_text(context, 10, y + bar_height/2, "kernel", hcenter = 0)
-                y += bar_height + bar_space
-
-                draw_box(context, initrd_time/10000, y, userspace_time/10000-initrd_time/10000, bar_height, 0.7, 0.7, 0.7)
-                draw_text(context, initrd_time/10000 + 10, y + bar_height/2, "initramfs", hcenter = 0)
-                y += bar_height + bar_space
-
-        else:
-                draw_box(context, 0, y, userspace_time/10000, bar_height, 0.6, 0.6, 0.6)
-                draw_text(context, 10, y + bar_height/2, "kernel", hcenter = 0)
-                y += bar_height + bar_space
-
-        draw_box(context, userspace_time/10000, y, finish_time/10000-userspace_time/10000, bar_height, 0.7, 0.7, 0.7)
-        draw_text(context, userspace_time/10000 + 10, y + bar_height/2, "userspace", hcenter = 0)
-        y += bar_height + bar_space
-
-        for name, ixt, aet, axt, iet in s:
-
-                drawn = False
-                left = -1
-
-                if ixt >= userspace_time and ixt <= finish_time:
-
-                        # Activating
-                        a = ixt
-                        b = min(filter(lambda x: x >= ixt, (aet, axt, iet, finish_time))) - ixt
-
-                        draw_box(context, a/10000, y, b/10000, bar_height, 1, 0, 0)
-                        drawn = True
-
-                        if left < 0:
-                                left = a
-
-                if aet >= userspace_time and aet <= finish_time:
-
-                        # Active
-                        a = aet
-                        b = min(filter(lambda x: x >= aet, (axt, iet, finish_time))) - aet
-
-                        draw_box(context, a/10000, y, b/10000, bar_height, .8, .6, .6)
-                        drawn = True
-
-                        if left < 0:
-                                left = a
-
-                if axt >= userspace_time and axt <= finish_time:
-
-                        # Deactivating
-                        a = axt
-                        b = min(filter(lambda x: x >= axt, (iet, finish_time))) - axt
-
-                        draw_box(context, a/10000, y, b/10000, bar_height, .6, .4, .4)
-                        drawn = True
-
-                        if left < 0:
-                                left = a
-
-                if drawn:
-                        x = left/10000
-
-                        if x < width/2-border:
-                                draw_text(context, x + 10, y + bar_height/2, name, hcenter = 0)
-                        else:
-                                draw_text(context, x - 10, y + bar_height/2, name, hcenter = 1)
-
-                        y += bar_height + bar_space
-
-        draw_text(context, 0, height-border*2, "Legend: Red = Activating; Pink = Active; Dark Pink = Deactivating", hcenter = 0, vcenter = -1)
-
-        if initrd_time > 0:
-                draw_text(context, 0, height-border*2 + bar_height, "Startup finished in %lums (kernel) + %lums (initramfs) + %lums (userspace) = %lums" % ( \
-                        initrd_time/1000, \
-                        (userspace_time - initrd_time)/1000, \
-                        (finish_time - userspace_time)/1000, \
-                        finish_time/1000), hcenter = 0, vcenter = -1)
-        else:
-                draw_text(context, 0, height-border*2 + bar_height, "Startup finished in %lums (kernel) + %lums (userspace) = %lums" % ( \
-                        userspace_time/1000, \
-                        (finish_time - userspace_time)/1000, \
-                        finish_time/1000), hcenter = 0, vcenter = -1)
-
-        surface.finish()
-
-parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter,
-                                 description='Process systemd profiling information',
-                                 epilog='''\
-time - print time spent in the kernel before reaching userspace
-blame - print list of running units ordered by time to init
-plot - output SVG graphic showing service initialization
-''')
-
-parser.add_argument('action', choices=('time', 'blame', 'plot'),
-                    default='time', nargs='?',
-                    help='action to perform (default: time)')
-parser.add_argument('--user', action='store_true',
-                    help='use the session bus')
-
-args = parser.parse_args()
-
-if args.user:
-        bus = Gio.BusType.SESSION
-else:
-        bus = Gio.BusType.SYSTEM
-
-verb = {'time' : time,
-	'blame': blame,
-	'plot' : plot,
-	}
-verb.get(args.action)()
diff --git a/src/analyze/systemd-analyze.in b/src/analyze/systemd-analyze.in
new file mode 100755
index 0000000..de602be
--- /dev/null
+++ b/src/analyze/systemd-analyze.in
@@ -0,0 +1,309 @@
+#!/usr/bin/python
+
+import sys, os
+import argparse
+from gi.repository import Gio
+try:
+        import cairo
+except ImportError:
+        cairo = None
+
+def acquire_time_data():
+        manager = Gio.DBusProxy.new_for_bus_sync(bus, Gio.DBusProxyFlags.NONE,
+                None, 'org.freedesktop.systemd1', '/org/freedesktop/systemd1', 'org.freedesktop.systemd1.Manager', None)
+        units = manager.ListUnits()
+
+        l = []
+
+        for i in units:
+                if i[5] != "":
+                        continue
+
+                properties = Gio.DBusProxy.new_for_bus_sync(bus, Gio.DBusProxyFlags.NONE,
+                        None, 'org.freedesktop.systemd1', i[6], 'org.freedesktop.DBus.Properties', None)
+
+                ixt = properties.Get('(ss)', 'org.freedesktop.systemd1.Unit', 'InactiveExitTimestampMonotonic')
+                aet = properties.Get('(ss)', 'org.freedesktop.systemd1.Unit', 'ActiveEnterTimestampMonotonic')
+                axt = properties.Get('(ss)', 'org.freedesktop.systemd1.Unit', 'ActiveExitTimestampMonotonic')
+                iet = properties.Get('(ss)', 'org.freedesktop.systemd1.Unit', 'InactiveEnterTimestampMonotonic')
+
+                l.append((str(i[0]), ixt, aet, axt, iet))
+
+        return l
+
+def acquire_start_time():
+        properties = Gio.DBusProxy.new_for_bus_sync(bus, Gio.DBusProxyFlags.NONE,
+                None, 'org.freedesktop.systemd1', '/org/freedesktop/systemd1', 'org.freedesktop.DBus.Properties', None)
+
+        # Note that the firmware/loader times are returned as positive
+        # values but are actually considered negative from the point
+        # in time of kernel initialization. Also, the monotonic kernel
+        # time will always be 0 since that's the epoch of the
+        # monotonic clock. Since we want to know whether the kernel
+        # timestamp is set at all we will instead ask for the realtime
+        # clock for this timestamp.
+
+        firmware_time = properties.Get('(ss)', 'org.freedesktop.systemd1.Manager', 'FirmwareTimestampMonotonic')
+        loader_time = properties.Get('(ss)', 'org.freedesktop.systemd1.Manager', 'LoaderTimestampMonotonic')
+        kernel_time = properties.Get('(ss)', 'org.freedesktop.systemd1.Manager', 'KernelTimestamp')
+        initrd_time = properties.Get('(ss)', 'org.freedesktop.systemd1.Manager', 'InitRDTimestampMonotonic')
+        userspace_time = properties.Get('(ss)', 'org.freedesktop.systemd1.Manager', 'UserspaceTimestampMonotonic')
+        finish_time = properties.Get('(ss)', 'org.freedesktop.systemd1.Manager', 'FinishTimestampMonotonic')
+
+        if finish_time == 0:
+                sys.exit("Bootup is not yet finished. Please try again later.")
+
+        assert firmware_time >= loader_time
+        assert initrd_time <= userspace_time
+        assert userspace_time <= finish_time
+
+        return firmware_time, loader_time, kernel_time, initrd_time, userspace_time, finish_time
+
+def draw_box(context, j, k, l, m, r = 0, g = 0, b = 0):
+        context.save()
+        context.set_source_rgb(r, g, b)
+        context.rectangle(j, k, l, m)
+        context.fill()
+        context.restore()
+
+def draw_text(context, x, y, text, size = 12, r = 0, g = 0, b = 0, vcenter = 0.5, hcenter = 0.5):
+        context.save()
+
+        context.set_source_rgb(r, g, b)
+        context.select_font_face("Sans", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
+        context.set_font_size(size)
+
+        if vcenter or hcenter:
+                x_bearing, y_bearing, width, height = context.text_extents(text)[:4]
+
+                if hcenter:
+                        x = x - width*hcenter - x_bearing
+
+                if vcenter:
+                        y = y - height*vcenter - y_bearing
+
+        context.move_to(x, y)
+        context.show_text(text)
+
+        context.restore()
+
+def time():
+
+        firmware_time, loader_time, kernel_time, initrd_time, userspace_time, finish_time = acquire_start_time()
+
+        sys.stdout.write("Startup finished in ")
+
+        if firmware_time > 0:
+                sys.stdout.write("%lums (firmware) + " % ((firmware_time - loader_time) / 1000))
+        if loader_time > 0:
+                sys.stdout.write("%lums (loader) + " % (loader_time / 1000))
+        if initrd_time > 0:
+                sys.stdout.write("%lums (kernel) + %lums (initrd) + " % (initrd_time / 1000, (userspace_time - initrd_time) / 1000))
+        elif kernel_time > 0:
+                sys.stdout.write("%lums (kernel) + " % (userspace_time  / 1000))
+
+        sys.stdout.write("%lums (userspace) " % ((finish_time - userspace_time) / 1000))
+
+        if kernel_time > 0:
+                sys.stdout.write("= %lums\n" % ((firmware_time + finish_time) / 1000))
+        else:
+                sys.stdout.write("= %lums\n" % ((finish_time - userspace_time) / 1000))
+
+def blame():
+
+        data = acquire_time_data()
+        s = sorted(data, key = lambda i: i[2] - i[1], reverse = True)
+
+        for name, ixt, aet, axt, iet in s:
+
+                if ixt <= 0 or aet <= 0:
+                        continue
+
+                if aet <= ixt:
+                        continue
+
+                sys.stdout.write("%6lums %s\n" % ((aet - ixt) / 1000, name))
+
+def plot():
+        if cairo is None:
+                sys.exit("Failed to initilize python-cairo required for 'plot' verb.")
+        firmware_time, loader_time, kernel_time, initrd_time, userspace_time, finish_time = acquire_start_time()
+        data = acquire_time_data()
+        s = sorted(data, key = lambda i: i[1])
+
+        # Account for kernel and initramfs bars if they exist
+        if initrd_time > 0:
+                count = 3
+        else:
+                count = 2
+
+        for name, ixt, aet, axt, iet in s:
+
+                if (ixt >= userspace_time and ixt <= finish_time) or \
+                                (aet >= userspace_time and aet <= finish_time) or \
+                                (axt >= userspace_time and axt <= finish_time):
+                        count += 1
+
+        border = 100
+        bar_height = 20
+        bar_space = bar_height * 0.1
+
+        # 1000px = 10s, 1px = 10ms
+        width = finish_time/10000 + border*2
+        height = count * (bar_height + bar_space) + border * 2
+
+        if width < 1000:
+                width = 1000
+
+        surface = cairo.SVGSurface(sys.stdout, width, height)
+        context = cairo.Context(surface)
+
+        draw_box(context, 0, 0, width, height, 1, 1, 1)
+
+        context.translate(border + 0.5, border + 0.5)
+
+        context.save()
+        context.set_line_width(1)
+        context.set_source_rgb(0.7, 0.7, 0.7)
+
+        for x in range(0, int(finish_time/10000) + 100, 100):
+                context.move_to(x, 0)
+                context.line_to(x, height-border*2)
+
+        context.move_to(0, 0)
+        context.line_to(width-border*2, 0)
+
+        context.move_to(0, height-border*2)
+        context.line_to(width-border*2, height-border*2)
+
+        context.stroke()
+        context.restore()
+
+        osrel = "Linux"
+        if os.path.exists("/etc/os-release"):
+                for line in open("/etc/os-release"):
+                        if line.startswith('PRETTY_NAME='):
+                                osrel = line[12:]
+                                osrel = osrel.strip('\"\n')
+                                break
+
+        banner = "{} {} ({} {}) {}".format(osrel, *(os.uname()[1:5]))
+        draw_text(context, 0, -15, banner, hcenter = 0, vcenter = 1)
+
+        for x in range(0, int(finish_time/10000) + 100, 100):
+                draw_text(context, x, -5, "%lus" % (x/100), vcenter = 0, hcenter = 0)
+
+        y = 0
+
+        # draw boxes for kernel and initramfs boot time
+        if initrd_time > 0:
+                draw_box(context, 0, y, initrd_time/10000, bar_height, 0.7, 0.7, 0.7)
+                draw_text(context, 10, y + bar_height/2, "kernel", hcenter = 0)
+                y += bar_height + bar_space
+
+                draw_box(context, initrd_time/10000, y, userspace_time/10000-initrd_time/10000, bar_height, 0.7, 0.7, 0.7)
+                draw_text(context, initrd_time/10000 + 10, y + bar_height/2, "initramfs", hcenter = 0)
+                y += bar_height + bar_space
+
+        else:
+                draw_box(context, 0, y, userspace_time/10000, bar_height, 0.6, 0.6, 0.6)
+                draw_text(context, 10, y + bar_height/2, "kernel", hcenter = 0)
+                y += bar_height + bar_space
+
+        draw_box(context, userspace_time/10000, y, finish_time/10000-userspace_time/10000, bar_height, 0.7, 0.7, 0.7)
+        draw_text(context, userspace_time/10000 + 10, y + bar_height/2, "userspace", hcenter = 0)
+        y += bar_height + bar_space
+
+        for name, ixt, aet, axt, iet in s:
+
+                drawn = False
+                left = -1
+
+                if ixt >= userspace_time and ixt <= finish_time:
+
+                        # Activating
+                        a = ixt
+                        b = min(filter(lambda x: x >= ixt, (aet, axt, iet, finish_time))) - ixt
+
+                        draw_box(context, a/10000, y, b/10000, bar_height, 1, 0, 0)
+                        drawn = True
+
+                        if left < 0:
+                                left = a
+
+                if aet >= userspace_time and aet <= finish_time:
+
+                        # Active
+                        a = aet
+                        b = min(filter(lambda x: x >= aet, (axt, iet, finish_time))) - aet
+
+                        draw_box(context, a/10000, y, b/10000, bar_height, .8, .6, .6)
+                        drawn = True
+
+                        if left < 0:
+                                left = a
+
+                if axt >= userspace_time and axt <= finish_time:
+
+                        # Deactivating
+                        a = axt
+                        b = min(filter(lambda x: x >= axt, (iet, finish_time))) - axt
+
+                        draw_box(context, a/10000, y, b/10000, bar_height, .6, .4, .4)
+                        drawn = True
+
+                        if left < 0:
+                                left = a
+
+                if drawn:
+                        x = left/10000
+
+                        if x < width/2-border:
+                                draw_text(context, x + 10, y + bar_height/2, name, hcenter = 0)
+                        else:
+                                draw_text(context, x - 10, y + bar_height/2, name, hcenter = 1)
+
+                        y += bar_height + bar_space
+
+        draw_text(context, 0, height-border*2, "Legend: Red = Activating; Pink = Active; Dark Pink = Deactivating", hcenter = 0, vcenter = -1)
+
+        if initrd_time > 0:
+                draw_text(context, 0, height-border*2 + bar_height, "Startup finished in %lums (kernel) + %lums (initramfs) + %lums (userspace) = %lums" % ( \
+                        initrd_time/1000, \
+                        (userspace_time - initrd_time)/1000, \
+                        (finish_time - userspace_time)/1000, \
+                        finish_time/1000), hcenter = 0, vcenter = -1)
+        else:
+                draw_text(context, 0, height-border*2 + bar_height, "Startup finished in %lums (kernel) + %lums (userspace) = %lums" % ( \
+                        userspace_time/1000, \
+                        (finish_time - userspace_time)/1000, \
+                        finish_time/1000), hcenter = 0, vcenter = -1)
+
+        surface.finish()
+
+parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter,
+                                 description='Process systemd profiling information',
+                                 epilog='''\
+time - print time spent in the kernel before reaching userspace
+blame - print list of running units ordered by time to init
+plot - output SVG graphic showing service initialization
+''')
+
+parser.add_argument('action', choices=('time', 'blame', 'plot'),
+                    default='time', nargs='?',
+                    help='action to perform (default: time)')
+parser.add_argument('--user', action='store_true',
+                    help='use the session bus')
+
+args = parser.parse_args()
+
+if args.user:
+        bus = Gio.BusType.SESSION
+else:
+        bus = Gio.BusType.SYSTEM
+
+verb = {'time' : time,
+	'blame': blame,
+	'plot' : plot,
+	}
+verb.get(args.action)()

commit a83ad683fd13e27b3c4e582ecd6c3852245dbe2f
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Fri Jan 4 21:18:17 2013 -0500

    service: fixup after ifdef dropping
    
    Commit 88516c0 removed one line too much.

diff --git a/src/core/service.c b/src/core/service.c
index a4e419b..70b93e8 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -977,9 +977,9 @@ static int service_load_sysv_name(Service *s, const char *name) {
 
         /* For SysV services we strip the rc.* and *.sh
          * prefixes/suffixes. */
-        if (endswith(name, ".sh.service"))
+        if (startswith(name, "rc.") ||
+            endswith(name, ".sh.service"))
                 return -ENOENT;
-        if (startswith(name, "rc."))
 
         STRV_FOREACH(p, UNIT(s)->manager->lookup_paths.sysvinit_path) {
                 char *path;

commit 0250d95659147bae10053a69bab88dc310c4ea39
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Wed Jan 2 14:48:30 2013 -0500

    systemd-analyze: reword comments

diff --git a/src/analyze/systemd-analyze b/src/analyze/systemd-analyze
index 1512b16..de602be 100755
--- a/src/analyze/systemd-analyze
+++ b/src/analyze/systemd-analyze
@@ -36,12 +36,12 @@ def acquire_start_time():
                 None, 'org.freedesktop.systemd1', '/org/freedesktop/systemd1', 'org.freedesktop.DBus.Properties', None)
 
         # Note that the firmware/loader times are returned as positive
-        # values but are atcually considered negative from the point
+        # values but are actually considered negative from the point
         # in time of kernel initialization. Also, the monotonic kernel
-        # time will always be 0 since that's where the epoch of the
-        # monotonic clock ist. Since we want to know whether the
-        # kernel time stamp is set at all, we will thus ask for the
-        # realtime clock for this timestamp, instead.
+        # time will always be 0 since that's the epoch of the
+        # monotonic clock. Since we want to know whether the kernel
+        # timestamp is set at all we will instead ask for the realtime
+        # clock for this timestamp.
 
         firmware_time = properties.Get('(ss)', 'org.freedesktop.systemd1.Manager', 'FirmwareTimestampMonotonic')
         loader_time = properties.Get('(ss)', 'org.freedesktop.systemd1.Manager', 'LoaderTimestampMonotonic')
@@ -51,8 +51,7 @@ def acquire_start_time():
         finish_time = properties.Get('(ss)', 'org.freedesktop.systemd1.Manager', 'FinishTimestampMonotonic')
 
         if finish_time == 0:
-                sys.stderr.write("Bootup is not yet finished. Please try again later.\n")
-                sys.exit(1)
+                sys.exit("Bootup is not yet finished. Please try again later.")
 
         assert firmware_time >= loader_time
         assert initrd_time <= userspace_time
@@ -127,8 +126,7 @@ def blame():
 
 def plot():
         if cairo is None:
-                sys.stderr.write("Failed to initilize python-cairo required for 'plot' verb.\n")
-                sys.exit(1)
+                sys.exit("Failed to initilize python-cairo required for 'plot' verb.")
         firmware_time, loader_time, kernel_time, initrd_time, userspace_time, finish_time = acquire_start_time()
         data = acquire_time_data()
         s = sorted(data, key = lambda i: i[1])

commit 7f8e692bb2c90e7ac857c3d60cf7b916c842ab24
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Wed Jan 2 14:48:24 2013 -0500

    build-sys: allow update-hwdb with seperate build dir

diff --git a/Makefile.am b/Makefile.am
index 64a4500..2a67355 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4096,11 +4096,11 @@ DISTCHECK_CONFIGURE_FLAGS += \
 endif
 
 hwdb-update:
-	( cd hwdb && \
-	wget -N http://www.linux-usb.org/usb.ids && \
-	wget -N http://pci-ids.ucw.cz/v2.2/pci.ids && \
-	wget -N http://standards.ieee.org/develop/regauth/oui/oui.txt && \
-	wget -N http://standards.ieee.org/develop/regauth/iab/iab.txt && \
+	( cd $(top_srcdir)/hwdb && \
+	wget -N http://www.linux-usb.org/usb.ids \
+	        http://pci-ids.ucw.cz/v2.2/pci.ids \
+		http://standards.ieee.org/develop/regauth/oui/oui.txt \
+	        http://standards.ieee.org/develop/regauth/iab/iab.txt && \
 	./ids-update.pl )
 
 upload: all distcheck

commit e241dd66f13dde958bdcb48d8943acea9298d94b
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Wed Jan 2 14:49:30 2013 -0500

    build-sys: drop unused $RUNTIME_DIR

diff --git a/Makefile.am b/Makefile.am
index 8f68a10..64a4500 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -142,7 +142,6 @@ AM_CPPFLAGS = \
 	-DSYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH=\"$(rootbindir)/systemd-tty-ask-password-agent\" \
 	-DSYSTEMD_STDIO_BRIDGE_BINARY_PATH=\"$(bindir)/systemd-stdio-bridge\" \
 	-DROOTPREFIX=\"$(rootprefix)\" \
-	-DRUNTIME_DIR=\"/run\" \
 	-DRANDOM_SEED=\"$(localstatedir)/lib/random-seed\" \
 	-DSYSTEMD_CRYPTSETUP_PATH=\"$(rootlibexecdir)/systemd-cryptsetup\" \
 	-DSYSTEM_GENERATOR_PATH=\"$(systemgeneratordir)\" \



More information about the systemd-commits mailing list