Package dak :: Module dak
[hide private]
[frames] | no frames]

Source Code for Module dak.dak

  1  #!/usr/bin/env python3 
  2   
  3  """ 
  4  Wrapper to launch dak functionality 
  5   
  6  G{importgraph} 
  7   
  8  """ 
  9  # Copyright (C) 2005, 2006 Anthony Towns <ajt@debian.org> 
 10  # Copyright (C) 2006 James Troup <james@nocrew.org> 
 11   
 12  # This program is free software; you can redistribute it and/or modify 
 13  # it under the terms of the GNU General Public License as published by 
 14  # the Free Software Foundation; either version 2 of the License, or 
 15  # (at your option) any later version. 
 16   
 17  # This program is distributed in the hope that it will be useful, 
 18  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
 19  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 20  # GNU General Public License for more details. 
 21   
 22  # You should have received a copy of the GNU General Public License 
 23  # along with this program; if not, write to the Free Software 
 24  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
 25   
 26  ################################################################################ 
 27   
 28  # well I don't know where you're from but in AMERICA, there's a little 
 29  # thing called "abstinent until proven guilty." 
 30  #  -- http://harrietmiers.blogspot.com/2005/10/wow-i-feel-loved.html 
 31   
 32  # (if James had a blog, I bet I could find a funny quote in it to use!) 
 33   
 34  ################################################################################ 
 35   
 36  import importlib 
 37  import os 
 38  import sys 
 39  import traceback 
 40   
 41  sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) 
 42   
 43  import daklib.utils 
 44   
 45  from daklib.daklog import Logger 
 46   
 47  ################################################################################ 
 48   
 49   
