]> git.ipfire.org Git - pakfire.git/commitdiff
Add possibility to package more than one source package in one environment.
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 23 Apr 2011 10:38:02 +0000 (12:38 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 23 Apr 2011 10:38:02 +0000 (12:38 +0200)
pakfire/api.py
pakfire/base.py
pakfire/builder.py

index ff6a070fa810140b63cb2037fb1b58ded2b31a21..6757e52f662468034df292066de6391ebb92f272 100644 (file)
@@ -47,8 +47,8 @@ def build(pkg, **kwargs):
 def shell(pkg, **kwargs):
        return Pakfire.shell(pkg, **kwargs)
 
-def dist(pkg, **kwargs):
-       return Pakfire.dist(pkg, **kwargs)
+def dist(pkgs, **kwargs):
+       return Pakfire.dist(pkgs, **kwargs)
 
 def provides(patterns, **pakfire_args):
        # Create pakfire instance.
index 79caf70934e0fba3d9705715d8121fe6bc8583ac..6412a842801792c87c6f6fe302fe30dcc069ae7a 100644 (file)
@@ -214,8 +214,9 @@ class Pakfire(object):
                        b.destroy()
 
        @staticmethod
-       def dist(pkg, resultdirs=None, **pakfire_args):
-               b = builder.Builder(pkg, **pakfire_args)
+       def dist(pkgs, resultdirs=None, **pakfire_args):
+               # Create a builder with empty package.
+               b = builder.Builder(None, **pakfire_args)
                p = b.pakfire
 
                if not resultdirs:
@@ -226,17 +227,24 @@ class Pakfire(object):
 
                try:
                        b.prepare()
-                       b.extract(build_deps=False)
 
-                       # Run the actual dist.
-                       b.dist()
+                       for pkg in pkgs:
+                               b.pkg = pkg
 
-                       # Copy-out all resultfiles
-                       for resultdir in resultdirs:
-                               if not resultdir:
-                                       continue
+                               b.extract(build_deps=False)
 
-                               b.copy_result(resultdir)
+                               # Run the actual dist.
+                               b.dist()
+
+                               # Copy-out all resultfiles
+                               for resultdir in resultdirs:
+                                       if not resultdir:
+                                               continue
+
+                                       b.copy_result(resultdir)
+
+                               # Cleanup the stuff that the package left.
+                               b.cleanup()
                finally:
                        b.destroy()
 
index 0802dbeb9a6e138211a1aa844dfc300843bb1fcc..d69be2938971a26473192f2c8476cd92af38d559 100644 (file)
@@ -29,7 +29,7 @@ class Builder(object):
        # The version of the kernel this machine is running.
        kernel_version = os.uname()[2]
 
-       def __init__(self, pkg, distro_config=None, build_id=None, **pakfire_args):
+       def __init__(self, pkg=None, distro_config=None, build_id=None, **pakfire_args):
                pakfire_args.update({
                        "builder" : True,
                })
@@ -40,16 +40,7 @@ class Builder(object):
                self.path = self.pakfire.path
 
                # Open the package.
-               if pkg:
-                       self.pkg = packages.open(self.pakfire, None, pkg)
-
-                       # Log the package information.
-                       if not isinstance(self.pkg, packages.Makefile):
-                               dump = self.pkg.dump(long=True)
-                               self.log.info(dump)
-               else:
-                       # No package was given.
-                       self.pkg = None
+               self.pkg = pkg
 
                # XXX need to make this configureable
                self.settings = {
@@ -74,6 +65,25 @@ class Builder(object):
 
                self.build_id = build_id
 
+       def get_pkg(self):
+               return getattr(self, "_pkg", None)
+
+       def set_pkg(self, pkg):
+               if pkg is None:
+                       self.__pkg = None
+                       return
+
+               self._pkg = packages.open(self.pakfire, None, pkg)
+
+               # Log the package information.
+               if not isinstance(self._pkg, packages.Makefile):
+                       dump = self._pkg.dump(long=True)
+                       self.log.info(dump)
+
+               assert self.pkg
+
+       pkg = property(get_pkg, set_pkg)
+
        @property
        def arch(self):
                """