def preInstall(self, packages=None, groups=None):
        super(DNFPayload, self).preInstall(packages, groups)
        self.requiredPackages += ["dnf"]
        if packages:
            self.requiredPackages += packages
        self.requiredGroups = groups

        # Write the langpacks config
        pyanaconda.iutil.mkdirChain(DNF_PLUGINCONF_DIR)
        langs = [self.data.lang.lang] + self.data.lang.addsupport

        # Start with the file in /etc, if one exists. Otherwise make an empty config
        if os.path.exists(_DNF_TARGET_LANGPACK_CONF):
            shutil.copy2(_DNF_TARGET_LANGPACK_CONF,
                         _DNF_INSTALLER_LANGPACK_CONF)
        else:
            with open(_DNF_INSTALLER_LANGPACK_CONF, "w") as f:
                f.write("[main]\n")

        # langpacks.conf is an INI style config file, read it and
        # add or change the enabled and langpack_locales entries without
        # changing anything else.
        keys = [("langpack_locales", "langpack_locales=" + ", ".join(langs)),
                ("enabled", "enabled=1")]
        simple_replace(_DNF_INSTALLER_LANGPACK_CONF, keys)
Ejemplo n.º 2
0
    def append_test(self):
        with tempfile.NamedTemporaryFile(mode="wt") as testconfig:
            testconfig.write(self.TEST_CONFIG)
            testconfig.flush()

            keys = [("NEWKEY", "NEWKEY=froboz")]
            simple_replace(testconfig.name, keys)

            config = SimpleConfigFile(testconfig.name)
            config.read()
            self.assertEqual(config.get("NEWKEY"), "froboz")
Ejemplo n.º 3
0
    def replace_test(self):
        with tempfile.NamedTemporaryFile(mode="wt") as testconfig:
            testconfig.write(self.TEST_CONFIG)
            testconfig.flush()

            keys = [("BOOT", "BOOT=never")]
            simple_replace(testconfig.name, keys)

            config = SimpleConfigFile(testconfig.name)
            config.read()
            self.assertEqual(config.get("BOOT"), "never")
Ejemplo n.º 4
0
    def append_test(self):
        with tempfile.NamedTemporaryFile(mode="wt") as testconfig:
            testconfig.write(self.TEST_CONFIG)
            testconfig.flush()

            keys = [("NEWKEY", "NEWKEY=froboz")]
            simple_replace(testconfig.name, keys)

            config = SimpleConfigFile(testconfig.name)
            config.read()
            self.assertEqual(config.get("NEWKEY"), "froboz")
Ejemplo n.º 5
0
    def replace_test(self):
        with tempfile.NamedTemporaryFile(mode="wt") as testconfig:
            testconfig.write(self.TEST_CONFIG)
            testconfig.flush()

            keys = [("BOOT", "BOOT=never")]
            simple_replace(testconfig.name, keys)

            config = SimpleConfigFile(testconfig.name)
            config.read()
            self.assertEqual(config.get("BOOT"), "never")
Ejemplo n.º 6
0
    def no_append_test(self):
        with tempfile.NamedTemporaryFile(mode="wt") as testconfig:
            testconfig.write(self.TEST_CONFIG)
            testconfig.flush()

            keys = [("BOOT", "BOOT=sometimes"), ("NEWKEY", "NEWKEY=froboz")]
            simple_replace(testconfig.name, keys, add=False)

            config = SimpleConfigFile(testconfig.name)
            config.read()
            self.assertEqual(config.get("BOOT"), "sometimes")
            self.assertEqual(config.get("NEWKEY"), "")
Ejemplo n.º 7
0
    def no_append_test(self):
        with tempfile.NamedTemporaryFile(mode="wt") as testconfig:
            testconfig.write(self.TEST_CONFIG)
            testconfig.flush()

            keys = [("BOOT", "BOOT=sometimes"), ("NEWKEY", "NEWKEY=froboz")]
            simple_replace(testconfig.name, keys, add=False)

            config = SimpleConfigFile(testconfig.name)
            config.read()
            self.assertEqual(config.get("BOOT"), "sometimes")
            self.assertEqual(config.get("NEWKEY"), "")
Ejemplo n.º 8
0
    def preInstall(self, packages=None, groups=None):
        super(DNFPayload, self).preInstall(packages, groups)
        self.requiredPackages += ["dnf"]
        if packages:
            self.requiredPackages += packages
        self.requiredGroups = groups

        # Write the langpacks config
        pyanaconda.iutil.mkdirChain(DNF_PLUGINCONF_DIR)
        langs = [self.data.lang.lang] + self.data.lang.addsupport

        # Start with the file in /etc, if one exists. Otherwise make an empty config
        if os.path.exists(_DNF_TARGET_LANGPACK_CONF):
            shutil.copy2(_DNF_TARGET_LANGPACK_CONF, _DNF_INSTALLER_LANGPACK_CONF)
        else:
            with open(_DNF_INSTALLER_LANGPACK_CONF, "w") as f:
                f.write("[main]\n")

        # langpacks.conf is an INI style config file, read it and
        # add or change the enabled and langpack_locales entries without
        # changing anything else.
        keys = [("langpack_locales", "langpack_locales=" + ", ".join(langs)), ("enabled", "enabled=1")]
        simple_replace(_DNF_INSTALLER_LANGPACK_CONF, keys)