#!/usr/bin/python
import asyncio
+import configparser
import datetime
+import io
import logging
import os.path
"mirrorlist?arch=%{arch}"
))
- def get_config(self, local=False):
- lines = [
- "[repo:%s]" % self.slug,
- "description = %s - %s" % (self.distro.name, self.summary),
- "enabled = 1",
- "baseurl = %s/%%{arch}" % (self.path if local else self.url),
+ def _make_config(self, local=False):
+ buffer = io.StringIO()
+ config = configparser.ConfigParser()
- # Key
- "key = %s/keys/%s" % (
- self.settings.get("baseurl", "https://pakfire.ipfire.org"),
- self.key.fingerprint,
- ),
- ]
+ section = "repo:%s" % self.slug
+ # Add a new section
+ config.add_section(section)
+
+ # Description
+ config.set(section, "description", "%s - %s" % (self.distro.name, self.summary))
+
+ # Base URL
+ config.set(section, "baseurl", self.path if local else self.url)
+
+ # Key
+ config.set(section, "key", self.key.public_key)
+
+ # Mirrorlist
if self.mirrored and not local:
- lines.append("mirrors = %s" % self.mirrorlist)
+ config.set(section, "mirrors", self.mirrorlist)
+ # Priority
if self.priority:
- lines.append("priority = %s" % self.priority)
+ config.set(section, "priority", "%s" % self.priority)
+
+ # Write the configuration
+ config.write(buffer)
- return "\n".join(lines)
+ return buffer.getvalue()
# Name