From: Michael Tremer Date: Sun, 13 Feb 2011 11:54:01 +0000 (+0100) Subject: Add local build repository to store built packages. X-Git-Tag: 0.9.3~180 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0ec833c6a681abd0853089bc2c4900ef570820a5;p=pakfire.git Add local build repository to store built packages. --- diff --git a/pakfire/__init__.py b/pakfire/__init__.py index ea7a59775..543b097fb 100644 --- a/pakfire/__init__.py +++ b/pakfire/__init__.py @@ -96,19 +96,28 @@ class Pakfire(object): raise BuildError, arch - def build(self, pkg, arch=None, resultdir=None): + def build(self, pkg, arch=None, resultdirs=None): self.check_build_mode() self.check_host_arch(arch) + if not resultdirs: + resultdirs = [] + + # Always include local repository + resultdirs.append(self.repos.local_build.path) + b = builder.Builder(pakfire=self, pkg=pkg) b.extract() - if not resultdir: - resultdir = self.config.get("resultdir") - try: b.build() - b.copy_result(resultdir) + + # Copy-out all resultfiles + for resultdir in resultdirs: + if not resultdir: + continue + + b.copy_result(resultdir) finally: b.cleanup() diff --git a/pakfire/cli.py b/pakfire/cli.py index a7e09f844..e1c6932a9 100644 --- a/pakfire/cli.py +++ b/pakfire/cli.py @@ -299,7 +299,7 @@ class CliBuilder(Cli): # XXX walk through the source tree and find a matching makefile pass - self.pakfire.build(pkg, arch=self.args.arch, resultdir=self.args.resultdir) + self.pakfire.build(pkg, arch=self.args.arch, resultdirs=[self.args.resultdir,]) def handle_shell(self): print self.args diff --git a/pakfire/config.py b/pakfire/config.py index 921cb284c..e86a4137c 100644 --- a/pakfire/config.py +++ b/pakfire/config.py @@ -17,6 +17,7 @@ class Config(object): "debug" : True, "logfile" : "/var/log/pakfire.log", "source_download_url" : SOURCE_DOWNLOAD_URL, + "local_build_repo_path" : LOCAL_BUILD_REPO_PATH, } self._config_repos = {} diff --git a/pakfire/constants.py b/pakfire/constants.py index 326777b57..7562d6404 100644 --- a/pakfire/constants.py +++ b/pakfire/constants.py @@ -8,6 +8,7 @@ CONFIG_DIR = os.path.join(SYSCONFDIR, "pakfire.repos.d") CONFIG_FILE = os.path.join(SYSCONFDIR, "pakfire.conf") CACHE_DIR = "/var/cache/pakfire" +LOCAL_BUILD_REPO_PATH = "/var/lib/pakfire/local" PACKAGES_DB = "var/lib/pakfire/packages.db" REPOSITORY_DB = "index.db" diff --git a/pakfire/repository.py b/pakfire/repository.py index c0a2b66e4..c884a637a 100644 --- a/pakfire/repository.py +++ b/pakfire/repository.py @@ -36,6 +36,11 @@ class Repositories(object): self.local = LocalRepository(self.pakfire) self.add_repo(self.local) + # If we running in build mode, we include our local build repository. + if self.pakfire.build: + self.local_build = LocalBuildRepository(self.pakfire) + self.add_repo(self.local_build) + for repo_name, repo_args in self.config.get_repos(): self._parse(repo_name, repo_args) @@ -239,6 +244,20 @@ class LocalRepository(RepositoryFactory): # XXX need to implement better get_by_name +class LocalBuildRepository(LocalRepository): + def __init__(self, pakfire): + RepositoryFactory.__init__(self, pakfire, "build", "Locally built packages") + + self.path = self.pakfire.config.get("local_build_repo_path") + if not os.path.exists(self.path): + os.makedirs(self.path) + + self.index = index.DirectoryIndex(self.pakfire, self, self.path) + + @property + def priority(self): + return 20000 + class RemoteRepository(RepositoryFactory): def __init__(self, pakfire, name, description, url, gpgkey, enabled):