]> git.ipfire.org Git - people/ms/pakfire.git/blobdiff - pakfire/builder.py
Try to design a better API.
[people/ms/pakfire.git] / pakfire / builder.py
index e022274b6548be9d21a379ce7e0294a702668215..a9fb3f1a92321c0e1899040a06f0d6a563e77a32 100644 (file)
@@ -12,6 +12,7 @@ import stat
 import time
 import uuid
 
+import base
 import depsolve
 import packages
 import repository
@@ -27,16 +28,26 @@ class Builder(object):
        # The version of the kernel this machine is running.
        kernel_version = os.uname()[2]
 
-       def __init__(self, pakfire, pkg, build_id=None, **settings):
-               self.pakfire = pakfire
-               self.pkg = pkg
+       def __init__(self, pkg, distro_config=None, build_id=None, **pakfire_args):
+               pakfire_args.update({
+                       "builder" : True,
+               })
 
+               # Create pakfire instance.
+               self.pakfire = base.Pakfire(distro_config=distro_config, **pakfire_args)
+               self.distro = self.pakfire.distro
+               self.path = self.pakfire.path
+
+               # Open the package.
+               self.pkg = packages.open(self.pakfire, None, pkg)
+
+               # XXX need to make this configureable
                self.settings = {
                        "enable_loop_devices" : True,
                        "enable_ccache"   : True,
                        "enable_icecream" : False,
                }
-               self.settings.update(settings)
+               #self.settings.update(settings)
 
                self.buildroot = "/buildroot"
 
@@ -53,6 +64,13 @@ class Builder(object):
 
                self.build_id = build_id
 
+       @property
+       def arch(self):
+               """
+                       Inherit architecture from distribution configuration.
+               """
+               return self.distro.arch
+
        @property
        def info(self):
                return {
@@ -62,10 +80,6 @@ class Builder(object):
                        "build_time" : self.build_time,
                }
 
-       @property
-       def path(self):
-               return self.pakfire.path
-
        def lock(self):
                filename = os.path.join(self.path, ".lock")
 
@@ -472,7 +486,7 @@ class Builder(object):
 
                        # Update personality it none was set
                        if not personality:
-                               personality = self.pakfire.distro.personality
+                               personality = self.distro.personality
 
                        # Make every shell to a login shell because we set a lot of
                        # environment things there.