X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fqueue_install.py;h=80787b5cb411c533bf243fa3ceb55c05925c5cc5;hb=e531ecdc04d1c9204ab001a3dac9eda2b6405338;hp=b4a38b96e4488ff697745bcf86382b9ee9ce27c0;hpb=bf38dcbe75f32f221887eeda8fce0e81e64db115;p=dak.git diff --git a/daklib/queue_install.py b/daklib/queue_install.py old mode 100644 new mode 100755 index b4a38b96..80787b5c --- a/daklib/queue_install.py +++ b/daklib/queue_install.py @@ -61,7 +61,7 @@ def package_to_queue(u, summary, short_summary, queue, chg, session, announce=No u.logger.log(["Moving to %s" % queue.queue_name, u.pkg.changes_file]) u.move_to_queue(queue) - chg.in_queue = queue.queue_id + chg.in_queue_id = queue.policy_queue_id session.add(chg) session.commit() @@ -69,59 +69,68 @@ def package_to_queue(u, summary, short_summary, queue, chg, session, announce=No u.check_override() # Send accept mail, announce to lists and close bugs - if announce and not cnf["Dinstall::Options::No-Mail"]: + if announce: template = os.path.join(cnf["Dir::Templates"], announce) u.update_subst() - u.Subst["__SUITE__"] = "" mail_message = utils.TemplateSubst(u.Subst, template) utils.send_mail(mail_message) u.announce(short_summary, True) ################################################################################ -# TODO: This logic needs to be replaced with policy queues before we upgrade -# security master +def is_unembargo(u): + session = DBConn().session() + cnf = Config() -#def is_unembargo(u): -# session = DBConn().session() -# cnf = Config() -# -# q = session.execute("SELECT package FROM disembargo WHERE package = :source AND version = :version", u.pkg.changes) -# if q.rowcount > 0: -# session.close() -# return True -# -# oldcwd = os.getcwd() -# os.chdir(cnf["Dir::Queue::Disembargo"]) -# disdir = os.getcwd() -# os.chdir(oldcwd) -# -# ret = False -# -# if u.pkg.directory == disdir: -# if u.pkg.changes["architecture"].has_key("source"): -# session.execute("INSERT INTO disembargo (package, version) VALUES (:package, :version)", u.pkg.changes) -# session.commit() -# -# ret = True -# -# session.close() -# -# return ret -# -#def queue_unembargo(u, summary, short_summary, session=None): -# return package_to_queue(u, summary, short_summary, "Unembargoed", -# perms=0660, build=True, announce='process-unchecked.accepted') + # If we dont have the disembargo queue we are not on security and so not interested + # in doing any security queue handling + if not get_policy_queue("disembargo"): + return False + + q = session.execute("SELECT package FROM disembargo WHERE package = :source AND version = :version", + {'source': u.pkg.changes["source"], + 'version': u.pkg.changes["version"]}) + if q.rowcount > 0: + session.close() + return True + + oldcwd = os.getcwd() + os.chdir(cnf["Dir::Queue::Disembargo"]) + disdir = os.getcwd() + os.chdir(oldcwd) + + ret = False + + if u.pkg.directory == disdir: + if u.pkg.changes["architecture"].has_key("source"): + session.execute("INSERT INTO disembargo (package, version) VALUES (:package, :version)", + {'source': u.pkg.changes["source"], + 'version': u.pkg.changes["version"]}) + session.commit() + + ret = True + + session.close() + + return ret + +def do_unembargo(u, summary, short_summary, chg, session=None): + return package_to_queue(u, summary, short_summary, + get_policy_queue('disembargo'), chg, session, + announce=None) # ################################################################################# # -#def is_embargo(u): -# # if embargoed queues are enabled always embargo -# return True -# -#def queue_embargo(u, summary, short_summary, session=None): -# return package_to_queue(u, summary, short_summary, "Unembargoed", -# perms=0660, build=True, announce='process-unchecked.accepted') +def is_embargo(u): + # if we are the security archive, we always have a embargo queue and its the + # last in line, so if that exists, return true + if get_policy_queue('embargo'): + return True + +def do_embargo(u, summary, short_summary, chg, session=None): + return package_to_queue(u, summary, short_summary, + get_policy_queue('embargo'), chg, session, + announce=None) ################################################################################ @@ -166,7 +175,7 @@ def is_autobyhand(u): def do_autobyhand(u, summary, short_summary, chg, session): print "Attempting AUTOBYHAND." - byhandleft = True + byhandleft = False for f, entry in u.pkg.files.items(): byhandfile = f @@ -188,7 +197,7 @@ def do_autobyhand(u, summary, short_summary, chg, session): if result == 0: os.unlink(byhandfile) - del entry + del u.pkg.files[f] else: print "Error processing %s, left as byhand." % (f) byhandleft = True @@ -209,7 +218,7 @@ def is_byhand(u): def do_byhand(u, summary, short_summary, chg, session): return package_to_queue(u, summary, short_summary, - get_queue('byhand'), chg, session, + get_policy_queue('byhand'), chg, session, announce=None) ################################################################################ @@ -226,28 +235,31 @@ def acknowledge_new(u, summary, short_summary, chg, session): print "Moving to NEW queue." u.logger.log(["Moving to new", u.pkg.changes_file]) - q = get_queue('new', session) + q = get_policy_queue('new', session) u.move_to_queue(q) - chg.in_queue = q.queue_id + chg.in_queue_id = q.policy_queue_id session.add(chg) session.commit() - if not cnf["Dinstall::Options::No-Mail"]: - print "Sending new ack." - template = os.path.join(cnf["Dir::Templates"], 'process-unchecked.new') - u.update_subst() - u.Subst["__SUMMARY__"] = summary - new_ack_message = utils.TemplateSubst(u.Subst, template) - utils.send_mail(new_ack_message) + print "Sending new ack." + template = os.path.join(cnf["Dir::Templates"], 'process-unchecked.new') + u.update_subst() + u.Subst["__SUMMARY__"] = summary + new_ack_message = utils.TemplateSubst(u.Subst, template) + utils.send_mail(new_ack_message) ################################################################################ +# FIXME: queues should be able to get autobuild +# the current logic doesnt allow this, as buildd stuff is AFTER accept... # q-unapproved hax0ring QueueInfo = { "new": { "is": is_new, "process": acknowledge_new }, "autobyhand" : { "is" : is_autobyhand, "process": do_autobyhand }, "byhand" : { "is": is_byhand, "process": do_byhand }, + "embargoed" : { "is": is_embargo, "process": do_embargo }, + "unembargoed" : { "is": is_unembargo, "process": do_unembargo }, } def determine_target(u): @@ -256,7 +268,7 @@ def determine_target(u): # Statically handled queues target = None - for q in ["new", "autobyhand", "byhand"]: + for q in ["autobyhand", "byhand", "new", "unembargoed", "embargoed"]: if QueueInfo[q]["is"](u): target = q break