]> git.ipfire.org Git - people/jschlag/pbs.git/commitdiff
Add command to list packages in a repository
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 9 Oct 2017 22:22:34 +0000 (23:22 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 9 Oct 2017 22:22:34 +0000 (23:22 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/builds.py
src/scripts/pakfire-build-service

index df57fec9dfcf872880b586029c06b74dd145cdc4..f2e9ef72250a83c7c56da75c3b8f100bde44863e 100644 (file)
@@ -59,6 +59,18 @@ def import_from_package(_pakfire, filename, distro=None, commit=None, type="rele
 
 
 class Builds(base.Object):
+       def _get_build(self, query, *args):
+               res = self.db.get(query, *args)
+
+               if res:
+                       return Build(self.backend, res.id, data=res)
+
+       def _get_builds(self, query, *args):
+               res = self.db.query(query, *args)
+
+               for row in res:
+                       yield Build(self.backend, row.id, data=row)
+
        def get_by_id(self, id, data=None):
                return Build(self.pakfire, id, data=data)
 
@@ -418,6 +430,12 @@ class Build(base.Object):
 
                return cmp(self.pkg, other.pkg)
 
+       def __iter__(self):
+               jobs = self.backend.jobs._get_jobs("SELECT * FROM jobs \
+                       WHERE build_id = %s", self.id)
+
+               return iter(sorted(jobs))
+
        @classmethod
        def create(cls, pakfire, pkg, type="release", owner=None, distro=None, public=True):
                assert type in ("release", "scratch", "test")
index b4ee9db367ef7b3a61deb9e6017bf1dd72de24b1..17883b2f1a1ce1be75c6a668e58d818a437da49b 100644 (file)
@@ -26,6 +26,9 @@ class Cli(object):
                        # Cleanup uploads
                        "cleanup-uploads" : self.backend.uploads.cleanup,
 
+                       # List repository
+                       "list-repository" : self._list_repository,
+
                        # Sends all queued messages
                        "process-message-queue" : self.backend.messages.process_queue,
 
@@ -58,6 +61,31 @@ class Cli(object):
                # Exit with error code
                sys.exit(r or 0)
 
+       def _list_repository(self, distro_name, repo_name, arch):
+               # Get distribution
+               distro = self.backend.distros.get_by_name(distro_name)
+               if not distro:
+                       print >>sys.stderr, "Could not find distribution: %s" % distro_name
+                       return 2
+
+               # Get repository
+               repo = distro.get_repo(repo_name)
+               if not repo:
+                       print >>sys.stderr, "Could not find repository: %s" % repo_name
+                       return 2
+
+               # Iterate through all of it
+               for build in repo:
+                       for job in build:
+                               if not job.type == "build":
+                                       continue
+
+                               if not job.arch in (arch, "noarch"):
+                                       continue
+
+                               for pkg in job:
+                                       print pkg
+
 # main
 
 cli = Cli()