]> git.decadent.org.uk Git - dak.git/blob - shell.py
Add new top level directories
[dak.git] / shell.py
1 #!/usr/bin/env python
2
3 # Launch dak functionality
4 # Copyright (c) 2005 Anthony Towns <ajt@debian.org>
5 # $Id: dak,v 1.1 2005-11-17 08:47:31 ajt Exp $
6
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
21 ################################################################################
22
23 # well I don't know where you're from but in AMERICA, there's a little
24 # thing called "abstinent until proven guilty."
25 #  -- http://harrietmiers.blogspot.com/2005/10/wow-i-feel-loved.html
26
27 # (if James had a blog, I bet I could find a funny quote in it to use!)
28
29 ################################################################################
30
31 import sys
32
33 ################################################################################
34
35 # maps a command name to a module name
36 functionality = [
37     ("ls",                       "Show which suites packages are in",
38                                  ("madison", "main"), ["madison"]),
39     ("rm",                       "Remove packages from suites", "melanie"),
40                                  
41     ("decode-dot-dak",           "Display contents of a .katie file", "ashley"),
42     ("override",                 "Query/change the overrides", "alicia"),
43
44     ("install",                  "Install a package from accepted (security only)",
45                                  "amber"),     # XXX - hmm (ajt)
46     ("reject-proposed-updates",  "Manually reject from proposed-updates", "lauren"),
47     ("process-new",              "Process NEW and BYHAND packages", "lisa"),
48
49     ("control-overrides",        "Manipulate/list override entries in bulk", 
50                                  "natalie"),
51     ("control-suite",            "Manipulate suites in bulk", "heidi"),
52
53     ("stats",                    "Generate stats pr0n", "saffron"),
54     ("cruft-report",             "Check for obsolete or duplicated packages",
55                                  "rene"),
56     ("queue-report",             "Produce a report on NEW and BYHAND packages",
57                                  "helena"),
58     ("compare-suites",           "Show fixable discrepencies between suites",
59                                  "andrea"),
60     
61     ("check-archive",            "Archive sanity checks", "tea"),
62     ("check-overrides",          "Override cruft checks", "cindy"),
63     ("check-proposed-updates",   "Dependency checking for proposed-updates", 
64                                  "jeri"),
65
66     ("examine-package",          "Show information useful for NEW processing",
67                                  "fernanda"),
68
69     ("init-db",                  "Update the database to match the conf file",
70                                  "alyson"),
71     ("init-dirs",                "Initial setup of the archive", "rose"),
72     ("import-archive",           "Populate SQL database based from an archive tree",
73                                  "neve"),
74
75     ("poolize",                  "Move packages from dists/ to pool/", "catherine"),
76     ("symlink-dists",            "Generate compatability symlinks from dists/",
77                                  "claire"),
78
79     ("process-unchecked",        "Process packages in queue/unchecked", "jennifer"),
80
81     ("process-accepted",         "Install packages into the pool", "kelly"),
82     ("generate-releases",        "Generate Release files", "ziyi"),
83     ("generate-index-diffs",     "Generate .diff/Index files", "tiffani"),
84
85     ("make-suite-file-list",     
86         "Generate lists of packages per suite for apt-ftparchive", "jenna"),
87     ("make-maintainers",         "Generates Maintainers file for BTS etc",
88                                  "charisma"),
89     ("make-overrides",           "Generates override files", "denise"),
90
91     ("mirror-split",             "Split the pool/ by architecture groups",
92                                  "billie"),
93
94     ("clean-proposed-updates",   "Remove obsolete .changes from proposed-updates",
95                                  "halle"),
96     ("clean-queues",             "Clean cruft from incoming", "shania"),
97     ("clean-suites",            
98         "Clean unused/superseded packages from the archive", "rhona"),
99
100     ("split-done",               "Split queue/done into a data-based hierarchy",
101                                  "nina"),
102
103     ("import-ldap-fingerprints", 
104         "Syncs fingerprint and uid tables with Debian LDAP db", "emilie"),
105     ("import-users-from-passwd",  
106         "Sync PostgreSQL users with passwd file", "julia"),
107     ("find-null-maintainers",    
108         "Check for users with no packages in the archive", "rosamund"),
109 ]
110
111 names = {}
112 for f in functionality:
113     if isinstance(f[2], str):
114         names[f[2]] = names[f[0]] = (f[2], "main")
115     else:
116         names[f[0]] = f[2]
117         for a in f[3]: names[a] = f[2]
118
119 ################################################################################
120
121 def main():
122     if len(sys.argv) == 0:
123         print "err, argc == 0? how is that possible?"
124         sys.exit(1);
125     elif len(sys.argv) == 1 or (len(sys.argv) == 2 and sys.argv[1] == "--help"):
126         print "Sub commands:"
127         for f in functionality:
128             print "  %-23s %s" % (f[0], f[1])
129         sys.exit(0);
130     else:
131         # should set PATH based on sys.argv[0] maybe
132         # possibly should set names based on sys.argv[0] too
133         sys.path = [sys.path[0]+"/py-symlinks"] + sys.path
134
135         cmdname = sys.argv[0]
136         cmdname = cmdname[cmdname.rfind("/")+1:]
137         if cmdname in names:
138             pass # invoke directly
139         else:
140             cmdname = sys.argv[1]
141             sys.argv = [sys.argv[0] + " " + sys.argv[1]] + sys.argv[2:]
142             if cmdname not in names:
143                 match = []
144                 for f in names:
145                     if f.startswith(cmdname):
146                         match.append(f)
147                 if len(match) == 1:
148                     cmdname = match[0]
149                 elif len(match) > 1:
150                     print "ambiguous command: %s" % ", ".join(match)
151                     sys.exit(1);
152                 else:
153                     print "unknown command \"%s\"" % (cmdname)
154                     sys.exit(1);
155
156         func = names[cmdname]
157         x = __import__(func[0])
158         x.__getattribute__(func[1])()
159
160 if __name__ == "__main__":
161     main()
162