[systemd-devel] [PATCH] add Mandriva distribution support

Andrey Borzenkov arvidjaar at gmail.com
Fri Mar 4 08:52:29 PST 2011


This merges several separate patches that I carry as part of
Mandriva systemd RPM. They touch those parts that are very
unlikely to be changed in near future and do not impose any
functionality change for systemd core. I also think it is
useful for troubleshooting to have real distribution name in
system logs, espicially when someone reports problem upstream.

The patch looks bigger than sum of replaced patches because

- previous patches were applied on top of distro=fedora, now
I need to add all those bits for distro=mandriva as well

- part of patch was done as spec file magic, but it seems more
logical to ship all these bits together

Signed-off-by: Andrey Borzenkov <arvidjaar at gmail.com>
Acked-By: Eugeni Dodonov <eugeni at mandriva.com>

---
 Makefile.am                    |   22 ++++++++++++++--
 configure.ac                   |   11 ++++++++
 src/fsck.c                     |    2 +-
 src/hostname-setup.c           |    4 +-
 src/locale-setup.c             |   22 ++++++++++++++++
 src/quotacheck.c               |    6 ++--
 src/service.c                  |   13 +++++++++
 src/systemctl.c                |    2 +-
 src/util.c                     |   27 +++++++++++++++++++
 src/vconsole-setup.c           |   55 ++++++++++++++++++++++++++++++++++++++++
 units/fedora/prefdm.service    |   20 --------------
 units/fedora/prefdm.service.m4 |   31 ++++++++++++++++++++++
 units/getty at .service.m4        |    3 ++
 units/graphical.target.m4      |    3 ++
 units/multi-user.target.m4     |    3 ++
 units/rescue.service.m4        |    8 +++++-
 units/serial-getty at .service.m4 |    3 ++
 17 files changed, 204 insertions(+), 31 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 1841ad5..dfb341b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -84,6 +84,12 @@ AM_CPPFLAGS += \
 	-DKBD_SETFONT=\"/usr/bin/setfont\" \
 	-DDEFAULT_FONT=\"LatArCyrHeb-16\"
 else
+if TARGET_MANDRIVA
+AM_CPPFLAGS += \
+	-DKBD_LOADKEYS=\"/bin/loadkeys\" \
+	-DKBD_SETFONT=\"/bin/setfont\" \
+	-DDEFAULT_FONT=\"LatArCyrHeb-16\"
+else
 AM_CPPFLAGS += \
 	-DKBD_LOADKEYS=\"/bin/loadkeys\" \
 	-DKBD_SETFONT=\"/bin/setfont\" \
@@ -91,6 +97,7 @@ AM_CPPFLAGS += \
 endif
 endif
 endif
+endif
 
 rootbin_PROGRAMS = \
 	systemd \
@@ -328,9 +335,14 @@ EXTRA_DIST = \
 	systemd.pc.in \
 	introspect.awk
 
-if TARGET_FEDORA
+if TARGET_FEDORA_OR_MANDRIVA
+EXTRA_DIST += \
+	units/fedora/prefdm.service.m4
+
+nodist_systemunit_DATA += \
+	units/fedora/prefdm.service
+
 dist_systemunit_DATA += \
-	units/fedora/prefdm.service \
 	units/fedora/rc-local.service \
 	units/fedora/halt-local.service
 endif
@@ -1063,6 +1075,9 @@ M4_PROCESS_USER = \
 units/%: units/%.m4 Makefile
 	$(M4_PROCESS_SYSTEM)
 
+units/fedora/%: units/%.m4 Makefile
+	$(M4_PROCESS_SYSTEM)
+
 units/user/%: units/%.m4 Makefile
 	$(M4_PROCESS_USER)
 
@@ -1324,7 +1339,7 @@ if HAVE_PLYMOUTH
 		$(LN_S) ../plymouth-halt.service plymouth-halt.service )
 endif
 
