]> git.ipfire.org Git - pbs.git/commitdiff
packages: Store build arches and apply them when creating jobs
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 30 Aug 2023 17:49:26 +0000 (17:49 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 30 Aug 2023 17:49:26 +0000 (17:49 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/builds.py
src/buildservice/packages.py
src/database.sql

index 5c27b9ab843385d2ca0f44a8f657f3cb39588a12..3f1b38867f1e8776e103918706a914750ac700a3 100644 (file)
@@ -559,8 +559,20 @@ class Build(base.DataObject):
        priority = property(get_priority, set_priority)
 
        @property
-       def supported_arches(self):
-               return self.pkg.supported_arches
+       def arches(self):
+               """
+                       Returns a list of all supported arches for this build
+               """
+               # If the package doesn't filter anything, report everything the distro supports
+               if not self.pkg.build_arches:
+                       return self.distro.arches
+
+               # Handle the special case of "noarch"
+               if "noarch" in self.pkg.build_arches:
+                       return ["noarch"]
+
+               # Otherwise we return all supported arches
+               return [arch for arch in self.distro.arches if arch in self.pkg.build_arches]
 
        # Jobs
 
@@ -596,28 +608,8 @@ class Build(base.DataObject):
                """
                        Called after a build has been created and creates all jobs
                """
-               arches = []
-
-               # Collect all supported arches
-               for arch in self.distro.arches:
-                       # Skip any unsupported arches
-                       #if self.pkg.supported_arches and not arch in self.pkg.supported_arches:
-                       #       log.debug("Build %s does not support %s" % (self.pkg, arch))
-                       #       continue
-
-                       arches.append(arch)
-
-               # Check for noarch
-               if not arches:
-                       if "noarch" in self.pkg.supported_arches:
-                               arches.append("noarch")
-
-               # Raise an error if nothing is supported at all
-               if not arches:
-                       raise RuntimeError("Build %s does not support any architectures" % self)
-
                # Create the jobs
-               for arch in arches:
+               for arch in self.arches:
                        self.backend.jobs.create(self, arch)
 
        async def _job_finished(self, job):
index 797119bdc7a3bcf7307e7f54294186f198f521fc..35cb0982ee23b2eb83d4a66e79b53a1c13615b68 100644 (file)
@@ -128,7 +128,7 @@ class Packages(base.Object):
                                recommends,
                                suggests,
                                size,
-                               supported_arches,
+                               build_arches,
                                commit_id,
                                build_id,
                                build_host,
@@ -162,7 +162,7 @@ class Packages(base.Object):
                        package.recommends,
                        package.suggests,
                        package.installsize,
-                       [], # XXX supported arches
+                       package.build_arches,
                        commit,
                        None, # package.build_id,
                        package.buildhost,
@@ -378,8 +378,8 @@ class Package(base.DataObject):
                return self.data.description
 
        @property
-       def supported_arches(self):
-               return self.data.supported_arches
+       def build_arches(self):
+               return self.data.build_arches
 
        @property
        def size(self):
index 643deb175713beb9fba78b9e8836e4c99d86ce3e..044efda5d1f320f05e46b07f88dbaf9d7dd433e9 100644 (file)
@@ -596,7 +596,7 @@ CREATE TABLE public.packages (
     summary text NOT NULL,
     description text NOT NULL,
     size bigint NOT NULL,
-    supported_arches text,
+    build_arches text[],
     uuid uuid NOT NULL,
     commit_id integer,
     build_id text,