From 5286089bbdc3bdaa15a4f6846bae7f4a56eb18bc Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sun, 22 Oct 2017 19:10:19 +0100 Subject: [PATCH] jobs: Allow getting a local repository configuration Signed-off-by: Michael Tremer --- src/buildservice/jobs.py | 17 ++++------------- src/buildservice/repository.py | 30 ++++++++++++++++++------------ 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/src/buildservice/jobs.py b/src/buildservice/jobs.py index 7de4125..e0ddcd8 100644 --- a/src/buildservice/jobs.py +++ b/src/buildservice/jobs.py @@ -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) diff --git a/src/buildservice/repository.py b/src/buildservice/repository.py index 0a3636d..de50da0 100644 --- a/src/buildservice/repository.py +++ b/src/buildservice/repository.py @@ -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), -- 2.47.3