]> git.ipfire.org Git - people/jschlag/pbs.git/commitdiff
jobs: Allow getting a local repository configuration
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 22 Oct 2017 18:10:19 +0000 (19:10 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 22 Oct 2017 18:10:19 +0000 (19:10 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/jobs.py
src/buildservice/repository.py

index 7de41256f49dc30cb48af161616f0f03b050f122..e0ddcd819018e295e20fbd1fe8f3c9b45d002b5c 100644 (file)
@@ -675,18 +675,7 @@ class Job(base.DataObject):
 
                return repos or self.distro.get_build_repos()
 
-       def get_repo_config(self):
-               """
-                       Get repository configuration file that is sent to the builder.
-               """
-               confs = []
-
-               for repo in self.get_build_repos():
-                       confs.append(repo.get_conf())
-
-               return "\n\n".join(confs)
-
-       def get_config(self):
+       def get_config(self, local=False):
                """
                        Get configuration file that is sent to the builder.
                """
@@ -696,7 +685,9 @@ class Job(base.DataObject):
                confs.append(self.distro.get_config())
 
                # Then add all repositories for this build.
-               confs.append(self.get_repo_config())
+               for repo in self.get_build_repos():
+                       conf = repo.get_conf(local=local)
+                       confs.append(conf)
 
                return "\n\n".join(confs)
 
index 0a3636d0c741febba1ae6bb1bc0d923dad363888..de50da002e900ff3c798ab0fe879a3bf77fc89fb 100644 (file)
@@ -137,36 +137,42 @@ class Repository(base.DataObject):
                }
 
        @property
-       def url(self):
-               url = os.path.join(
-                       self.settings.get("repository_baseurl", "http://pakfire.ipfire.org/repositories/"),
+       def basepath(self):
+               return "/".join((
                        self.distro.identifier,
                        self.identifier,
+               ))
+
+       @property
+       def path(self):
+               return os.path.join(REPOS_DIR, self.basepath, "%{arch}")
+
+       @property
+       def url(self):
+               return os.path.join(
+                       self.settings.get("repository_baseurl", "http://pakfire.ipfire.org/repositories/"),
+                       self.basepath,
                        "%{arch}"
                )
 
-               return url
-
        @property
        def mirrorlist(self):
-               url = os.path.join(
+               return os.path.join(
                        self.settings.get("mirrorlist_baseurl", "https://pakfire.ipfire.org/"),
                        "distro", self.distro.identifier,
                        "repo", self.identifier,
                        "mirrorlist?arch=%{arch}"
                )
 
-               return url
-
-       def get_conf(self):
+       def get_conf(self, local=False):
                lines = [
                        "[repo:%s]" % self.identifier,
                        "description = %s - %s" % (self.distro.name, self.summary),
                        "enabled = 1",
-                       "baseurl = %s" % self.url,
+                       "baseurl = %s" % (self.path if local else self.url),
                ]
 
-               if self.mirrored:
+               if self.mirrored and not local:
                        lines.append("mirrors = %s" % self.mirrorlist)
 
                if self.priority:
@@ -487,7 +493,7 @@ class RepositoryAux(base.DataObject):
        def distro(self):
                return self.pakfire.distros.get_by_id(self.data.distro_id)
 
-       def get_conf(self):
+       def get_conf(self, local=False):
                lines = [
                        "[repo:%s]" % self.identifier,
                        "description = %s - %s" % (self.distro.name, self.name),