50 -def init():
51 """Setup the list of modules and brief explanation of what they 52 do.""" 53 54 functionality = [ 55 ("ls", 56 "Show which suites packages are in"), 57 ("override", 58 "Query/change the overrides"), 59 ("check-archive", 60 "Archive sanity checks"), 61 ("queue-report", 62 "Produce a report on NEW and BYHAND packages"), 63 ("show-new", 64 "Output html for packages in NEW"), 65 ("show-deferred", 66 "Output html and symlinks for packages in DEFERRED"), 67 ("graph", 68 "Output graphs of number of packages in various queues"), 69 70 ("rm", 71 "Remove packages from suites"), 72 73 ("process-new", 74 "Process NEW and BYHAND packages"), 75 ("process-upload", 76 "Process packages in queue/unchecked"), 77 ("process-commands", 78 "Process command files (*.dak-commands)"), 79 ("process-policy", 80 "Process packages in policy queues from COMMENTS files"), 81 82 ("dominate", 83 "Remove obsolete source and binary associations from suites"), 84 ("export", 85 "Export uploads from policy queues"), 86 ("export-suite", 87 "export a suite to a flat directory structure"), 88 ("make-pkg-file-mapping", 89 "Generate package <-> file mapping"), 90 ("generate-releases", 91 "Generate Release files"), 92 ("generate-packages-sources2", 93 "Generate Packages/Sources files"), 94 ("contents", 95 "Generate content files"), 96 ("metadata", 97 "Load data for packages/sources files"), 98 ("generate-index-diffs", 99 "Generate .diff/Index files"), 100 ("clean-suites", 101 "Clean unused/superseded packages from the archive"), 102 ("manage-build-queues", 103 "Clean and update metadata for build queues"), 104 ("manage-debug-suites", 105 "Clean obsolete packages from debug suites"), 106 ("manage-external-signature-requests", 107 "Maintain external signature requests"), 108 ("clean-queues", 109 "Clean cruft from incoming"), 110 ("archive-dedup-pool", 111 "De-duplicates files in the pool directory"), 112 113 ("transitions", 114 "Manage the release transition file"), 115 ("check-overrides", 116 "Override cruft checks"), 117 ("control-overrides", 118 "Manipulate/list override entries in bulk"), 119 ("control-suite", 120 "Manipulate suites in bulk"), 121 ("update-suite", 122 "Update suite with packages from a different suite"), 123 ("cruft-report", 124 "Check for obsolete or duplicated packages"), 125 ("auto-decruft", 126 "Clean cruft without reverse dependencies automatically"), 127 ("examine-package", 128 "Show information useful for NEW processing"), 129 ("import", 130 "Import existing source and binary packages"), 131 ("import-repository", 132 "Import packages from another repository"), 133 ("import-keyring", 134 "Populate fingerprint/uid table based on a new/updated keyring"), 135 ("import-users-from-passwd", 136 "Sync PostgreSQL users with passwd file"), 137 ("acl", 138 "Manage upload ACLs"), 139 ("admin", 140 "Perform administration on the dak database"), 141 ("update-db", 142 "Updates databae schema to latest revision"), 143 ("init-dirs", 144 "Initial setup of the archive"), 145 ("make-maintainers", 146 "Generates Maintainers file for BTS etc"), 147 ("make-overrides", 148 "Generates override files"), 149 ("new-security-install", 150 "New way to install a security upload into the archive"), 151 ("stats", 152 "Generate statistics"), 153 ("bts-categorize", 154 "Categorize uncategorized bugs filed against ftp.debian.org"), 155 ("add-user", 156 "Add a user to the archive"), 157 ("make-changelog", 158 "Generate changelog between two suites"), 159 ("copy-installer", 160 "Copies the installer from one suite to another"), 161 ("external-overrides", 162 "Modify external overrides"), 163 ("write-sections", 164 "Write out section descriptions"), 165 ("find-files", 166 "Find files related to a given source package and version"), 167 ] 168 return functionality
169 170 ################################################################################ 171 172
173 -def usage(functionality, exit_code=0):
174 """Print a usage message and exit with 'exit_code'.""" 175 176 print("""Usage: dak COMMAND [...] 177 Run DAK commands. (Will also work if invoked as COMMAND.) 178 179 Available commands:""") 180 for (command, description) in functionality: 181 print(" %-23s %s" % (command, description)) 182 sys.exit(exit_code)
183 184 ################################################################################ 185 186
187 -def main():
188 """Launch dak functionality.""" 189 190 try: 191 logger = Logger('dak top-level', print_starting=False) 192 except OSError: 193 logger = None 194 195 functionality = init() 196 modules = [command for (command, _) in functionality] 197 198 if len(sys.argv) == 0: 199 daklib.utils.fubar("err, argc == 0? how is that possible?") 200 elif (len(sys.argv) == 1 201 or (len(sys.argv) == 2 202 and (sys.argv[1] == "--help" or sys.argv[1] == "-h"))): 203 usage(functionality) 204 205 # First see if we were invoked with/as the name of a module 206 cmdname = sys.argv[0] 207 cmdname = cmdname[cmdname.rfind("/") + 1:] 208 if cmdname in modules: 209 pass 210 # Otherwise the argument is the module 211 else: 212 cmdname = sys.argv[1] 213 sys.argv = [sys.argv[0] + " " + sys.argv[1]] + sys.argv[2:] 214 if cmdname not in modules: 215 match = [] 216 for name in modules: 217 if name.startswith(cmdname): 218 match.append(name) 219 if len(match) == 1: 220 cmdname = match[0] 221 elif len(match) > 1: 222 daklib.utils.warn("ambiguous command '%s' - could be %s" 223 % (cmdname, ", ".join(match))) 224 usage(functionality, 1) 225 else: 226 daklib.utils.warn("unknown command '%s'" % (cmdname)) 227 usage(functionality, 1) 228 229 # Invoke the module 230 module = importlib.import_module("dak.{}".format(cmdname.replace("-", "_"))) 231 232 try: 233 module.main() 234 except KeyboardInterrupt: 235 msg = 'KeyboardInterrupt caught; exiting' 236 print(msg) 237 if logger: 238 logger.log([msg]) 239 sys.exit(1) 240 except SystemExit: 241 raise 242 except: 243 if logger: 244 for line in traceback.format_exc().split('\n')[:-1]: 245 logger.log(['exception', line]) 246 raise
247 248 ################################################################################ 249 250 251 if __name__ == "__main__": 252 os.environ['LANG'] = 'C' 253 os.environ['LC_ALL'] = 'C' 254 main() 255