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() |
531 |
raise ValueError("Multiple packages found for %s: %s" % (upstream, ", ".join(downstream[upstream].keys()))) |
|
532 |
|
# Directories packages are located in |
533 |
|
root = os.path.expanduser(PKGROOT) |
534 |
|
|
535 |
return downstream[upstream].keys() |
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: |
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 |
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') |