if test == None:
# Edit is broken
- answer = "XXX"
- prompt = "Broken edit: [E]dit again, Drop changes?"
-
- while prompt.find(answer) == -1:
- answer = daklib.utils.our_raw_input(prompt)
- if answer == "":
- answer = "E"
- answer = answer[:1].upper()
-
- if answer == 'E':
- continue
- elif answer == 'D':
- os.unlink(tempfile)
- os.unlink(lockfile)
- print "OK, discarding changes"
- sys.exit(0)
- print "Edit was unparsable."
++ print "Edit was unparsable."
+ prompt = "[E]dit again, Drop changes?"
- default = "E"
- else:
- print "Edit looks okay.\n"
++ default = "E"
+ else:
- # No problems in loading the new file, jump out of the while loop
++ print "Edit looks okay.\n"
+ print "------------------------------------------------------------------------"
+ transition_info(test)
+
+ prompt = "[S]ave, Edit again, Drop changes?"
+ default = "S"
+
+ answer = "XXX"
+ while prompt.find(answer) == -1:
+ answer = daklib.utils.our_raw_input(prompt)
+ if answer == "":
+ answer = default
+ answer = answer[:1].upper()
+
+ if answer == 'E':
+ continue
+ elif answer == 'D':
+ os.unlink(edit_file)
+ print "OK, discarding changes"
+ sys.exit(0)
+ elif answer == 'S':
+ # Ready to save
break
- else:
- print "You pressed something you shouldn't have :("
- sys.exit(1)
++ else:
++ print "You pressed something you shouldn't have :("
++ sys.exit(1)
# We seem to be done and also have a working file. Copy over.
- # We are not using daklib.utils.copy here, as we use sudo to get this file copied, to
- # limit the rights needed to edit transitions
- os.spawnl(os.P_WAIT, "/usr/bin/sudo", "/usr/bin/sudo", "-u", "dak", "-H",
- "cp", tempfile, trans_file)
-
- os.unlink(tempfile)
- os.unlink(lockfile)
-
- # Before we finish print out transition info again
- print "\n\n------------------------------------------------------------------------"
- print "Edit done, file saved, currently defined transitions:\n"
- transitions = load_transitions(Cnf["Dinstall::Reject::ReleaseTransitions"])
- transition_info(transitions)
-
- ################################################################################
-
- def load_transitions(trans_file):
- # Parse the yaml file
- sourcefile = file(trans_file, 'r')
- sourcecontent = sourcefile.read()
- try:
- trans = syck.load(sourcecontent)
- except syck.error, msg:
- # Someone fucked it up
- print "ERROR: %s" % (msg)
- return None
- return trans
-
- ################################################################################
-
- def print_info(trans, source, expected, rm, reason, packages):
- print """
- Looking at transition: %s
- Source: %s
- New Version: %s
- Responsible: %s
- Description: %s
- Blocked Packages (total: %d): %s
- """ % (trans, source, expected, rm, reason, len(packages), ", ".join(packages))
- return
-
- ################################################################################
-
- def transition_info(transitions):
- for trans in transitions:
- t = transitions[trans]
- source = t["source"]
- expected = t["new"]
-
- # Will be None if nothing is in testing.
- current = daklib.database.get_suite_version(source, "testing")
-
- print_info(trans, source, expected, t["rm"], t["reason"], t["packages"])
+ write_transitions_from_file(edit_file)
+ os.unlink(edit_file)
- if current == None:
- # No package in testing
- print "Transition source %s not in testing, transition still ongoing." % (source)
- else:
- compare = apt_pkg.VersionCompare(current, expected)
- print "Apt compare says: %s" % (compare)
- if compare < 0:
- # This is still valid, the current version in database is older than
- # the new version we wait for
- print "This transition is still ongoing, we currently have version %s" % (current)
- else:
- print "This transition is over, the target package reached testing, should be removed"
- print "%s wanted version: %s, has %s" % (source, expected, current)
- print "-------------------------------------------------------------------------"
+ print "Transitions file updated."
################################################################################