icedtea: Simplify update script

This commit is contained in:
Ricardo M. Correia 2014-12-03 05:41:51 +01:00
parent d2488119cc
commit 31522e13c7

View File

@ -3,7 +3,7 @@
import subprocess, urllib.request, re, os, tarfile
from html.parser import HTMLParser
HG_URL = 'http://icedtea.classpath.org/hg/release/icedtea{}-forest-{}'
URL = 'http://icedtea.classpath.org/download/drops/icedtea{}/{}'
DOWNLOAD_URL = 'http://icedtea.wildebeest.org/download/source/'
DOWNLOAD_HTML = DOWNLOAD_URL + '?C=M;O=D'
@ -89,7 +89,7 @@ def get_old_bundle_attrs(jdk, bundle):
def get_old_attrs(jdk):
attrs = {}
for attr in ('branch', 'version', 'url', 'sha256'):
for attr in ('version', 'url', 'sha256'):
attrs[attr] = get_jdk_attr(jdk, attr)
attrs['bundles'] = {}
@ -128,8 +128,8 @@ def get_new_bundle_attr(makefile, bundle, attr):
return m.group(1)
def get_new_bundle_attrs(jdk, version, branch, path):
hg_url = HG_URL.format(jdk, branch)
def get_new_bundle_attrs(jdk, version, path):
url = URL.format(jdk, version)
attrs = {}
@ -139,14 +139,16 @@ def get_new_bundle_attrs(jdk, version, branch, path):
makefile = get_member_file(tar, 'Makefile.am')
hotspot_map = get_member_file(tar, 'hotspot.map.in')
hotspot_map = hotspot_map.replace('@ICEDTEA_RELEASE@', version)
for bundle in BUNDLES:
battrs = {}
battrs['url'] = 'http://icedtea.wildebeest.org/download/drops/icedtea{}/{}/{}.tar.bz2'.format(jdk, version, bundle)
battrs['url'] = '{}/{}.tar.bz2'.format(url, bundle)
if bundle == 'hotspot':
m = re.search(r'^default (.*?) (.*?) (.*?) (.*?)$', hotspot_map, re.MULTILINE)
if m == None:
raise Exception('Could not find info for hotspot bundle in hotspot.map.in')
raise Exception('Could not find info for hotspot bundle in hotspot.map.in')
battrs['sha256'] = m.group(4)
else:
@ -182,7 +184,6 @@ def get_new_attrs(jdk):
print('Update available, generating new attributes for JDK {}...'.format(jdk))
attrs['version'] = version
attrs['branch'] = '.'.join(version.split('.')[:2])
attrs['url'] = url
print('Downloading tarball from url "{}"...'.format(url))
@ -192,7 +193,7 @@ def get_new_attrs(jdk):
print('Inspecting tarball for bundle information...')
attrs['bundles'] = get_new_bundle_attrs(jdk, attrs['version'], attrs['branch'], path)
attrs['bundles'] = get_new_bundle_attrs(jdk, attrs['version'], path)
print('Done!')
@ -201,21 +202,19 @@ def get_new_attrs(jdk):
def generate_jdk(jdk):
attrs = get_new_attrs(jdk)
branch = attrs['branch']
src_version = attrs['version'].replace(branch, '${branch}')
src_url = attrs['url'].replace(attrs['version'], '${version}')
version = attrs['version']
src_url = attrs['url'].replace(version, '${version}')
hg_url = HG_URL.format(jdk, branch)
src_hg_url = HG_URL.format(jdk, '${branch}')
common_url = URL.format(jdk, version)
src_common_url = URL.format(jdk, '${version}')
src = ' icedtea{} = rec {{\n'.format(jdk)
src += ' branch = "{}";\n'.format(branch)
src += ' version = "{}";\n'.format(src_version)
src += ' version = "{}";\n'.format(version)
src += '\n'
src += ' url = "{}";\n'.format(src_url)
src += ' sha256 = "{}";\n'.format(attrs['sha256'])
src += '\n'
src += ' hg_url = "{}";\n'.format(src_hg_url)
src += ' common_url = "{}";\n'.format(src_common_url)
src += '\n'
src += ' bundles = {\n'
@ -223,7 +222,7 @@ def generate_jdk(jdk):
battrs = attrs['bundles'][bundle]
b_url = battrs['url']
b_url = b_url.replace(hg_url, '${hg_url}')
b_url = b_url.replace(common_url, '${common_url}')
src += ' {} = rec {{\n'.format(bundle)
src += ' url = "{}";\n'.format(b_url)