-if TARGET_FEDORA
+if TARGET_FEDORA_OR_MANDRIVA
 	$(MKDIR_P) -m 0755 $(DESTDIR)$(systemunitdir)/final.target.wants
 	( cd $(DESTDIR)$(systemunitdir)/multi-user.target.wants && \
 		rm -f rc-local.service && \
@@ -1339,6 +1354,7 @@ if TARGET_FEDORA
 		rm -f display-manager.service && \
 		$(LN_S) $(systemunitdir)/display-manager.service display-manager.service )
 endif
+
 if TARGET_DEBIAN_OR_UBUNTU
 	( cd $(DESTDIR)$(systemunitdir) && \
 		rm -f runlevel5.target && \
diff --git a/configure.ac b/configure.ac
index 2cf31e4..0fe5d79 100644
--- a/configure.ac
+++ b/configure.ac
@@ -282,6 +282,7 @@ if test "z$with_distro" = "z"; then
                 test -f "/etc/slackware-version" && with_distro="slackware"
                 test -f "/etc/frugalware-release" && with_distro="frugalware"
                 test -f "/etc/altlinux-release" && with_distro="altlinux"
+                test -f "/etc/mandriva-release" && with_distro="mandriva"
                 if test "x`lsb_release -is 2>/dev/null`" = "xUbuntu"; then
                         with_distro="ubuntu"
                 fi
@@ -373,6 +374,14 @@ case $with_distro in
                 M4_DISTRO_FLAG=-DTARGET_ALTLINUX=1
 		have_plymouth=true
                 ;;
+        mandriva)
+                SYSTEM_SYSVINIT_PATH=/etc/rc.d/init.d
+                SYSTEM_SYSVRCND_PATH=/etc/rc.d
+                SPECIAL_SYSLOG_SERVICE=rsyslog.service
+                AC_DEFINE(TARGET_MANDRIVA, [], [Target is Mandriva])
+                M4_DISTRO_FLAG=-DTARGET_MANDRIVA=1
+		have_plymouth=true
+                ;;
         other)
                 AS_IF([test "x$with_syslog_service" = "x"],
                         [AC_MSG_ERROR([With --distro=other, you must pass --with-syslog-service= to configure])])
@@ -430,6 +439,8 @@ AM_CONDITIONAL(TARGET_GENTOO, test x"$with_distro" = xgentoo)
 AM_CONDITIONAL(TARGET_SLACKWARE, test x"$with_distro" = xslackware)
 AM_CONDITIONAL(TARGET_FRUGALWARE, test x"$with_distro" = xfrugalware)
 AM_CONDITIONAL(TARGET_ALTLINUX, test x"$with_distro" = xaltlinux)
+AM_CONDITIONAL(TARGET_MANDRIVA, test x"$with_distro" = xmandriva)
+AM_CONDITIONAL(TARGET_FEDORA_OR_MANDRIVA, test x"$with_distro" = xfedora -o x"$with_distro" = xmandriva)
 
 AM_CONDITIONAL(HAVE_PLYMOUTH, test -n "$have_plymouth")
 
