summaryrefslogtreecommitdiff
blob: 5d1163710bc769f901c873baf642b93057c27503 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/python

"""Update gdb snapshots"""

from __future__ import print_function

import distutils.version
import glob
import logging
import re
import shutil
import sys

from common import * # pylint: disable=wildcard-import,unused-wildcard-import


CATEGORY = 'sys-devel'
PN = 'gdb'
URL = 'ftp://sourceware.org/pub/gdb/snapshots/current/'


def main(argv):
	opts = common_main(argv, CATEGORY, PN)

	remote_list = ver_sort(
		x for x in list_snaps(URL, debug=opts.debug)
		if x.startswith('%s-weekly-' % PN) and '.tar' in x)

	# Create the lists of curr/new versions.
	old_pkgs = set(glob.glob('%s-*.ebuild' % PN))
	new_pkgs = set()
	for snap in remote_list:
		m = re.match(r'%s-weekly-([0-9.]+)\.tar' % PN, snap)
		if m:
			ebuild = '%s-%s.ebuild' % (PN, m.group(1))
			new_pkgs.add(ebuild)
			logging.debug('found remote %s', ebuild)
		else:
			logging.warning('skipping reomte %s', snap)

	# Create ebuilds for the new versions we found.
	closest_ver = distutils.version.LooseVersion('0')
	for pkg in new_pkgs - old_pkgs:
		logging.info('adding %s', pkg)
		ver = get_ver(pkg)
		for opkg in old_pkgs:
			if '.50.' not in opkg:
				continue
			over = get_ver(opkg)
			if over < ver and over > closest_ver:
				closest_ver = over
		logging.info(' copying from %s', closest_ver)
		ebuild = '%s-%s.ebuild' % (PN, closest_ver)
		shutil.copy(ebuild, pkg)
		git(['add', pkg])
		run_ebuild(pkg, 'fetch')
		#run_ebuild(pkg, 'manifest')

	# Clean out the old snapshots.
	for pkg in ver_sort(old_pkgs - new_pkgs):
		if '.50.' not in pkg:
			continue
		logging.info('cleaning old %s', pkg)
		git(['rm', '-f', pkg])

	run(['repoman', 'manifest'])
	git(['add', 'Manifest'])


if __name__ == '__main__':
	main(sys.argv[1:])