43 |
# to be able to sleep for a while |
# to be able to sleep for a while |
44 |
import time |
import time |
45 |
|
|
46 |
|
# version freeze |
47 |
|
import datetime |
48 |
|
|
49 |
MEDIA="Core Release Source" |
MEDIA="Core Release Source" |
50 |
URL="http://download.gnome.org/sources/" |
URL="http://download.gnome.org/sources/" |
51 |
PKGROOT='~/pkgs' |
PKGROOT='~/pkgs' |
624 |
|
|
625 |
def cmd_parse_ftp_release_list(options, parser): |
def cmd_parse_ftp_release_list(options, parser): |
626 |
# XXX - not working yet |
# XXX - not working yet |
627 |
def _send_reply_mail(contents, orig_msg, to): |
def _send_reply_mail(contents, orig_msg, to, error=False): |
628 |
"""Send an reply email""" |
"""Send an reply email""" |
629 |
contents.seek(0) |
contents.seek(0) |
630 |
msg = MIMEText(contents.read(), _charset='utf-8') |
msg = MIMEText(contents.read(), _charset='utf-8') |
631 |
msg['Subject'] = "Re: %s" % orig_msg['Subject'] |
if error: |
632 |
|
# XXX - ugly |
633 |
|
contents.seek(0) |
634 |
|
lastline = contents.read().splitlines()[-1] |
635 |
|
# Remove things like "ERROR: " and so on from the last line |
636 |
|
lastline = re.sub(r'^(?:[^ :]+:\s+)+', '', lastline) |
637 |
|
subjecterrror = " (ERROR: %s)" % lastline if lastline else " (ERROR)" |
638 |
|
else: |
639 |
|
subjecterror = "" |
640 |
|
msg['Subject'] = "Re: %s%s" (orig_msg['Subject'], subjecterror) |
641 |
msg['To'] = to |
msg['To'] = to |
642 |
msg["In-Reply-To"] = orig_msg["Message-ID"] |
msg["In-Reply-To"] = orig_msg["Message-ID"] |
643 |
msg["References"] = orig_msg["Message-ID"] |
msg["References"] = orig_msg["Message-ID"] |
655 |
msg = email.email.message_from_file(sys.stdin) |
msg = email.email.message_from_file(sys.stdin) |
656 |
|
|
657 |
if options.mail: |
if options.mail: |
658 |
stdout = tempfile.NamedTemporaryFile() |
stdout = tempfile.TemporaryFile() |
659 |
stderr = stdout |
stderr = stdout |
660 |
else: |
else: |
661 |
stdout = sys.stdout |
stdout = sys.stdout |
662 |
stderr = sys.stderr |
stderr = sys.stderr |
663 |
|
|
664 |
|
version_freeze = datetime.datetime(2012,3,7,23,59,0) |
665 |
|
now = datetime.datetime.utcnow() |
666 |
|
if now > version_freeze: |
667 |
|
print >>stderr, "ERROR: Past version freeze" |
668 |
|
if options.mail: _send_reply_mail(stdout, msg, options.mail, error=True) |
669 |
|
sys.exit(1) |
670 |
|
|
671 |
try: |
try: |
672 |
module = msg['X-Module-Name'] |
module = msg['X-Module-Name'] |
673 |
version = msg['X-Module-Version'] |
version = msg['X-Module-Version'] |
674 |
hexdigest = msg['X-Module-SHA256-tar.xz'] |
hexdigest = msg['X-Module-SHA256-tar.xz'] |
675 |
except KeyError, e: |
except KeyError, e: |
676 |
print >>stderr, "ERROR: %s" % e |
print >>stderr, "ERROR: %s" % e |
677 |
if options.mail: _send_reply_mail(stdout, msg, options.mail) |
if options.mail: _send_reply_mail(stdout, msg, options.mail, error=True) |
678 |
sys.exit(1) |
sys.exit(1) |
679 |
|
|
680 |
try: |
try: |
681 |
packages = get_downstream_from_upstream(module, version) |
packages = get_downstream_from_upstream(module, version) |
682 |
except ValueError, e: |
except ValueError, e: |
683 |
print >>stderr, "ERROR: %s" % e |
print >>stderr, "ERROR: %s" % e |
684 |
if options.mail: _send_reply_mail(stdout, msg, options.mail) |
if options.mail: _send_reply_mail(stdout, msg, options.mail, error=True) |
685 |
sys.exit(1) |
sys.exit(1) |
686 |
|
|
687 |
if options.wait: |
if options.wait: |
690 |
if os.fork() != 0: sys.exit(0) |
if os.fork() != 0: sys.exit(0) |
691 |
time.sleep(SLEEP_INITIAL) |
time.sleep(SLEEP_INITIAL) |
692 |
|
|
693 |
|
error = False |
694 |
for package in packages: |
for package in packages: |
695 |
subprocess.call(['mga-gnome', 'increase', '--submit', '--hash', hexdigest, package, version], stdout=stdout, stderr=stderr) |
if subprocess.call(['mga-gnome', 'increase', '--submit', '--hash', hexdigest, package, version], stdout=stdout, stderr=stderr): |
696 |
|
error = True |
697 |
|
|
698 |
if options.mail: _send_reply_mail(stdout, msg, options.mail) |
if options.mail: _send_reply_mail(stdout, msg, options.mail, error=error) |
699 |
|
|
700 |
def main(): |
def main(): |
701 |
description = """Mageia GNOME commands.""" |
description = """Mageia GNOME commands.""" |