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: |
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() |
|
raise ValueError("Multiple packages found for %s: %s" % (upstream, ", ".join(downstream[upstream].keys()))) |
|
531 |
|
|
532 |
return downstream[upstream].keys() |
# 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 |
|
# 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: |
571 |
def cmd_co(options, parser): |
def cmd_co(options, parser): |
572 |
root = os.path.expanduser(PKGROOT) |
root = os.path.expanduser(PKGROOT) |
573 |
|
|
574 |
for package, module, package_version, spec_version in sorted(join_streams()): |
for package, module, package_version, spec_version, downstream_files in sorted(join_streams()): |
575 |
print "%s => %s" % (module, package) |
print "%s => %s" % (module, package) |
576 |
subprocess.call(['mgarepo', 'co', package], cwd=root) |
subprocess.call(['mgarepo', 'co', package], cwd=root) |
577 |
|
|
596 |
if only_diff_version and package_version == spec_version: |
if only_diff_version and package_version == spec_version: |
597 |
continue |
continue |
598 |
|
|
599 |
yield (package, module, package_version, spec_version) |
yield (package, module, package_version, spec_version, downstream_files[package]) |
600 |
|
|
601 |
def cmd_ls(options, parser): |
def cmd_ls(options, parser): |
602 |
for package, module, package_version, spec_version in sorted(join_streams(show_version=options.show_version, only_diff_version=options.diff)): |
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", |
print package,"\t", |
604 |
if options.upstream: print module, "\t", |
if options.upstream: print module, "\t", |
605 |
if options.show_version: print spec_version, "\t", package_version, "\t", |
if options.show_version: print spec_version, "\t", package_version, "\t", |
606 |
print |
print |
607 |
|
|
608 |
def cmd_patches(options, parser): |
def cmd_patches(options, parser): |
609 |
upstream = get_upstream_names() |
root = os.path.expanduser(PKGROOT) |
|
downstream, downstream_files = get_downstream_names() |
|
|
|
|
|
path = os.path.expanduser(PKGROOT) |
|
|
|
|
|
import pprint |
|
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].keys(): |
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: |
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') |