diff --git a/src/fsck.c b/src/fsck.c
index 7855f3a..dbfb475 100644
--- a/src/fsck.c
+++ b/src/fsck.c
@@ -121,7 +121,7 @@ static int parse_proc_cmdline(void) {
                         arg_skip = true;
                 else if (startswith(w, "fsck.mode"))
                         log_warning("Invalid fsck.mode= parameter. Ignoring.");
-#ifdef TARGET_FEDORA
+#if defined(TARGET_FEDORA) || defined(TARGET_MANDRIVA)
                 else if (strneq(w, "fastboot", l))
                         arg_skip = true;
                 else if (strneq(w, "forcefsck", l))
diff --git a/src/hostname-setup.c b/src/hostname-setup.c
index 8b0ff79..ef68d78 100644
--- a/src/hostname-setup.c
+++ b/src/hostname-setup.c
@@ -30,7 +30,7 @@
 #include "util.h"
 #include "log.h"
 
-#if defined(TARGET_FEDORA) || defined(TARGET_ALTLINUX)
+#if defined(TARGET_FEDORA) || defined(TARGET_ALTLINUX) || defined(TARGET_MANDRIVA)
 #define FILENAME "/etc/sysconfig/network"
 #elif defined(TARGET_SUSE) || defined(TARGET_SLACKWARE) || defined(TARGET_FRUGALWARE)
 #define FILENAME "/etc/HOSTNAME"
@@ -87,7 +87,7 @@ static int read_and_strip_hostname(const char *path, char **hn) {
 
 static int read_distro_hostname(char **hn) {
 
-#if defined(TARGET_FEDORA) || defined(TARGET_ARCH) || defined(TARGET_GENTOO) || defined(TARGET_ALTLINUX)
+#if defined(TARGET_FEDORA) || defined(TARGET_ARCH) || defined(TARGET_GENTOO) || defined(TARGET_ALTLINUX) || defined(TARGET_MANDRIVA)
         int r;
         FILE *f;
 
diff --git a/src/locale-setup.c b/src/locale-setup.c
index 2360cea..7684681 100644
--- a/src/locale-setup.c
+++ b/src/locale-setup.c
@@ -181,6 +181,28 @@ int locale_setup(void) {
                 if (r != -ENOENT)
                         log_warning("Failed to read /etc/profile.env: %s", strerror(-r));
         }
+#elif defined(TARGET_MANDRIVA)
+        if (r <= 0 &&
+            (r = parse_env_file("/etc/sysconfig/i18n", NEWLINE,
+                                "LANG",              &variables[VARIABLE_LANG],
+                                "LC_CTYPE",          &variables[VARIABLE_LC_CTYPE],
+                                "LC_NUMERIC",        &variables[VARIABLE_LC_NUMERIC],
+                                "LC_TIME",           &variables[VARIABLE_LC_TIME],
+                                "LC_COLLATE",        &variables[VARIABLE_LC_COLLATE],
+                                "LC_MONETARY",       &variables[VARIABLE_LC_MONETARY],
+                                "LC_MESSAGES",       &variables[VARIABLE_LC_MESSAGES],
+                                "LC_PAPER",          &variables[VARIABLE_LC_PAPER],
+                                "LC_NAME",           &variables[VARIABLE_LC_NAME],
+                                "LC_ADDRESS",        &variables[VARIABLE_LC_ADDRESS],
+                                "LC_TELEPHONE",      &variables[VARIABLE_LC_TELEPHONE],
+                                "LC_MEASUREMENT",    &variables[VARIABLE_LC_MEASUREMENT],
+                                "LC_IDENTIFICATION", &variables[VARIABLE_LC_IDENTIFICATION],
+                                NULL)) < 0) {
+
+		if (r != -ENOENT)
+			log_warning("Failed to read /etc/sysconfig/i18n: %s", strerror(-r));
+        }
+
 #endif
 
         if (!variables[VARIABLE_LANG]) {
diff --git a/src/quotacheck.c b/src/quotacheck.c
index 5d61146..5ced933 100644
--- a/src/quotacheck.c
+++ b/src/quotacheck.c
@@ -50,7 +50,7 @@ static int parse_proc_cmdline(void) {
                         arg_skip = true;
                 else if (startswith(w, "quotacheck.mode"))
                         log_warning("Invalid quotacheck.mode= parameter. Ignoring.");
-#ifdef TARGET_FEDORA
+#if defined(TARGET_FEDORA) || defined(TARGET_MANDRIVA)
                 else if (strneq(w, "forcequotacheck", l))
                         arg_force = true;
 #endif
@@ -61,8 +61,8 @@ static int parse_proc_cmdline(void) {
 }
 
 static void test_files(void) {
-#ifdef TARGET_FEDORA
-        /* This exists only on Fedora */
+#if defined(TARGET_FEDORA) || defined(TARGET_MANDRIVA)
+        /* This exists only on Fedora or Mandriva */
         if (access("/forcequotacheck", F_OK) >= 0)
                 arg_force = true;
 #endif
diff --git a/src/service.c b/src/service.c
index 8517579..5f606e6 100644
--- a/src/service.c
+++ b/src/service.c
@@ -275,7 +275,13 @@ static int sysv_translate_facility(const char *name, const char *filename, char
         static const char * const table[] = {
                 /* LSB defined facilities */
                 "local_fs",             SPECIAL_LOCAL_FS_TARGET,
+#ifndef TARGET_MANDRIVA
+		/* Due to unfortunate name selection in Mandriva,
+		 * $network is provided by network-up which is ordered
+		 * after network which actually starts interfaces.
+		 * To break the loop, just ignore it */
                 "network",              SPECIAL_NETWORK_TARGET,
+#endif
                 "named",                SPECIAL_NSS_LOOKUP_TARGET,
                 "portmap",              SPECIAL_RPCBIND_TARGET,
                 "remote_fs",            SPECIAL_REMOTE_FS_TARGET,
@@ -300,6 +306,13 @@ static int sysv_translate_facility(const char *name, const char *filename, char
 #ifdef TARGET_SUSE
                 "smtp",                 SPECIAL_MAIL_TRANSFER_AGENT_TARGET,
 #endif
+
+#ifdef TARGET_MANDRIVA
+                "exim",                 SPECIAL_MAIL_TRANSFER_AGENT_TARGET,
+                "masqmail",             SPECIAL_MAIL_TRANSFER_AGENT_TARGET,
+                "postfix",              SPECIAL_MAIL_TRANSFER_AGENT_TARGET,
+                "sendmail",             SPECIAL_MAIL_TRANSFER_AGENT_TARGET,
+#endif
         };
 
         unsigned i;
diff --git a/src/systemctl.c b/src/systemctl.c
index b733b47..19e810e 100644
--- a/src/systemctl.c
+++ b/src/systemctl.c
@@ -4038,7 +4038,7 @@ static int install_info_apply(const char *verb, LookupPaths *paths, InstallInfo
         }
 
         if (!f) {
-#if defined(TARGET_FEDORA) && defined (HAVE_SYSV_COMPAT)
+#if (defined(TARGET_FEDORA) || defined(TARGET_MANDRIVA)) && defined (HAVE_SYSV_COMPAT)
 
                 if (endswith(i->name, ".service")) {
                         char *sysv;
diff --git a/src/util.c b/src/util.c
index b02a77e..e5fc88f 100644
--- a/src/util.c
+++ b/src/util.c
@@ -3252,6 +3252,33 @@ void status_welcome(void) {
         if (!ansi_color)
                 const_color = "0;33"; /* Orange/Brown for Ubuntu */
 
+#elif defined(TARGET_MANDRIVA)
+
+	if (!pretty_name) {
+		char *s, *v = NULL, *p;
+
+		if ((r = read_one_line_file("/etc/mandriva-release", &s) < 0))
+			log_warning("Failed to read /etc/mandriva-release: %s", strerror(-r));
+		else {
+			p = strstr(s, " release ");
+			if (p) {
+				*p = '\0';
+				v = p += 9;
+				while (*p && *p != ' ')
+				p++;
+				*p = '\0';
+
+				/* This corresponds to standard rc.sysinit */
+				asprintf(&pretty_name,
+					"\x1B[1;36m%s\x1B[0;39m %s", s, v);
+				/* and fake it so colour is right */
+				const_color = "0";
+			} else
+				log_warning("Failed to parse /etc/mandriva-release");
+			free(s);
+		}
+	}
+
 #endif
 
         if (!pretty_name && !const_pretty)
diff --git a/src/vconsole-setup.c b/src/vconsole-setup.c
index 1952dfb..f142e8e 100644
--- a/src/vconsole-setup.c
+++ b/src/vconsole-setup.c
@@ -147,6 +147,9 @@ int main(int argc, char **argv) {
 #ifdef TARGET_GENTOO
         char *vc_unicode = NULL;
 #endif
+#ifdef TARGET_MANDRIVA
+	char *vc_keytable = NULL;
+#endif
         int fd = -1;
         bool utf8;
         int r = EXIT_FAILURE;
@@ -345,6 +348,58 @@ int main(int argc, char **argv) {
                         if (r != -ENOENT)
                                 log_warning("Failed to read /etc/conf.d/keymaps: %s", strerror(-r));
                 }
+
+#elif defined(TARGET_MANDRIVA)
+
+                if ((r = parse_env_file("/etc/sysconfig/i18n", NEWLINE,
+                                        "SYSFONT", &vc_font,
+                                        "SYSFONTACM", &vc_font_map,
+                                        "UNIMAP", &vc_font_unimap,
+                                        NULL)) < 0) {
+
+                        if (r != -ENOENT)
+                                log_warning("Failed to read /etc/sysconfig/i18n: %s", strerror(-r));
+                }
+
+		if ((r = parse_env_file("/etc/sysconfig/keyboard", NEWLINE,
+					"KEYTABLE", &vc_keytable,
+					"KEYMAP", &vc_keymap,
+					"UNIKEYTABLE", &vc_keymap,
+					"GRP_TOGGLE", &vc_keymap_toggle,
+					NULL)) < 0) {
+
+			if (r != -ENOENT)
+				log_warning("Failed to read /etc/sysconfig/i18n: %s", strerror(-r));
+		}
+
+		if (vc_keytable) {
+			if (vc_keymap)
+				free(vc_keymap);
+			if (utf8) {
+				if (endswith(vc_keytable, ".uni") || strstr(vc_keytable, ".uni."))
+					vc_keymap = strdup(vc_keytable);
+				else {
+					char *s;
+					if ((s = strstr(vc_keytable, ".map")))
+						vc_keytable[s-vc_keytable+1] = '\0';
+					vc_keymap = strappend(vc_keytable, ".uni");
+				}
+			} else
+				vc_keymap = strdup(vc_keytable);
+		}
+		free(vc_keytable);
+
+                if (access("/etc/sysconfig/console/default.kmap", F_OK) >= 0) {
+                        char *t;
+
+                        if (!(t = strdup("/etc/sysconfig/console/default.kmap"))) {
+                                log_error("Out of memory.");
+                                goto finish;
+                        }
+
+                        free(vc_keymap);
+                        vc_keymap = t;
+		}
 #endif
         }
 
diff --git a/units/fedora/prefdm.service b/units/fedora/prefdm.service
deleted file mode 100644
index e7bd123..0000000
--- a/units/fedora/prefdm.service
+++ /dev/null
@@ -1,20 +0,0 @@
-#  This file is part of systemd.
-#
-#  systemd is free software; you can redistribute it and/or modify it
-#  under the terms of the GNU General Public License as published by
-#  the Free Software Foundation; either version 2 of the License, or
-#  (at your option) any later version.
-
-[Unit]
-Description=Display Manager
-After=syslog.target livesys-late.service rc-local.service systemd-user-sessions.service
-
-# On Fedora gdm/X11 is on tty1. We explicitly cancel the getty here to
-# avoid any races around that.
-Conflicts=getty at tty1.service plymouth-quit.service
-After=getty at tty1.service plymouth-quit.service
-
-[Service]
-ExecStart=/etc/X11/prefdm -nodaemon
-Restart=always
-RestartSec=0
diff --git a/units/fedora/prefdm.service.m4 b/units/fedora/prefdm.service.m4
new file mode 100644
index 0000000..7cffcbe
--- /dev/null
+++ b/units/fedora/prefdm.service.m4
@@ -0,0 +1,31 @@
+#  This file is part of systemd.
+#
+#  systemd is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+
+[Unit]
+Description=Display Manager
+After=syslog.target livesys-late.service rc-local.service systemd-user-sessions.service
+m4_ifdef(`TARGET_MANDRIVA',
+`# These dependencies are in original SysV script that starts display manager
+After=network.target acpid.service lircmd.service fs.service haldaemon.service
+# Hide SysV script
+Names=dm.service')
+
+m4_ifdef(`TARGET_FEDORA',
+`# On Fedora gdm/X11 is on tty1. We explicitly cancel the getty here to
+# avoid any races around that.
+Conflicts=getty at tty1.service
+After=getty at tty1.service')
+Conflicts=plymouth-quit.service
+After=plymouth-quit.service
+
+[Service]
+m4_ifdef(`TARGET_FEDORA',
+`ExecStart=/etc/X11/prefdm -nodaemon',
+`ExecStart=/etc/X11/prefdm
+Type=forking')
+Restart=always
+RestartSec=0
diff --git a/units/getty at .service.m4 b/units/getty at .service.m4
index d282912..8e1f250 100644
--- a/units/getty at .service.m4
+++ b/units/getty at .service.m4
@@ -21,6 +21,9 @@ After=local.service
 m4_ifdef(`TARGET_ALTLINUX',
 After=rc-local.service
 )m4_dnl
+m4_ifdef(`TARGET_MANDRIVA',
+After=rc-local.service
+)m4_dnl
 
 # If additional gettys are spawned during boot then we should make
 # sure that this is synchronized before getty.target, even though
diff --git a/units/graphical.target.m4 b/units/graphical.target.m4
index e2750c8..1931d7f 100644
--- a/units/graphical.target.m4
+++ b/units/graphical.target.m4
@@ -23,6 +23,9 @@ Names=runlevel5.target
 m4_ifdef(`TARGET_ALTLINUX',
 Names=runlevel5.target
 )m4_dnl
+m4_ifdef(`TARGET_MANDRIVA',
+Names=runlevel5.target
+)m4_dnl
 AllowIsolate=yes
 
 [Install]
diff --git a/units/multi-user.target.m4 b/units/multi-user.target.m4
index 9df0142..51e7b66 100644
--- a/units/multi-user.target.m4
+++ b/units/multi-user.target.m4
@@ -29,6 +29,9 @@ m4_dnl On Debian/Ubuntu Runlevel 2, 3, 4 and 5 are multi-user
 Names=runlevel2.target runlevel3.target runlevel4.target runlevel5.target
 )m4_dnl
 )m4_dnl
+m4_ifdef(`TARGET_MANDRIVA',
+Names=runlevel3.target
+)m4_dnl
 AllowIsolate=yes
 
 [Install]
diff --git a/units/rescue.service.m4 b/units/rescue.service.m4
index 2a0d328..8b42e9f 100644
--- a/units/rescue.service.m4
+++ b/units/rescue.service.m4
@@ -13,6 +13,9 @@ DefaultDependencies=no
 Conflicts=shutdown.target
 After=basic.target
 Before=shutdown.target
+m4_ifdef(`TARGET_MANDRIVA',
+`# Hide SysV script
+Names=single.service')
 
 [Service]
 Environment=HOME=/root
@@ -22,7 +25,10 @@ ExecStartPre=-/bin/echo 'Welcome to rescue mode. Use "systemctl default" or ^D t
 m4_ifdef(`TARGET_FEDORA',
 `EnvironmentFile=/etc/sysconfig/init
 ExecStart=-/bin/bash -c "exec ${SINGLE}"',
-`ExecStart=-/sbin/sulogin')
+m4_ifdef(`TARGET_MANDRIVA',
+`EnvironmentFile=/etc/sysconfig/init
+ExecStart=-/bin/bash -c "exec ${SINGLE}"',
+`ExecStart=-/sbin/sulogin'))
 ExecStopPost=-/bin/systemctl --fail default
 StandardInput=tty-force
 KillMode=process-group
diff --git a/units/serial-getty at .service.m4 b/units/serial-getty at .service.m4
index 2b3c8ed..d42330a 100644
--- a/units/serial-getty at .service.m4
+++ b/units/serial-getty at .service.m4
@@ -21,6 +21,9 @@ After=local.service
 m4_ifdef(`TARGET_ALTLINUX',
 After=rc-local.service
 )m4_dnl
+m4_ifdef(`TARGET_MANDRIVA',
+After=rc-local.service
+)m4_dnl
 
 # If additional gettys are spawned during boot then we should make
 # sure that this is synchronized before getty.target, even though
-- 
tg: (f1779fd..) upstream/mandriva (depends on: origin/master)


More information about the systemd-devel mailing list