]> git.ipfire.org Git - pakfire.git/commitdiff
Add local build repository to store built packages.
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 13 Feb 2011 11:54:01 +0000 (12:54 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 13 Feb 2011 11:54:01 +0000 (12:54 +0100)
pakfire/__init__.py
pakfire/cli.py
pakfire/config.py
pakfire/constants.py
pakfire/repository.py

index ea7a59775084e00f0316551928010b22927070ab..543b097fb22608a0d81ee6f0b007442522715285 100644 (file)
@@ -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()
 
index a7e09f844042741d8cac882893ad22188bf7b229..e1c6932a939a28aae243b949f4aa236974d9ff63 100644 (file)
@@ -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
index 921cb284c88e3e00294a2d4cf98fa60379996bf1..e86a4137c61f293076bdd8272ba57d8ca3706f3f 100644 (file)
@@ -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 = {}
index 326777b57732495bd6af51ab605ef2965fa811a0..7562d640444d84f8000f8be5ea9f99619f59a148 100644 (file)
@@ -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"
index c0a2b66e413949807df625b0e7bfcfe778b1e9f9..c884a637a21307649fb7b12d6bf002cc368550bc 100644 (file)
@@ -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):