274 |
if not force: return False |
if not force: return False |
275 |
|
|
276 |
# XXX - os.path.join is hackish |
# XXX - os.path.join is hackish |
277 |
if subprocess.check_output(["svn", "diff", os.path.join(self.path, '..')]) != '': |
svn_diff_output = subprocess.check_output(["svn", "diff", os.path.join(self.path, '..')]) |
278 |
|
if svn_diff_output != '': |
279 |
|
print svn_diff_output |
280 |
print >>sys.stderr, "ERROR: Package has uncommitted changes!" |
print >>sys.stderr, "ERROR: Package has uncommitted changes!" |
281 |
return False |
if not force: |
282 |
|
return False |
283 |
|
|
284 |
|
# Forcing package submission: revert changes |
285 |
|
try: |
286 |
|
print >>sys.stderr, "WARNING: Force used; reverting svn changes" |
287 |
|
subprocess.check_call(["svn", "revert", "-R", os.path.join(self.path, '..')]) |
288 |
|
except subprocess.CalledProcessError: |
289 |
|
return False |
290 |
|
|
291 |
with open(self.path, "rw") as f: |
with open(self.path, "rw") as f: |
292 |
data = f.read() |
data = f.read() |
337 |
# Check patches still apply |
# Check patches still apply |
338 |
subprocess.check_call(['bm', '-p', '--nodeps'], cwd=self.cwd) |
subprocess.check_call(['bm', '-p', '--nodeps'], cwd=self.cwd) |
339 |
except subprocess.CalledProcessError: |
except subprocess.CalledProcessError: |
340 |
|
logfile = os.path.join(os.path.dirname(self.path), 'log.%s' % os.path.splitext(os.path.basename(self.path))[0]) |
341 |
|
if os.path.exists(logfile) |
342 |
|
subprocess.call(['tail', '-n', '15', logfile]) |
343 |
return False |
return False |
344 |
|
|
345 |
return True |
return True |
539 |
if upstream not in downstream: |
if upstream not in downstream: |
540 |
raise ValueError("No packages for upstream name: %s" % upstream) |
raise ValueError("No packages for upstream name: %s" % upstream) |
541 |
|
|
542 |
if len(downstream[upstream]) != 1: |
if len(downstream[upstream]) == 1: |
543 |
# XXX - Make it more intelligent |
return downstream[upstream].keys() |
544 |
raise ValueError("Multiple packages found for %s: %s" % (upstream, ", ".join(downstream[upstream].keys()))) |
|
545 |
|
# Directories packages are located in |
546 |
|
root = os.path.expanduser(PKGROOT) |
547 |
|
|
548 |
|
packages = {} |
549 |
|
for package in downstream[upstream].keys(): |
550 |
|
cwd = os.path.join(root, package) |
551 |
|
|
552 |
|
# Checkout package to ensure the checkout reflects the latest changes |
553 |
|
try: |
554 |
|
subprocess.check_call(['mgarepo', 'co', package], cwd=root) |
555 |
|
except subprocess.CalledProcessError: |
556 |
|
raise ValueError("Multiple packages found and cannot checkout %s" % package) |
557 |
|
|
558 |
|
# Determine version from spec file |
559 |
|
try: |
560 |
|
packages[package] = SpecFile(os.path.join(cwd, "SPECS", "%s.spec" % package)).version |
561 |
|
except subprocess.CalledProcessError: |
562 |
|
raise ValueError("Multiple packages found and cannot determine version of %s" % package) |
563 |
|
|
564 |
|
# Return all packages reflecting the current version |
565 |
|
matches = [package for package in packages if packages[package] == version] |
566 |
|
if len(matches): |
567 |
|
return matches |
568 |
|
|
569 |
|
# Return all packages reflecting the version before the current version |
570 |
|
latest_version = get_latest_version(packages.values(), max_version=version) |
571 |
|
matches = [package for package in packages if packages[package] == latest_version] |
572 |
|
if len(matches): |
573 |
|
return matches |
574 |
|
|
575 |
return downstream[upstream].keys() |
# Give up |
576 |
|
raise ValueError("Multiple packages found and cannot determine package for version %s" % version) |
577 |
|
|
578 |
def write_file(path, data): |
def write_file(path, data): |
579 |
with tempfile.NamedTemporaryFile(dir=os.path.dirname(path), delete=False) as fdst: |
with tempfile.NamedTemporaryFile(dir=os.path.dirname(path), delete=False) as fdst: |
697 |
if error: |
if error: |
698 |
# XXX - ugly |
# XXX - ugly |
699 |
contents.seek(0) |
contents.seek(0) |
700 |
lastline = contents.read().splitlines()[-1] |
lastline = contents.read().rstrip().splitlines()[-1] |
701 |
# Remove things like "ERROR: " and so on from the last line |
# Remove things like "ERROR: " and so on from the last line |
702 |
lastline = re.sub(r'^(?:[^ :]+:\s+)+', '', lastline) |
lastline = re.sub(r'^(?:[^ :]+:\s+)+', '', lastline) |
703 |
subjecterror = " (ERROR: %s)" % lastline if lastline else " (ERROR)" |
subjecterror = " (ERROR: %s)" % lastline if lastline else " (ERROR)" |
758 |
|
|
759 |
error = False |
error = False |
760 |
for package in packages: |
for package in packages: |
761 |
if subprocess.call(['mga-gnome', 'increase', '--submit', '--hash', hexdigest, package, version], stdout=stdout, stderr=stderr): |
cmd = ['mga-gnome', 'increase', '--submit', '--hash', hexdigest] |
762 |
|
if options.force: |
763 |
|
cmd.append('--force') |
764 |
|
cmd.extend((package, version)) |
765 |
|
if subprocess.call(cmd, stdout=stdout, stderr=stderr): |
766 |
error = True |
error = True |
767 |
|
|
768 |
if options.mail: _send_reply_mail(stdout, msg, options.mail, error=error) |
if options.mail: _send_reply_mail(stdout, msg, options.mail, error=error) |
826 |
subparser.add_argument("-m", "--mail", help="Email address to send the progress to") |
subparser.add_argument("-m", "--mail", help="Email address to send the progress to") |
827 |
subparser.add_argument("-w", "--wait", action="store_true", |
subparser.add_argument("-w", "--wait", action="store_true", |
828 |
help="Wait before trying to retrieve the new version") |
help="Wait before trying to retrieve the new version") |
829 |
|
subparser.add_argument("-f", "--force", action="store_true", |
830 |
|
help="Force submission") |
831 |
subparser.set_defaults( |
subparser.set_defaults( |
832 |
func=cmd_parse_ftp_release_list |
func=cmd_parse_ftp_release_list, force=False, wait=False |
833 |
) |
) |
834 |
|
|
835 |
if len(sys.argv) == 1: |
if len(sys.argv) == 1: |
852 |
sys.exit(0) |
sys.exit(0) |
853 |
|
|
854 |
if __name__ == "__main__": |
if __name__ == "__main__": |
855 |
|
os.environ['PYTHONUNBUFFERED'] = '1' |
856 |
main() |
main() |