36 |
# for checking hashes |
# for checking hashes |
37 |
import hashlib |
import hashlib |
38 |
|
|
39 |
|
# for parsing ftp-release-list emails |
40 |
|
import email |
41 |
|
from email.mime.text import MIMEText |
42 |
|
|
43 |
|
|
44 |
MEDIA="Core Release Source" |
MEDIA="Core Release Source" |
45 |
URL="http://download.gnome.org/sources/" |
URL="http://download.gnome.org/sources/" |
46 |
PKGROOT='~/pkgs' |
PKGROOT='~/pkgs' |
486 |
|
|
487 |
return TARBALLS, FILES |
return TARBALLS, FILES |
488 |
|
|
489 |
|
def get_downstream_from_upstream(upstream, version): |
490 |
|
# Determine the package name |
491 |
|
downstream, downstream_files = get_downstream_names() |
492 |
|
|
493 |
|
if upstream not in downstream: |
494 |
|
raise ValueError("No packages for upstream name: %s" % upstream) |
495 |
|
|
496 |
|
if len(downstream[upstream]) != 1: |
497 |
|
# XXX - Make it more intelligent |
498 |
|
raise ValueError("ERROR: Multiple packages found for %s: %s" % (upstream, ", ".join(downstream[upstream]))) |
499 |
|
|
500 |
|
return list(downstream[upstream]) |
501 |
|
|
502 |
def write_file(path, data): |
def write_file(path, data): |
503 |
with tempfile.NamedTemporaryFile(dir=os.path.dirname(path), delete=False) as fdst: |
with tempfile.NamedTemporaryFile(dir=os.path.dirname(path), delete=False) as fdst: |
560 |
def cmd_package_new_version(options, parser): |
def cmd_package_new_version(options, parser): |
561 |
# Determine the package name |
# Determine the package name |
562 |
if options.upstream: |
if options.upstream: |
563 |
downstream, downstream_files = get_downstream_names() |
try: |
564 |
|
package = get_downstream_from_upstream(options.package, options.version)[0] |
565 |
if options.package not in downstream: |
except ValueError, e: |
566 |
print >>sys.stderr, "ERROR: No packages for upstream name: %s" % options.package |
print >>sys.stderr, "ERROR: %s" % e |
|
sys.exit(1) |
|
|
|
|
|
if len(downstream[options.package]) != 1: |
|
|
# XXX - Make it more intelligent |
|
|
print >>sys.stderr, "ERROR: Multiple packages found for %s: %s" % (options.package, ", ".join(downstream[options.package])) |
|
567 |
sys.exit(1) |
sys.exit(1) |
|
|
|
|
package = list(downstream[options.package])[0] |
|
568 |
else: |
else: |
569 |
package = options.package |
package = options.package |
570 |
|
|
608 |
except subprocess.CalledProcessError: |
except subprocess.CalledProcessError: |
609 |
sys.exit(1) |
sys.exit(1) |
610 |
|
|
611 |
|
def cmd_parse_ftp_release_list(options, parser): |
612 |
|
# XXX - not working yet |
613 |
|
def _send_reply_mail(contents, orig_msg, to): |
614 |
|
"""Send an reply email""" |
615 |
|
contents.seek(0) |
616 |
|
msg = MIMEText(contents.read(), _charset='utf-8') |
617 |
|
msg['Subject'] = "Re: %s" % orig_msg['Subject'] |
618 |
|
msg['To'] = to |
619 |
|
msg["In-Reply-To"] = orig_msg["Message-ID"] |
620 |
|
msg["References"] = orig_msg["Message-ID"] |
621 |
|
|
622 |
|
# Call sendmail program directly so it doesn't matter if the service is running |
623 |
|
cmd = ['/usr/sbin/sendmail', '-oi', '--'] |
624 |
|
cmd.extend([to]) |
625 |
|
p = subprocess.Popen(cmd, stdin=subprocess.PIPE) |
626 |
|
p.stdin.write(msg.as_string()) |
627 |
|
p.stdin.flush() |
628 |
|
p.stdin.close() |
629 |
|
p.wait() |
630 |
|
|
631 |
|
|
632 |
|
msg = email.email.message_from_file(sys.stdin) |
633 |
|
|
634 |
|
if options.mail: |
635 |
|
stdout = tempfile.NamedTemporaryFile() |
636 |
|
stderr = stdout |
637 |
|
else: |
638 |
|
stdout = sys.stdout |
639 |
|
stderr = sys.stderr |
640 |
|
|
641 |
|
try: |
642 |
|
module = msg['X-Module-Name'] |
643 |
|
version = msg['X-Module-Version'] |
644 |
|
hexdigest = msg['X-Module-SHA256-tar.xz'] |
645 |
|
except KeyError, e: |
646 |
|
print >>stderr, "ERROR: %s" % e |
647 |
|
if options.mail: _send_reply_mail(stdout, msg, options.mail) |
648 |
|
sys.exit(1) |
649 |
|
|
650 |
|
try: |
651 |
|
packages = get_downstream_from_upstream(module, version) |
652 |
|
except ValueError, e: |
653 |
|
print >>stderr, "ERROR: %s" % e |
654 |
|
if options.mail: _send_reply_mail(stdout, msg, options.mail) |
655 |
|
sys.exit(1) |
656 |
|
|
657 |
|
for package in packages: |
658 |
|
subprocess.call(['mga-gnome', 'increase', '-s', '--hash', hexdigest, package, version], stdout=stdout, stderr=stderr) |
659 |
|
|
660 |
|
if options.mail: _send_reply_mail(stdout, msg, options.mail) |
661 |
|
|
662 |
def main(): |
def main(): |
663 |
description = """Mageia GNOME commands.""" |
description = """Mageia GNOME commands.""" |
707 |
func=cmd_package_new_version, submit=False, upstream=False, hexdigest=None, algo="sha256" |
func=cmd_package_new_version, submit=False, upstream=False, hexdigest=None, algo="sha256" |
708 |
) |
) |
709 |
|
|
710 |
|
subparser = subparsers.add_parser('gnome-release-email', help='Submit packages based on GNOME ftp-release-list email') |
711 |
|
subparser.add_argument("-m", "--mail", help="Email address to send the progress to") |
712 |
|
subparser.set_defaults( |
713 |
|
func=cmd_parse_ftp_release_list |
714 |
|
) |
715 |
|
|
716 |
if len(sys.argv) == 1: |
if len(sys.argv) == 1: |
717 |
parser.print_help() |
parser.print_help() |
718 |
sys.exit(2) |
sys.exit(2) |