2017-05-16 11:01:07 +00:00
|
|
|
#!/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.
|
|
|
|
#
|
2017-06-27 16:29:11 +00:00
|
|
|
from __future__ import print_function, unicode_literals
|
2017-05-16 11:01:07 +00:00
|
|
|
|
2017-06-27 16:29:11 +00:00
|
|
|
import os.path
|
2017-05-16 11:01:07 +00:00
|
|
|
from hashlib import sha256
|
2017-06-27 16:29:11 +00:00
|
|
|
from subprocess import call, check_output
|
2017-05-16 11:01:07 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
import lzma
|
|
|
|
except ImportError:
|
|
|
|
try:
|
|
|
|
from backports import lzma
|
|
|
|
except ImportError:
|
2017-06-27 16:29:11 +00:00
|
|
|
print('backports.lzma not installed, falling back to xz shell command')
|
2017-05-16 11:01:07 +00:00
|
|
|
lzma = None
|
|
|
|
|
2017-06-27 16:29:11 +00:00
|
|
|
# Compress WebUI javascript and gettext.js
|
|
|
|
call(['python', 'minify_web_js.py'])
|
|
|
|
call(['python', 'gen_web_gettext.py'])
|
2017-05-16 11:01:07 +00:00
|
|
|
|
2017-06-27 16:29:11 +00:00
|
|
|
version = check_output(['python', 'version.py']).strip()
|
2017-05-16 11:01:07 +00:00
|
|
|
|
2017-06-27 16:29:11 +00:00
|
|
|
# Create release archive
|
|
|
|
release_dir = 'dist/release-%s' % version
|
|
|
|
print('Creating release archive for ' + version)
|
2018-10-02 14:39:51 +00:00
|
|
|
call(
|
|
|
|
'python setup.py --quiet egg_info --egg-base /tmp sdist --formats=tar --dist-dir=%s'
|
|
|
|
% release_dir,
|
|
|
|
shell=True,
|
|
|
|
)
|
2017-05-16 11:01:07 +00:00
|
|
|
|
2017-06-27 16:29:11 +00:00
|
|
|
# Compress release archive with xz
|
|
|
|
tar_path = os.path.join(release_dir, 'deluge-%s.tar' % version)
|
|
|
|
tarxz_path = tar_path + '.xz'
|
|
|
|
print('Compressing tar (%s) with xz' % tar_path)
|
2017-05-16 11:01:07 +00:00
|
|
|
if lzma:
|
2017-06-27 16:29:11 +00:00
|
|
|
with open(tar_path, 'rb') as tar_file, open(tarxz_path, 'wb') as xz_file:
|
2018-10-02 14:39:51 +00:00
|
|
|
xz_file.write(
|
|
|
|
lzma.compress(bytes(tar_file.read()), preset=9 | lzma.PRESET_EXTREME)
|
|
|
|
)
|
2017-05-16 11:01:07 +00:00
|
|
|
else:
|
2017-06-27 16:29:11 +00:00
|
|
|
call(['xz', '-e9zkf', tar_path])
|
2017-05-16 11:01:07 +00:00
|
|
|
|
2017-06-27 16:29:11 +00:00
|
|
|
# Calculate shasum and add to sha256sums.txt
|
|
|
|
with open(tarxz_path, 'rb') as _file:
|
2018-10-02 14:39:51 +00:00
|
|
|
sha256sum = '%s %s' % (
|
|
|
|
sha256(_file.read()).hexdigest(),
|
|
|
|
os.path.basename(tarxz_path),
|
|
|
|
)
|
2017-06-27 16:29:11 +00:00
|
|
|
with open(os.path.join(release_dir, 'sha256sums.txt'), 'w') as _file:
|
2017-05-16 11:01:07 +00:00
|
|
|
_file.write(sha256sum + '\n')
|
2017-06-27 16:29:11 +00:00
|
|
|
|
|
|
|
print('Complete: %s' % release_dir)
|