]> git.ipfire.org Git - people/jschlag/pbs.git/blame - src/scripts/pakfire-build-service
Redesign mastering repositories
[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
612ee16e
MT
26 # Cleanup repositories
27 "cleanup-repositories" : self.backend.repos.cleanup,
28
ca4f2d92
MT
29 # Cleanup sessions
30 "cleanup-sessions" : self.backend.sessions.cleanup,
31
be8d5956
MT
32 # Cleanup uploads
33 "cleanup-uploads" : self.backend.uploads.cleanup,
34
ac10fd43
MT
35 # Create test jobs
36 "create-test-jobs" : self.backend.jobqueue.create_test_jobs,
37
13b9276e
MT
38 # Dist
39 "dist" : self.backend.sources.dist,
40
764b87d2
MT
41 # List repository
42 "list-repository" : self._list_repository,
43
c06ce6d1
MT
44 # Sends all queued messages
45 "process-message-queue" : self.backend.messages.process_queue,
76353712 46
6cd8afe7
MT
47 # Pull sources
48 "pull-sources" : self.backend.sources.pull,
49
9729c5b3 50 # Remaster Repositories
58697386 51 "remaster-repositories" : self.backend.repos.remaster,
9729c5b3 52
709118bc
MT
53 # Restart failed jobs
54 "restart-failed-jobs" : self.backend.jobs.restart_failed,
55
76353712
MT
56 # Send bug updates to Bugzilla
57 "send-bug-updates" : self.backend.bugzilla.send_all,
c06ce6d1 58 }
43025dca
MT
59
60 def __call__(self, *args):
c1271bd0
MT
61 # Parse tornado settings
62 args = tornado.options.parse_command_line(args)
63
64 if not len(args) >= 1:
43025dca
MT
65 print >>sys.stderr, "Insufficient number of arguments"
66 return 2
67
68 args = list(args)
43025dca
MT
69 command = args.pop(0)
70
71 # Get called command
72 try:
73 command = self._commands[command]
74 except KeyError:
75 print >>sys.stderr, "Command not found: %s" % command
76 return 2
77
78 # Execute command
79 r = command(*args)
80
81 # Exit with error code
82 sys.exit(r or 0)
83
764b87d2
MT
84 def _list_repository(self, distro_name, repo_name, arch):
85 # Get distribution
86 distro = self.backend.distros.get_by_name(distro_name)
87 if not distro:
88 print >>sys.stderr, "Could not find distribution: %s" % distro_name
89 return 2
90
91 # Get repository
92 repo = distro.get_repo(repo_name)
93 if not repo:
94 print >>sys.stderr, "Could not find repository: %s" % repo_name
95 return 2
96
97 # Iterate through all of it
98 for build in repo:
99 for job in build:
4f90cf84
MT
100 # Skip all test jobs
101 if job.test:
764b87d2
MT
102 continue
103
104 if not job.arch in (arch, "noarch"):
105 continue
106
107 for pkg in job:
108 print pkg
109
43025dca
MT
110# main
111
112cli = Cli()
113cli(*sys.argv)