diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2018-05-25 22:11:28 +0200 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2018-05-25 22:11:28 +0200 |
commit | 151b096f3d2859a9c77915477047c998cf2c1a95 (patch) | |
tree | 8a9d448ad5c377e0562066d14eb11f24a10a24f4 /maint/download_release.py | |
parent | a9b4b7a210a11275e1d0d55a1df651adb2f3542f (diff) | |
download | blogc-151b096f3d2859a9c77915477047c998cf2c1a95.tar.gz blogc-151b096f3d2859a9c77915477047c998cf2c1a95.tar.bz2 blogc-151b096f3d2859a9c77915477047c998cf2c1a95.zip |
maint: download latest build by default
Diffstat (limited to 'maint/download_release.py')
-rwxr-xr-x | maint/download_release.py | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/maint/download_release.py b/maint/download_release.py index 2d145b2..3046406 100755 --- a/maint/download_release.py +++ b/maint/download_release.py @@ -4,27 +4,42 @@ import os import re import requests +import shutil import subprocess import sys +re_version = re.compile(r'blogc-([^\'"]+)\.tar\.gz') re_distfile = re.compile(r'(blogc[^\'"]+)\.sha512') base_url = 'https://distfiles.rgm.io/blogc' cwd = os.path.dirname(os.path.abspath(__file__)) def download_release(version): - release_url = '%s/blogc-%s' % (base_url, version) - r = requests.get('%s/' % release_url) - r.raise_for_status() + if version is None: + release_url = '%s/LATEST' % (base_url,) + r = requests.get(release_url) + r.raise_for_status() + match = re_version.search(r.content) + if match is None: + raise RuntimeError('Could not guess version') + version = match.group(1) + else: + release_url = '%s/blogc-%s' % (base_url, version) + r = requests.get(release_url) + r.raise_for_status() + + dest_path = os.path.join(cwd, 'releases', version) + if os.path.exists(dest_path): + shutil.rmtree(dest_path) + os.makedirs(dest_path) for distfile in set(re_distfile.findall(r.content)): file_url = '%s/%s' % (release_url, distfile) - dest_path = os.path.join(cwd, 'releases', version) - subprocess.check_call(['wget', '-c', '-P', dest_path, file_url, + subprocess.check_call(['wget', '-P', dest_path, file_url, '%s.sha512' % file_url]) subprocess.check_call(['sha512sum', '-c', '%s.sha512' % distfile], cwd=dest_path) if __name__ == '__main__': - download_release(sys.argv[1]) + download_release(sys.argv[1] if len(sys.argv) > 1 else None) |