build.py: write downloads.json, ignore directories with leading underscore
This commit is contained in:
parent
d27c1e8cd4
commit
6fe64796fb
1 changed files with 24 additions and 13 deletions
|
@ -2,6 +2,7 @@
|
||||||
#vim: et:ts=4:sw=4:sts=4
|
#vim: et:ts=4:sw=4:sts=4
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
|
import datetime
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import ox
|
import ox
|
||||||
|
@ -86,7 +87,7 @@ def build_oxjs(downloads=False, geo=False):
|
||||||
if not is_jquery_min:
|
if not is_jquery_min:
|
||||||
write_link(link_source, link_target)
|
write_link(link_source, link_target)
|
||||||
# remove dangling links from dev tree that might
|
# 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 path, dirnames, filenames in os.walk(dev_path):
|
||||||
for f in filenames:
|
for f in filenames:
|
||||||
f = os.path.join(path, f)
|
f = os.path.join(path, f)
|
||||||
|
@ -193,19 +194,22 @@ def build_oxjs(downloads=False, geo=False):
|
||||||
|
|
||||||
# downloads
|
# downloads
|
||||||
if 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/'
|
download_path = root_path + 'downloads/'
|
||||||
# source
|
# source
|
||||||
source_file = 'OxJS.%s.source.tar.gz' % version
|
source_file = download_path + 'OxJS.%s.source.tar.gz' % version
|
||||||
source_tar = tarfile.open(download_path + source_file, 'w:gz')
|
data['size']['source'] = write_tarfile(source_file, root_path, 'OxJS', filter_source)
|
||||||
source_tar.add(root_path, arcname='OxJS', filter=filter_source)
|
write_link(source_file, source_file.replace(version, 'latest'))
|
||||||
source_tar.close()
|
|
||||||
write_link(source_file, root_path + 'downloads/OxJS.latest.source.tar.gz')
|
|
||||||
# build
|
# build
|
||||||
build_file = 'OxJS.%s.build.tar.gz' % version
|
build_file = download_path + 'OxJS.%s.build.tar.gz' % version
|
||||||
build_tar = tarfile.open(download_path + build_file, 'w:gz')
|
data['size']['build'] = write_tarfile(build_file, root_path, 'OxJS', filter_build)
|
||||||
build_tar.add(root_path, arcname='OxJS', filter=filter_build)
|
write_link(build_file, build_file.replace(version, 'latest'))
|
||||||
build_tar.close()
|
# json
|
||||||
write_link(build_file, root_path + 'downloads/OxJS.latest.build.tar.gz')
|
write_file(download_path + 'downloads.json', json.dumps(data, indent=4, sort_keys=True))
|
||||||
|
|
||||||
|
|
||||||
def copy_file(source, target):
|
def copy_file(source, target):
|
||||||
|
@ -220,9 +224,10 @@ def filter_build(tarinfo):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def filter_source(tarinfo):
|
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
|
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 None
|
||||||
return tarinfo
|
return tarinfo
|
||||||
|
|
||||||
|
@ -257,6 +262,12 @@ def write_path(file):
|
||||||
if path and not os.path.exists(path):
|
if path and not os.path.exists(path):
|
||||||
os.makedirs(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__':
|
if __name__ == '__main__':
|
||||||
build_oxjs(downloads='-downloads' in sys.argv, geo=not '-nogeo' in sys.argv)
|
build_oxjs(downloads='-downloads' in sys.argv, geo=not '-nogeo' in sys.argv)
|
||||||
|
|
Loading…
Reference in a new issue