From 6fe64796fbf3a26a03cef766769ff632b63d45b5 Mon Sep 17 00:00:00 2001 From: rolux Date: Sun, 17 Jun 2012 12:58:43 +0200 Subject: [PATCH] build.py: write downloads.json, ignore directories with leading underscore --- tools/build/build.py | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/tools/build/build.py b/tools/build/build.py index 672cbe95..9cf10f68 100755 --- a/tools/build/build.py +++ b/tools/build/build.py @@ -2,6 +2,7 @@ #vim: et:ts=4:sw=4:sts=4 import base64 +import datetime import json import os import ox @@ -86,7 +87,7 @@ def build_oxjs(downloads=False, geo=False): if not is_jquery_min: write_link(link_source, link_target) # remove dangling links from dev tree that might - # be left over from renames or removed files + # be left over from renamed or removed files for path, dirnames, filenames in os.walk(dev_path): for f in filenames: f = os.path.join(path, f) @@ -193,19 +194,22 @@ def build_oxjs(downloads=False, geo=False): # downloads if downloads: + data = { + 'date': datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ'), + 'size': {'minified': os.path.getsize(build_path + 'Ox.js')}, + 'version': version + } download_path = root_path + 'downloads/' # source - source_file = 'OxJS.%s.source.tar.gz' % version - source_tar = tarfile.open(download_path + source_file, 'w:gz') - source_tar.add(root_path, arcname='OxJS', filter=filter_source) - source_tar.close() - write_link(source_file, root_path + 'downloads/OxJS.latest.source.tar.gz') + source_file = download_path + 'OxJS.%s.source.tar.gz' % version + data['size']['source'] = write_tarfile(source_file, root_path, 'OxJS', filter_source) + write_link(source_file, source_file.replace(version, 'latest')) # build - build_file = 'OxJS.%s.build.tar.gz' % version - build_tar = tarfile.open(download_path + build_file, 'w:gz') - build_tar.add(root_path, arcname='OxJS', filter=filter_build) - build_tar.close() - write_link(build_file, root_path + 'downloads/OxJS.latest.build.tar.gz') + build_file = download_path + 'OxJS.%s.build.tar.gz' % version + data['size']['build'] = write_tarfile(build_file, root_path, 'OxJS', filter_build) + write_link(build_file, build_file.replace(version, 'latest')) + # json + write_file(download_path + 'downloads.json', json.dumps(data, indent=4, sort_keys=True)) def copy_file(source, target): @@ -220,9 +224,10 @@ def filter_build(tarinfo): return None def filter_source(tarinfo): - if re.search('^OxJS/(demos|downloads/|tools/geo/png/icons/)', tarinfo.name): + # FIXME: demos and tests should be removed anyway + if re.search('^OxJS/(demos|downloads/|tests|tools/geo/png/icons/)', tarinfo.name): return None - if re.search('/\.', tarinfo.name) or re.search('(\.gz|[~])$', tarinfo.name): + if re.search('/[._]', tarinfo.name) or re.search('(\.gz|[~])$', tarinfo.name): return None return tarinfo @@ -257,6 +262,12 @@ def write_path(file): if path and not os.path.exists(path): os.makedirs(path) +def write_tarfile(file, path, arcname, filter): + print 'writing', file + build_tar = tarfile.open(file, 'w:gz') + build_tar.add(path, arcname=arcname, filter=filter) + build_tar.close() + return os.path.getsize(file) if __name__ == '__main__': build_oxjs(downloads='-downloads' in sys.argv, geo=not '-nogeo' in sys.argv)