def main(): cnf = Config() Arguments = [('h', "help", "External-Overrides::Options::Help"), ('f', 'force', 'External-Overrides::Options::Force')] args = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) try: Options = cnf.subtree("External-Overrides::Options") except KeyError: Options = {} if Options.has_key("Help"): usage() force = False if Options.has_key("Force") and Options["Force"]: force = True logger = daklog.Logger('external-overrides') command = args[0] if command in ('import', 'i'): external_overrides_import(args[1], args[2], args[3], sys.stdin, force) elif command in ('copy', 'c'): external_overrides_copy(args[1], args[2], force) else: print "E: Unknown commands."
def main(): global Options, Logger, Sections, Priorities cnf = Config() session = DBConn().session() Arguments = [('a', "automatic", "Process-New::Options::Automatic"), ('b', "no-binaries", "Process-New::Options::No-Binaries"), ('c', "comments", "Process-New::Options::Comments"), ('h', "help", "Process-New::Options::Help"), ('m', "manual-reject", "Process-New::Options::Manual-Reject", "HasArg"), ('t', "trainee", "Process-New::Options::Trainee"), ('q', 'queue', 'Process-New::Options::Queue', 'HasArg'), ('n', "no-action", "Process-New::Options::No-Action")] changes_files = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) for i in [ "automatic", "no-binaries", "comments", "help", "manual-reject", "no-action", "version", "trainee" ]: if not cnf.has_key("Process-New::Options::%s" % (i)): cnf["Process-New::Options::%s" % (i)] = "" queue_name = cnf.get('Process-New::Options::Queue', 'new') new_queue = session.query(PolicyQueue).filter_by( queue_name=queue_name).one() if len(changes_files) == 0: uploads = new_queue.uploads else: uploads = session.query(PolicyQueueUpload).filter_by(policy_queue=new_queue) \ .join(DBChange).filter(DBChange.changesname.in_(changes_files)).all() Options = cnf.subtree("Process-New::Options") if Options["Help"]: usage() if not Options["No-Action"]: try: Logger = daklog.Logger("process-new") except CantOpenError as e: Options["Trainee"] = "True" Sections = Section_Completer(session) Priorities = Priority_Completer(session) readline.parse_and_bind("tab: complete") if len(uploads) > 1: sys.stderr.write("Sorting changes...\n") uploads = sort_uploads(new_queue, uploads, session, Options["No-Binaries"]) if Options["Comments"]: show_new_comments(uploads, session) else: for upload in uploads: do_pkg(upload, session) end()
def main(): global Options, Logger cnf = Config() session = DBConn().session() Arguments = [('h', "help", "Archive-Dedup-Pool::Options::Help")] apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) for i in ["help"]: key = "Archive-Dedup-Pool::Options::%s" % i if key not in cnf: cnf[key] = "" Options = cnf.subtree("Archive-Dedup-Pool::Options") if Options["Help"]: usage() Logger = daklog.Logger("archive-dedup-pool") dedup(session) Logger.close()
def binary_scan_all(cnf, limit): Logger = daklog.Logger('contents scan-binary') result = BinaryContentsScanner.scan_all(limit) processed = '%(processed)d packages processed' % result remaining = '%(remaining)d packages remaining' % result Logger.log([processed, remaining]) Logger.close()
def write_all(cnf, archive_names=[], suite_names=[], component_names=[], force=None): Logger = daklog.Logger('contents generate') ContentsWriter.write_all(Logger, archive_names, suite_names, component_names, force) Logger.close()
def main(): cnf = Config() Arguments = [('h',"help","DEP11::Options::Help"), ('s',"suite","DEP11::Options::Suite", "HasArg"), ('e',"expire","DEP11::Options::ExpireCache"), ('h',"write-hints","DEP11::Options::WriteHints"), ] for i in ["help", "suite", "ExpireCache"]: if not cnf.has_key("DEP11::Options::%s" % (i)): cnf["DEP11::Options::%s" % (i)] = "" arguments = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) Options = cnf.subtree("DEP11::Options") if Options["Help"]: usage() return suitename = Options["Suite"] if not suitename: print("You need to specify a suite!") sys.exit(1) # check if we have some important config options set if not cnf.has_key("Dir::MetaInfo"): print("You need to specify a metadata export directory (Dir::MetaInfo)") sys.exit(1) if not cnf.has_key("DEP11::Url"): print("You need to specify a metadata public web URL (DEP11::Url)") sys.exit(1) if not cnf.has_key("DEP11::IconSizes"): print("You need to specify a list of allowed icon-sizes (DEP11::IconSizes)") sys.exit(1) if Options["WriteHints"] and not cnf.has_key("Dir::MetaInfoHints"): print("You need to specify an export directory for DEP-11 hints files (Dir::MetaInfoHints)") sys.exit(1) logger = daklog.Logger('generate-metadata') from daklib.dbconn import Component, DBConn, get_suite, Suite session = DBConn().session() suite = get_suite(suitename.lower(), session) if Options["ExpireCache"]: expire_dep11_data_cache(session, suitename, logger) process_suite(session, suite, logger) # export database content as Components-<arch>.xz YAML documents write_component_files(session, suite, logger) if Options["WriteHints"]: write_hints_files(session, suite, logger) # we're done logger.close()
def main(): global Options, Logger cnf = Config() session = DBConn().session() Arguments = [('h', "help", "Process-Policy::Options::Help"), ('n', "no-action", "Process-Policy::Options::No-Action")] for i in ["help", "no-action"]: key = "Process-Policy::Options::%s" % i if key not in cnf: cnf[key] = "" queue_name = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) if len(queue_name) != 1: print("E: Specify exactly one policy queue") sys.exit(1) queue_name = queue_name[0] Options = cnf.subtree("Process-Policy::Options") if Options["Help"]: usage() Logger = daklog.Logger("process-policy") if not Options["No-Action"]: urgencylog = UrgencyLog() with ArchiveTransaction() as transaction: session = transaction.session try: pq = session.query(PolicyQueue).filter_by( queue_name=queue_name).one() except NoResultFound: print("E: Cannot find policy queue %s" % queue_name) sys.exit(1) commentsdir = os.path.join(pq.path, 'COMMENTS') # The comments stuff relies on being in the right directory os.chdir(pq.path) do_comments(commentsdir, pq, "REJECT.", "REJECTED.", "NOTOK", comment_reject, transaction) do_comments(commentsdir, pq, "ACCEPT.", "ACCEPTED.", "OK", comment_accept, transaction) do_comments(commentsdir, pq, "ACCEPTED.", "ACCEPTED.", "OK", comment_accept, transaction) remove_unreferenced_binaries(pq, transaction) remove_unreferenced_sources(pq, transaction) if not Options['No-Action']: urgencylog.close()
def main(): global Options, Logger cnf = Config() for i in ["Help", "No-Action", "All"]: if not cnf.has_key("Manage-Build-Queues::Options::%s" % (i)): cnf["Manage-Build-Queues::Options::%s" % (i)] = "" Arguments = [('h', "help", "Manage-Build-Queues::Options::Help"), ('n', "no-action", "Manage-Build-Queues::Options::No-Action"), ('a', "all", "Manage-Build-Queues::Options::All")] queue_names = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) Options = cnf.subtree("Manage-Build-Queues::Options") if Options["Help"]: usage() Logger = daklog.Logger('manage-build-queues', Options['No-Action']) starttime = datetime.now() session = DBConn().session() with ArchiveTransaction() as transaction: session = transaction.session if Options['All']: if len(queue_names) != 0: print "E: Cannot use both -a and a queue name" sys.exit(1) queues = session.query(BuildQueue) else: queues = session.query(BuildQueue).filter( BuildQueue.queue_name.in_(queue_names)) for q in queues: Logger.log([ 'cleaning queue %s using datetime %s' % (q.queue_name, starttime) ]) clean(q, transaction, now=starttime) if not Options['No-Action']: transaction.commit() else: transaction.rollback() Logger.close()
def main(): global Options, Logger cnf = Config() for i in ["Help"]: key = "Manage-External-Signature-Requests::Options::{}".format(i) if key not in cnf: cnf[key] = "" Arguments = [('h', "help", "Manage-External-Signature-Requests::Options::Help")] apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) Options = cnf.subtree("Manage-External-Signature-Requests::Options") if Options["Help"]: usage() Logger = daklog.Logger('manage-external-signature-requests') if 'External-Signature-Requests' not in cnf: print("DAK not configured to handle external signature requests") return config = cnf.subtree('External-Signature-Requests') session = DBConn().session() export_external_signature_requests(session, config['Export']) if 'ExportSigningKeys' in config: args = { 'pubring': cnf.get('Dinstall::SigningPubKeyring') or None, 'secring': cnf.get('Dinstall::SigningKeyring') or None, 'homedir': cnf.get('Dinstall::SigningHomedir') or None, 'passphrase_file': cnf.get('Dinstall::SigningPassphraseFile') or None, } sign_external_signature_requests( session, config['Export'], config.value_list('ExportSigningKeys'), args) session.close() Logger.close()
def main(): global Options, Logger cnf = Config() for i in ["Help", "No-Action", "All"]: key = "Manage-Debug-Suites::Options::%s" % i if key not in cnf: cnf[key] = "" Arguments = [('h', "help", "Manage-Debug-Suites::Options::Help"), ('n', "no-action", "Manage-Debug-Suites::Options::No-Action"), ('a', "all", "Manage-Debug-Suites::Options::All")] debug_suite_names = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) Options = cnf.subtree("Manage-Debug-Suites::Options") if Options["Help"]: usage() Logger = daklog.Logger('manage-debug-suites', Options['No-Action']) with ArchiveTransaction() as transaction: session = transaction.session if Options['All']: if len(debug_suite_names) != 0: print("E: Cannot use both -a and a queue name") sys.exit(1) raise Exception("Not yet implemented.") else: debug_suites = session.query(Suite).filter( Suite.suite_name.in_(debug_suite_names)) for debug_suite in debug_suites: Logger.log( ['cleaning debug suite {0}'.format(debug_suite.suite_name)]) clean(debug_suite, transaction) if not Options['No-Action']: transaction.commit() else: transaction.rollback() Logger.close()
def main(): global Options, Logger cnf = Config() Arguments = [('h', "help", "Obsolete::Options::Help"), ('s', "suite", "Obsolete::Options::Suite", "HasArg"), ('n', "no-action", "Obsolete::Options::No-Action"), ('f', "force", "Obsolete::Options::Force")] cnf['Obsolete::Options::Help'] = '' cnf['Obsolete::Options::No-Action'] = '' cnf['Obsolete::Options::Force'] = '' apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) Options = cnf.subtree("Obsolete::Options") if Options['Help']: usage() if not Options['No-Action']: Logger = daklog.Logger("dominate") session = DBConn().session() suites_query = (session.query(Suite).order_by( Suite.suite_name).filter(~exists().where( Suite.suite_id == PolicyQueue.suite_id))) if 'Suite' in Options: suites_query = suites_query.filter( Suite.suite_name.in_(utils.split_args(Options['Suite']))) if not Options['Force']: suites_query = suites_query.filter_by(untouchable=False) suites = suites_query.all() assocs = list(retrieve_associations(suites, session)) if Options['No-Action']: headers = ('source package', 'source version', 'package', 'version', 'arch', 'suite', 'id') print(tabulate(assocs, headers, tablefmt="orgtbl")) session.rollback() else: delete_associations(assocs, session) session.commit() if Logger: Logger.close()
def main(): global Options, Logger cnf = Config() for i in ["Help", "Incoming", "No-Action", "Verbose"]: key = "Clean-Queues::Options::%s" % i if key not in cnf: cnf[key] = "" if "Clean-Queues::Options::Days" not in cnf: cnf["Clean-Queues::Options::Days"] = "14" Arguments = [('h', "help", "Clean-Queues::Options::Help"), ('d', "days", "Clean-Queues::Options::Days", "IntLevel"), ('i', "incoming", "Clean-Queues::Options::Incoming", "HasArg"), ('n', "no-action", "Clean-Queues::Options::No-Action"), ('v', "verbose", "Clean-Queues::Options::Verbose")] apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) Options = cnf.subtree("Clean-Queues::Options") if Options["Help"]: usage() Logger = daklog.Logger('clean-queues', Options['No-Action']) init(cnf) if Options["Verbose"]: print("Processing incoming...") flush_orphans() reject = cnf["Dir::Reject"] if os.path.exists(reject) and os.path.isdir(reject): if Options["Verbose"]: print("Processing reject directory...") os.chdir(reject) flush_old() Logger.close()
def main(): cnf = Config() Arguments = [ ('h', "help", "DEP11::Options::Help"), ('e', "expire", "DEP11::Options::ExpireCache"), ('s', "suite", "DEP11::Options::Suite", "HasArg"), ] for i in ["help", "suite", "ExpireCache"]: if not cnf.has_key("DEP11::Options::%s" % (i)): cnf["DEP11::Options::%s" % (i)] = "" arguments = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) Options = cnf.subtree("DEP11::Options") if Options["Help"]: usage() return suitename = Options["Suite"] if not suitename: print("You need to specify a suite!") return logger = daklog.Logger('generate-metadata') from daklib.dbconn import Component, DBConn, get_suite, Suite session = DBConn().session() suite = get_suite(suitename.lower(), session) if Options["ExpireCache"]: expire_dep11_data_cache(session, suitename) process_suite(session, suite, logger) # export database content as Components-<arch>.xz YAML documents write_component_files(suite) # we're done logger.close()
def main(): global Options, Logger cnf = Config() Arguments = [('h', "help", "Obsolete::Options::Help"), ('s', "suite", "Obsolete::Options::Suite", "HasArg"), ('n', "no-action", "Obsolete::Options::No-Action"), ('f', "force", "Obsolete::Options::Force")] cnf['Obsolete::Options::Help'] = '' cnf['Obsolete::Options::No-Action'] = '' cnf['Obsolete::Options::Force'] = '' apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) Options = cnf.subtree("Obsolete::Options") if Options['Help']: usage() if 'Suite' not in Options: query_suites = DBConn().session().query(Suite) suites = [suite.suite_name for suite in query_suites] cnf['Obsolete::Options::Suite'] = str(','.join(suites)) if not Options['No-Action']: Logger = daklog.Logger("dominate") session = DBConn().session() for suite_name in utils.split_args(Options['Suite']): suite = session.query(Suite).filter_by(suite_name = suite_name).one() # Skip policy queues. We don't want to remove obsolete packages from those. policy_queue = session.query(PolicyQueue).filter_by(suite=suite).first() if policy_queue is not None: continue if not suite.untouchable or Options['Force']: doDaDoDa(suite.suite_id, session) if Options['No-Action']: session.rollback() else: session.commit() if Logger: Logger.close()
def main(): cnf = Config() Logger = daklog.Logger('generate-filelist') Arguments = [('h', "help", "Filelist::Options::Help"), ('s', "suite", "Filelist::Options::Suite", "HasArg"), ('c', "component", "Filelist::Options::Component", "HasArg"), ('a', "architecture", "Filelist::Options::Architecture", "HasArg"), ('i', "incremental", "Filelist::Options::Incremental")] session = DBConn().session() query_suites = session.query(Suite) suites = [suite.suite_name for suite in query_suites] if not cnf.has_key('Filelist::Options::Suite'): cnf['Filelist::Options::Suite'] = ','.join(suites).encode() query_components = session.query(Component) components = \ [component.component_name for component in query_components] if not cnf.has_key('Filelist::Options::Component'): cnf['Filelist::Options::Component'] = ','.join(components).encode() query_architectures = session.query(Architecture) architectures = \ [architecture.arch_string for architecture in query_architectures] if not cnf.has_key('Filelist::Options::Architecture'): cnf['Filelist::Options::Architecture'] = ','.join( architectures).encode() cnf['Filelist::Options::Help'] = '' cnf['Filelist::Options::Incremental'] = '' apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) Options = cnf.subtree("Filelist::Options") if Options['Help']: usage() pool = DakProcessPool() query_suites = query_suites. \ filter(Suite.suite_name.in_(utils.split_args(Options['Suite']))) query_components = query_components. \ filter(Component.component_name.in_(utils.split_args(Options['Component']))) query_architectures = query_architectures. \ filter(Architecture.arch_string.in_(utils.split_args(Options['Architecture']))) def parse_results(message): # Split out into (code, msg) code, msg = message if code == PROC_STATUS_SUCCESS: Logger.log([msg]) elif code == PROC_STATUS_SIGNALRAISED: Logger.log(['E: Subprocess recieved signal ', msg]) else: Logger.log(['E: ', msg]) for suite in query_suites: suite_id = suite.suite_id for component in query_components: component_id = component.component_id for architecture in query_architectures: architecture_id = architecture.arch_id if architecture not in suite.architectures: pass elif architecture.arch_string == 'source': pool.apply_async( writeSourceList, (suite_id, component_id, Options['Incremental']), callback=parse_results) elif architecture.arch_string == 'all': pool.apply_async(writeAllList, (suite_id, component_id, architecture_id, 'deb', Options['Incremental']), callback=parse_results) pool.apply_async(writeAllList, (suite_id, component_id, architecture_id, 'udeb', Options['Incremental']), callback=parse_results) else: # arch any pool.apply_async(writeBinaryList, (suite_id, component_id, architecture_id, 'deb', Options['Incremental']), callback=parse_results) pool.apply_async(writeBinaryList, (suite_id, component_id, architecture_id, 'udeb', Options['Incremental']), callback=parse_results) pool.close() pool.join() # this script doesn't change the database session.close() Logger.close() sys.exit(pool.overall_status())
def main(): global Options, Logger, results cnf = Config() for i in ["Help", "Suite", "Force"]: if not cnf.has_key("Generate-Packages-Sources::Options::%s" % (i)): cnf["Generate-Packages-Sources::Options::%s" % (i)] = "" Arguments = [('h', "help", "Generate-Packages-Sources::Options::Help"), ('s', "suite", "Generate-Packages-Sources::Options::Suite"), ('f', "force", "Generate-Packages-Sources::Options::Force")] suite_names = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) Options = cnf.subtree("Generate-Packages-Sources::Options") if Options["Help"]: usage() Logger = daklog.Logger('generate-packages-sources') session = DBConn().session() if Options["Suite"]: # Something here suites = [] for s in suite_names: suite = get_suite(s.lower(), session) if suite: suites.append(suite) else: print "cannot find suite %s" % s Logger.log(['cannot find suite %s' % s]) else: suites = session.query(Suite).filter(Suite.untouchable == False).all() startdir = os.getcwd() os.chdir(cnf["Dir::TempPath"]) broken = [] # For each given suite, each architecture, run one apt-ftparchive for s in suites: results = [] # Setup a multiprocessing Pool. As many workers as we have CPU cores. pool = Pool() arch_list = get_suite_architectures(s.suite_name, skipsrc=False, skipall=False, session=session) Logger.log([ 'generating output for Suite %s, Architectures %s' % (s.suite_name, map(sname, arch_list)) ]) for a in arch_list: pool.apply_async( generate_packages_sources, (a.arch_string, s.suite_name, cnf["Dir::TempPath"]), callback=get_result) # No more work will be added to our pool, close it and then wait for all to finish pool.close() pool.join() if len(results) > 0: Logger.log( ['Trouble, something with a-f broke, resultcodes: %s' % (results)]) print "Trouble, something with a-f broke, resultcodes: %s" % (results) sys.exit(1) os.chdir(startdir) # this script doesn't change the database session.close() Logger.close()
def main(): global Options, Logger cnf = Config() for i in ["Help", "No-Action", "Maximum"]: key = "Clean-Suites::Options::%s" % i if key not in cnf: cnf[key] = "" Arguments = [('h', "help", "Clean-Suites::Options::Help"), ('a', 'archive', 'Clean-Suites::Options::Archive', 'HasArg'), ('n', "no-action", "Clean-Suites::Options::No-Action"), ('m', "maximum", "Clean-Suites::Options::Maximum", "HasArg")] apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) Options = cnf.subtree("Clean-Suites::Options") if cnf["Clean-Suites::Options::Maximum"] != "": try: # Only use Maximum if it's an integer max_delete = int(cnf["Clean-Suites::Options::Maximum"]) if max_delete < 1: utils.fubar("If given, Maximum must be at least 1") except ValueError as e: utils.fubar("If given, Maximum must be an integer") else: max_delete = None if Options["Help"]: usage() program = "clean-suites" if Options['No-Action']: program = "clean-suites (no action)" Logger = daklog.Logger(program, debug=Options["No-Action"]) session = DBConn().session() archives = None if 'Archive' in Options: archive_names = Options['Archive'].split(',') archives = session.query(Archive).filter( Archive.archive_name.in_(archive_names)).all() if len(archives) == 0: utils.fubar('Unknown archive.') now_date = datetime.now() set_archive_delete_dates(now_date, session) check_binaries(now_date, session) clean_binaries(now_date, session) check_sources(now_date, session) check_files(now_date, session) clean(now_date, archives, max_delete, session) clean_maintainers(now_date, session) clean_fingerprints(now_date, session) clean_byhash(now_date, session) clean_empty_directories(session) session.rollback() Logger.close()
def main(): global Logger cnf = Config() Arguments = [('a', "add", "Control-Overrides::Options::Add"), ('c', "component", "Control-Overrides::Options::Component", "HasArg"), ('h', "help", "Control-Overrides::Options::Help"), ('l', "list", "Control-Overrides::Options::List"), ('q', "quiet", "Control-Overrides::Options::Quiet"), ('s', "suite", "Control-Overrides::Options::Suite", "HasArg"), ('S', "set", "Control-Overrides::Options::Set"), ('C', "change", "Control-Overrides::Options::Change"), ('n', "no-action", "Control-Overrides::Options::No-Action"), ('t', "type", "Control-Overrides::Options::Type", "HasArg")] # Default arguments for i in ["add", "help", "list", "quiet", "set", "change", "no-action"]: key = "Control-Overrides::Options::%s" % i if key not in cnf: cnf[key] = "" if "Control-Overrides::Options::Component" not in cnf: cnf["Control-Overrides::Options::Component"] = "main" if "Control-Overrides::Options::Suite" not in cnf: cnf["Control-Overrides::Options::Suite"] = "unstable" if "Control-Overrides::Options::Type" not in cnf: cnf["Control-Overrides::Options::Type"] = "deb" file_list = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) if cnf["Control-Overrides::Options::Help"]: usage() session = DBConn().session() mode = None for i in ["add", "list", "set", "change"]: if cnf["Control-Overrides::Options::%s" % (i)]: if mode: utils.fubar("Can not perform more than one action at once.") mode = i # Need an action... if mode is None: utils.fubar("No action specified.") (suite, component, otype) = (cnf["Control-Overrides::Options::Suite"], cnf["Control-Overrides::Options::Component"], cnf["Control-Overrides::Options::Type"]) if mode == "list": list_overrides(suite, component, otype, session) else: if get_suite(suite).untouchable: utils.fubar("%s: suite is untouchable" % suite) action = True if cnf["Control-Overrides::Options::No-Action"]: utils.warn("In No-Action Mode") action = False Logger = daklog.Logger("control-overrides", mode) if file_list: for f in file_list: process_file(utils.open_file(f), suite, component, otype, mode, action, session) else: process_file(sys.stdin, suite, component, otype, mode, action, session) Logger.close()
def main(): cnf = Config() Arguments = [('h', "help", "Make-Maintainers::Options::Help"), ('a', "archive", "Make-Maintainers::Options::Archive", 'HasArg'), ('s', "source", "Make-Maintainers::Options::Source"), ('p', "print", "Make-Maintainers::Options::Print")] for i in ["Help", "Source", "Print"]: key = "Make-Maintainers::Options::%s" % i if key not in cnf: cnf[key] = "" extra_files = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) Options = cnf.subtree("Make-Maintainers::Options") if Options["Help"] or not Options.get('Archive'): usage() Logger = daklog.Logger('make-maintainers') session = DBConn().session() archive = session.query(Archive).filter_by( archive_name=Options['Archive']).one() # dictionary packages to maintainer names maintainers = dict() # dictionary packages to list of uploader names uploaders = dict() query = session.execute( text(''' SELECT bs.package, bs.name AS maintainer, array_agg(mu.name) OVER ( PARTITION BY bs.source, bs.id ORDER BY mu.name ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS uploaders FROM ( SELECT DISTINCT ON (package) * FROM ( SELECT s.id AS source, 0 AS id, s.source AS package, s.version, m.name FROM source AS s INNER JOIN maintainer AS m ON s.maintainer = m.id INNER JOIN src_associations AS sa ON s.id = sa.source INNER JOIN suite on sa.suite = suite.id WHERE suite.archive_id = :archive_id UNION SELECT b.source, b.id, b.package, b.version, m.name FROM binaries AS b INNER JOIN maintainer AS m ON b.maintainer = m.id INNER JOIN bin_associations AS ba ON b.id = ba.bin INNER JOIN suite on ba.suite = suite.id WHERE NOT :source_only AND suite.archive_id = :archive_id ) AS bs ORDER BY package, version desc ) AS bs LEFT OUTER JOIN -- find all uploaders for a given source src_uploaders AS su ON bs.source = su.source LEFT OUTER JOIN maintainer AS mu ON su.maintainer = mu.id ''').params(archive_id=archive.archive_id, source_only="True" if Options["Source"] else "False")) Logger.log(['database']) for entry in query: maintainers[entry['package']] = entry['maintainer'] if all(x is None for x in entry['uploaders']): uploaders[entry['package']] = [''] else: uploaders[entry['package']] = entry['uploaders'] Logger.log(['files']) # Process any additional Maintainer files (e.g. from pseudo # packages) for filename in extra_files: extrafile = utils.open_file(filename) for line in extrafile.readlines(): line = re_comments.sub('', line).strip() if line == "": continue (package, maintainer) = line.split(None, 1) maintainers[package] = maintainer uploaders[package] = [maintainer] if Options["Print"]: for package in sorted(maintainers): sys.stdout.write(format(package, maintainers[package])) else: maintainer_file = open('Maintainers', 'w') uploader_file = open('Uploaders', 'w') for package in sorted(uploaders): maintainer_file.write(format(package, maintainers[package])) for uploader in uploaders[package]: uploader_file.write(format(package, uploader)) uploader_file.close() maintainer_file.close() Logger.close()
def main(): global Logger cnf = Config() for i in ["Help", "Suite", "Force", "Quiet"]: key = "Generate-Releases::Options::%s" % i if key not in cnf: cnf[key] = "" Arguments = [('h', "help", "Generate-Releases::Options::Help"), ('a', 'archive', 'Generate-Releases::Options::Archive', 'HasArg'), ('s', "suite", "Generate-Releases::Options::Suite"), ('f', "force", "Generate-Releases::Options::Force"), ('q', "quiet", "Generate-Releases::Options::Quiet"), ('o', 'option', '', 'ArbItem')] suite_names = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) Options = cnf.subtree("Generate-Releases::Options") if Options["Help"]: usage() Logger = daklog.Logger('generate-releases') pool = DakProcessPool() session = DBConn().session() if Options["Suite"]: suites = [] for s in suite_names: suite = get_suite(s.lower(), session) if suite: suites.append(suite) else: print("cannot find suite %s" % s) Logger.log(['cannot find suite %s' % s]) else: query = session.query(Suite).filter(Suite.untouchable == False) # noqa:E712 if 'Archive' in Options: archive_names = utils.split_args(Options['Archive']) query = query.join(Suite.archive).filter(Archive.archive_name.in_(archive_names)) suites = query.all() for s in suites: # Setup a multiprocessing Pool. As many workers as we have CPU cores. if s.untouchable and not Options["Force"]: print("Skipping %s (untouchable)" % s.suite_name) continue if not Options["Quiet"]: print("Processing %s" % s.suite_name) Logger.log(['Processing release file for Suite: %s' % (s.suite_name)]) pool.apply_async(generate_helper, (s.suite_id, )) # No more work will be added to our pool, close it and then wait for all to finish pool.close() pool.join() retcode = pool.overall_status() if retcode > 0: # TODO: CENTRAL FUNCTION FOR THIS / IMPROVE LOGGING Logger.log(['Release file generation broken: %s' % (','.join([str(x[1]) for x in pool.results]))]) Logger.close() sys.exit(retcode)
def main(): global Options, Logger cnf = Config() summarystats = SummaryStats() Arguments = [('a', "automatic", "Dinstall::Options::Automatic"), ('h', "help", "Dinstall::Options::Help"), ('n', "no-action", "Dinstall::Options::No-Action"), ('p', "no-lock", "Dinstall::Options::No-Lock"), ('s', "no-mail", "Dinstall::Options::No-Mail"), ('d', "directory", "Dinstall::Options::Directory", "HasArg")] for i in ["automatic", "help", "no-action", "no-lock", "no-mail", "version", "directory"]: key = "Dinstall::Options::%s" % i if key not in cnf: cnf[key] = "" changes_files = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) Options = cnf.subtree("Dinstall::Options") if Options["Help"]: usage() # -n/--dry-run invalidates some other options which would involve things happening if Options["No-Action"]: Options["Automatic"] = "" # Obtain lock if not in no-action mode and initialize the log if not Options["No-Action"]: lock_fd = os.open(os.path.join(cnf["Dir::Lock"], 'process-upload.lock'), os.O_RDWR | os.O_CREAT) try: fcntl.flock(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB) except IOError as e: if e.errno in (errno.EACCES, errno.EAGAIN): utils.fubar("Couldn't obtain lock; assuming another 'dak process-upload' is already running.") else: raise # Initialise UrgencyLog() - it will deal with the case where we don't # want to log urgencies urgencylog = UrgencyLog() Logger = daklog.Logger("process-upload", Options["No-Action"]) # If we have a directory flag, use it to find our files if cnf["Dinstall::Options::Directory"] != "": # Note that we clobber the list of files we were given in this case # so warn if the user has done both if len(changes_files) > 0: utils.warn("Directory provided so ignoring files given on command line") changes_files = utils.get_changes_files(cnf["Dinstall::Options::Directory"]) Logger.log(["Using changes files from directory", cnf["Dinstall::Options::Directory"], len(changes_files)]) elif not len(changes_files) > 0: utils.fubar("No changes files given and no directory specified") else: Logger.log(["Using changes files from command-line", len(changes_files)]) process_changes(changes_files) if summarystats.accept_count: sets = "set" if summarystats.accept_count > 1: sets = "sets" print("Installed %d package %s, %s." % (summarystats.accept_count, sets, utils.size_type(int(summarystats.accept_bytes)))) Logger.log(["total", summarystats.accept_count, summarystats.accept_bytes]) if summarystats.reject_count: sets = "set" if summarystats.reject_count > 1: sets = "sets" print("Rejected %d package %s." % (summarystats.reject_count, sets)) Logger.log(["rejected", summarystats.reject_count]) if not Options["No-Action"]: urgencylog.close() Logger.close()
def main(): cnf = Config() Arguments = [ ('h', "help", "Override::Options::Help"), ('c', "check", "Override::Options::Check"), ('d', "done", "Override::Options::Done", "HasArg"), ('n', "no-action", "Override::Options::No-Action"), ('s', "suite", "Override::Options::Suite", "HasArg"), ] for i in ["help", "check", "no-action"]: if not cnf.has_key("Override::Options::%s" % (i)): cnf["Override::Options::%s" % (i)] = "" if not cnf.has_key("Override::Options::Suite"): cnf["Override::Options::Suite"] = "unstable" arguments = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) Options = cnf.subtree("Override::Options") if Options["Help"]: usage() session = DBConn().session() if not arguments: utils.fubar("package name is a required argument.") package = arguments.pop(0) suite_name = Options["Suite"] if arguments and len(arguments) > 2: utils.fubar("Too many arguments") suite = get_suite(suite_name, session) if suite is None: utils.fubar("Unknown suite '{0}'".format(suite_name)) if arguments and len(arguments) == 1: # Determine if the argument is a priority or a section... arg = arguments.pop() q = session.execute( """ SELECT ( SELECT COUNT(*) FROM section WHERE section = :arg ) AS secs, ( SELECT COUNT(*) FROM priority WHERE priority = :arg ) AS prios """, {'arg': arg}) r = q.fetchall() if r[0][0] == 1: arguments = (arg, ".") elif r[0][1] == 1: arguments = (".", arg) else: utils.fubar("%s is not a valid section or priority" % (arg)) # Retrieve current section/priority... oldsection, oldsourcesection, oldpriority = None, None, None for packagetype in ['source', 'binary']: eqdsc = '!=' if packagetype == 'source': eqdsc = '=' q = session.execute( """ SELECT priority.priority AS prio, section.section AS sect, override_type.type AS type FROM override, priority, section, suite, override_type WHERE override.priority = priority.id AND override.type = override_type.id AND override_type.type %s 'dsc' AND override.section = section.id AND override.package = :package AND override.suite = suite.id AND suite.suite_name = :suite_name """ % (eqdsc), { 'package': package, 'suite_name': suite_name }) if q.rowcount == 0: continue if q.rowcount > 1: utils.fubar("%s is ambiguous. Matches %d packages" % (package, q.rowcount)) r = q.fetchone() if packagetype == 'binary': oldsection = r[1] oldpriority = r[0] else: oldsourcesection = r[1] oldpriority = 'source' if not oldpriority and not oldsourcesection: utils.fubar("Unable to find package %s" % (package)) if oldsection and oldsourcesection and oldsection != oldsourcesection: # When setting overrides, both source & binary will become the same section utils.warn("Source is in section '%s' instead of '%s'" % (oldsourcesection, oldsection)) if not oldsection: oldsection = oldsourcesection if not arguments: print "%s is in section '%s' at priority '%s'" % (package, oldsection, oldpriority) sys.exit(0) # At this point, we have a new section and priority... check they're valid... newsection, newpriority = arguments if newsection == ".": newsection = oldsection if newpriority == ".": newpriority = oldpriority s = get_section(newsection, session) if s is None: utils.fubar("Supplied section %s is invalid" % (newsection)) newsecid = s.section_id p = get_priority(newpriority, session) if p is None: utils.fubar("Supplied priority %s is invalid" % (newpriority)) newprioid = p.priority_id if newpriority == oldpriority and newsection == oldsection: print "I: Doing nothing" sys.exit(0) if oldpriority == 'source' and newpriority != 'source': utils.fubar("Trying to change priority of a source-only package") if Options["Check"] and newpriority != oldpriority: check_override_compliance(package, p, suite.archive.path, suite_name, cnf, session) # If we're in no-action mode if Options["No-Action"]: if newpriority != oldpriority: print "I: Would change priority from %s to %s" % (oldpriority, newpriority) if newsection != oldsection: print "I: Would change section from %s to %s" % (oldsection, newsection) if Options.has_key("Done"): print "I: Would also close bug(s): %s" % (Options["Done"]) sys.exit(0) if newpriority != oldpriority: print "I: Will change priority from %s to %s" % (oldpriority, newpriority) if newsection != oldsection: print "I: Will change section from %s to %s" % (oldsection, newsection) if not Options.has_key("Done"): pass #utils.warn("No bugs to close have been specified. Noone will know you have done this.") else: print "I: Will close bug(s): %s" % (Options["Done"]) game_over() Logger = daklog.Logger("override") dsc_otype_id = get_override_type('dsc').overridetype_id # We're already in a transaction # We're in "do it" mode, we have something to do... do it if newpriority != oldpriority: session.execute( """ UPDATE override SET priority = :newprioid WHERE package = :package AND override.type != :otypedsc AND suite = (SELECT id FROM suite WHERE suite_name = :suite_name)""", { 'newprioid': newprioid, 'package': package, 'otypedsc': dsc_otype_id, 'suite_name': suite_name }) Logger.log(["changed priority", package, oldpriority, newpriority]) if newsection != oldsection: q = session.execute( """ UPDATE override SET section = :newsecid WHERE package = :package AND suite = (SELECT id FROM suite WHERE suite_name = :suite_name)""", { 'newsecid': newsecid, 'package': package, 'suite_name': suite_name }) Logger.log(["changed section", package, oldsection, newsection]) session.commit() if Options.has_key("Done"): if not cnf.has_key("Dinstall::BugServer"): utils.warn( "Asked to send Done message but Dinstall::BugServer is not configured" ) Logger.close() return Subst = {} Subst["__OVERRIDE_ADDRESS__"] = cnf["Dinstall::MyEmailAddress"] Subst["__BUG_SERVER__"] = cnf["Dinstall::BugServer"] bcc = [] if cnf.find("Dinstall::Bcc") != "": bcc.append(cnf["Dinstall::Bcc"]) if bcc: Subst["__BCC__"] = "Bcc: " + ", ".join(bcc) else: Subst["__BCC__"] = "X-Filler: 42" if cnf.has_key("Dinstall::PackagesServer"): Subst["__CC__"] = "Cc: " + package + "@" + cnf[ "Dinstall::PackagesServer"] + "\nX-DAK: dak override" else: Subst["__CC__"] = "X-DAK: dak override" Subst["__ADMIN_ADDRESS__"] = cnf["Dinstall::MyAdminAddress"] Subst["__DISTRO__"] = cnf["Dinstall::MyDistribution"] Subst["__WHOAMI__"] = utils.whoami() Subst["__SOURCE__"] = package summary = "Concerning package %s...\n" % (package) summary += "Operating on the %s suite\n" % (suite_name) if newpriority != oldpriority: summary += "Changed priority from %s to %s\n" % (oldpriority, newpriority) if newsection != oldsection: summary += "Changed section from %s to %s\n" % (oldsection, newsection) Subst["__SUMMARY__"] = summary template = os.path.join(cnf["Dir::Templates"], "override.bug-close") for bug in utils.split_args(Options["Done"]): Subst["__BUG_NUMBER__"] = bug mail_message = utils.TemplateSubst(Subst, template) utils.send_mail(mail_message) Logger.log(["closed bug", bug]) Logger.close()
def main(): cnf = Config() Arguments = [('h',"help","Make-Maintainers::Options::Help"), ('a',"archive","Make-Maintainers::Options::Archive",'HasArg'), ('s',"source","Make-Maintainers::Options::Source"), ('p',"print","Make-Maintainers::Options::Print")] for i in ["Help", "Source", "Print" ]: if not cnf.has_key("Make-Maintainers::Options::%s" % (i)): cnf["Make-Maintainers::Options::%s" % (i)] = "" extra_files = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) Options = cnf.subtree("Make-Maintainers::Options") if Options["Help"] or not Options.get('Archive'): usage() Logger = daklog.Logger('make-maintainers') session = DBConn().session() archive = session.query(Archive).filter_by(archive_name=Options['Archive']).one() # dictionary packages to maintainer names maintainers = dict() # dictionary packages to list of uploader names uploaders = dict() source_query = session.query(DBSource).from_statement(''' select distinct on (source.source) source.* from source join src_associations sa on source.id = sa.source join suite on sa.suite = suite.id where suite.archive_id = :archive_id order by source.source, source.version desc''') \ .params(archive_id=archive.archive_id) binary_query = session.query(DBBinary).from_statement(''' select distinct on (binaries.package) binaries.* from binaries join bin_associations ba on binaries.id = ba.bin join suite on ba.suite = suite.id where suite.archive_id = :archive_id order by binaries.package, binaries.version desc''') \ .params(archive_id=archive.archive_id) Logger.log(['sources']) for source in source_query: maintainers[source.source] = source.maintainer.name uploaders[source.source] = uploader_list(source) if not Options["Source"]: Logger.log(['binaries']) for binary in binary_query: if binary.package not in maintainers: maintainers[binary.package] = binary.maintainer.name uploaders[binary.package] = uploader_list(binary.source) Logger.log(['files']) # Process any additional Maintainer files (e.g. from pseudo # packages) for filename in extra_files: extrafile = utils.open_file(filename) for line in extrafile.readlines(): line = re_comments.sub('', line).strip() if line == "": continue (package, maintainer) = line.split(None, 1) maintainers[package] = maintainer uploaders[package] = [maintainer] if Options["Print"]: for package in sorted(maintainers): sys.stdout.write(format(package, maintainers[package])) else: maintainer_file = open('Maintainers', 'w') uploader_file = open('Uploaders', 'w') for package in sorted(uploaders): maintainer_file.write(format(package, maintainers[package])) for uploader in uploaders[package]: uploader_file.write(format(package, uploader)) uploader_file.close() maintainer_file.close() Logger.close()
def main(): global Logger, Options, sections, priorities cnf = Config() Arguments = [('h', "help", "Check-Overrides::Options::Help"), ('n', "no-action", "Check-Overrides::Options::No-Action")] for i in ["help", "no-action"]: key = "Check-Overrides::Options::%s" % i if key not in cnf: cnf[key] = "" apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) Options = cnf.subtree("Check-Overrides::Options") if Options["Help"]: usage() session = DBConn().session() # init sections, priorities: # We need forward and reverse sections = get_sections(session) for name, entry in list(sections.items()): sections[entry] = name priorities = get_priorities(session) for name, entry in list(priorities.items()): priorities[entry] = name if not Options["No-Action"]: Logger = daklog.Logger("check-overrides") else: Logger = daklog.Logger("check-overrides", 1) for suite in session.query(Suite).filter(Suite.overrideprocess == True): # noqa:E712 originosuite = None originremark = '' if suite.overrideorigin is not None: originosuite = get_suite(suite.overrideorigin, session) if originosuite is None: utils.fubar("%s has an override origin suite of %s but it doesn't exist!" % (suite.suite_name, suite.overrideorigin)) originosuite = originosuite.suite_name originremark = " taking missing from %s" % originosuite print("Processing %s%s..." % (suite.suite_name, originremark)) # Get a list of all suites that use the override file of 'suite.suite_name' as # well as the suite ocodename = suite.codename suiteids = [x.suite_id for x in session.query(Suite).filter(Suite.overridecodename == ocodename).all()] if suite.suite_id not in suiteids: suiteids.append(suite.suite_id) if len(suiteids) < 1: utils.fubar("Couldn't find id's of all suites: %s" % suiteids) for component in session.query(Component).all(): # It is crucial for the dsc override creation based on binary # overrides that 'dsc' goes first component_name = component.component_name otypes = ['dsc'] for ot in session.query(OverrideType): if ot.overridetype == 'dsc': continue otypes.append(ot.overridetype) for otype in otypes: print("Processing %s [%s - %s]" % (suite.suite_name, component_name, otype)) sys.stdout.flush() process(suite.suite_name, suiteids, originosuite, component_name, otype, session) Logger.close()
def main(): global Logger cnf = Config() Arguments = [('a', "add", "Control-Suite::Options::Add", "HasArg"), ('b', "britney", "Control-Suite::Options::Britney"), ('f', 'force', 'Control-Suite::Options::Force'), ('h', "help", "Control-Suite::Options::Help"), ('l', "list", "Control-Suite::Options::List", "HasArg"), ('r', "remove", "Control-Suite::Options::Remove", "HasArg"), ('s', "set", "Control-Suite::Options::Set", "HasArg")] for i in ["add", "britney", "help", "list", "remove", "set", "version"]: key = "Control-Suite::Options::%s" % i if key not in cnf: cnf[key] = "" try: file_list = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) except SystemError as e: print("%s\n" % e) usage(1) Options = cnf.subtree("Control-Suite::Options") if Options["Help"]: usage() force = "Force" in Options and Options["Force"] action = None for i in ("add", "list", "remove", "set"): if cnf["Control-Suite::Options::%s" % (i)] != "": suite_name = cnf["Control-Suite::Options::%s" % (i)] if action: utils.fubar("Can only perform one action at a time.") action = i # Need an action... if action is None: utils.fubar("No action specified.") britney = False if action == "set" and cnf["Control-Suite::Options::Britney"]: britney = True if action == "list": session = DBConn().session() suite = session.query(Suite).filter_by(suite_name=suite_name).one() get_list(suite, session) else: Logger = daklog.Logger("control-suite") with ArchiveTransaction() as transaction: session = transaction.session suite = session.query(Suite).filter_by(suite_name=suite_name).one() if action == "set" and not suite.allowcsset: if force: utils.warn( "Would not normally allow setting suite {0} (allowcsset is FALSE), but --force used" .format(suite_name)) else: utils.fubar( "Will not reset suite {0} due to its database configuration (allowcsset is FALSE)" .format(suite_name)) if file_list: for f in file_list: process_file(utils.open_file(f), suite, action, transaction, britney, force) else: process_file(sys.stdin, suite, action, transaction, britney, force) Logger.close()
def main(): from daklib.config import Config from daklib import daklog cnf = Config() Arguments = [('h', "help", "Generate-Packages-Sources::Options::Help"), ('a', 'archive', 'Generate-Packages-Sources::Options::Archive', 'HasArg'), ('s', "suite", "Generate-Packages-Sources::Options::Suite", 'HasArg'), ('f', "force", "Generate-Packages-Sources::Options::Force"), ('o', 'option', '', 'ArbItem')] apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) try: Options = cnf.subtree("Generate-Packages-Sources::Options") except KeyError: Options = {} if Options.has_key("Help"): usage() from daklib.dakmultiprocessing import DakProcessPool, PROC_STATUS_SUCCESS, PROC_STATUS_SIGNALRAISED pool = DakProcessPool() logger = daklog.Logger('generate-packages-sources2') from daklib.dbconn import Component, DBConn, get_suite, Suite, Archive session = DBConn().session() session.execute("SELECT add_missing_description_md5()") session.commit() import daklib.utils if Options.has_key("Suite"): suites = [] suite_names = daklib.utils.split_args(Options['Suite']) for s in suite_names: suite = get_suite(s.lower(), session) if suite: suites.append(suite) else: print "I: Cannot find suite %s" % s logger.log(['Cannot find suite %s' % s]) else: query = session.query(Suite).filter(Suite.untouchable == False) if 'Archive' in Options: archive_names = daklib.utils.split_args(Options['Archive']) query = query.join(Suite.archive).filter( Archive.archive_name.in_(archive_names)) suites = query.all() force = Options.has_key("Force") and Options["Force"] def parse_results(message): # Split out into (code, msg) code, msg = message if code == PROC_STATUS_SUCCESS: logger.log(msg) elif code == PROC_STATUS_SIGNALRAISED: logger.log(['E: Subprocess received signal ', msg]) else: logger.log(['E: ', msg]) # Lock tables so that nobody can change things underneath us session.execute("LOCK TABLE src_associations IN SHARE MODE") session.execute("LOCK TABLE bin_associations IN SHARE MODE") for s in suites: component_ids = [c.component_id for c in s.components] if s.untouchable and not force: import daklib.utils daklib.utils.fubar( "Refusing to touch %s (untouchable and not forced)" % s.suite_name) for c in component_ids: pool.apply_async(generate_sources, [s.suite_id, c], callback=parse_results) if not s.include_long_description: pool.apply_async(generate_translations, [s.suite_id, c], callback=parse_results) for a in s.architectures: if a == 'source': continue pool.apply_async(generate_packages, [s.suite_id, c, a.arch_id, 'deb'], callback=parse_results) pool.apply_async(generate_packages, [s.suite_id, c, a.arch_id, 'udeb'], callback=parse_results) pool.close() pool.join() # this script doesn't change the database session.close() logger.close() sys.exit(pool.overall_status())
def main(): global Options, Logger, Queue, changes cnf = Config() Arguments = [('h', "Help", "Security::Options::Help"), ('n', "No-Action", "Security::Options::No-Action"), ('c', 'Changesfile', "Security::Options::Changesfile"), ('s', "Sudo", "Security::Options::Sudo"), ('A', "Approve", "Security::Options::Approve")] for i in ["Help", "No-Action", "Changesfile", "Sudo", "Approve"]: key = "Security::Options::%s" % i if key not in cnf: cnf[key] = "" changes_files = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) Options = cnf.subtree("Security::Options") if Options['Help']: usage() changesfiles = {} for a in changes_files: if not a.endswith(".changes"): utils.fubar("not a .changes file: %s" % (a)) changesfiles[a] = 1 changes = list(changesfiles.keys()) username = utils.getusername() if username != "dak": print("Non-dak user: %s" % username) Options["Sudo"] = "y" if Options["No-Action"]: Options["Sudo"] = "" if not Options["Sudo"] and not Options["No-Action"]: Logger = daklog.Logger("security-install") session = DBConn().session() # If we call ourselve to approve, we do just that and exit if Options["Approve"]: do_Approve() sys.exit() if len(changes) == 0: utils.fubar("Need changes files as arguments") # Yes, we could do this inside do_Approve too. But this way we see who exactly # called it (ownership of the file) acceptfiles = {} for change in changes: dbchange = get_dbchange(os.path.basename(change), session) # strip epoch from version version = dbchange.version version = version[(version.find(':') + 1):] # strip possible version from source (binNMUs) source = dbchange.source.split(None, 1)[0] acceptfilename = "%s/COMMENTS/ACCEPT.%s_%s" % (os.path.dirname( os.path.abspath(changes[0])), source, version) acceptfiles[acceptfilename] = 1 print( "Would create %s now and then go on to accept this package, if you allow me to." % (list(acceptfiles.keys()))) if Options["No-Action"]: sys.exit(0) else: six.moves.input("Press Enter to continue") for acceptfilename in acceptfiles: with open(acceptfilename, "w") as accept_file: accept_file.write("OK\n") do_Approve()