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)
    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")
    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")
    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")
    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")
    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"), "")
    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"), "")
Beispiel #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)