drop systemd-sysv-convert, provide only the package name for now

https://fedorahosted.org/fpc/ticket/308
This commit is contained in:
Kay Sievers 2013-07-13 12:50:50 +02:00
parent c3b79820c7
commit 5ccbe72a72
2 changed files with 3 additions and 156 deletions

View File

@ -1,148 +0,0 @@
#!/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()

View File

@ -28,8 +28,6 @@ Source0: http://www.freedesktop.org/software/systemd/%{name}-%{version}.t
Source1: 90-default.preset Source1: 90-default.preset
Source7: 99-default-disable.preset Source7: 99-default-disable.preset
Source5: 85-display-manager.preset Source5: 85-display-manager.preset
# Feodora's SysV convert script. meh.
Source2: systemd-sysv-convert
# Stop-gap, just to ensure things work fine with rsyslog without having to change the package right-away # Stop-gap, just to ensure things work fine with rsyslog without having to change the package right-away
Source4: listen.conf Source4: listen.conf
# Prevent accidental removal of the systemd package # Prevent accidental removal of the systemd package
@ -106,6 +104,9 @@ Provides: nss-myhostname = 0.4
# systemd-analyze got merged in F19, drop at F21 # systemd-analyze got merged in F19, drop at F21
Obsoletes: systemd-analyze < 198 Obsoletes: systemd-analyze < 198
Provides: systemd-analyze = 198 Provides: systemd-analyze = 198
# systemd-sysv-convert was removed in f20: https://fedorahosted.org/fpc/ticket/308
Obsoletes: systemd-sysv < 206
Provides: systemd-sysv = 206
%description %description
systemd is a system and service manager for Linux, compatible with systemd is a system and service manager for Linux, compatible with
@ -290,9 +291,6 @@ mkdir -p %{buildroot}%{_localstatedir}/log/journal
touch %{buildroot}%{_localstatedir}/lib/systemd/catalog/database touch %{buildroot}%{_localstatedir}/lib/systemd/catalog/database
touch %{buildroot}%{_sysconfdir}/udev/hwdb.bin touch %{buildroot}%{_sysconfdir}/udev/hwdb.bin
# Install SysV conversion tool for systemd
install -m 0755 %{SOURCE2} %{buildroot}%{_bindir}/
# Install rsyslog fragment # Install rsyslog fragment
mkdir -p %{buildroot}%{_sysconfdir}/rsyslog.d/ mkdir -p %{buildroot}%{_sysconfdir}/rsyslog.d/
install -m 0644 %{SOURCE4} %{buildroot}%{_sysconfdir}/rsyslog.d/ install -m 0644 %{SOURCE4} %{buildroot}%{_sysconfdir}/rsyslog.d/
@ -751,9 +749,6 @@ getent passwd systemd-journal-gateway >/dev/null 2>&1 || useradd -r -l -u 191 -g
%dir %{_datadir}/gtk-doc/html/libudev %dir %{_datadir}/gtk-doc/html/libudev
%{_datadir}/gtk-doc/html/libudev/* %{_datadir}/gtk-doc/html/libudev/*
%files sysv
%{_bindir}/systemd-sysv-convert
%files python %files python
%{python_sitearch}/systemd/__init__.py %{python_sitearch}/systemd/__init__.py
%{python_sitearch}/systemd/__init__.pyc %{python_sitearch}/systemd/__init__.pyc