]> err.no Git - systemd/commitdiff
build-sys: add Mandriva distribution support v20
authorAndrey Borzenkov <arvidjaar@gmail.com>
Tue, 8 Mar 2011 18:47:29 +0000 (19:47 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 8 Mar 2011 18:47:36 +0000 (19:47 +0100)
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

16 files changed:
Makefile.am
configure.ac
src/fsck.c
src/hostname-setup.c
src/locale-setup.c
src/quotacheck.c
src/service.c
src/systemctl.c
src/util.c
src/vconsole-setup.c
units/getty@.service.m4
units/graphical.target.m4
units/mandriva/prefdm.service [new file with mode: 0644]
units/multi-user.target.m4
units/rescue.service.m4
units/serial-getty@.service.m4

index 8d34dab8d9a5d51271b9d0ea2e9327f207b4eac8..4caa2433b1ce6e6b10b79c660d60928b30c7220c 100644 (file)
@@ -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 \
@@ -337,6 +344,13 @@ dist_systemunit_DATA += \
        units/fedora/halt-local.service
 endif
 
+if TARGET_MANDRIVA
+dist_systemunit_DATA += \
+       units/mandriva/prefdm.service \
+       units/fedora/rc-local.service \
+       units/fedora/halt-local.service
+endif
+
 if HAVE_PLYMOUTH
 dist_systemunit_DATA += \
        units/plymouth-start.service \
@@ -1357,6 +1371,23 @@ if TARGET_FEDORA
                rm -f display-manager.service && \
                $(LN_S) $(systemunitdir)/display-manager.service display-manager.service )
 endif
+
+if TARGET_MANDRIVA
+       $(MKDIR_P) -m 0755 $(DESTDIR)$(systemunitdir)/final.target.wants
+       ( cd $(DESTDIR)$(systemunitdir)/multi-user.target.wants && \
+               rm -f rc-local.service && \
+               $(LN_S) $(systemunitdir)/rc-local.service rc-local.service )
+       ( cd $(DESTDIR)$(systemunitdir)/final.target.wants && \
+               rm -f halt-local.service && \
+               $(LN_S) $(systemunitdir)/halt-local.service halt-local.service )
+       ( cd $(DESTDIR)$(systemunitdir) && \
+               rm -f display-manager.service && \
+               $(LN_S) prefdm.service display-manager.service )
+       ( cd $(DESTDIR)$(systemunitdir)/graphical.target.wants && \
+               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 && \
index 097718eec1670cc92d923ef5cb97c7507a27596a..cae2dce367ef2451c82eba1d338a5e790b8b9f7a 100644 (file)
@@ -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,7 @@ 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(HAVE_PLYMOUTH, test -n "$have_plymouth")
 
index 7855f3ac071cd0d094065deab2ce135f36bb56ff..dbfb47517fedbbf2da1d8cf610664cfa47b0511a 100644 (file)
@@ -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))
index 8b0ff793847ee78ecec438009cff10ba15314d96..ef68d783953d3e2fc8894f8c6db996d058651258 100644 (file)
@@ -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;
 
index 2360cea85bac7e4bc22e254f9614742edb285d49..7684681cca64c926d600f3c2252d9a715ef21c61 100644 (file)
@@ -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]) {
index 5d61146d9325e607a8d193b58c3b618f26af2138..5ced93318e8f7fde69c3d00dc340366e199f89d0 100644 (file)
@@ -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
index e99dfcd4a2c428843386dc081aafa9207569e0ec..70999f354511bc89962d06339c7c2ecb16f887a7 100644 (file)
@@ -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,
index 23e659756f8e84fd75236d83295c7a2365749eec..63e74d904a93d0cceac7c3ac3d80fd17080b3b70 100644 (file)
@@ -4042,7 +4042,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;
index b02a77eed8ab65e144cbf557e12a5974e0ec880c..96cf6605f3c5f8b2335c03517ecbaa0b9c8832ac 100644 (file)
@@ -3252,6 +3252,32 @@ void status_welcome(void) {
         if (!ansi_color)
                 const_color = "0;33"; /* Orange/Brown for Ubuntu */
 
+#elif defined(TARGET_MANDRIVA)
+
+        if (!pretty_name) {
+                char *s, *p;
+
+                if ((r = read_one_line_file("/etc/mandriva-release", &s) < 0)) {
+                        if (r != -ENOENT)
+                                log_warning("Failed to read /etc/mandriva-release: %s", strerror(-r));
+                } else {
+                        p = strstr(s, " release ");
+                        if (p) {
+                                *p = '\0';
+                                p += 9;
+                                p[strcspn(p, " ")] = '\0';
+
+                                /* This corresponds to standard rc.sysinit */
+                                if (asprintf(&pretty_name, "%s\x1B[0;39m %s", s, p) > 0)
+                                        const_color = "1;36";
+                                else
+                                        log_warning("Failed to allocate Mandriva version string.");
+                        } else
+                                log_warning("Failed to parse /etc/mandriva-release");
+                        free(s);
+                }
+        }
+
 #endif
 
         if (!pretty_name && !const_pretty)
index 1952dfb0f154b0bd11fc6b363c972b8db31f6f73..5b977126faefb352601ca892cb256efd4f676c55 100644 (file)
@@ -146,6 +146,9 @@ int main(int argc, char **argv) {
         char *vc_font_unimap = NULL;
 #ifdef TARGET_GENTOO
         char *vc_unicode = NULL;
+#endif
+#ifdef TARGET_MANDRIVA
+        char *vc_keytable = NULL;
 #endif
         int fd = -1;
         bool utf8;
@@ -345,6 +348,64 @@ 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 (!vc_keymap) {
+                                log_error("Out of memory.");
+                                goto finish;
+                        }
+                }
+
+                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
         }
 
index d282912274110b6cb80cc1801ad8167670d808ca..8e1f250ad0080d6ece211284c9d6d132307f03ff 100644 (file)
@@ -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
index e2750c8640138df1c43d13361f49a5796af0e2fc..1931d7f9860107376cbbd1bf76d3b912b100dd2d 100644 (file)
@@ -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/mandriva/prefdm.service b/units/mandriva/prefdm.service
new file mode 100644 (file)
index 0000000..43b505d
--- /dev/null
@@ -0,0 +1,24 @@
+#  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
+After=network.target acpid.service fs.service haldaemon.service
+
+# Do not stop plymouth, it is done in prefdm if required
+Conflicts=plymouth-quit.service
+After=plymouth-quit.service
+
+# Hide SysV script
+Names=dm.service
+
+[Service]
+ExecStart=/etc/X11/prefdm
+Type=forking
+Restart=always
+RestartSec=0
index 9df01424465cdec9816c5366f75911706fcb3a89..51e7b6664cfaa4c9ae5a1eb9bee38edcf5c2adce 100644 (file)
@@ -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]
index 2a0d3280ecebd729bd57ec0b76886e6cca36c9c7..8b42e9f690c75fbde95099b3d9ea0ad70038ef23 100644 (file)
@@ -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
index 2b3c8edd57a6bfa3faab7be35f3c5debf90c72e3..d42330a1ad6cd96505542e7118a77118493a6175 100644 (file)
@@ -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