]> git.ipfire.org Git - pakfire.git/commitdiff
system: Add host distro
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 3 Dec 2016 19:16:17 +0000 (20:16 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 3 Dec 2016 19:16:17 +0000 (20:16 +0100)
The system module loads details about the host's distribution
which will be used by Pakfire if nothing else is configured.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/base.py
src/pakfire/system.py

index acd07a21945fd090a4969a5d1ba2d575b64b6329..aa9bdafd423e0c48bd514382ee1dd2ca3bb1341b 100644 (file)
@@ -46,13 +46,16 @@ from .i18n import _
 class Pakfire(object):
        mode = None
 
-       def __init__(self, path="/", arch=None):
+       def __init__(self, path="/", arch=None, distro=None):
                # The path where we are operating in
                self.path = path
 
                # Default to system architecture
                self.arch = arch or system.arch
 
+               # Default to system distribution
+               self.distro = distro or system.distro
+
                # Check if we are operating as the root user
                self.check_root_user()
 
@@ -66,10 +69,6 @@ class Pakfire(object):
                # Initialize the keyring
                self.keyring = keyring.Keyring(self)
 
-               # Get more information about the distribution we are running
-               # or building
-               self.distro = distro.Distribution(self.config.get("distro"))
-
                self.pool = satsolver.Pool(self.arch.name)
                self.repos = repository.Repositories(self)
 
index 1c4b6dc950f5f7210a1f4c2071d25bddbb68dead..f64cd82f1d7de06e9ea66dfb0e628d8508c8665d 100644 (file)
@@ -25,6 +25,7 @@ import socket
 import tempfile
 
 from . import arch
+from . import distro
 from . import shell
 
 from . import _pakfire
@@ -37,8 +38,12 @@ class System(object):
                the system this software is running on.
        """
        def __init__(self):
+               # Load the system's native architecture
                self.arch = arch.Arch(self.native_arch)
 
+               # Load the system's distribution
+               self.distro = distro.Distribution()
+
        @property
        def hostname(self):
                hn = socket.gethostname()
@@ -49,14 +54,6 @@ class System(object):
 
                return hn
 
-       @property
-       def distro(self):
-               if not hasattr(self, "_distro"):
-                       from . import distro
-                       self._distro = distro.Distribution()
-
-               return self._distro
-
        @property
        def native_arch(self):
                """