diff options
author | Calum Lind <calumlind+deluge@gmail.com> | 2017-05-16 12:01:07 +0100 |
---|---|---|
committer | Calum Lind <calumlind+deluge@gmail.com> | 2017-05-17 13:56:56 +0100 |
commit | fefe742ea15616826f5ddccfedc59f1e27d97875 (patch) | |
tree | 0853f76621f2c9b6200d09332bbba15eedb3b808 /packaging | |
parent | 0c36b63f222b76f64e6cbe9f12754a5204953722 (diff) | |
download | deluge-fefe742ea15616826f5ddccfedc59f1e27d97875.tar.gz deluge-fefe742ea15616826f5ddccfedc59f1e27d97875.tar.bz2 deluge-fefe742ea15616826f5ddccfedc59f1e27d97875.zip |
[Packaging] Add a make_release file for source packaging
Diffstat (limited to 'packaging')
-rwxr-xr-x | packaging/source/make_release.py | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/packaging/source/make_release.py b/packaging/source/make_release.py new file mode 100755 index 000000000..5c3e2aeb3 --- /dev/null +++ b/packaging/source/make_release.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# Copyright 2014 Calum Lind <calumlind@gmail.com> +# +# This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with +# the additional special exception to link portions of this program with the OpenSSL library. +# See LICENSE for more details. +# + +import contextlib +import os +import sys +import tarfile +from hashlib import sha256 +from subprocess import STDOUT, CalledProcessError, call, check_output + + +sys.path.append('.') +from version import get_version # NOQA, isort: skip, + +try: + import lzma +except ImportError: + try: + from backports import lzma + except ImportError: + print('backports.lzma not installed, falling back to `tar`') + lzma = None + + +"""Get latest annotated tag""" +try: + release_tag = check_output('git describe --exact-match --abbrev=0'.split(), stderr=STDOUT) +except CalledProcessError: + # Fallback to dev build tag. + dev_tag = check_output('git describe --tags --abbrev=0'.split()).strip() + release_tag = dev_tag + +version = release_tag.split('deluge-')[1] +version_alt = get_version(prefix='deluge-', suffix='.dev0') +release_dir = 'release' +source_dir = os.path.join(release_dir, release_tag) + +# TODO: tag found/not found continue? (add option to specify tag) + +# TODO: Verify version and date changed in Changelog? +# if check_output(('git grep -l "%s" | grep -v ChangeLog' % version).split()): +# sys.exit(1) + +"""Create release archive""" +try: + os.mkdir(release_dir) +except OSError: + pass + +print('Creating release archive for ' + release_tag) +call('git archive --format=tar --prefix={tag}/ {tag} | tar -x -C {_dir}'.format( + tag=release_tag, _dir=release_dir), shell=True) + +"""Compress WebUI javascript""" +call(['python', 'minify_web_js.py']) + +"""Create source release tarball.""" +tarball = release_tag + '.tar.xz' +tarball_path = os.path.join(release_dir, tarball) +if lzma: + with contextlib.closing(lzma.LZMAFile(tarball_path, mode='w')) as xz_file: + with tarfile.open(fileobj=xz_file, mode='w') as _file: + _file.add(source_dir, arcname=release_tag) +else: + call(['tar', '-cJf', tarball_path, '-C', release_dir, release_tag]) + +"""Calculate shasum and add to SHASUMS256.txt""" +with open(tarball_path, 'rb') as _file: + sha256sum = '%s %s' % (sha256(_file.read()).hexdigest(), tarball) +with open(os.path.join(release_dir, 'SHASUMS256.txt'), 'w') as _file: + _file.write(sha256sum + '\n') |