]> git.ipfire.org Git - people/jschlag/pbs.git/blame - src/scripts/pakfire-build-service
Allow jobs to be superseeded by each other
[people/jschlag/pbs.git] / src / scripts / pakfire-build-service
CommitLineData
43025dca
MT
1#!/usr/bin/python
2
3import sys
4
5# Use tornado's logging options
6import tornado.options
7tornado.options.parse_command_line()
8
9import pakfire.buildservice
10
11class Cli(object):
12 def __init__(self, *args, **kwargs):
13 # Initialise backend
14 self.backend = pakfire.buildservice.Backend(*args, **kwargs)
15
c06ce6d1 16 self._commands = {
13b9276e
MT
17 # Check build dependencies
18 "check-build-dependencies" : self.backend.jobqueue.check_build_dependencies,
19
c660ff59 20 # Run mirror check
cda268cc 21 "check-mirrors" : self.backend.mirrors.check,
c660ff59 22
0f302058
MT
23 # Cleanup files
24 "cleanup-files" : self.backend.cleanup_files,
25
ca4f2d92
MT
26 # Cleanup sessions
27 "cleanup-sessions" : self.backend.sessions.cleanup,
28
be8d5956
MT
29 # Cleanup uploads
30 "cleanup-uploads" : self.backend.uploads.cleanup,
31
ac10fd43
MT
32 # Create test jobs
33 "create-test-jobs" : self.backend.jobqueue.create_test_jobs,
34
13b9276e
MT
35 # Dist
36 "dist" : self.backend.sources.dist,
37
764b87d2
MT
38 # List repository
39 "list-repository" : self._list_repository,
40
c06ce6d1
MT
41 # Sends all queued messages
42 "process-message-queue" : self.backend.messages.process_queue,
76353712 43
6cd8afe7
MT
44 # Pull sources
45 "pull-sources" : self.backend.sources.pull,
46
9729c5b3 47 # Remaster Repositories
58697386 48 "remaster-repositories" : self.backend.repos.remaster,
9729c5b3 49
709118bc
MT
50 # Restart failed jobs
51 "restart-failed-jobs" : self.backend.jobs.restart_failed,
52
76353712
MT
53 # Send bug updates to Bugzilla
54 "send-bug-updates" : self.backend.bugzilla.send_all,
c06ce6d1 55 }
43025dca
MT
56
57 def __call__(self, *args):
58 if not len(args) >= 2:
59 print >>sys.stderr, "Insufficient number of arguments"
60 return 2
61
62 args = list(args)
63 basename = args.pop(0)
64 command = args.pop(0)
65
66 # Get called command
67 try:
68 command = self._commands[command]
69 except KeyError:
70 print >>sys.stderr, "Command not found: %s" % command
71 return 2
72
73 # Execute command
74 r = command(*args)
75
76 # Exit with error code
77 sys.exit(r or 0)
78
764b87d2
MT
79 def _list_repository(self, distro_name, repo_name, arch):
80 # Get distribution
81 distro = self.backend.distros.get_by_name(distro_name)
82 if not distro:
83 print >>sys.stderr, "Could not find distribution: %s" % distro_name
84 return 2
85
86 # Get repository
87 repo = distro.get_repo(repo_name)
88 if not repo:
89 print >>sys.stderr, "Could not find repository: %s" % repo_name
90 return 2
91
92 # Iterate through all of it
93 for build in repo:
94 for job in build:
95 if not job.type == "build":
96 continue
97
98 if not job.arch in (arch, "noarch"):
99 continue
100
101 for pkg in job:
102 print pkg
103
43025dca
MT
104# main
105
106cli = Cli()
107cli(*sys.argv)