]> git.ipfire.org Git - people/ms/bricklayer.git/commitdiff
Read /etc/os-release to fetch release information
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 5 May 2021 21:57:10 +0000 (21:57 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 5 May 2021 21:57:10 +0000 (21:57 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/python/__init__.py
src/python/step.py
src/python/util.py [new file with mode: 0644]

index 03ceaacd3a688ddb811bf428e4f6834b5f7e46a2..4993ee83760e6db5807790de2276ee11b63267d8 100644 (file)
@@ -50,7 +50,8 @@ dist_pkgpython_PYTHON = \
        src/python/i18n.py \
        src/python/lang.py \
        src/python/logger.py \
-       src/python/step.py
+       src/python/step.py \
+       src/python/util.py
 
 pkgpython_tuidir = $(pkgpythondir)/tui
 
index 2e1ed7b388589d5c7af26fd2edfc47999de970d0..69373d49fc9ecedf9f96c80177dc8104f982f069 100644 (file)
@@ -27,6 +27,7 @@ from . import lang
 from . import logger
 from . import step
 from . import tui
+from . import util
 from .i18n import _
 from .errors import *
 
@@ -50,6 +51,9 @@ class Bricklayer(object):
                        "language" : lang.default_language,
                }
 
+               # Read OS information
+               self.os = self._read_os_release()
+
                # Hardware
                self.disks = disk.Disks(self)
 
@@ -112,3 +116,10 @@ class Bricklayer(object):
 
                # Run it
                return step.run(self.tui)
+
+       def _read_os_release(self):
+               """
+                       Read /etc/os-release
+               """
+               with open("/etc/os-release") as f:
+                       return util.config_read(f)
index 7368c1563d62d7ffa8a47d734e0a8cb60ceae36b..db9340c40f543e00de85838b153cb47f89e601a0 100644 (file)
@@ -72,10 +72,13 @@ class Welcome(InteractiveStep):
                Shows a very warm welcome message to the user
        """
        def run(self, tui):
+               name = self.bricklayer.os.get("NAME")
+
                tui.message(
                        title=_("Welcome"),
                        text=_("Welcome to the %s installation program.\n\n"
-                               "Selecting Cancel on any of the following screens will reboot the computer."),
+                               "Selecting Cancel on any of the following screens will reboot the "
+                               "computer.") % name,
                        buttons=(_("Start Installation"), _("Cancel"))
                )
 
diff --git a/src/python/util.py b/src/python/util.py
new file mode 100644 (file)
index 0000000..f5d26fb
--- /dev/null
@@ -0,0 +1,42 @@
+###############################################################################
+#                                                                             #
+# Bricklayer - An Installer for IPFire                                        #
+# Copyright (C) 2021 IPFire Development Team                                  #
+#                                                                             #
+# This program 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.                      #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
+
+def config_read(f):
+       """
+               Read a configuration file in key/value format
+       """
+       res = {}
+
+       # Read lines and split them by key/value
+       for line in f:
+               # Strip any trailing newline
+               line = line.rstrip()
+
+               # Split key/value
+               key, delim, value = line.partition("=")
+
+               # Unquote value
+               if value and value[0] == "\"" and value[-1] == "\"":
+                       value = value[1:-1]
+
+               # Store the value
+               res[key] = value
+
+       return res