import apt_pkg, apt_inst
import examine_package
import subprocess
+import daklib.daksubprocess
+from sqlalchemy import or_
from daklib.dbconn import *
from daklib.queue import *
################################################################################
+def takenover_binaries(upload, missing, session):
+ rows = []
+ binaries = set([x.package for x in upload.binaries])
+ for m in missing:
+ if m['type'] != 'dsc':
+ binaries.remove(m['package'])
+ if binaries:
+ source = upload.binaries[0].source.source
+ suite = upload.target_suite.overridesuite or \
+ upload.target_suite.suite_name
+ suites = [s[0] for s in session.query(Suite.suite_name).filter \
+ (or_(Suite.suite_name == suite,
+ Suite.overridesuite == suite)).all()]
+ rows = session.query(DBSource.source, DBBinary.package).distinct(). \
+ filter(DBBinary.package.in_(binaries)). \
+ join(DBBinary.source). \
+ filter(DBSource.source != source). \
+ join(DBBinary.suites). \
+ filter(Suite.suite_name.in_(suites)). \
+ order_by(DBSource.source, DBBinary.package).all()
+ return rows
+
+################################################################################
+
def print_new (upload, missing, indexed, session, file=sys.stdout):
check_valid(missing, session)
index = 0
if not m['valid']:
line = line + ' [!]'
print >>file, line
- notes = get_new_comments(upload.changes.source)
+ takenover = takenover_binaries(upload, missing, session)
+ if takenover:
+ print '\n\nBINARIES TAKEN OVER\n'
+ for t in takenover:
+ print '%s: %s' % (t[0], t[1])
+ notes = get_new_comments(upload.policy_queue, upload.changes.source)
for note in notes:
print "\nAuthor: %s\nVersion: %s\nTimestamp: %s\n\n%s" \
% (note.author, note.version, note.notedate, note.comment)
suite_name = upload.target_suite.suite_name
handler = PolicyQueueUploadHandler(upload, session)
missing = [(m['type'], m["package"]) for m in handler.missing_overrides(hints=missing)]
+
+ less_cmd = ("less", "-R", "-")
+ less_process = daklib.daksubprocess.Popen(less_cmd, bufsize=0, stdin=subprocess.PIPE)
try:
- sys.stdout = os.popen("less -R -", 'w', 0)
+ sys.stdout = less_process.stdin
print examine_package.display_changes(suite_name, changes)
source = upload.source
print examined
print examine_package.output_package_relations()
+ less_process.stdin.close()
except IOError as e:
if e.errno == errno.EPIPE:
utils.warn("[examine_package] Caught EPIPE; skipping.")
except KeyboardInterrupt:
utils.warn("[examine_package] Caught C-c; skipping.")
finally:
+ less_process.wait()
sys.stdout = save_stdout
################################################################################
changes=changes,
)
- subprocess.check_call(shell_command, shell=True)
+ daklib.daksubprocess.check_call(shell_command, shell=True)
################################################################################
missing = handler.missing_overrides(hints=missing)
broken = not check_valid(missing, session)
+ changesname = os.path.basename(upload.changes.changesname)
+
+ print
+ print changesname
+ print "-" * len(changesname)
+ print
+ print " Target: {0}".format(upload.target_suite.suite_name)
+ print " Changed-By: {0}".format(upload.changes.changedby)
+ print
+
#if len(byhand) == 0 and len(missing) == 0:
# break
continue
if answer == 'A' and not Options["Trainee"]:
- try:
- check_daily_lock()
- add_overrides(missing, upload.target_suite, session)
- if Config().find_b("Dinstall::BXANotify"):
- do_bxa_notification(missing, upload, session)
- handler.accept()
- done = True
- Logger.log(["NEW ACCEPT", upload.changes.changesname])
- except CantGetLockError:
- print "Hello? Operator! Give me the number for 911!"
- print "Dinstall in the locked area, cant process packages, come back later"
+ add_overrides(missing, upload.target_suite, session)
+ if Config().find_b("Dinstall::BXANotify"):
+ do_bxa_notification(missing, upload, session)
+ handler.accept()
+ done = True
+ Logger.log(["NEW ACCEPT", upload.changes.changesname])
elif answer == 'C':
check_pkg(upload, upload_copy, session)
elif answer == 'E' and not Options["Trainee"]:
missing = edit_overrides (missing, upload, session)
elif answer == 'M' and not Options["Trainee"]:
reason = Options.get('Manual-Reject', '') + "\n"
- reason = reason + "\n\n=====\n\n".join([n.comment for n in get_new_comments(upload.changes.source, session=session)])
+ reason = reason + "\n\n=====\n\n".join([n.comment for n in get_new_comments(upload.policy_queue, upload.changes.source, session=session)])
reason = get_reject_reason(reason)
if reason is not None:
Logger.log(["NEW REJECT", upload.changes.changesname])
handler.reject(reason)
done = True
elif answer == 'N':
- if edit_note(get_new_comments(upload.changes.source, session=session),
+ if edit_note(get_new_comments(upload.policy_queue, upload.changes.source, session=session),
upload, session, bool(Options["Trainee"])) == 0:
end()
sys.exit(0)
elif answer == 'P' and not Options["Trainee"]:
- if prod_maintainer(get_new_comments(upload.changes.source, session=session),
+ if prod_maintainer(get_new_comments(upload.policy_queue, upload.changes.source, session=session),
upload) == 0:
end()
sys.exit(0)
elif answer == 'R' and not Options["Trainee"]:
confirm = utils.our_raw_input("Really clear note (y/N)? ").lower()
if confirm == "y":
- for c in get_new_comments(upload.changes.source, upload.changes.version, session=session):
+ for c in get_new_comments(upload.policy_queue, upload.changes.source, upload.changes.version, session=session):
session.delete(c)
session.commit()
elif answer == 'O' and not Options["Trainee"]:
confirm = utils.our_raw_input("Really clear all notes (y/N)? ").lower()
if confirm == "y":
- for c in get_new_comments(upload.changes.source, session=session):
+ for c in get_new_comments(upload.policy_queue, upload.changes.source, session=session):
session.delete(c)
session.commit()
-h, --help show this help and exit.
-m, --manual-reject=MSG manual reject with `msg'
-n, --no-action don't do anything
+ -q, --queue=QUEUE operate on a different queue
-t, --trainee FTP Trainee mode
-V, --version display the version number and exit
################################################################################
-def check_daily_lock():
- """
- Raises CantGetLockError if the dinstall daily.lock exists.
- """
-
- cnf = Config()
- try:
- lockfile = cnf.get("Process-New::DinstallLockFile",
- os.path.join(cnf['Dir::Lock'], 'processnew.lock'))
-
- os.open(lockfile,
- os.O_RDONLY | os.O_CREAT | os.O_EXCL)
- except OSError as e:
- if e.errno == errno.EEXIST or e.errno == errno.EACCES:
- raise CantGetLockError
-
- os.unlink(lockfile)
-
@contextlib.contextmanager
def lock_package(package):
"""
dsc = upload.source
cnf = Config()
+ group = cnf.get('Dinstall::UnprivGroup') or None
+
#bcc = "X-DAK: dak process-new"
#if cnf.has_key("Dinstall::Bcc"):
# u.Subst["__BCC__"] = bcc + "\nBcc: %s" % (cnf["Dinstall::Bcc"])
try:
with lock_package(upload.changes.source):
- with UploadCopy(upload) as upload_copy:
+ with UploadCopy(upload, group=group) as upload_copy:
handler = PolicyQueueUploadHandler(upload, session)
if handler.get_action() is not None:
print "PENDING %s\n" % handler.get_action()
################################################################################
-def sort_uploads(uploads, session, nobinaries=False):
+def sort_uploads(new_queue, uploads, session, nobinaries=False):
sources = {}
sorteduploads = []
suitesrc = [s.source for s in session.query(DBSource.source). \
filter(DBSource.suites.any(Suite.suite_name.in_(['unstable', 'experimental'])))]
comments = [p.package for p in session.query(NewComment.package). \
- filter_by(trainee=False).distinct()]
+ filter_by(trainee=False, policy_queue=new_queue).distinct()]
for upload in uploads:
source = upload.changes.source
if not source in sources:
if len(uploads) > 1:
sys.stderr.write("Sorting changes...\n")
- uploads = sort_uploads(uploads, session, Options["No-Binaries"])
+ uploads = sort_uploads(new_queue, uploads, session, Options["No-Binaries"])
if Options["Comments"]:
show_new_comments(uploads, session)
else:
for upload in uploads:
- print "\n" + os.path.basename(upload.changes.changesname)
-
do_pkg (upload, session)
end()