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' |
52 |
SLEEP_INITIAL=300 |
SLEEP_INITIAL=180 |
53 |
|
SLEEP_REPEAT=30 |
54 |
|
SLEEP_TIMES=20 |
55 |
|
|
56 |
re_majmin = re.compile(r'^([0-9]+\.[0-9]+).*') |
re_majmin = re.compile(r'^([0-9]+\.[0-9]+).*') |
57 |
re_version = re.compile(r'([-.]|\d+|[^-.\d]+)') |
re_version = re.compile(r'([-.]|\d+|[^-.\d]+)') |
259 |
else spec.sources() |
else spec.sources() |
260 |
return dict((os.path.basename(name), name) for name, no, flags in srclist) |
return dict((os.path.basename(name), name) for name, no, flags in srclist) |
261 |
|
|
262 |
def update(self, version): |
def update(self, version, force=False): |
263 |
"""Update specfile (increase version)""" |
"""Update specfile (increase version)""" |
264 |
cur_version = self.version |
cur_version = self.version |
265 |
|
|
271 |
|
|
272 |
if judgement < 5: |
if judgement < 5: |
273 |
print "WARNING: %s!" % (msg) |
print "WARNING: %s!" % (msg) |
274 |
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, '..')]) != '': |
if subprocess.check_output(["svn", "diff", os.path.join(self.path, '..')]) != '': |
304 |
print "ERROR: Increased version to %s, but RPM doesn't agree!?!" % version |
print "ERROR: Increased version to %s, but RPM doesn't agree!?!" % version |
305 |
return False |
return False |
306 |
|
|
307 |
|
|
308 |
|
# Try to download the new tarball various times and wait between attempts |
309 |
|
tries = 0 |
310 |
|
while tries < SLEEP_TIMES: |
311 |
|
tries += 1 |
312 |
|
if tries > 1: time.sleep(SLEEP_REPEAT) |
313 |
|
try: |
314 |
|
# Download new tarball |
315 |
|
subprocess.check_call(['mgarepo', 'sync', '-d'], cwd=self.cwd) |
316 |
|
# success, so exit loop |
317 |
|
break |
318 |
|
except subprocess.CalledProcessError, e: |
319 |
|
# mgarepo sync returns 1 if the tarball cannot be downloaded |
320 |
|
if e.returncode != 1: |
321 |
|
return False |
322 |
|
else: |
323 |
|
return False |
324 |
|
|
325 |
|
|
326 |
try: |
try: |
|
# Download new tarball |
|
|
subprocess.check_call(['mgarepo', 'sync', '-d'], cwd=self.cwd) |
|
327 |
# Check patches still apply |
# Check patches still apply |
328 |
subprocess.check_call(['bm', '-p', '--nodeps'], cwd=self.cwd) |
subprocess.check_call(['bm', '-p', '--nodeps'], cwd=self.cwd) |
329 |
except subprocess.CalledProcessError: |
except subprocess.CalledProcessError: |
491 |
def get_downstream_names(): |
def get_downstream_names(): |
492 |
re_file = re.compile(r'^(?P<module>.*?)[_-](?:(?P<oldversion>([0-9]+[\.])*[0-9]+)-)?(?P<version>([0-9]+[\.\-])*[0-9]+)\.(?P<format>(?:tar\.|diff\.)?[a-z][a-z0-9]*)$') |
re_file = re.compile(r'^(?P<module>.*?)[_-](?:(?P<oldversion>([0-9]+[\.])*[0-9]+)-)?(?P<version>([0-9]+[\.\-])*[0-9]+)\.(?P<format>(?:tar\.|diff\.)?[a-z][a-z0-9]*)$') |
493 |
|
|
494 |
contents = subprocess.check_output(['urpmf', '--files', '.', "--media", MEDIA], close_fds=True).strip("\n").splitlines() |
contents = subprocess.check_output(['urpmf', '--qf', '%name|%version|%files', '.', "--media", MEDIA], close_fds=True).strip("\n").splitlines() |
495 |
|
|
496 |
FILES = {} |
FILES = {} |
497 |
TARBALLS = {} |
TARBALLS = {} |
498 |
|
|
499 |
for line in contents: |
for line in contents: |
500 |
try: |
try: |
501 |
srpm, filename = line.split(":") |
srpm, version, filename = line.split("|") |
502 |
except ValueError: |
except ValueError: |
503 |
print >>sys.stderr, line |
print >>sys.stderr, line |
504 |
continue |
continue |
510 |
module = fileinfo['module'] |
module = fileinfo['module'] |
511 |
|
|
512 |
if module not in TARBALLS: |
if module not in TARBALLS: |
513 |
TARBALLS[module] = set() |
TARBALLS[module] = {} |
514 |
TARBALLS[module].add(srpm) |
TARBALLS[module][srpm] = version |
515 |
|
|
516 |
if srpm not in FILES: |
if srpm not in FILES: |
517 |
FILES[srpm] = set() |
FILES[srpm] = set() |
526 |
if upstream not in downstream: |
if upstream not in downstream: |
527 |
raise ValueError("No packages for upstream name: %s" % upstream) |
raise ValueError("No packages for upstream name: %s" % upstream) |
528 |
|
|
529 |
if len(downstream[upstream]) != 1: |
if len(downstream[upstream]) == 1: |
530 |
# XXX - Make it more intelligent |
return downstream[upstream].keys() |
531 |
raise ValueError("Multiple packages found for %s: %s" % (upstream, ", ".join(downstream[upstream]))) |
|
532 |
|
# Directories packages are located in |
533 |
|
root = os.path.expanduser(PKGROOT) |
534 |
|
|
535 |
|
packages = {} |
536 |
|
for package in downstream[upstream].keys(): |
537 |
|
cwd = os.path.join(root, package) |
538 |
|
|
539 |
|
# Checkout package to ensure the checkout reflects the latest changes |
540 |
|
try: |
541 |
|
subprocess.check_call(['mgarepo', 'co', package], cwd=root) |
542 |
|
except subprocess.CalledProcessError: |
543 |
|
raise ValueError("Multiple packages found and cannot checkout %s" % package) |
544 |
|
|
545 |
|
# Determine version from spec file |
546 |
|
try: |
547 |
|
packages[package] = SpecFile(os.path.join(cwd, "SPECS", "%s.spec" % package)).version |
548 |
|
except subprocess.CalledProcessError: |
549 |
|
raise ValueError("Multiple packages found and cannot determine version of %s" % package) |
550 |
|
|
551 |
|
# Return all packages reflecting the current version |
552 |
|
matches = [package for package in packages if packages[package] == version] |
553 |
|
if len(matches): |
554 |
|
return matches |
555 |
|
|
556 |
|
# Return all packages reflecting the version before the current version |
557 |
|
latest_version = get_latest_version(packages.values(), max_version=version) |
558 |
|
matches = [package for package in packages if packages[package] == latest_version] |
559 |
|
if len(matches): |
560 |
|
return matches |
561 |
|
|
562 |
return list(downstream[upstream]) |
# Give up |
563 |
|
raise ValueError("Multiple packages found and cannot determine package for version %s" % version) |
564 |
|
|
565 |
def write_file(path, data): |
def write_file(path, data): |
566 |
with tempfile.NamedTemporaryFile(dir=os.path.dirname(path), delete=False) as fdst: |
with tempfile.NamedTemporaryFile(dir=os.path.dirname(path), delete=False) as fdst: |
569 |
os.rename(fdst.name, path) |
os.rename(fdst.name, path) |
570 |
|
|
571 |
def cmd_co(options, parser): |
def cmd_co(options, parser): |
572 |
upstream = get_upstream_names() |
root = os.path.expanduser(PKGROOT) |
|
downstream, downstream_files = get_downstream_names() |
|
573 |
|
|
574 |
cwd = os.path.expanduser(PKGROOT) |
for package, module, package_version, spec_version, downstream_files in sorted(join_streams()): |
575 |
|
print "%s => %s" % (module, package) |
576 |
|
subprocess.call(['mgarepo', 'co', package], cwd=root) |
577 |
|
|
578 |
matches = upstream & set(downstream.keys()) |
def join_streams(show_version=False, only_diff_version=False): |
579 |
for module in matches: |
root = os.path.expanduser(PKGROOT) |
|
print module, "\t".join(downstream[module]) |
|
|
for package in downstream[module]: |
|
|
subprocess.call(['mgarepo', 'co', package], cwd=cwd) |
|
580 |
|
|
|
def join_streams(): |
|
581 |
upstream = get_upstream_names() |
upstream = get_upstream_names() |
582 |
downstream, downstream_files = get_downstream_names() |
downstream, downstream_files = get_downstream_names() |
583 |
|
|
584 |
matches = upstream & set(downstream.keys()) |
matches = upstream & set(downstream.keys()) |
585 |
for module in matches: |
for module in matches: |
586 |
for package in downstream[module]: |
for package in downstream[module].keys(): |
587 |
yield (package, module) |
package_version = downstream[module][package] |
588 |
|
spec_version = None |
589 |
|
if show_version or only_diff_version: |
590 |
|
cwd = os.path.join(root, package) |
591 |
|
try: |
592 |
|
spec_version = SpecFile(os.path.join(cwd, "SPECS", "%s.spec" % package)).version |
593 |
|
except subprocess.CalledProcessError: |
594 |
|
spec_version = 'N/A' |
595 |
|
|
596 |
def cmd_ls(options, parser): |
if only_diff_version and package_version == spec_version: |
597 |
for package, module in sorted(join_streams()): |
continue |
|
print "\t".join((package, module)) if options.upstream else package |
|
598 |
|
|
599 |
def cmd_patches(options, parser): |
yield (package, module, package_version, spec_version, downstream_files[package]) |
|
upstream = get_upstream_names() |
|
|
downstream, downstream_files = get_downstream_names() |
|
600 |
|
|
601 |
path = os.path.expanduser(PKGROOT) |
def cmd_ls(options, parser): |
602 |
|
for package, module, package_version, spec_version, downstream_files in sorted(join_streams(show_version=options.show_version, only_diff_version=options.diff)): |
603 |
|
print package,"\t", |
604 |
|
if options.upstream: print module, "\t", |
605 |
|
if options.show_version: print spec_version, "\t", package_version, "\t", |
606 |
|
print |
607 |
|
|
608 |
import pprint |
def cmd_patches(options, parser): |
609 |
|
root = os.path.expanduser(PKGROOT) |
610 |
|
|
611 |
matches = upstream & set(downstream.keys()) |
for package, module, package_version, spec_version, downstream_files in sorted(join_streams()): |
612 |
for module in sorted(matches): |
for filename in downstream_files: |
613 |
for srpm in downstream[module]: |
if '.patch' in filename or '.diff' in filename: |
614 |
for filename in downstream_files[srpm]: |
|
615 |
if '.patch' in filename or '.diff' in filename: |
p = Patch(os.path.join(root, package, "SOURCES", filename), show_path=options.path) |
616 |
|
valid = "" |
617 |
p = Patch(os.path.join(path, srpm, "SOURCES", filename), show_path=options.path) |
forwarded = "" |
618 |
valid = "" |
if p.dep3['headers']: |
619 |
forwarded = "" |
forwarded = p.dep3['headers'].get('Forwarded', "no") |
620 |
if p.dep3['headers']: |
if p.dep3['valid']: |
621 |
forwarded = p.dep3['headers'].get('Forwarded', "no") |
valid="VALID" |
622 |
if p.dep3['valid']: |
print "\t".join((module, package, str(p), forwarded, valid)) |
|
valid="VALID" |
|
|
print "\t".join((module, srpm, str(p), forwarded, valid)) |
|
623 |
|
|
624 |
def cmd_dep3(options, parser): |
def cmd_dep3(options, parser): |
625 |
p = Patch(options.patch) |
p = Patch(options.patch) |
649 |
# SpecFile class handles the actual version+release change |
# SpecFile class handles the actual version+release change |
650 |
s = SpecFile(os.path.join(cwd, "SPECS", "%s.spec" % package)) |
s = SpecFile(os.path.join(cwd, "SPECS", "%s.spec" % package)) |
651 |
print "%s => %s" % (s.version, options.version) |
print "%s => %s" % (s.version, options.version) |
652 |
if not s.update(options.version): |
if not s.update(options.version, force=options.force): |
653 |
sys.exit(1) |
sys.exit(1) |
654 |
|
|
655 |
# Check hash, if given |
# Check hash, if given |
677 |
sys.exit(1) |
sys.exit(1) |
678 |
|
|
679 |
def cmd_parse_ftp_release_list(options, parser): |
def cmd_parse_ftp_release_list(options, parser): |
|
# XXX - not working yet |
|
680 |
def _send_reply_mail(contents, orig_msg, to, error=False): |
def _send_reply_mail(contents, orig_msg, to, error=False): |
681 |
"""Send an reply email""" |
"""Send an reply email""" |
682 |
contents.seek(0) |
contents.seek(0) |
734 |
# maildrop aborts and will try to deliver after 5min |
# maildrop aborts and will try to deliver after 5min |
735 |
# fork to avoid this |
# fork to avoid this |
736 |
if os.fork() != 0: sys.exit(0) |
if os.fork() != 0: sys.exit(0) |
737 |
time.sleep(SLEEP_INITIAL) |
# wait SLEEP_INITIAL after the message was sent |
738 |
|
secs = SLEEP_INITIAL |
739 |
|
t = email.utils.parsedate_tz(msg['Date']) |
740 |
|
if t is not None: |
741 |
|
msg_time = email.utils.mktime_tz(t) |
742 |
|
secs = SLEEP_INITIAL - (time.time() - msg_time) |
743 |
|
|
744 |
|
if secs > 0: time.sleep(secs) |
745 |
|
|
746 |
error = False |
error = False |
747 |
for package in packages: |
for package in packages: |
766 |
subparser = subparsers.add_parser('packages', help='list all GNOME packages') |
subparser = subparsers.add_parser('packages', help='list all GNOME packages') |
767 |
subparser.add_argument("-m", "--m", action="store_true", dest="upstream", |
subparser.add_argument("-m", "--m", action="store_true", dest="upstream", |
768 |
help="Show upstream module") |
help="Show upstream module") |
769 |
|
subparser.add_argument( "--version", action="store_true", dest="show_version", |
770 |
|
help="Show version numbers") |
771 |
|
subparser.add_argument( "--diff", action="store_true", dest="diff", |
772 |
|
help="Only show packages with different version") |
773 |
subparser.set_defaults( |
subparser.set_defaults( |
774 |
func=cmd_ls, upstream=False |
func=cmd_ls, upstream=False, show_version=False, diff=False |
775 |
) |
) |
776 |
|
|
777 |
subparser = subparsers.add_parser('patches', help='list all GNOME patches') |
subparser = subparsers.add_parser('patches', help='list all GNOME patches') |
790 |
subparser = subparsers.add_parser('increase', help='Increase version number') |
subparser = subparsers.add_parser('increase', help='Increase version number') |
791 |
subparser.add_argument("package", help="Package name") |
subparser.add_argument("package", help="Package name") |
792 |
subparser.add_argument("version", help="Version number") |
subparser.add_argument("version", help="Version number") |
793 |
|
subparser.add_argument("-f", "--force", action="store_true", dest="force", |
794 |
|
help="Override warnings, just do it") |
795 |
subparser.add_argument("-u", "--upstream", action="store_true", dest="upstream", |
subparser.add_argument("-u", "--upstream", action="store_true", dest="upstream", |
796 |
help="Package name reflects the upstream name") |
help="Package name reflects the upstream name") |
797 |
subparser.add_argument("-s", "--submit", action="store_true", dest="submit", |
subparser.add_argument("-s", "--submit", action="store_true", dest="submit", |
801 |
subparser.add_argument("--hash", dest="hexdigest", |
subparser.add_argument("--hash", dest="hexdigest", |
802 |
help="Hexdigest of the hash") |
help="Hexdigest of the hash") |
803 |
subparser.set_defaults( |
subparser.set_defaults( |
804 |
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", |
805 |
|
force=False |
806 |
) |
) |
807 |
|
|
808 |
subparser = subparsers.add_parser('gnome-release-email', help='Submit packages based on GNOME ftp-release-list email') |
subparser = subparsers.add_parser('gnome-release-email', help='Submit packages based on GNOME ftp-release-list email') |