chiark / gitweb /
Merge branch 'python-systemd-reader'
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 1 Mar 2013 00:53:42 +0000 (19:53 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 1 Mar 2013 01:05:12 +0000 (20:05 -0500)
* python-systemd-reader:
  python-systemd: rename Journal to Reader
  build-sys: upload python documentation to freedesktop.org
  systemd-python: add Journal class for reading journal
  python: build html docs using sphinx
  journalct: also print Python code in --new-id
  python: utilize uuid.UUID in logging
  python: add systemd.id128 module
  ... and 34 other commits

In short: python module systemd.id128 is added, and existing
systemd.journal gains a new class systemd.journal.Reader, which can be
used to iterate over journal entries. Documentation is provided, and
accessible under e.g.
    pydoc3 systemd.journal.Reader
or
    firefox http://www.freedesktop.org/software/systemd/man/python-systemd/

1  2 
Makefile.am
configure.ac
src/journal/journalctl.c

diff --combined Makefile.am
@@@ -267,7 -267,8 +267,7 @@@ rootbin_PROGRAMS = 
        systemd-ask-password \
        systemd-tty-ask-password-agent \
        systemd-tmpfiles \
 -      systemd-machine-id-setup \
 -      systemd-analyze
 +      systemd-machine-id-setup
  
  bin_PROGRAMS = \
        systemd-cgls \
        systemd-stdio-bridge \
        systemd-nspawn \
        systemd-detect-virt \
 -      systemd-delta
 +      systemd-delta \
 +      systemd-analyze
 +
 +bin_SCRIPTS = \
 +      src/kernel-install/kernel-install
 +
 +EXTRA_DIST += \
 +      src/kernel-install/kernel-install
  
  rootlibexec_PROGRAMS = \
        systemd \
@@@ -519,7 -513,7 +519,7 @@@ man/index.html
  
  NON_INDEX_XML_FILES = $(filter-out man/systemd.index.xml,$(XML_FILES))
  
 -XML_GLOB = $(wildcard $(top_srcdir)/man/*.xml $(top_srcdir)/man/*.xml.in)
 +XML_GLOB = $(wildcard $(top_srcdir)/man/*.xml $(top_srcdir)/man/*.xml.in $(top_builddir)/man/*.xml)
  update-man-list: make-man-rules.py $(XML_GLOB)
        $(AM_V_GEN)$(PYTHON) $^ > $(top_srcdir)/Makefile-man.tmp
        $(AM_V_at)mv $(top_srcdir)/Makefile-man.tmp $(top_srcdir)/Makefile-man.am
@@@ -855,8 -849,6 +855,8 @@@ libsystemd_core_la_SOURCES = 
        src/core/tcpwrap.h \
        src/core/cgroup-attr.c \
        src/core/cgroup-attr.h \
 +      src/core/cgroup-semantics.c \
 +      src/core/cgroup-semantics.h \
        src/core/securebits.h \
        src/core/initreq.h \
        src/core/special.h \
@@@ -1568,6 -1560,7 +1568,6 @@@ libsystemd_daemon_la_CFLAGS = 
  
  libsystemd_daemon_la_LDFLAGS = \
        $(AM_LDFLAGS) \
 -      -shared \
        -version-info $(LIBSYSTEMD_DAEMON_CURRENT):$(LIBSYSTEMD_DAEMON_REVISION):$(LIBSYSTEMD_DAEMON_AGE) \
        -Wl,--version-script=$(top_srcdir)/src/libsystemd-daemon/libsystemd-daemon.sym
  
@@@ -2268,6 -2261,7 +2268,6 @@@ libsystemd_id128_la_CFLAGS = 
  
  libsystemd_id128_la_LDFLAGS = \
        $(AM_LDFLAGS) \
 -      -shared \
        -version-info $(LIBSYSTEMD_ID128_CURRENT):$(LIBSYSTEMD_ID128_REVISION):$(LIBSYSTEMD_ID128_AGE) \
        -Wl,--version-script=$(top_srcdir)/src/libsystemd-id128/libsystemd-id128.sym
  
@@@ -2314,18 -2308,6 +2314,18 @@@ EXTRA_DIST += 
        src/libsystemd-id128/libsystemd-id128.sym
  
  # ------------------------------------------------------------------------------
 +
 +rootlibexec_PROGRAMS += \
 +      systemd-activate
 +
 +systemd_activate_SOURCES = \
 +      src/activate/activate.c
 +
 +systemd_activate_LDADD = \
 +      libsystemd-shared.la \
 +      libsystemd-daemon.la
 +
 +# ------------------------------------------------------------------------------
  systemd_journald_SOURCES = \
        src/journal/journald.c \
        src/journal/journald-server.h
@@@ -2470,6 -2452,7 +2470,6 @@@ libsystemd_journal_la_CFLAGS = 
  
  libsystemd_journal_la_LDFLAGS = \
        $(AM_LDFLAGS) \
 -      -shared \
        -version-info $(LIBSYSTEMD_JOURNAL_CURRENT):$(LIBSYSTEMD_JOURNAL_REVISION):$(LIBSYSTEMD_JOURNAL_AGE) \
        -Wl,--version-script=$(top_srcdir)/src/journal/libsystemd-journal.sym
  
@@@ -2571,8 -2554,6 +2571,8 @@@ libsystemd-journal-uninstall-hook
  INSTALL_EXEC_HOOKS += libsystemd-journal-install-hook
  UNINSTALL_EXEC_HOOKS += libsystemd-journal-uninstall-hook
  
 +# ------------------------------------------------------------------------------
 +
  # Update catalog on installation. Do not bother if installing
  # in DESTDIR, since this is likely for packaging purposes.
  catalog-update-hook:
@@@ -3273,6 -3254,7 +3273,6 @@@ libsystemd_login_la_CFLAGS = 
  
  libsystemd_login_la_LDFLAGS = \
        $(AM_LDFLAGS) \
 -      -shared \
        -version-info $(LIBSYSTEMD_LOGIN_CURRENT):$(LIBSYSTEMD_LOGIN_REVISION):$(LIBSYSTEMD_LOGIN_AGE) \
        -Wl,--version-script=$(top_srcdir)/src/login/libsystemd-login.sym
  
@@@ -3398,7 -3380,9 +3398,9 @@@ EXTRA_DIST += 
  # ------------------------------------------------------------------------------
  if HAVE_PYTHON_DEVEL
  pkgpyexec_LTLIBRARIES = \
-       _journal.la
+       _journal.la \
+       id128.la \
+       _reader.la
  
  _journal_la_SOURCES = \
        src/python-systemd/_journal.c
@@@ -3418,11 -3402,75 +3420,75 @@@ _journal_la_LIBADD = 
        $(PYTHON_LIBS) \
        libsystemd-journal.la
  
+ id128_la_SOURCES = \
+       src/python-systemd/id128.c \
+       src/python-systemd/id128-constants.h \
+       src/python-systemd/pyutil.c \
+       src/python-systemd/pyutil.h
+ id128_la_CFLAGS = \
+       $(AM_CFLAGS) \
+         -fvisibility=default \
+       $(PYTHON_CFLAGS) \
+       -I$(top_builddir)/src/python-systemd
+ id128_la_LDFLAGS = \
+       $(AM_LDFLAGS) \
+       -shared \
+       -module \
+       -avoid-version
+ id128_la_LIBADD = \
+       $(PYTHON_LIBS) \
+       libsystemd-id128.la
+ _reader_la_SOURCES = \
+       src/python-systemd/_reader.c \
+       src/python-systemd/pyutil.c \
+       src/python-systemd/pyutil.h
+ _reader_la_CFLAGS = \
+       $(AM_CFLAGS) \
+         -fvisibility=default \
+       $(PYTHON_CFLAGS)
+ _reader_la_LDFLAGS = \
+       $(AM_LDFLAGS) \
+       -shared \
+       -module \
+       -avoid-version
+ _reader_la_LIBADD = \
+       $(PYTHON_LIBS) \
+       libsystemd-journal.la \
+       libsystemd-id128.la \
+       libsystemd-shared.la
  dist_pkgpyexec_PYTHON = \
        src/python-systemd/journal.py \
        src/python-systemd/__init__.py
+ src/python-systemd/id128-constants.h: src/systemd/sd-messages.h Makefile
+       $(AM_V_at)$(MKDIR_P) $(dir $@)
+       $(AM_V_GEN)$(SED) -n -r 's/,//g; s/#define (SD_MESSAGE_[A-Z0-9_]+)\s.*/add_id(m, "\1", \1) JOINER/p' <$< >$@
+ BUILT_SOURCES += \
+       src/python-systemd/id128-constants.h
  endif
  
+ PAPER = $(shell cat /etc/papersize 2>/dev/null || echo a4)
+ SPHINXOPTS = -D latex_paper_size=$(PAPER)
+ sphinx-%:
+       $(AM_V_at)test -n "$(SPHINX_BUILD)" || { echo " *** sphinx-build is not available"; exit 1; }
+       $(AM_V_GEN)PYTHONPATH=$(DESTDIR)$(pyexecdir) LD_LIBRARY_PATH=$(DESTDIR)$(libdir) $(SPHINX_BUILD) -b $* $(SPHINXOPTS) $(top_srcdir)/src/python-systemd/docs $(top_builddir)/man/python-systemd/
+       $(AM_V_at)echo Output has been generated in $(abs_top_builddir)/man/python-systemd/
+ destdir-sphinx: all
+       dir="`mktemp -d /tmp/systemd-install.XXXXXX`" && \
+               $(MAKE) DESTDIR="$$dir" install && \
+               $(MAKE) DESTDIR="$$dir" sphinx-html && \
+               rm -rf "$$dir"
  # ------------------------------------------------------------------------------
  SED_PROCESS = \
        $(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
@@@ -3743,17 -3791,19 +3809,19 @@@ upload: all distchec
        scp systemd-$(VERSION).tar.xz fdo:/srv/www.freedesktop.org/www/software/systemd/
        scp man/*.html tango:public/systemd-man/
  
- doc-sync: all
+ www_target = www.freedesktop.org:/srv/www.freedesktop.org/www/software/systemd
+ doc-sync: all destdir-sphinx
        gtkdoc-rebase --html-dir=docs/libudev/html --online
-       rsync -av --delete docs/libudev/html/ --omit-dir-times www.freedesktop.org:/srv/www.freedesktop.org/www/software/systemd/libudev/
+       rsync -av --delete docs/libudev/html/ --omit-dir-times $(www_target)/libudev/
        gtkdoc-rebase --html-dir=docs/gudev/html --online
-       rsync -av --delete docs/gudev/html/ --omit-dir-times www.freedesktop.org:/srv/www.freedesktop.org/www/software/systemd/gudev/
-       rsync -av --delete-excluded --include="*.html" --exclude="*" --omit-dir-times man/ www.freedesktop.org:/srv/www.freedesktop.org/www/software/systemd/man/
+       rsync -av --delete docs/gudev/html/ --omit-dir-times $(www_target)/gudev/
+       rsync -av --delete-excluded --include="*.html" --exclude="*" --omit-dir-times man/ $(www_target)/man/
+       rsync -av --delete --omit-dir-times man/python-systemd/ $(www_target)/man/python-systemd/
  
  git-tag:
        git tag "v$(VERSION)" -m "systemd $(VERSION)"
  
  install-tree: all
        rm -rf $(abs_srcdir)/install-tree
-       make install DESTDIR=$(abs_srcdir)/install-tree
+       $(MAKE) install DESTDIR=$(abs_srcdir)/install-tree
        tree $(abs_srcdir)/install-tree
diff --combined configure.ac
@@@ -176,6 -176,7 +176,7 @@@ AS_IF([test "x$with_python" != "xno"], 
                PYTHON_LIBS="`$PYTHON_CONFIG --ldflags`"
                AC_SUBST(PYTHON_CFLAGS)
                AC_SUBST(PYTHON_LIBS)
+               AC_PATH_PROGS(SPHINX_BUILD, sphinx-build-${PYTHON_VERSION} sphinx-build)
          ])
  ])
  AM_CONDITIONAL([HAVE_PYTHON_DEVEL], [test "$have_python_devel" = "yes"])
@@@ -276,7 -277,7 +277,7 @@@ AM_CONDITIONAL(HAVE_SELINUX, [test "$ha
  if test "x${have_selinux}" != xno ; then
          sushell=/sbin/sushell
  else
 -        sushell=/bin/bash
 +        sushell=/bin/sh
  fi
  AC_SUBST(sushell)
  
diff --combined src/journal/journalctl.c
@@@ -433,7 -433,7 +433,7 @@@ static int parse_argv(int argc, char *a
          if (arg_follow && !arg_no_tail && arg_lines < 0)
                  arg_lines = 10;
  
 -        if (arg_since_set && arg_until_set && arg_since_set > arg_until_set) {
 +        if (arg_since_set && arg_until_set && arg_since > arg_until) {
                  log_error("--since= must be before --until=.");
                  return -EINVAL;
          }
@@@ -462,14 -462,17 +462,17 @@@ static int generate_new_id128(void) 
                 "As UUID:\n"
                 "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\n\n"
                 "As macro:\n"
-               "#define MESSAGE_XYZ SD_ID128_MAKE(",
+                "#define MESSAGE_XYZ SD_ID128_MAKE(",
                 SD_ID128_FORMAT_VAL(id),
                 SD_ID128_FORMAT_VAL(id));
          for (i = 0; i < 16; i++)
                  printf("%02x%s", id.bytes[i], i != 15 ? "," : "");
+         fputs(")\n\n", stdout);
  
-         fputs(")\n", stdout);
+         printf("As Python constant:\n"
+                ">>> import uuid\n"
+                ">>> MESSAGE_XYZ = uuid.UUID('" SD_ID128_FORMAT_STR "')\n",
+                SD_ID128_FORMAT_VAL(id));
  
          return 0;
  }
@@@ -1076,8 -1079,6 +1079,8 @@@ int main(int argc, char *argv[]) 
                                          log_error("Failed to determine timestamp: %s", strerror(-r));
                                          goto finish;
                                  }
 +                                if (usec > arg_until)
 +                                        goto finish;
                          }
  
                          if (!arg_merge) {