From 639e1e7eda3f03cffe63de90b2f3d95a95da37f1 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Apr 04 2011 23:17:39 +0000 Subject: New upstream release --- diff --git a/.gitignore b/.gitignore index ebdc3d7..788f14d 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ systemd-*src.rpm /systemd-20.tar.bz2 /systemd-21.tar.bz2 /systemd-22.tar.bz2 +/systemd-23.tar.bz2 diff --git a/sources b/sources index dabeb17..13307dd 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -79cfbca526eaa5833723b48adeb0b323 systemd-22.tar.bz2 +24b46ce024316189653ebb39fa745ab2 systemd-23.tar.bz2 diff --git a/systemd-sysv-convert b/systemd-sysv-convert new file mode 100755 index 0000000..1c3f1a9 --- /dev/null +++ b/systemd-sysv-convert @@ -0,0 +1,148 @@ +#!/usr/bin/python +# -*- Mode: Python; python-indent: 8; indent-tabs-mode: t -*- + +import sys, os, argparse, errno + +def find_service(service, runlevel): + priority = -1 + + for l in os.listdir("/etc/rc%i.d" % runlevel): + if len(l) < 4: + continue + + if l[0] != 'S' or l[3:] != service: + continue + + p = int(l[1:3]) + + if p >= 0 and p <= 99 and p >= priority: + priority = p; + + return priority + +def lookup_database(services): + try: + database = open("/var/lib/systemd/sysv-convert/database", "r") + except IOError, e: + if e.errno != errno.ENOENT: + raise e + + return {} + + found = {} + k = 0 + + for line in database: + service, r, p = line.strip().split("\t", 3) + k += 1 + + try: + runlevel = int(r) + priority = int(p) + except ValueError, e: + sys.stderr.write("Failed to parse database line %i. Ignoring." % k) + continue + + if runlevel not in (2, 3, 4, 5): + sys.stderr.write("Runlevel out of bounds in database line %i. Ignoring." % k) + continue + + if priority < 0 or priority > 99: + sys.stderr.write("Priority out of bounds in database line %i. Ignoring." % k) + continue + + if service not in services: + continue + + if service not in found: + found[service] = {} + + if runlevel not in found[service] or found[service][runlevel] < priority: + found[service][runlevel] = priority + + return found + +def mkdir_p(path): + try: + os.makedirs(path, 0755) + except OSError, e: + if e.errno != errno.EEXIST: + raise e + +if os.geteuid() != 0: + sys.stderr.write("Need to be root.\n") + sys.exit(1) + +parser = argparse.ArgumentParser(description='Save and Restore SysV Service Runlevel Information') + +parser.add_argument('services', metavar='SERVICE', type=str, nargs='+', + help='Service names') + +parser.add_argument('--save', dest='save', action='store_const', + const=True, default=False, + help='Save SysV runlevel information for one or more services') + +parser.add_argument('--show', dest='show', action='store_const', + const=True, default=False, + help='Show saved SysV runlevel information for one or more services') + +parser.add_argument('--apply', dest='apply', action='store_const', + const=True, default=False, + help='Apply saved SysV runlevel information for one or more services to systemd counterparts') + +a = parser.parse_args() + +if a.save: + for service in a.services: + if not os.access("/etc/rc.d/init.d/%s" % service, os.F_OK): + sys.stderr.write("SysV service %s does not exist.\n" % service) + sys.exit(1) + + mkdir_p("/var/lib/systemd/sysv-convert") + database = open("/var/lib/systemd/sysv-convert/database", "a") + + for runlevel in (2, 3, 4, 5): + priority = find_service(service, runlevel) + + if priority >= 0: + database.write("%s\t%s\t%s\n" % (service, runlevel, priority)) + +elif a.show: + found = lookup_database(a.services) + + if len(found) <= 0: + sys.stderr.write("No information about passed services found.\n") + sys.exit(1) + + for service, data in found.iteritems(): + for runlevel, priority in data.iteritems(): + sys.stdout.write("SysV service %s enabled in runlevel %s at priority %s\n" % (service, runlevel, priority)) + +elif a.apply: + for service in a.services: + if not os.access("/lib/systemd/system/%s.service" % service, os.F_OK): + sys.stderr.write("systemd service %s.service does not exist.\n" % service) + sys.exit(1) + + found = lookup_database(a.services) + + if len(found) <= 0: + sys.stderr.write("No information about passed services found.\n") + sys.exit(1) + + for service, data in found.iteritems(): + for runlevel in data.iterkeys(): + + sys.stderr.write("ln -sf /lib/systemd/system/%s.service /etc/systemd/system/runlevel%i.target.wants/%s.service\n" % (service, runlevel, service)) + + mkdir_p("/etc/systemd/system/runlevel%i.target.wants" % runlevel) + + try: + os.symlink("/lib/systemd/system/%s.service" % service, + "/etc/systemd/system/runlevel%i.target.wants/%s.service" % (runlevel, service)) + except OSError, e: + if e.errno != errno.EEXIST: + raise e + +else: + parser.print_help() diff --git a/systemd.spec b/systemd.spec index 17935ff..8859b57 100644 --- a/systemd.spec +++ b/systemd.spec @@ -1,7 +1,7 @@ Name: systemd Url: http://www.freedesktop.org/wiki/Software/systemd BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -Version: 22 +Version: 23 Release: 1%{?dist} License: GPLv2+ Group: System Environment/Base @@ -29,11 +29,12 @@ Requires: dbus >= 1.3.2 Requires: udev >= 160 Requires: libudev >= 160 Requires: initscripts >= 9.22 -Conflicts: selinux-policy < 3.8.7 +Conflicts: selinux-policy < 3.9.16-10.fc15 Requires: kernel >= 2.6.35.2-9.fc14 Source0: http://www.freedesktop.org/software/systemd/%{name}-%{version}.tar.bz2 # Adds support for the %%{_unitdir} macro Source1: macros.systemd +Source2: systemd-sysv-convert # For sysvinit tools Obsoletes: SysVinit < 2.86-24, sysvinit < 2.86-24 @@ -77,6 +78,14 @@ Requires: polkit %description gtk Graphical front-end for systemd. +%package sysv +Group: System Environment/Base +Summary: SysV tools for systemd +Requires: %{name} = %{version}-%{release} + +%description sysv +SysV compatibility tools for systemd + %prep %setup -q @@ -123,6 +132,9 @@ mkdir -p %{buildroot}/lib/systemd/system/syslog.target.wants mkdir -p %{buildroot}%{_sysconfdir}/rpm/ install -m 0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/rpm/ +# Install SysV conversion tool for systemd +install -m 0755 %{SOURCE2} %{buildroot}%{_bindir}/ + %clean rm -rf $RPM_BUILD_ROOT @@ -189,6 +201,7 @@ fi %{_sysconfdir}/xdg/systemd %{_sysconfdir}/tmpfiles.d/systemd.conf %{_sysconfdir}/tmpfiles.d/x11.conf +%{_sysconfdir}/tmpfiles.d/legacy.conf %ghost %config(noreplace) %{_sysconfdir}/machine-id /bin/systemd /bin/systemd-notify @@ -219,7 +232,7 @@ fi %{_mandir}/man5/* %{_mandir}/man7/* %{_mandir}/man8/* -%{_datadir}/systemd +%{_libdir}/systemd %{_datadir}/dbus-1/services/org.freedesktop.systemd1.service %{_datadir}/dbus-1/system-services/org.freedesktop.systemd1.service %{_datadir}/dbus-1/interfaces/org.freedesktop.systemd1.*.xml @@ -232,6 +245,7 @@ fi %dir %{_sysconfdir}/tmpfiles.d %dir %{_sysconfdir}/sysctl.d %dir %{_sysconfdir}/modules-load.d +%dir %{_sysconfdir}/binfmt.d %dir %{_sysconfdir}/bash_completion.d %dir /lib/systemd /lib/systemd/system @@ -257,7 +271,14 @@ fi %{_datadir}/polkit-1/actions/org.freedesktop.systemd1.policy %{_mandir}/man1/systemadm.* +%files sysv +%{_bindir}/systemd-sysv-convert + %changelog +* Tue Apr 5 2011 Lennart Poettering - 23-1 +- New upstream release +- Include systemd-sysv-convert + * Fri Apr 1 2011 Lennart Poettering - 22-1 - New upstream release