]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
always use /etc/os-release and ignore all distro-specific files
authorKay Sievers <kay.sievers@vrfy.org>
Mon, 13 Feb 2012 00:46:44 +0000 (01:46 +0100)
committerKay Sievers <kay.sievers@vrfy.org>
Mon, 13 Feb 2012 00:51:51 +0000 (01:51 +0100)
The text mode welcome message will only show the distro name stored
in /etc/os-release and no longer read any distro-specific files.  If
/etc/os-release does not exist, 'Linux' will be printed.

When the source tree is is ./configure'd, only /etc-os-release is read
to guess the distro to build for. If /etc/os-release does not exist,
--with-distro= needs to be specified.

configure.ac
src/util.c

index bef2418ed73d8982e90fa8670bc4a2d901e306bf..d95f22dfcc677d073610b9bc7f748fe7028e3cb0 100644 (file)
@@ -45,6 +45,7 @@ AC_SUBST(GETTEXT_PACKAGE)
 AC_PROG_MKDIR_P
 AC_PROG_LN_S
 AC_PROG_SED
+AC_PROG_GREP
 AC_PROG_AWK
 
 AC_PROG_CC
@@ -394,29 +395,15 @@ AM_CONDITIONAL(HAVE_XSLTPROC, test x"$XSLTPROC" != x)
 
 AC_PATH_PROG([M4], [m4])
 
-AC_ARG_WITH(distro, AS_HELP_STRING([--with-distro=DISTRO],[Specify the distribution to target: One of fedora, suse, debian, ubuntu, arch, gentoo, slackware, altlinux or other]))
+AC_ARG_WITH(distro, AS_HELP_STRING([--with-distro=DISTRO],[Specify the distribution to target: One of fedora, suse, debian, ubuntu, arch, gentoo, slackware, altlinuxi, mandriva, meego, mageia, angstrom or other]))
 if test "z$with_distro" = "z"; then
         if test "$cross_compiling" = yes; then
                 AC_MSG_WARN([Target distribution cannot be reliably detected when cross-compiling. You should specify it with --with-distro (see $0 --help for recognized distros)])
         else
-                test -f "/etc/redhat-release" && with_distro="fedora"
-                test -f "/etc/SuSE-release" && with_distro="suse"
-                test -f "/etc/debian_version" &&  with_distro="debian"
-                test -f "/etc/arch-release" && with_distro="arch"
-                test -f "/etc/gentoo-release" && with_distro="gentoo"
-                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"
-                test -f "/etc/meego-release" && with_distro="meego"
-                test -f "/etc/angstrom-version" && with_distro="angstrom"
-                test -f "/etc/mageia-release" && with_distro="mageia"
-                if test "x`lsb_release -is 2>/dev/null`" = "xUbuntu"; then
-                        with_distro="ubuntu"
-                fi
+                with_distro=$($GREP '^ID=' /etc/os-release | $SED 's/ID=//');
         fi
         if test "z$with_distro" = "z"; then
-                with_distro=`uname -s`
+                with_distro=other
         fi
 fi
 with_distro=`echo ${with_distro} | tr '[[:upper:]]' '[[:lower:]]' `
@@ -436,7 +423,7 @@ case $with_distro in
                 M4_DEFINES=-DTARGET_FEDORA=1
                 have_plymouth=yes
                 ;;
-        suse)
+        opensuse|suse)
                 SYSTEM_SYSVRCND_PATH=/etc/init.d
                 AC_DEFINE(TARGET_SUSE, [], [Target is openSUSE/SLE])
                 M4_DEFINES=-DTARGET_SUSE=1
index 33299229bfb4926bf9a2c795689baa2beeb9da79..e9869ea4fad3bfd3695d41a6de7059db6deedfed 100644 (file)
@@ -3788,139 +3788,6 @@ void status_welcome(void) {
                         log_warning("Failed to read /etc/os-release: %s", strerror(-r));
         }
 
-#if defined(TARGET_FEDORA)
-        if (!pretty_name) {
-                if ((r = read_one_line_file("/etc/system-release", &pretty_name)) < 0) {
-
-                        if (r != -ENOENT)
-                                log_warning("Failed to read /etc/system-release: %s", strerror(-r));
-                }
-        }
-
-        if (!ansi_color && pretty_name) {
-
-                /* This tries to mimic the color magic the old Red Hat sysinit
-                 * script did. */
-
-                if (startswith(pretty_name, "Red Hat"))
-                        const_color = "0;31"; /* Red for RHEL */
-                else if (startswith(pretty_name, "Fedora"))
-                        const_color = "0;34"; /* Blue for Fedora */
-        }
-
-#elif defined(TARGET_SUSE)
-
-        if (!pretty_name) {
-                if ((r = read_one_line_file("/etc/SuSE-release", &pretty_name)) < 0) {
-
-                        if (r != -ENOENT)
-                                log_warning("Failed to read /etc/SuSE-release: %s", strerror(-r));
-                }
-        }
-
-        if (!ansi_color)
-                const_color = "0;32"; /* Green for openSUSE */
-
-#elif defined(TARGET_GENTOO)
-
-        if (!pretty_name) {
-                if ((r = read_one_line_file("/etc/gentoo-release", &pretty_name)) < 0) {
-
-                        if (r != -ENOENT)
-                                log_warning("Failed to read /etc/gentoo-release: %s", strerror(-r));
-                }
-        }
-
-        if (!ansi_color)
-                const_color = "1;34"; /* Light Blue for Gentoo */
-
-#elif defined(TARGET_ALTLINUX)
-
-        if (!pretty_name) {
-                if ((r = read_one_line_file("/etc/altlinux-release", &pretty_name)) < 0) {
-
-                        if (r != -ENOENT)
-                                log_warning("Failed to read /etc/altlinux-release: %s", strerror(-r));
-                }
-        }
-
-        if (!ansi_color)
-                const_color = "0;36"; /* Cyan for ALTLinux */
-
-
-#elif defined(TARGET_DEBIAN)
-
-        if (!pretty_name) {
-                char *version;
-
-                if ((r = read_one_line_file("/etc/debian_version", &version)) < 0) {
-
-                        if (r != -ENOENT)
-                                log_warning("Failed to read /etc/debian_version: %s", strerror(-r));
-                } else {
-                        pretty_name = strappend("Debian ", version);
-                        free(version);
-
-                        if (!pretty_name)
-                                log_warning("Failed to allocate Debian version string.");
-                }
-        }
-
-        if (!ansi_color)
-                const_color = "1;31"; /* Light Red for Debian */
-
-#elif defined(TARGET_UBUNTU)
-
-        if ((r = parse_env_file("/etc/lsb-release", NEWLINE,
-                                "DISTRIB_DESCRIPTION", &pretty_name,
-                                NULL)) < 0) {
-
-                if (r != -ENOENT)
-                        log_warning("Failed to read /etc/lsb-release: %s", strerror(-r));
-        }
-
-        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);
-                }
-        }
-#elif defined(TARGET_MEEGO)
-
-        if (!pretty_name) {
-                if ((r = read_one_line_file("/etc/meego-release", &pretty_name)) < 0) {
-
-                        if (r != -ENOENT)
-                                log_warning("Failed to read /etc/meego-release: %s", strerror(-r));
-                }
-        }
-
-       if (!ansi_color)
-               const_color = "1;35"; /* Bright Magenta for MeeGo */
-#endif
-
         if (!pretty_name && !const_pretty)
                 const_pretty = "Linux";