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 ] 166 return functionality
167 168 ################################################################################ 169 170
171 -def usage(functionality, exit_code=0):
172 """Print a usage message and exit with 'exit_code'.""" 173 174 print("""Usage: dak COMMAND [...] 175 Run DAK commands. (Will also work if invoked as COMMAND.) 176 177 Available commands:""") 178 for (command, description) in functionality: 179 print(" %-23s %s" % (command, description)) 180 sys.exit(exit_code)
181 182 ################################################################################ 183 184
185 -def main():
186 """Launch dak functionality.""" 187 188 try: 189 logger = Logger('dak top-level', print_starting=False) 190 except OSError: 191 logger = None 192 193 functionality = init() 194 modules = [command for (command, _) in functionality] 195 196 if len(sys.argv) == 0: 197 daklib.utils.fubar("err, argc == 0? how is that possible?") 198 elif (len(sys.argv) == 1 199 or (len(sys.argv) == 2 200 and (sys.argv[1] == "--help" or sys.argv[1] == "-h"))): 201 usage(functionality) 202 203 # First see if we were invoked with/as the name of a module 204 cmdname = sys.argv[0] 205 cmdname = cmdname[cmdname.rfind("/") + 1:] 206 if cmdname in modules: 207 pass 208 # Otherwise the argument is the module 209 else: 210 cmdname = sys.argv[1] 211 sys.argv = [sys.argv[0] + " " + sys.argv[1]] + sys.argv[2:] 212 if cmdname not in modules: 213 match = [] 214 for name in modules: 215 if name.startswith(cmdname): 216 match.append(name) 217 if len(match) == 1: 218 cmdname = match[0] 219 elif len(match) > 1: 220 daklib.utils.warn("ambiguous command '%s' - could be %s" 221 % (cmdname, ", ".join(match))) 222 usage(functionality, 1) 223 else: 224 daklib.utils.warn("unknown command '%s'" % (cmdname)) 225 usage(functionality, 1) 226 227 # Invoke the module 228 module = importlib.import_module("dak.{}".format(cmdname.replace("-", "_"))) 229 230 try: 231 module.main() 232 except KeyboardInterrupt: 233 msg = 'KeyboardInterrupt caught; exiting' 234 print(msg) 235 if logger: 236 logger.log([msg]) 237 sys.exit(1) 238 except SystemExit: 239 raise 240 except: 241 if logger: 242 for line in traceback.format_exc().split('\n')[:-1]: 243 logger.log(['exception', line]) 244 raise
245 246 ################################################################################ 247 248 249 if __name__ == "__main__": 250 os.environ['LANG'] = 'C' 251 os.environ['LC_ALL'] = 'C' 252 main() 253